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" |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 58 | #include "qdf_types.h" |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 59 | #include "qdf_trace.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 60 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 61 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 62 | #endif |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 63 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 64 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 65 | #include <cdp_txrx_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 66 | |
| 67 | #include <net/addrconf.h> |
| 68 | #include <linux/wireless.h> |
| 69 | #include <net/cfg80211.h> |
| 70 | #include <linux/inetdevice.h> |
| 71 | #include <net/addrconf.h> |
| 72 | #include "wlan_hdd_cfg80211.h" |
| 73 | #include "wlan_hdd_ext_scan.h" |
| 74 | #include "wlan_hdd_p2p.h" |
| 75 | #include <linux/rtnetlink.h> |
| 76 | #include "sap_api.h" |
| 77 | #include <linux/semaphore.h> |
| 78 | #include <linux/ctype.h> |
| 79 | #include <linux/compat.h> |
| 80 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #include <soc/qcom/subsystem_restart.h> |
| 82 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | #include <wlan_hdd_hostapd.h> |
| 84 | #include <wlan_hdd_softap_tx_rx.h> |
| 85 | #include "cfg_api.h" |
| 86 | #include "qwlan_version.h" |
| 87 | #include "wma_types.h" |
| 88 | #include "wlan_hdd_tdls.h" |
| 89 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 90 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 92 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 93 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 94 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | #include "wlan_hdd_nan.h" |
| 96 | #include "wlan_hdd_debugfs.h" |
| 97 | #include "wlan_hdd_driver_ops.h" |
| 98 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 99 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 100 | |
| 101 | #include <wlan_hdd_ipa.h> |
| 102 | #include "hif.h" |
| 103 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 104 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 106 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 108 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 109 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 110 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 111 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 112 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 113 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 114 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 115 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 116 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 117 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 118 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 119 | #include "os_if_wifi_pos.h" |
| 120 | #include "wifi_pos_api.h" |
| 121 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 122 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 123 | #include "os_if_nan.h" |
| 124 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 125 | #include "wlan_reg_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 126 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 127 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 128 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 129 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 130 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 131 | #include "wlan_disa_ucfg_api.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 132 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 133 | #ifdef CNSS_GENL |
| 134 | #include <net/cnss_nl.h> |
| 135 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 136 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 137 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 138 | #include <wlan_green_ap_ucfg_api.h> |
| 139 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 140 | #ifdef MODULE |
| 141 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 142 | #else |
| 143 | #define WLAN_MODULE_NAME "wlan" |
| 144 | #endif |
| 145 | |
| 146 | #ifdef TIMER_MANAGER |
| 147 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 148 | #else |
| 149 | #define TIMER_MANAGER_STR "" |
| 150 | #endif |
| 151 | |
| 152 | #ifdef MEMORY_DEBUG |
| 153 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 154 | #else |
| 155 | #define MEMORY_DEBUG_STR "" |
| 156 | #endif |
| 157 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 158 | int wlan_start_ret_val; |
| 159 | static DECLARE_COMPLETION(wlan_start_comp); |
| 160 | static unsigned int dev_num = 1; |
| 161 | static struct cdev wlan_hdd_state_cdev; |
| 162 | static struct class *class; |
| 163 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 164 | #ifndef MODULE |
| 165 | static struct gwlan_loader *wlan_loader; |
| 166 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 167 | struct kobj_attribute *attr, |
| 168 | const char *buf, size_t count); |
| 169 | struct gwlan_loader { |
| 170 | bool loaded_state; |
| 171 | struct kobject *boot_wlan_obj; |
| 172 | struct attribute_group *attr_group; |
| 173 | }; |
| 174 | |
| 175 | static struct kobj_attribute wlan_boot_attribute = |
| 176 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 177 | |
| 178 | static struct attribute *attrs[] = { |
| 179 | &wlan_boot_attribute.attr, |
| 180 | NULL, |
| 181 | }; |
| 182 | |
| 183 | #define MODULE_INITIALIZED 1 |
| 184 | #endif |
| 185 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 186 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 187 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 188 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 189 | |
| 190 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 191 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 192 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 194 | /* the Android framework expects this param even though we don't use it */ |
| 195 | #define BUF_LEN 20 |
| 196 | static char fwpath_buffer[BUF_LEN]; |
| 197 | static struct kparam_string fwpath = { |
| 198 | .string = fwpath_buffer, |
| 199 | .maxlen = BUF_LEN, |
| 200 | }; |
| 201 | |
| 202 | static char *country_code; |
| 203 | static int enable_11d = -1; |
| 204 | static int enable_dfs_chan_scan = -1; |
| 205 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 206 | /* |
| 207 | * spinlock for synchronizing asynchronous request/response |
| 208 | * (full description of use in wlan_hdd_main.h) |
| 209 | */ |
| 210 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 211 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 213 | #define WLAN_NLINK_CESIUM 30 |
| 214 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 215 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 216 | |
| 217 | #define WOW_MAX_FILTER_LISTS 1 |
| 218 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 219 | #define WOW_MIN_PATTERN_SIZE 6 |
| 220 | #define WOW_MAX_PATTERN_SIZE 64 |
| 221 | |
| 222 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 223 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 224 | .flags = WIPHY_WOWLAN_ANY | |
| 225 | WIPHY_WOWLAN_MAGIC_PKT | |
| 226 | WIPHY_WOWLAN_DISCONNECT | |
| 227 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 228 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 229 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 230 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 231 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 232 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 233 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 234 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 235 | }; |
| 236 | #endif |
| 237 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 238 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 239 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 240 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 241 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 242 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 243 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 244 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 245 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 246 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 247 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 251 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 252 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 253 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 254 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 255 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 273 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 274 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 275 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 276 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 277 | }; |
| 278 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 279 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 280 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 281 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 282 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 283 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 284 | }; |
| 285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 286 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 287 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 288 | |
| 289 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 290 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 291 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 292 | #endif |
| 293 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 294 | void hdd_start_complete(int ret) |
| 295 | { |
| 296 | wlan_start_ret_val = ret; |
| 297 | |
| 298 | complete(&wlan_start_comp); |
| 299 | } |
| 300 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 301 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 302 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 303 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 304 | * |
| 305 | * Return: none |
| 306 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 307 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 308 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 309 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 310 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 311 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 312 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 316 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 317 | * @vdev_id: vdev_id |
| 318 | * @action: action type |
| 319 | * @reason: reason type |
| 320 | * |
| 321 | * Return: none |
| 322 | */ |
| 323 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 324 | enum netif_action_type action, enum netif_reason_type reason) |
| 325 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 326 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 327 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 328 | |
| 329 | if (!hdd_ctx) { |
| 330 | hdd_err("hdd ctx is NULL"); |
| 331 | return; |
| 332 | } |
| 333 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 334 | |
| 335 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 339 | * Store WLAN driver version and timestamp info in global variables such that |
| 340 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 341 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 342 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 343 | #ifdef BUILD_TAG |
| 344 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 345 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 346 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 347 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 348 | |
| 349 | /** |
| 350 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 351 | * @device_mode: device mode |
| 352 | * |
| 353 | * This utility function helps log string conversion of device mode. |
| 354 | * |
| 355 | * Return: string conversion of device mode, if match found; |
| 356 | * "Unknown" otherwise. |
| 357 | */ |
| 358 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 359 | { |
| 360 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 361 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 362 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 363 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 364 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 365 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 366 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 367 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 368 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 369 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 370 | default: |
| 371 | return "Unknown"; |
| 372 | } |
| 373 | } |
| 374 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 375 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 376 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 377 | * @hdd_ctx: HDD context |
| 378 | * @chan_list: buf hold returned chan list |
| 379 | * @chan_num: input buf size and output returned chan num |
| 380 | * |
| 381 | * This function helps get current available chan list from regulatory |
| 382 | * module. It excludes the "disabled" and "invalid" channels. |
| 383 | * |
| 384 | * Return: 0 for success. |
| 385 | */ |
| 386 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 387 | uint8_t *chan_list, |
| 388 | uint32_t *chan_num) |
| 389 | { |
| 390 | int i = 0, j = 0; |
| 391 | struct regulatory_channel *cur_chan_list; |
| 392 | struct wlan_objmgr_pdev *pdev; |
| 393 | |
| 394 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 395 | return -EINVAL; |
| 396 | |
| 397 | pdev = hdd_ctx->hdd_pdev; |
| 398 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 399 | sizeof(struct regulatory_channel)); |
| 400 | if (!cur_chan_list) |
| 401 | return -ENOMEM; |
| 402 | |
| 403 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 404 | QDF_STATUS_SUCCESS) { |
| 405 | qdf_mem_free(cur_chan_list); |
| 406 | return -EINVAL; |
| 407 | } |
| 408 | |
| 409 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 410 | uint32_t ch = cur_chan_list[i].chan_num; |
| 411 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 412 | ch); |
| 413 | |
| 414 | if (state != CHANNEL_STATE_DISABLE && |
| 415 | state != CHANNEL_STATE_INVALID && |
| 416 | j < *chan_num) { |
| 417 | chan_list[j] = (uint8_t)ch; |
| 418 | j++; |
| 419 | } |
| 420 | } |
| 421 | *chan_num = j; |
| 422 | qdf_mem_free(cur_chan_list); |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 427 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 428 | * @adapter: HDD adapter |
| 429 | * @chan_number: Channel number |
| 430 | * @chan_bw: Bandwidth |
| 431 | * |
| 432 | * Checks if the given bandwidth is valid for the given channel number. |
| 433 | * |
| 434 | * Return: 0 for success, non-zero for failure |
| 435 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 436 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 437 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 438 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 439 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 440 | uint8_t chan[NUM_CHANNELS]; |
| 441 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 442 | bool found = false; |
| 443 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 444 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 445 | |
| 446 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 447 | if (!hal) { |
| 448 | hdd_err("Invalid HAL context"); |
| 449 | return -EINVAL; |
| 450 | } |
| 451 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 452 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 453 | &len); |
| 454 | if (ret) { |
| 455 | hdd_err("error %d in getting valid channel list", ret); |
| 456 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | for (i = 0; i < len; i++) { |
| 460 | if (chan[i] == chan_number) { |
| 461 | found = true; |
| 462 | break; |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | if (found == false) { |
| 467 | hdd_err("Channel not in driver's valid channel list"); |
| 468 | return -EOPNOTSUPP; |
| 469 | } |
| 470 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 471 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 472 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 473 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 474 | return -EINVAL; |
| 475 | } |
| 476 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 477 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 478 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 479 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 480 | return -EINVAL; |
| 481 | } |
| 482 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 483 | (chan_bw != CH_WIDTH_MAX)) { |
| 484 | hdd_err("Only BW20 possible on channel 14"); |
| 485 | return -EINVAL; |
| 486 | } |
| 487 | } |
| 488 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 489 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 490 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 491 | (chan_bw != CH_WIDTH_MAX)) { |
| 492 | hdd_err("Only BW20 possible on channel 165"); |
| 493 | return -EINVAL; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | return 0; |
| 498 | } |
| 499 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 500 | /** |
| 501 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 502 | * |
| 503 | * Block the unloading of the driver (or) interface up until the |
| 504 | * cds recovery is completed |
| 505 | * |
| 506 | * Return: true for recovery completion else false |
| 507 | */ |
| 508 | static bool hdd_wait_for_recovery_completion(void) |
| 509 | { |
| 510 | int retry = 0; |
| 511 | |
| 512 | /* Wait for recovery to complete */ |
| 513 | while (cds_is_driver_recovering()) { |
| 514 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 515 | hdd_err("Recovery in progress; wait here!!!"); |
| 516 | msleep(1000); |
| 517 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 518 | hdd_err("SSR never completed, error"); |
| 519 | /* |
| 520 | * Trigger the bug_on in the internal builds, in the |
| 521 | * customer builds self-recovery will be enabled |
| 522 | * in those cases just return error. |
| 523 | */ |
| 524 | if (cds_is_self_recovery_enabled()) |
| 525 | return false; |
| 526 | QDF_BUG(0); |
| 527 | } |
| 528 | } |
| 529 | |
| 530 | hdd_info("Recovery completed successfully!"); |
| 531 | return true; |
| 532 | } |
| 533 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 534 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 535 | unsigned long state, void *data) |
| 536 | { |
| 537 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 538 | struct netdev_notifier_info *dev_notif_info = data; |
| 539 | struct net_device *dev = dev_notif_info->dev; |
| 540 | #else |
| 541 | struct net_device *dev = data; |
| 542 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 543 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 544 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 545 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 546 | ENTER_DEV(dev); |
| 547 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | /* Make sure that this callback corresponds to our device. */ |
| 549 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 550 | return NOTIFY_DONE; |
| 551 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 552 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 553 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 554 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 555 | return NOTIFY_DONE; |
| 556 | } |
| 557 | |
| 558 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 559 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 560 | return NOTIFY_DONE; |
| 561 | } |
| 562 | |
| 563 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 564 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 565 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 566 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 567 | return NOTIFY_DONE; |
| 568 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 569 | |
| 570 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 571 | hdd_err("%s: Driver module is closed", __func__); |
| 572 | return NOTIFY_DONE; |
| 573 | } |
| 574 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 575 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | return NOTIFY_DONE; |
| 577 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 578 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | dev->name, state); |
| 580 | |
| 581 | switch (state) { |
| 582 | case NETDEV_REGISTER: |
| 583 | break; |
| 584 | |
| 585 | case NETDEV_UNREGISTER: |
| 586 | break; |
| 587 | |
| 588 | case NETDEV_UP: |
| 589 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 590 | break; |
| 591 | |
| 592 | case NETDEV_DOWN: |
| 593 | break; |
| 594 | |
| 595 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 596 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 597 | complete(&adapter->linkup_event_var); |
| 598 | break; |
| 599 | |
| 600 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 601 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 602 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 603 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 604 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 606 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 607 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 608 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 609 | /* |
| 610 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 611 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 612 | * flag after which driver does not send the cfg80211_scan_done. |
| 613 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 614 | */ |
| 615 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 616 | break; |
| 617 | |
| 618 | default: |
| 619 | break; |
| 620 | } |
| 621 | |
| 622 | return NOTIFY_DONE; |
| 623 | } |
| 624 | |
| 625 | /** |
| 626 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 627 | * @nb: pointer to notifier block |
| 628 | * @state: state |
| 629 | * @ndev: ndev pointer |
| 630 | * |
| 631 | * Return: 0 on success, error number otherwise. |
| 632 | */ |
| 633 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 634 | unsigned long state, |
| 635 | void *ndev) |
| 636 | { |
| 637 | int ret; |
| 638 | |
| 639 | cds_ssr_protect(__func__); |
| 640 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 641 | cds_ssr_unprotect(__func__); |
| 642 | |
| 643 | return ret; |
| 644 | } |
| 645 | |
| 646 | struct notifier_block hdd_netdev_notifier = { |
| 647 | .notifier_call = hdd_netdev_notifier_call, |
| 648 | }; |
| 649 | |
| 650 | /* variable to hold the insmod parameters */ |
| 651 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 652 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 653 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 654 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 655 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 656 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 657 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 658 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 659 | /** |
| 660 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 661 | * @ch_width: NL channel width |
| 662 | * |
| 663 | * Converts the NL channel width to the driver's internal representation |
| 664 | * |
| 665 | * Return: Converted channel width. In case of non matching NL channel width, |
| 666 | * CH_WIDTH_MAX will be returned. |
| 667 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 668 | 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] | 669 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 670 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 671 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 672 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 673 | switch (ch_width) { |
| 674 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 675 | case NL80211_CHAN_WIDTH_20: |
| 676 | return CH_WIDTH_20MHZ; |
| 677 | case NL80211_CHAN_WIDTH_40: |
| 678 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 679 | case NL80211_CHAN_WIDTH_80: |
| 680 | return CH_WIDTH_80MHZ; |
| 681 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 682 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 683 | return CH_WIDTH_80P80MHZ; |
| 684 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 685 | return CH_WIDTH_160MHZ; |
| 686 | else |
| 687 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 688 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 689 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 690 | return CH_WIDTH_160MHZ; |
| 691 | else |
| 692 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 693 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 694 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 695 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 696 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 697 | default: |
| 698 | hdd_err("Invalid channel width %d, setting to default", |
| 699 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 700 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 701 | } |
| 702 | } |
| 703 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 704 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 705 | * @hal: handler to HAL |
| 706 | * @channel: channel id |
| 707 | * @bw_offset: bandwidth offset |
| 708 | * |
| 709 | * Function invokes sme api to find the operating class |
| 710 | * |
| 711 | * Return: operating class |
| 712 | */ |
| 713 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 714 | uint8_t bw_offset) |
| 715 | { |
| 716 | uint8_t opclass = 0; |
| 717 | |
| 718 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 719 | return opclass; |
| 720 | } |
| 721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 722 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 723 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 724 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 725 | * @bitmask: Bitmask of log levels to be enabled |
| 726 | * |
| 727 | * Called immediately after the cfg.ini is read in order to configure |
| 728 | * the desired trace levels. |
| 729 | * |
| 730 | * Return: None |
| 731 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 732 | 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] | 733 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 734 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 735 | int qdf_print_idx = -1; |
| 736 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 737 | /* |
| 738 | * if the bitmask is the default value, then a bitmask was not |
| 739 | * specified in cfg.ini, so leave the logging level alone (it |
| 740 | * will remain at the "compiled in" default value) |
| 741 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 742 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 743 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 744 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 745 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 747 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 748 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 749 | QDF_TRACE_LEVEL_NONE, 0); |
| 750 | |
| 751 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 752 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 754 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | while (0 != bitmask) { |
| 756 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 757 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 758 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 759 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 760 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 762 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | level++; |
| 764 | bitmask >>= 1; |
| 765 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 766 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | } |
| 768 | |
| 769 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 770 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 771 | * @hdd_ctx: HDD context pointer |
| 772 | * |
| 773 | * Return: 0 if the context is valid. Error code otherwise |
| 774 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 775 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 776 | { |
| 777 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 778 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 779 | return -ENODEV; |
| 780 | } |
| 781 | |
| 782 | if (cds_is_driver_recovering()) { |
| 783 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 784 | (void *)_RET_IP_, cds_get_driver_state()); |
| 785 | return -EAGAIN; |
| 786 | } |
| 787 | |
| 788 | if (hdd_ctx->start_modules_in_progress || |
| 789 | hdd_ctx->stop_modules_in_progress) { |
| 790 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 791 | (void *)_RET_IP_); |
| 792 | return -EAGAIN; |
| 793 | } |
| 794 | |
| 795 | return 0; |
| 796 | } |
| 797 | |
| 798 | |
| 799 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | * wlan_hdd_validate_context() - check the HDD context |
| 801 | * @hdd_ctx: HDD context pointer |
| 802 | * |
| 803 | * Return: 0 if the context is valid. Error code otherwise |
| 804 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 805 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 806 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 808 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | return -ENODEV; |
| 810 | } |
| 811 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 812 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 813 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 814 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 815 | return -EAGAIN; |
| 816 | } |
| 817 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 818 | if (cds_is_load_or_unload_in_progress()) { |
| 819 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 820 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 821 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 822 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 823 | |
| 824 | if (hdd_ctx->start_modules_in_progress || |
| 825 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 826 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 827 | (void *)_RET_IP_); |
| 828 | return -EAGAIN; |
| 829 | } |
| 830 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 831 | if (cds_is_driver_in_bad_state()) { |
| 832 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 833 | (void *)_RET_IP_, cds_get_driver_state()); |
| 834 | return -ENODEV; |
| 835 | } |
| 836 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | return 0; |
| 838 | } |
| 839 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 840 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 841 | { |
| 842 | if (!adapter) { |
| 843 | hdd_err("adapter is null"); |
| 844 | return -EINVAL; |
| 845 | } |
| 846 | |
| 847 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 848 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 849 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 850 | return -EINVAL; |
| 851 | } |
| 852 | |
| 853 | if (!adapter->dev) { |
| 854 | hdd_err("adapter net_device is null"); |
| 855 | return -EINVAL; |
| 856 | } |
| 857 | |
| 858 | if (!(adapter->dev->flags & IFF_UP)) { |
| 859 | hdd_info("adapter net_device is not up"); |
| 860 | return -EAGAIN; |
| 861 | } |
| 862 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 863 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 864 | hdd_info("adapter session is not open"); |
| 865 | return -EAGAIN; |
| 866 | } |
| 867 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 868 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 869 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 870 | return -EINVAL; |
| 871 | } |
| 872 | |
| 873 | return 0; |
| 874 | } |
| 875 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 877 | * wlan_hdd_validate_modules_state() - Check modules status |
| 878 | * @hdd_ctx: HDD context pointer |
| 879 | * |
| 880 | * Check's the driver module's state and returns true if the |
| 881 | * modules are enabled returns false if modules are closed. |
| 882 | * |
| 883 | * Return: True if modules are enabled or false. |
| 884 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 885 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 886 | { |
| 887 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 888 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 889 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 890 | hdd_notice("Modules not enabled, Present status: %d", |
| 891 | hdd_ctx->driver_status); |
| 892 | return false; |
| 893 | } |
| 894 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 895 | return true; |
| 896 | } |
| 897 | |
| 898 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 899 | * 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] | 900 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | * |
| 902 | * This function sets the IBSS power save config parameters to WMA |
| 903 | * which will send it to firmware if FW supports IBSS power save |
| 904 | * before vdev start. |
| 905 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 906 | * 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] | 907 | * on failure. |
| 908 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 909 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 910 | { |
| 911 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 912 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 913 | |
| 914 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 915 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 916 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 917 | } |
| 918 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 919 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 921 | hdd_ctx->config->ibssATIMWinSize, |
| 922 | VDEV_CMD); |
| 923 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 924 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 925 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 926 | } |
| 927 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 928 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 929 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 930 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 931 | VDEV_CMD); |
| 932 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 933 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 934 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 935 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 936 | } |
| 937 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 938 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 939 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 940 | hdd_ctx->config-> |
| 941 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 942 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 943 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 944 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 945 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 946 | } |
| 947 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 948 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 950 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 951 | VDEV_CMD); |
| 952 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 953 | hdd_err("WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 954 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | } |
| 956 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 957 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 958 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 959 | hdd_ctx->config->ibssInactivityCount, |
| 960 | VDEV_CMD); |
| 961 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 962 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 963 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | } |
| 965 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 966 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 967 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 968 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 969 | VDEV_CMD); |
| 970 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 971 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 972 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 973 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | } |
| 975 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 976 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 978 | hdd_ctx->config->ibssPsWarmupTime, |
| 979 | VDEV_CMD); |
| 980 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 981 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 982 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 983 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 984 | } |
| 985 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 986 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 987 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 988 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 989 | VDEV_CMD); |
| 990 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 991 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 992 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 993 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | } |
| 995 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 996 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | } |
| 998 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 999 | #ifdef FEATURE_RUNTIME_PM |
| 1000 | /** |
| 1001 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1002 | * @hdd_ctx: HDD context |
| 1003 | * |
| 1004 | * Return: None |
| 1005 | */ |
| 1006 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1007 | { |
| 1008 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1009 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1010 | qdf_runtime_lock_init(&ctx->dfs); |
| 1011 | |
| 1012 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1013 | } |
| 1014 | |
| 1015 | /** |
| 1016 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1017 | * @hdd_ctx: HDD Context |
| 1018 | * |
| 1019 | * Return: None |
| 1020 | */ |
| 1021 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1022 | { |
| 1023 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1024 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1025 | qdf_runtime_lock_deinit(&ctx->dfs); |
| 1026 | |
| 1027 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1028 | } |
| 1029 | |
| 1030 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
| 1031 | { |
| 1032 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 1033 | |
| 1034 | qdf_runtime_lock_init(&ctx->connect); |
| 1035 | } |
| 1036 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 1037 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1038 | { |
| 1039 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 1040 | |
| 1041 | qdf_runtime_lock_deinit(&ctx->connect); |
| 1042 | } |
| 1043 | #else /* FEATURE_RUNTIME_PM */ |
| 1044 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1045 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
| 1046 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 1047 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1048 | #endif /* FEATURE_RUNTIME_PM */ |
| 1049 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | #define INTF_MACADDR_MASK 0x7 |
| 1051 | |
| 1052 | /** |
| 1053 | * hdd_update_macaddr() - update mac address |
| 1054 | * @config: hdd configuration |
| 1055 | * @hw_macaddr: mac address |
| 1056 | * |
| 1057 | * Mac address for multiple virtual interface is found as following |
| 1058 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1059 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1060 | * define the mac address for the remaining interfaces and locally |
| 1061 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1062 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1063 | * interface). |
| 1064 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1065 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1066 | * |
| 1067 | * Return: None |
| 1068 | */ |
| 1069 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1070 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1071 | { |
| 1072 | int8_t i; |
| 1073 | uint8_t macaddr_b3, tmp_br3; |
| 1074 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1075 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1076 | QDF_MAC_ADDR_SIZE); |
| 1077 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1078 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1079 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1080 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1081 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1082 | INTF_MACADDR_MASK; |
| 1083 | macaddr_b3 += tmp_br3; |
| 1084 | |
| 1085 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1086 | * mac address range before collision |
| 1087 | */ |
| 1088 | macaddr_b3 ^= (1 << 7); |
| 1089 | |
| 1090 | /* Set locally administered bit */ |
| 1091 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1092 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1093 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1094 | MAC_ADDRESS_STR, i, |
| 1095 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1096 | } |
| 1097 | } |
| 1098 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1099 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1100 | { |
| 1101 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1102 | struct tdls_start_params tdls_cfg; |
| 1103 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1104 | struct hdd_config *cfg = hdd_ctx->config; |
| 1105 | QDF_STATUS status; |
| 1106 | |
| 1107 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1108 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1109 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1110 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1111 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1112 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1113 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1114 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1115 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1116 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1117 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1118 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1119 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1120 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1121 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1122 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1123 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1124 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1125 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1126 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1127 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1128 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1129 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1130 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1131 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1132 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1133 | (cfg->fTDLSExternalControl ? |
| 1134 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1135 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1136 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1137 | |
| 1138 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1139 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1140 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1141 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1142 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1143 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1144 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1145 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 1146 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 1147 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 1148 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
| 1149 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1150 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1151 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1152 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1153 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1154 | |
| 1155 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1156 | if (status != QDF_STATUS_SUCCESS) { |
| 1157 | hdd_err("failed pmo psoc configuration"); |
| 1158 | return -EINVAL; |
| 1159 | } |
| 1160 | |
| 1161 | hdd_ctx->tdls_umac_comp_active = true; |
| 1162 | /* enable napier specific tdls data path */ |
| 1163 | hdd_ctx->tdls_nap_active = true; |
| 1164 | |
| 1165 | return 0; |
| 1166 | } |
| 1167 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1168 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1169 | struct wma_tgt_services *cfg) |
| 1170 | { |
| 1171 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1172 | |
| 1173 | /* Set up UAPSD */ |
| 1174 | config->apUapsdEnabled &= cfg->uapsd; |
| 1175 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1176 | /* 11AX mode support */ |
| 1177 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1178 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1179 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1180 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1181 | /* 11AC mode support */ |
| 1182 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1183 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1184 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1185 | |
| 1186 | /* ARP offload: override user setting if invalid */ |
| 1187 | config->fhostArpOffload &= cfg->arp_offload; |
| 1188 | |
| 1189 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1190 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1191 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1192 | if (cfg->pno_offload) |
| 1193 | config->PnoOffload = true; |
| 1194 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1195 | #ifdef FEATURE_WLAN_TDLS |
| 1196 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1197 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1198 | cfg->en_tdls_offchan; |
| 1199 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1200 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1201 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1202 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1203 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1204 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1206 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1207 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1208 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1209 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1210 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1211 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1212 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1213 | |
| 1214 | } |
| 1215 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1216 | /** |
| 1217 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1218 | * @hdd_ctx: HDD context |
| 1219 | * |
| 1220 | * Sets the Nss per vdev type based on INI |
| 1221 | * |
| 1222 | * Return: None |
| 1223 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1224 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1225 | { |
| 1226 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1227 | uint8_t max_supp_nss = 1; |
| 1228 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1229 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1230 | max_supp_nss = 2; |
| 1231 | |
| 1232 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1233 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1234 | |
| 1235 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1236 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1237 | } |
| 1238 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1239 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1240 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1241 | * @hdd_ctx: HDD context |
| 1242 | * |
| 1243 | * Updates wiphy vhtcap fields |
| 1244 | * |
| 1245 | * Return: None |
| 1246 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1247 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1248 | { |
| 1249 | struct ieee80211_supported_band *band_5g = |
| 1250 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1251 | uint32_t val; |
| 1252 | |
| 1253 | if (!band_5g) { |
| 1254 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1255 | return; |
| 1256 | } |
| 1257 | |
| 1258 | val = hdd_ctx->config->txBFCsnValue; |
| 1259 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1260 | |
| 1261 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1262 | band_5g->vht_cap.cap |= |
| 1263 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1264 | |
| 1265 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1266 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1267 | } |
| 1268 | |
| 1269 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1270 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1271 | * @hdd_ctx: HDD context |
| 1272 | * |
| 1273 | * Sets the DBS capability as per INI and firmware capability |
| 1274 | * |
| 1275 | * Return: None |
| 1276 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1277 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1278 | { |
| 1279 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1280 | uint8_t hw_dbs_capable = 0; |
| 1281 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1282 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1283 | ((cfg_ini->dual_mac_feature_disable == |
| 1284 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1285 | (cfg_ini->dual_mac_feature_disable == |
| 1286 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1287 | hw_dbs_capable = 1; |
| 1288 | |
| 1289 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1290 | } |
| 1291 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1292 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1293 | struct wma_tgt_ht_cap *cfg) |
| 1294 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1295 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | uint32_t value, val32; |
| 1297 | uint16_t val16; |
| 1298 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1299 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1300 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1301 | uint8_t enable_tx_stbc; |
| 1302 | |
| 1303 | /* check and update RX STBC */ |
| 1304 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1305 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1306 | |
| 1307 | /* get the MPDU density */ |
| 1308 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1309 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1310 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1311 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1312 | value = 0; |
| 1313 | } |
| 1314 | |
| 1315 | /* |
| 1316 | * MPDU density: |
| 1317 | * override user's setting if value is larger |
| 1318 | * than the one supported by target |
| 1319 | */ |
| 1320 | if (value > cfg->mpdu_density) { |
| 1321 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1322 | cfg->mpdu_density); |
| 1323 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1324 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1325 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1326 | } |
| 1327 | |
| 1328 | /* get the HT capability info */ |
| 1329 | 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] | 1330 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1331 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1332 | return; |
| 1333 | } |
| 1334 | val16 = (uint16_t) val32; |
| 1335 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1336 | |
| 1337 | /* Set the LDPC capability */ |
| 1338 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1339 | |
| 1340 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1341 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1342 | |
| 1343 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1344 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1345 | |
| 1346 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1347 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1348 | |
| 1349 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1350 | |
| 1351 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1352 | pconfig->enable2x2 = 1; |
| 1353 | } else { |
| 1354 | pconfig->enable2x2 = 0; |
| 1355 | enable_tx_stbc = 0; |
| 1356 | |
| 1357 | /* 1x1 */ |
| 1358 | /* Update Rx Highest Long GI data Rate */ |
| 1359 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1360 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1361 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1362 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1363 | 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] | 1364 | } |
| 1365 | |
| 1366 | /* Update Tx Highest Long GI data Rate */ |
| 1367 | if (sme_cfg_set_int |
| 1368 | (hdd_ctx->hHal, |
| 1369 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1370 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1371 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1372 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | } |
| 1374 | } |
| 1375 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1376 | enable_tx_stbc = 0; |
| 1377 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1378 | |
| 1379 | val32 = val16; |
| 1380 | 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] | 1381 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1382 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1383 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1384 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1385 | 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] | 1386 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1387 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1388 | |
| 1389 | if (pconfig->enable2x2) { |
| 1390 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1391 | mcs_set[value] = |
| 1392 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1393 | |
| 1394 | status = |
| 1395 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1396 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1397 | mcs_set, |
| 1398 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1399 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1400 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1401 | } |
| 1402 | } |
| 1403 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1404 | } |
| 1405 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1406 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1407 | struct wma_tgt_vht_cap *cfg) |
| 1408 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1409 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1410 | uint32_t value = 0; |
| 1411 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1412 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1413 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1414 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1415 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1416 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1417 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1418 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1419 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1420 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1421 | return; |
| 1422 | } |
| 1423 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1424 | /* Get the current MPDU length */ |
| 1425 | status = |
| 1426 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1427 | &value); |
| 1428 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1429 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1430 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1431 | value = 0; |
| 1432 | } |
| 1433 | |
| 1434 | /* |
| 1435 | * VHT max MPDU length: |
| 1436 | * override if user configured value is too high |
| 1437 | * that the target cannot support |
| 1438 | */ |
| 1439 | if (value > cfg->vht_max_mpdu) { |
| 1440 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1441 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1442 | cfg->vht_max_mpdu); |
| 1443 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1444 | if (status == QDF_STATUS_E_FAILURE) |
| 1445 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1446 | } |
| 1447 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1448 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1449 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1450 | |
| 1451 | if (pconfig->enable2x2) |
| 1452 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1453 | |
| 1454 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1455 | QDF_STATUS_E_FAILURE) { |
| 1456 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1457 | } |
| 1458 | |
| 1459 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1460 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1461 | if (pconfig->enable2x2) |
| 1462 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1463 | |
| 1464 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1465 | QDF_STATUS_E_FAILURE) { |
| 1466 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1467 | } |
| 1468 | |
| 1469 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1470 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1471 | if (pconfig->enable2x2) |
| 1472 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1473 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1474 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1475 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1476 | |
| 1477 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1478 | QDF_STATUS_E_FAILURE) { |
| 1479 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1480 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1481 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1482 | 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] | 1483 | &value); |
| 1484 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1485 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1486 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1487 | value = 0; |
| 1488 | } |
| 1489 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1490 | /* Set HW RX LDPC capability */ |
| 1491 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1492 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1494 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1495 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1497 | if (status == QDF_STATUS_E_FAILURE) |
| 1498 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | /* Get current GI 80 value */ |
| 1502 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1503 | &value); |
| 1504 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1505 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1506 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | value = 0; |
| 1508 | } |
| 1509 | |
| 1510 | /* set the Guard interval 80MHz */ |
| 1511 | if (value && !cfg->vht_short_gi_80) { |
| 1512 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1513 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1514 | cfg->vht_short_gi_80); |
| 1515 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1516 | if (status == QDF_STATUS_E_FAILURE) |
| 1517 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | } |
| 1519 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1520 | /* Get VHT TX STBC cap */ |
| 1521 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1522 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1523 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1524 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1525 | value = 0; |
| 1526 | } |
| 1527 | |
| 1528 | /* VHT TX STBC cap */ |
| 1529 | if (value && !cfg->vht_tx_stbc) { |
| 1530 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1531 | cfg->vht_tx_stbc); |
| 1532 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1533 | if (status == QDF_STATUS_E_FAILURE) |
| 1534 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | } |
| 1536 | |
| 1537 | /* Get VHT RX STBC cap */ |
| 1538 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1539 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1540 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1541 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | value = 0; |
| 1543 | } |
| 1544 | |
| 1545 | /* VHT RX STBC cap */ |
| 1546 | if (value && !cfg->vht_rx_stbc) { |
| 1547 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1548 | cfg->vht_rx_stbc); |
| 1549 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1550 | if (status == QDF_STATUS_E_FAILURE) |
| 1551 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1552 | } |
| 1553 | |
| 1554 | /* Get VHT SU Beamformer cap */ |
| 1555 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 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 VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | value = 0; |
| 1561 | } |
| 1562 | |
| 1563 | /* set VHT SU Beamformer cap */ |
| 1564 | if (value && !cfg->vht_su_bformer) { |
| 1565 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1566 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1567 | cfg->vht_su_bformer); |
| 1568 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1569 | if (status == QDF_STATUS_E_FAILURE) |
| 1570 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | /* check and update SU BEAMFORMEE capabality */ |
| 1574 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1575 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1576 | |
| 1577 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1578 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1579 | pconfig->enableTxBF); |
| 1580 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1581 | if (status == QDF_STATUS_E_FAILURE) |
| 1582 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1583 | |
| 1584 | /* Get VHT MU Beamformer cap */ |
| 1585 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1586 | &value); |
| 1587 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1588 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1589 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | value = 0; |
| 1591 | } |
| 1592 | |
| 1593 | /* set VHT MU Beamformer cap */ |
| 1594 | if (value && !cfg->vht_mu_bformer) { |
| 1595 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1596 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1597 | cfg->vht_mu_bformer); |
| 1598 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1599 | if (status == QDF_STATUS_E_FAILURE) |
| 1600 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1601 | } |
| 1602 | |
| 1603 | /* Get VHT MU Beamformee cap */ |
| 1604 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1605 | &value); |
| 1606 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1607 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1608 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | value = 0; |
| 1610 | } |
| 1611 | |
| 1612 | /* set VHT MU Beamformee cap */ |
| 1613 | if (value && !cfg->vht_mu_bformee) { |
| 1614 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1615 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1616 | cfg->vht_mu_bformee); |
| 1617 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1618 | if (status == QDF_STATUS_E_FAILURE) |
| 1619 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | } |
| 1621 | |
| 1622 | /* Get VHT MAX AMPDU Len exp */ |
| 1623 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1624 | &value); |
| 1625 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1626 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1627 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1628 | value = 0; |
| 1629 | } |
| 1630 | |
| 1631 | /* |
| 1632 | * VHT max AMPDU len exp: |
| 1633 | * override if user configured value is too high |
| 1634 | * that the target cannot support. |
| 1635 | * Even though Rome publish ampdu_len=7, it can |
| 1636 | * only support 4 because of some h/w bug. |
| 1637 | */ |
| 1638 | |
| 1639 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1640 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1641 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1642 | cfg->vht_max_ampdu_len_exp); |
| 1643 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1644 | if (status == QDF_STATUS_E_FAILURE) |
| 1645 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1646 | } |
| 1647 | |
| 1648 | /* Get VHT TXOP PS CAP */ |
| 1649 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1650 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1651 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1652 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1653 | value = 0; |
| 1654 | } |
| 1655 | |
| 1656 | /* set VHT TXOP PS cap */ |
| 1657 | if (value && !cfg->vht_txop_ps) { |
| 1658 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1659 | cfg->vht_txop_ps); |
| 1660 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1661 | if (status == QDF_STATUS_E_FAILURE) |
| 1662 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1663 | } |
| 1664 | |
| 1665 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1666 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1667 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1668 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1669 | else |
| 1670 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1671 | |
| 1672 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1673 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1674 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1675 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1676 | VHT_CAP_160_AND_80P80_SUPP); |
| 1677 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1678 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1679 | band_5g->vht_cap.cap |= |
| 1680 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1681 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1682 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1683 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1684 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1685 | VHT_CAP_160_SUPP); |
| 1686 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1687 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | band_5g->vht_cap.cap |= |
| 1689 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1690 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1691 | } |
| 1692 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1693 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1694 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1695 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1696 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1697 | &value); |
| 1698 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1699 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1700 | value = 0; |
| 1701 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1702 | /* set the Guard interval 160MHz */ |
| 1703 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1704 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1705 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1706 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1707 | |
| 1708 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1709 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1710 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1711 | |
| 1712 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1713 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1714 | |
| 1715 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1716 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1717 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1718 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1719 | |
| 1720 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1721 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1722 | |
| 1723 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1724 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1725 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1726 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1727 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1728 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1729 | |
| 1730 | band_5g->vht_cap.cap |= |
| 1731 | (cfg->vht_max_ampdu_len_exp << |
| 1732 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1733 | |
| 1734 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1735 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1736 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1737 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1738 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1739 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1740 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1741 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1742 | |
| 1743 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1744 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1745 | |
| 1746 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1747 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1748 | /** |
| 1749 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1750 | * @hdd_ctx: Pointer to the HDD context |
| 1751 | * |
| 1752 | * Auto-generate mac address using device serial number. |
| 1753 | * Keep the first 3 bytes of OUI as before and replace |
| 1754 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1755 | * |
| 1756 | * Return: 0 for success |
| 1757 | * Non zero failure code for errors |
| 1758 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1759 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1760 | { |
| 1761 | unsigned int serialno = 0; |
| 1762 | struct qdf_mac_addr mac_addr = { |
| 1763 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1764 | }; |
| 1765 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1766 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1767 | if (serialno == 0) |
| 1768 | return -EINVAL; |
| 1769 | |
| 1770 | serialno &= 0x00ffffff; |
| 1771 | |
| 1772 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1773 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1774 | mac_addr.bytes[5] = serialno & 0xff; |
| 1775 | |
| 1776 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1777 | return 0; |
| 1778 | } |
| 1779 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1780 | /** |
| 1781 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1782 | * configuration to cfg_ini in HDD |
| 1783 | * @hdd_ctx: Pointer to hdd_ctx |
| 1784 | * @cfg: target configuration |
| 1785 | * |
| 1786 | * Return: None |
| 1787 | */ |
| 1788 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1789 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1790 | struct wma_tgt_cfg *cfg) |
| 1791 | { |
| 1792 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1793 | } |
| 1794 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1795 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1796 | struct wma_tgt_cfg *cfg) |
| 1797 | { |
| 1798 | } |
| 1799 | #endif |
| 1800 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1801 | uint8_t hdd_check_green_ap_enable(struct hdd_context *hdd_ctx, |
| 1802 | bool *is_enabled) |
| 1803 | { |
| 1804 | struct hdd_config *cfg; |
| 1805 | uint32_t concurrency_mode; |
| 1806 | |
| 1807 | cfg = hdd_ctx->config; |
| 1808 | if (!cfg) { |
| 1809 | hdd_err("NULL hdd config"); |
| 1810 | return -EINVAL; |
| 1811 | } |
| 1812 | |
| 1813 | concurrency_mode = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc); |
| 1814 | |
| 1815 | if (cfg->enable2x2 && cfg->enableGreenAP) { |
| 1816 | if ((concurrency_mode & (1 << QDF_SAP_MODE)) && |
| 1817 | !(concurrency_mode & (~(1 << QDF_SAP_MODE)))) |
| 1818 | *is_enabled = true; |
| 1819 | } |
| 1820 | return 0; |
| 1821 | } |
| 1822 | |
| 1823 | static int hdd_update_green_ap_config(struct hdd_context *hdd_ctx) |
| 1824 | { |
| 1825 | struct green_ap_user_cfg green_ap_cfg; |
| 1826 | struct hdd_config *cfg = hdd_ctx->config; |
| 1827 | QDF_STATUS status; |
| 1828 | |
| 1829 | green_ap_cfg.host_enable_egap = cfg->enable_egap; |
| 1830 | green_ap_cfg.egap_inactivity_time = cfg->egap_inact_time; |
| 1831 | green_ap_cfg.egap_wait_time = cfg->egap_wait_time; |
| 1832 | green_ap_cfg.egap_feature_flags = cfg->egap_feature_flag; |
| 1833 | |
| 1834 | status = ucfg_green_ap_update_user_config(hdd_ctx->hdd_pdev, |
| 1835 | &green_ap_cfg); |
| 1836 | if (status != QDF_STATUS_SUCCESS) { |
| 1837 | hdd_err("failed to update green ap user configuration"); |
| 1838 | return -EINVAL; |
| 1839 | } |
| 1840 | |
| 1841 | return 0; |
| 1842 | } |
| 1843 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1844 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1845 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1846 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1847 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1848 | struct wma_tgt_cfg *cfg = param; |
| 1849 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1850 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1851 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1852 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1853 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1854 | if (ret) { |
| 1855 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1856 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1857 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1858 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1859 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1860 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1861 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1862 | ret = hdd_update_green_ap_config(hdd_ctx); |
| 1863 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1864 | if (cds_cfg) { |
| 1865 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1866 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1867 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1868 | cds_cfg->sub_20_channel_width = |
| 1869 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1870 | } else { |
| 1871 | cds_cfg->sub_20_channel_width = |
| 1872 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1873 | } |
| 1874 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1875 | |
| 1876 | /* first store the INI band capability */ |
| 1877 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1878 | |
| 1879 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1880 | hdd_ctx->is_fils_roaming_supported = |
| 1881 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1882 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1883 | /* |
| 1884 | * now overwrite the target band capability with INI |
| 1885 | * setting if INI setting is a subset |
| 1886 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1887 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1888 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1889 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1890 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1891 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1892 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1893 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1894 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | } |
| 1896 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1897 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1898 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1899 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1900 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1901 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1902 | } |
| 1903 | |
| 1904 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1905 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1906 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1908 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1910 | static struct qdf_mac_addr default_mac_addr = { |
| 1911 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1912 | }; |
| 1913 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1914 | &default_mac_addr)) { |
| 1915 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1916 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1917 | MAC_ADDRESS_STR, |
| 1918 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1919 | intfMacAddr[0].bytes)); |
| 1920 | } else { |
| 1921 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1922 | MAC_ADDRESS_STR, |
| 1923 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1924 | intfMacAddr[0].bytes)); |
| 1925 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1926 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1927 | } |
| 1928 | |
| 1929 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1930 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1931 | |
| 1932 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1933 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1934 | hdd_lpass_target_config(hdd_ctx, cfg); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1935 | ucfg_green_ap_target_config(hdd_ctx->hdd_pdev, cfg->egap_support); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1936 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1937 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1938 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1939 | |
| 1940 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1941 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1942 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1943 | if (cfg->services.en_11ax) { |
| 1944 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1945 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1946 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1947 | |
| 1948 | hdd_update_vdev_nss(hdd_ctx); |
| 1949 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1950 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1951 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1952 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1953 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1954 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1955 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1956 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1957 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1958 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1959 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1960 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1961 | hdd_ctx->current_antenna_mode); |
| 1962 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1963 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1964 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1965 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1966 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1967 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1968 | if ((hdd_ctx->config->txBFCsnValue > |
| 1969 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1970 | !cfg->tx_bfee_8ss_enabled) |
| 1971 | hdd_ctx->config->txBFCsnValue = |
| 1972 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1973 | |
| 1974 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1975 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1976 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1977 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1978 | |
| 1979 | |
| 1980 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1981 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1982 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1983 | |
| 1984 | /* |
| 1985 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1986 | */ |
| 1987 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1988 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1989 | /* |
| 1990 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1991 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1992 | * configure the STA mode wow pattern. |
| 1993 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1994 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1995 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1996 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1997 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1998 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1999 | /* |
| 2000 | * This needs to be done after HDD pdev is created and stored since |
| 2001 | * it will access the HDD pdev object lock. |
| 2002 | */ |
| 2003 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2004 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2005 | /* Configure NAN datapath features */ |
| 2006 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2007 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2008 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2009 | } |
| 2010 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2011 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2012 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2013 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2014 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2015 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2016 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2017 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2018 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2019 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2020 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2021 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2022 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2023 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2024 | |
| 2025 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2026 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 2027 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2028 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2029 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2030 | true; |
| 2031 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2032 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2033 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2034 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2035 | |
| 2036 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2037 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2038 | |
| 2039 | /** |
| 2040 | * hdd_is_valid_mac_address() - validate MAC address |
| 2041 | * @pMacAddr: Pointer to the input MAC address |
| 2042 | * |
| 2043 | * This function validates whether the given MAC address is valid or not |
| 2044 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2045 | * where X is the hexa decimal digit character and separated by ':' |
| 2046 | * This algorithm works even if MAC address is not separated by ':' |
| 2047 | * |
| 2048 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2049 | * digits and a separator colon : appears in the input string only after |
| 2050 | * an even number of hex digits. |
| 2051 | * |
| 2052 | * Return: 1 for valid and 0 for invalid |
| 2053 | */ |
| 2054 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2055 | { |
| 2056 | int xdigit = 0; |
| 2057 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2058 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2059 | while (*pMacAddr) { |
| 2060 | if (isxdigit(*pMacAddr)) { |
| 2061 | xdigit++; |
| 2062 | } else if (':' == *pMacAddr) { |
| 2063 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2064 | break; |
| 2065 | |
| 2066 | ++separator; |
| 2067 | } else { |
| 2068 | /* Invalid MAC found */ |
| 2069 | return 0; |
| 2070 | } |
| 2071 | ++pMacAddr; |
| 2072 | } |
| 2073 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2074 | } |
| 2075 | |
| 2076 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2077 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2078 | * @dev: Handle to struct net_device to be updated. |
| 2079 | * |
| 2080 | * Return: None |
| 2081 | */ |
| 2082 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2083 | { |
| 2084 | dev->header_ops = NULL; |
| 2085 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2086 | dev->hard_header_len = ETH_HLEN; |
| 2087 | dev->mtu = ETH_DATA_LEN; |
| 2088 | dev->addr_len = ETH_ALEN; |
| 2089 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2090 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2091 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2092 | |
| 2093 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2094 | } |
| 2095 | |
| 2096 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2097 | * __hdd__mon_open() - HDD Open function |
| 2098 | * @dev: Pointer to net_device structure |
| 2099 | * |
| 2100 | * This is called in response to ifconfig up |
| 2101 | * |
| 2102 | * Return: 0 for success; non-zero for failure |
| 2103 | */ |
| 2104 | static int __hdd_mon_open(struct net_device *dev) |
| 2105 | { |
| 2106 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2107 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2108 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2109 | |
| 2110 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2111 | |
| 2112 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2113 | if (ret) |
| 2114 | return ret; |
| 2115 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2116 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2117 | |
| 2118 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2119 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2120 | if (ret) { |
| 2121 | hdd_err("Failed to start WLAN modules return"); |
| 2122 | return ret; |
| 2123 | } |
| 2124 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2125 | |
| 2126 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2127 | ret = hdd_start_adapter(adapter); |
| 2128 | if (ret) { |
| 2129 | hdd_err("Failed to start adapter :%d", |
| 2130 | adapter->device_mode); |
| 2131 | return ret; |
| 2132 | } |
| 2133 | hdd_err("hdd_start_adapters() successful !"); |
| 2134 | } |
| 2135 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2136 | } |
| 2137 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2138 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2139 | |
| 2140 | if (!ret) |
| 2141 | ret = hdd_enable_monitor_mode(dev); |
| 2142 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2143 | return ret; |
| 2144 | } |
| 2145 | |
| 2146 | /** |
| 2147 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2148 | * @dev: Pointer to net_device structure |
| 2149 | * |
| 2150 | * This is called in response to ifconfig up |
| 2151 | * |
| 2152 | * Return: 0 for success; non-zero for failure |
| 2153 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2154 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2155 | { |
| 2156 | int ret; |
| 2157 | |
| 2158 | cds_ssr_protect(__func__); |
| 2159 | ret = __hdd_mon_open(dev); |
| 2160 | cds_ssr_unprotect(__func__); |
| 2161 | |
| 2162 | return ret; |
| 2163 | } |
| 2164 | |
| 2165 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2166 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2167 | * @adapter: pointer to HDD adapter |
| 2168 | * |
| 2169 | * This function is called to start the device specific adapter for |
| 2170 | * the mode passed in the adapter's device_mode. |
| 2171 | * |
| 2172 | * Return: 0 for success; non-zero for failure |
| 2173 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2174 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2175 | { |
| 2176 | |
| 2177 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2178 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2179 | |
| 2180 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2181 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2182 | |
| 2183 | switch (device_mode) { |
| 2184 | case QDF_P2P_CLIENT_MODE: |
| 2185 | case QDF_P2P_DEVICE_MODE: |
| 2186 | case QDF_OCB_MODE: |
| 2187 | case QDF_STA_MODE: |
| 2188 | case QDF_MONITOR_MODE: |
| 2189 | ret = hdd_start_station_adapter(adapter); |
| 2190 | if (ret) |
| 2191 | goto err_start_adapter; |
| 2192 | break; |
| 2193 | case QDF_P2P_GO_MODE: |
| 2194 | case QDF_SAP_MODE: |
| 2195 | ret = hdd_start_ap_adapter(adapter); |
| 2196 | if (ret) |
| 2197 | goto err_start_adapter; |
| 2198 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2199 | case QDF_IBSS_MODE: |
| 2200 | /* |
| 2201 | * For IBSS interface is initialized as part of |
| 2202 | * hdd_init_station_mode() |
| 2203 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2204 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2205 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2206 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2207 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2208 | default: |
| 2209 | hdd_err("Invalid session type %d", device_mode); |
| 2210 | QDF_ASSERT(0); |
| 2211 | goto err_start_adapter; |
| 2212 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2213 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2214 | if (hdd_set_fw_params(adapter)) |
| 2215 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2216 | |
| 2217 | /* |
| 2218 | * Action frame registered in one adapter which will |
| 2219 | * applicable to all interfaces |
| 2220 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2221 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2222 | if (ret < 0) { |
| 2223 | hdd_err("Failed to register frames - ret %d", ret); |
| 2224 | goto err_start_adapter; |
| 2225 | } |
| 2226 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2227 | exit_with_success: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2228 | EXIT(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2229 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2230 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2231 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2232 | err_start_adapter: |
| 2233 | return -EINVAL; |
| 2234 | } |
| 2235 | |
| 2236 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2237 | * hdd_enable_power_management() - API to Enable Power Management |
| 2238 | * |
| 2239 | * API invokes Bus Interface Layer power management functionality |
| 2240 | * |
| 2241 | * Return: None |
| 2242 | */ |
| 2243 | static void hdd_enable_power_management(void) |
| 2244 | { |
| 2245 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2246 | |
| 2247 | if (!hif_ctx) { |
| 2248 | hdd_err("Bus Interface Context is Invalid"); |
| 2249 | return; |
| 2250 | } |
| 2251 | |
| 2252 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2253 | } |
| 2254 | |
| 2255 | /** |
| 2256 | * hdd_disable_power_management() - API to disable Power Management |
| 2257 | * |
| 2258 | * API disable Bus Interface Layer Power management functionality |
| 2259 | * |
| 2260 | * Return: None |
| 2261 | */ |
| 2262 | static void hdd_disable_power_management(void) |
| 2263 | { |
| 2264 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2265 | |
| 2266 | if (!hif_ctx) { |
| 2267 | hdd_err("Bus Interface Context is Invalid"); |
| 2268 | return; |
| 2269 | } |
| 2270 | |
| 2271 | hif_disable_power_management(hif_ctx); |
| 2272 | } |
| 2273 | |
| 2274 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2275 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2276 | * |
| 2277 | * API to update the HW and SW information in the driver |
| 2278 | * |
| 2279 | * Return: None |
| 2280 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2281 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2282 | { |
| 2283 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2284 | size_t target_hw_name_len; |
| 2285 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2286 | |
| 2287 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2288 | if (!hif_sc) { |
| 2289 | hdd_err("HIF context is NULL"); |
| 2290 | return; |
| 2291 | } |
| 2292 | |
| 2293 | /* |
| 2294 | * target hw version/revision would only be retrieved after firmware |
| 2295 | * download |
| 2296 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2297 | hif_get_hw_info(hif_sc, |
| 2298 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2299 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2300 | &target_hw_name); |
| 2301 | |
| 2302 | if (hdd_ctx->target_hw_name) |
| 2303 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2304 | |
| 2305 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2306 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2307 | if (hdd_ctx->target_hw_name) |
| 2308 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2309 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2310 | |
| 2311 | /* Get the wlan hw/fw version */ |
| 2312 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2313 | } |
| 2314 | |
| 2315 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2316 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2317 | * @hdd_ctx: Pointer to hdd context |
| 2318 | * |
| 2319 | * Return: none |
| 2320 | */ |
| 2321 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2322 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2323 | { |
| 2324 | uint8_t num_entries = 0; |
| 2325 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2326 | uint8_t *tx_sched_wrr_ac; |
| 2327 | int i; |
| 2328 | cds_context_type *cds_ctx; |
| 2329 | |
| 2330 | if (NULL == hdd_ctx) |
| 2331 | return; |
| 2332 | |
| 2333 | if (NULL == hdd_ctx->config) { |
| 2334 | /* Do nothing if hdd_ctx is invalid */ |
| 2335 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2336 | return; |
| 2337 | } |
| 2338 | |
| 2339 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2340 | |
| 2341 | if (!cds_ctx) { |
| 2342 | hdd_err("Invalid CDS Context"); |
| 2343 | return; |
| 2344 | } |
| 2345 | |
| 2346 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2347 | switch (i) { |
| 2348 | case OL_TX_WMM_AC_BE: |
| 2349 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2350 | break; |
| 2351 | case OL_TX_WMM_AC_BK: |
| 2352 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2353 | break; |
| 2354 | case OL_TX_WMM_AC_VI: |
| 2355 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2356 | break; |
| 2357 | case OL_TX_WMM_AC_VO: |
| 2358 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2359 | break; |
| 2360 | default: |
| 2361 | tx_sched_wrr_ac = NULL; |
| 2362 | break; |
| 2363 | } |
| 2364 | |
| 2365 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2366 | tx_sched_wrr_param, |
| 2367 | &num_entries, |
| 2368 | sizeof(tx_sched_wrr_param)); |
| 2369 | |
| 2370 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2371 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2372 | tx_sched_wrr_param[0]; |
| 2373 | cds_ctx->ac_specs[i].credit_threshold = |
| 2374 | tx_sched_wrr_param[1]; |
| 2375 | cds_ctx->ac_specs[i].send_limit = |
| 2376 | tx_sched_wrr_param[2]; |
| 2377 | cds_ctx->ac_specs[i].credit_reserve = |
| 2378 | tx_sched_wrr_param[3]; |
| 2379 | cds_ctx->ac_specs[i].discard_weight = |
| 2380 | tx_sched_wrr_param[4]; |
| 2381 | } |
| 2382 | |
| 2383 | num_entries = 0; |
| 2384 | } |
| 2385 | } |
| 2386 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2387 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2388 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2389 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2390 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2391 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2392 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2393 | |
| 2394 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2395 | if (!adapter) { |
| 2396 | hdd_err("Adapter is NULL"); |
| 2397 | return PM_MAX_NUM_OF_MODE; |
| 2398 | } |
| 2399 | |
| 2400 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2401 | adapter->device_mode); |
| 2402 | } |
| 2403 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2404 | static void hdd_register_policy_manager_callback( |
| 2405 | struct wlan_objmgr_psoc *psoc) |
| 2406 | { |
| 2407 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2408 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2409 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2410 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2411 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2412 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2413 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2414 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2415 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2416 | if (QDF_STATUS_SUCCESS != |
| 2417 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2418 | hdd_err("HDD callback registration with policy manager failed"); |
| 2419 | } |
| 2420 | } |
| 2421 | #else |
| 2422 | static void hdd_register_policy_manager_callback( |
| 2423 | struct wlan_objmgr_psoc *psoc) |
| 2424 | { |
| 2425 | } |
| 2426 | #endif |
| 2427 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2428 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2429 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2430 | { |
| 2431 | struct nan_callbacks cb_obj = {0}; |
| 2432 | |
| 2433 | cb_obj.ndi_open = hdd_ndi_open; |
| 2434 | cb_obj.ndi_close = hdd_ndi_close; |
| 2435 | cb_obj.ndi_start = hdd_ndi_start; |
| 2436 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2437 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2438 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2439 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2440 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2441 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2442 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2443 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2444 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2445 | } |
| 2446 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2447 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2448 | { |
| 2449 | } |
| 2450 | #endif |
| 2451 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2452 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2453 | /** |
| 2454 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2455 | * |
| 2456 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2457 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2458 | * |
| 2459 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2460 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2461 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2462 | * fixed. |
| 2463 | * |
| 2464 | * Return: None |
| 2465 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2466 | static void hdd_check_for_leaks(void) |
| 2467 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2468 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2469 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2470 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2471 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2472 | } |
| 2473 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2474 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2475 | #else |
| 2476 | static inline void hdd_check_for_leaks(void) {} |
| 2477 | |
| 2478 | #define hdd_debug_domain_set(domain) |
| 2479 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2480 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2481 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2482 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2483 | * @hdd_ctx: HDD context |
| 2484 | * @adapter: HDD adapter |
| 2485 | * @reinit: flag to indicate from SSR or normal path |
| 2486 | * |
| 2487 | * This function maintains the driver state machine it will be invoked from |
| 2488 | * startup, reinit and change interface. Depending on the driver state shall |
| 2489 | * perform the opening of the modules. |
| 2490 | * |
| 2491 | * Return: 0 for success; non-zero for failure |
| 2492 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2493 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2494 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2495 | bool reinit) |
| 2496 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2497 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2498 | qdf_device_t qdf_dev; |
| 2499 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2500 | bool unint = false; |
| 2501 | void *hif_ctx; |
| 2502 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2503 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2504 | |
| 2505 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2506 | if (!qdf_dev) { |
| 2507 | hdd_err("QDF Device Context is Invalid return"); |
| 2508 | return -EINVAL; |
| 2509 | } |
| 2510 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2511 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2512 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2513 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2514 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2515 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2516 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2517 | hdd_info("Driver modules already Enabled"); |
| 2518 | EXIT(); |
| 2519 | return 0; |
| 2520 | } |
| 2521 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2522 | hdd_ctx->start_modules_in_progress = true; |
| 2523 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2524 | switch (hdd_ctx->driver_status) { |
| 2525 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2526 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2527 | unint = true; |
| 2528 | /* Fall through dont add break here */ |
| 2529 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2530 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2531 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2532 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2533 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2534 | if (!reinit && !unint) { |
| 2535 | ret = pld_power_on(qdf_dev->dev); |
| 2536 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2537 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2538 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2539 | goto release_lock; |
| 2540 | } |
| 2541 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2542 | |
| 2543 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2544 | hdd_ctx->config->enable_fw_log); |
| 2545 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2546 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2547 | qdf_dev->bus_type, |
| 2548 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2549 | HIF_ENABLE_TYPE_PROBE); |
| 2550 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2551 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2552 | goto power_down; |
| 2553 | } |
| 2554 | |
| 2555 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2556 | if (!hif_ctx) { |
| 2557 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2558 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2559 | goto power_down; |
| 2560 | } |
| 2561 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2562 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2563 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2564 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2565 | status); |
| 2566 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2567 | goto hif_close; |
| 2568 | } |
| 2569 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2570 | ret = hdd_update_config(hdd_ctx); |
| 2571 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2572 | hdd_err("Failed to update configuration; errno: %d", |
| 2573 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2574 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2575 | } |
| 2576 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2577 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2578 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2579 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2580 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2581 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2582 | ret = qdf_status_to_os_return(status); |
| 2583 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2584 | } |
| 2585 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2586 | /* initalize components configurations after psoc open */ |
| 2587 | ret = hdd_update_components_config(hdd_ctx); |
| 2588 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2589 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2590 | ret); |
| 2591 | goto close; |
| 2592 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2593 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2594 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2595 | hdd_err("Failed to Open cds post open; status: %d", |
| 2596 | status); |
| 2597 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2598 | goto close; |
| 2599 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2600 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2601 | /* |
| 2602 | * NAN compoenet requires certian operations like, open adapter, |
| 2603 | * close adapter, etc. to be initiated by HDD, for those |
| 2604 | * register HDD callbacks with UMAC's NAN componenet. |
| 2605 | */ |
| 2606 | hdd_nan_register_callbacks(hdd_ctx); |
| 2607 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2608 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2609 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2610 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2611 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2612 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2613 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2614 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2615 | } |
| 2616 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2617 | hdd_register_policy_manager_callback( |
| 2618 | hdd_ctx->hdd_psoc); |
| 2619 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2620 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2621 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2622 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2623 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2624 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2625 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2626 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2627 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2628 | hdd_ftm_mc_process_msg); |
| 2629 | break; |
| 2630 | } |
| 2631 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2632 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2633 | break; |
| 2634 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2635 | |
| 2636 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2637 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2638 | if (ret) { |
| 2639 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2640 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2641 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2642 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2643 | } |
| 2644 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2645 | /* Fall through dont add break here */ |
| 2646 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2647 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2648 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2649 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2650 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2651 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2652 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2653 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2654 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2655 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2656 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2657 | break; |
| 2658 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2659 | |
| 2660 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2661 | if (ret) { |
| 2662 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2663 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2664 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2665 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2666 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2667 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2668 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2669 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2670 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2671 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2672 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2673 | default: |
| 2674 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2675 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2676 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2677 | goto release_lock; |
| 2678 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2679 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2680 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2681 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2682 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2683 | EXIT(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2684 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2685 | return 0; |
| 2686 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2687 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2688 | cds_post_disable(); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2689 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2690 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2691 | cds_txrx_free: |
| 2692 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2693 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2694 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2695 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2696 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2697 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2698 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2699 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2700 | deinit_config: |
| 2701 | cds_deinit_ini_config(); |
| 2702 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2703 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2704 | ol_cds_free(); |
| 2705 | |
| 2706 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2707 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2708 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2709 | power_down: |
| 2710 | if (!reinit && !unint) |
| 2711 | pld_power_off(qdf_dev->dev); |
| 2712 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2713 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2714 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2715 | |
| 2716 | /* many adapter resources are not freed by design in SSR case */ |
| 2717 | if (!reinit) |
| 2718 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2719 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2720 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2721 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2722 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2723 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2724 | } |
| 2725 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2726 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2727 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2728 | { |
| 2729 | int ret = os_if_wifi_pos_register_nl(); |
| 2730 | |
| 2731 | if (ret) |
| 2732 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2733 | |
| 2734 | return ret; |
| 2735 | } |
| 2736 | |
| 2737 | static int hdd_deactivate_wifi_pos(void) |
| 2738 | { |
| 2739 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2740 | |
| 2741 | if (ret) |
| 2742 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2743 | |
| 2744 | return ret; |
| 2745 | } |
| 2746 | |
| 2747 | /** |
| 2748 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2749 | * @hdd_ctx: hdd context |
| 2750 | * |
| 2751 | * Return: status of operation |
| 2752 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2753 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2754 | { |
| 2755 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2756 | struct hdd_config *cfg = hdd_ctx->config; |
| 2757 | |
| 2758 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2759 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2760 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2761 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2762 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2763 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2764 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2765 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2766 | } |
| 2767 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2768 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2769 | { |
| 2770 | return oem_activate_service(hdd_ctx); |
| 2771 | } |
| 2772 | |
| 2773 | static int hdd_deactivate_wifi_pos(void) |
| 2774 | { |
| 2775 | return 0; |
| 2776 | } |
| 2777 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2778 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2779 | { |
| 2780 | } |
| 2781 | #endif |
| 2782 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2783 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2784 | * __hdd_open() - HDD Open function |
| 2785 | * @dev: Pointer to net_device structure |
| 2786 | * |
| 2787 | * This is called in response to ifconfig up |
| 2788 | * |
| 2789 | * Return: 0 for success; non-zero for failure |
| 2790 | */ |
| 2791 | static int __hdd_open(struct net_device *dev) |
| 2792 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2793 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2794 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2795 | int ret; |
| 2796 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2797 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2798 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2799 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2800 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2801 | /* Nothing to be done if device is unloading */ |
| 2802 | if (cds_is_driver_unloading()) { |
| 2803 | hdd_err("Driver is unloading can not open the hdd"); |
| 2804 | return -EBUSY; |
| 2805 | } |
| 2806 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2807 | if (cds_is_driver_recovering()) { |
| 2808 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2809 | return -EBUSY; |
| 2810 | } |
| 2811 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2812 | mutex_lock(&hdd_init_deinit_lock); |
| 2813 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2814 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2815 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2816 | /* |
| 2817 | * This scenario can be hit in cases where in the wlan driver after |
| 2818 | * registering the netdevices and there is a failure in driver |
| 2819 | * initialization. So return error gracefully because the netdevices |
| 2820 | * will be de-registered as part of the load failure. |
| 2821 | */ |
| 2822 | |
| 2823 | if (!cds_is_driver_loaded()) { |
| 2824 | hdd_err("Failed to start the wlan driver!!"); |
| 2825 | ret = -EIO; |
| 2826 | goto err_hdd_hdd_init_deinit_lock; |
| 2827 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2828 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2829 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2830 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2831 | if (ret) { |
| 2832 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2833 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2834 | } |
| 2835 | |
| 2836 | |
| 2837 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2838 | ret = hdd_start_adapter(adapter); |
| 2839 | if (ret) { |
| 2840 | hdd_err("Failed to start adapter :%d", |
| 2841 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2842 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2843 | } |
| 2844 | } |
| 2845 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2846 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2847 | 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] | 2848 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2849 | /* Enable TX queues only when we are connected */ |
| 2850 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2851 | WLAN_START_ALL_NETIF_QUEUE, |
| 2852 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2853 | } |
| 2854 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2855 | /* Enable carrier and transmit queues for NDI */ |
| 2856 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2857 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2858 | wlan_hdd_netif_queue_control(adapter, |
| 2859 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2860 | WLAN_CONTROL_PATH); |
| 2861 | } |
| 2862 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2863 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2864 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2865 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2866 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2867 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2868 | return ret; |
| 2869 | } |
| 2870 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2871 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2872 | /** |
| 2873 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2874 | * @dev: Pointer to net_device structure |
| 2875 | * |
| 2876 | * This is called in response to ifconfig up |
| 2877 | * |
| 2878 | * Return: 0 for success; non-zero for failure |
| 2879 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2880 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2881 | { |
| 2882 | int ret; |
| 2883 | |
| 2884 | cds_ssr_protect(__func__); |
| 2885 | ret = __hdd_open(dev); |
| 2886 | cds_ssr_unprotect(__func__); |
| 2887 | |
| 2888 | return ret; |
| 2889 | } |
| 2890 | |
| 2891 | /** |
| 2892 | * __hdd_stop() - HDD stop function |
| 2893 | * @dev: Pointer to net_device structure |
| 2894 | * |
| 2895 | * This is called in response to ifconfig down |
| 2896 | * |
| 2897 | * Return: 0 for success; non-zero for failure |
| 2898 | */ |
| 2899 | static int __hdd_stop(struct net_device *dev) |
| 2900 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2901 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2902 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2903 | int ret; |
| 2904 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2905 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2906 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2907 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2908 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2909 | |
| 2910 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2911 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2912 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | |
| 2914 | /* Nothing to be done if the interface is not opened */ |
| 2915 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2916 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2917 | return -ENODEV; |
| 2918 | } |
| 2919 | |
| 2920 | /* Make sure the interface is marked as closed */ |
| 2921 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2922 | |
| 2923 | hdd_debug("Disabling Auto Power save timer"); |
| 2924 | sme_ps_disable_auto_ps_timer( |
| 2925 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2926 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2927 | |
| 2928 | /* |
| 2929 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2930 | * be called on that interface |
| 2931 | */ |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 2932 | hdd_notice("Disabling queues, adapter device mode: %s(%d)", |
| 2933 | hdd_device_mode_to_string(adapter->device_mode), |
| 2934 | adapter->device_mode); |
| 2935 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2936 | wlan_hdd_netif_queue_control(adapter, |
| 2937 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2938 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2939 | |
| 2940 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2941 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2942 | * bursty in nature and depends on the need to transfer. The service |
| 2943 | * layer may down the interface after the usage and up again when |
| 2944 | * required. In some sense, the NDI is expected to be available |
| 2945 | * (like SAP) iface until NDI delete request is issued by the service |
| 2946 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2947 | * interface (NDI). |
| 2948 | */ |
| 2949 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2950 | return 0; |
| 2951 | |
| 2952 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2953 | * The interface is marked as down for outside world (aka kernel) |
| 2954 | * But the driver is pretty much alive inside. The driver needs to |
| 2955 | * tear down the existing connection on the netdev (session) |
| 2956 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2957 | * for this interface. The call also needs to wait until the above |
| 2958 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2959 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2960 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2961 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2962 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2963 | |
| 2964 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2965 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2966 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2967 | |
| 2968 | /* |
| 2969 | * Find if any iface is up. If any iface is up then can't put device to |
| 2970 | * sleep/power save mode |
| 2971 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2972 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2973 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2974 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 2975 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2976 | hdd_prevent_suspend_timeout( |
| 2977 | hdd_ctx->config->iface_change_wait_time, |
| 2978 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2979 | } |
| 2980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2981 | EXIT(); |
| 2982 | return 0; |
| 2983 | } |
| 2984 | |
| 2985 | /** |
| 2986 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2987 | * @dev: pointer to net_device structure |
| 2988 | * |
| 2989 | * This is called in response to ifconfig down |
| 2990 | * |
| 2991 | * Return: 0 for success and error number for failure |
| 2992 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2993 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2994 | { |
| 2995 | int ret; |
| 2996 | |
| 2997 | cds_ssr_protect(__func__); |
| 2998 | ret = __hdd_stop(dev); |
| 2999 | cds_ssr_unprotect(__func__); |
| 3000 | |
| 3001 | return ret; |
| 3002 | } |
| 3003 | |
| 3004 | /** |
| 3005 | * __hdd_uninit() - HDD uninit function |
| 3006 | * @dev: Pointer to net_device structure |
| 3007 | * |
| 3008 | * This is called during the netdev unregister to uninitialize all data |
| 3009 | * associated with the device |
| 3010 | * |
| 3011 | * Return: None |
| 3012 | */ |
| 3013 | static void __hdd_uninit(struct net_device *dev) |
| 3014 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3015 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3016 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3018 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3019 | |
| 3020 | do { |
| 3021 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3022 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3023 | break; |
| 3024 | } |
| 3025 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3026 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3027 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3028 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3029 | break; |
| 3030 | } |
| 3031 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3032 | if (dev != adapter->dev) |
| 3033 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3034 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3035 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3036 | |
| 3037 | /* after uninit our adapter structure will no longer be valid */ |
| 3038 | adapter->dev = NULL; |
| 3039 | adapter->magic = 0; |
| 3040 | } while (0); |
| 3041 | |
| 3042 | EXIT(); |
| 3043 | } |
| 3044 | |
| 3045 | /** |
| 3046 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3047 | * @dev: pointer to net_device structure |
| 3048 | * |
| 3049 | * This is called during the netdev unregister to uninitialize all data |
| 3050 | * associated with the device |
| 3051 | * |
| 3052 | * Return: none |
| 3053 | */ |
| 3054 | static void hdd_uninit(struct net_device *dev) |
| 3055 | { |
| 3056 | cds_ssr_protect(__func__); |
| 3057 | __hdd_uninit(dev); |
| 3058 | cds_ssr_unprotect(__func__); |
| 3059 | } |
| 3060 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3061 | static int hdd_open_cesium_nl_sock(void) |
| 3062 | { |
| 3063 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3064 | struct netlink_kernel_cfg cfg = { |
| 3065 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3066 | .input = NULL |
| 3067 | }; |
| 3068 | #endif |
| 3069 | int ret = 0; |
| 3070 | |
| 3071 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3072 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3073 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3074 | THIS_MODULE, |
| 3075 | #endif |
| 3076 | &cfg); |
| 3077 | #else |
| 3078 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3079 | WLAN_NLINK_MCAST_GRP_ID, |
| 3080 | NULL, NULL, THIS_MODULE); |
| 3081 | #endif |
| 3082 | |
| 3083 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3084 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3085 | ret = -ECONNREFUSED; |
| 3086 | } |
| 3087 | |
| 3088 | return ret; |
| 3089 | } |
| 3090 | |
| 3091 | static void hdd_close_cesium_nl_sock(void) |
| 3092 | { |
| 3093 | if (NULL != cesium_nl_srv_sock) { |
| 3094 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3095 | cesium_nl_srv_sock = NULL; |
| 3096 | } |
| 3097 | } |
| 3098 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3099 | /** |
| 3100 | * __hdd_set_mac_address() - set the user specified mac address |
| 3101 | * @dev: Pointer to the net device. |
| 3102 | * @addr: Pointer to the sockaddr. |
| 3103 | * |
| 3104 | * This function sets the user specified mac address using |
| 3105 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3106 | * |
| 3107 | * Return: 0 for success, non zero for failure |
| 3108 | */ |
| 3109 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3110 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3111 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3112 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3113 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3114 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | int ret; |
| 3116 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3117 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3118 | |
| 3119 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3120 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3121 | if (0 != ret) |
| 3122 | return ret; |
| 3123 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3124 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3125 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3126 | |
| 3127 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3128 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3129 | } |
| 3130 | |
| 3131 | /** |
| 3132 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3133 | * function from SSR |
| 3134 | * @dev: pointer to net_device structure |
| 3135 | * @addr: Pointer to the sockaddr |
| 3136 | * |
| 3137 | * This function sets the user specified mac address using |
| 3138 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3139 | * |
| 3140 | * Return: 0 for success. |
| 3141 | */ |
| 3142 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3143 | { |
| 3144 | int ret; |
| 3145 | |
| 3146 | cds_ssr_protect(__func__); |
| 3147 | ret = __hdd_set_mac_address(dev, addr); |
| 3148 | cds_ssr_unprotect(__func__); |
| 3149 | |
| 3150 | return ret; |
| 3151 | } |
| 3152 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3153 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3154 | { |
| 3155 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3156 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3157 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3158 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3159 | break; |
| 3160 | } |
| 3161 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3162 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3163 | return NULL; |
| 3164 | |
| 3165 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3166 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3167 | } |
| 3168 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3169 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3170 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3171 | { |
| 3172 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3173 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3174 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3175 | if (!memcmp(releaseAddr, |
| 3176 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3177 | 6)) { |
| 3178 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3179 | break; |
| 3180 | } |
| 3181 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3182 | } |
| 3183 | |
| 3184 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3185 | /** |
| 3186 | * __hdd_set_multicast_list() - set the multicast address list |
| 3187 | * @dev: Pointer to the WLAN device. |
| 3188 | * @skb: Pointer to OS packet (sk_buff). |
| 3189 | * |
| 3190 | * This funciton sets the multicast address list. |
| 3191 | * |
| 3192 | * Return: None |
| 3193 | */ |
| 3194 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3195 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3196 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | int i = 0, status; |
| 3198 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3199 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3200 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3201 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3202 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3204 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3205 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3206 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3207 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3209 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3210 | goto out; |
| 3211 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3212 | status = hdd_validate_adapter(adapter); |
| 3213 | if (status) |
| 3214 | goto out; |
| 3215 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3216 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3217 | hdd_err("%s: Driver module is closed", __func__); |
| 3218 | return; |
| 3219 | } |
| 3220 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3221 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3222 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3223 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3224 | goto out; |
| 3225 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3226 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3227 | /* Delete already configured multicast address list */ |
| 3228 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3229 | hdd_info("clear previously configured MC address list"); |
| 3230 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3231 | pmo_mc_list_change_notify); |
| 3232 | } |
| 3233 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3234 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3235 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3236 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3237 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | } else { |
| 3239 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3240 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3241 | 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] | 3242 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3243 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3244 | pmo_mc_list_change_notify); |
| 3245 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3246 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3248 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3249 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | if (i == mc_count) |
| 3251 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3252 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3253 | 0, ETH_ALEN); |
| 3254 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3255 | ha->addr, ETH_ALEN); |
| 3256 | hdd_info("mlist[%d] = %pM", i, |
| 3257 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | i++; |
| 3259 | } |
| 3260 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3261 | |
| 3262 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3263 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3264 | mc_list_request->count = mc_count; |
| 3265 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3266 | if (status == 0) { |
| 3267 | hdd_enable_mc_addr_filtering(adapter, |
| 3268 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3269 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3270 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3271 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3272 | out: |
| 3273 | if (mc_list_request) |
| 3274 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3275 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | } |
| 3277 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3278 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3279 | /** |
| 3280 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3281 | * @dev: pointer to net_device |
| 3282 | * |
| 3283 | * Return: none |
| 3284 | */ |
| 3285 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3286 | { |
| 3287 | cds_ssr_protect(__func__); |
| 3288 | __hdd_set_multicast_list(dev); |
| 3289 | cds_ssr_unprotect(__func__); |
| 3290 | } |
| 3291 | #endif |
| 3292 | |
| 3293 | /** |
| 3294 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3295 | * @dev: Pointer to the WLAN device. |
| 3296 | * @skb: Pointer to OS packet (sk_buff). |
| 3297 | * |
| 3298 | * This function is registered with the Linux OS for network |
| 3299 | * core to decide which queue to use first. |
| 3300 | * |
| 3301 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3302 | */ |
| 3303 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3304 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3305 | , void *accel_priv |
| 3306 | #endif |
| 3307 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3308 | , select_queue_fallback_t fallback |
| 3309 | #endif |
| 3310 | ) |
| 3311 | { |
| 3312 | return hdd_wmm_select_queue(dev, skb); |
| 3313 | } |
| 3314 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3315 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | .ndo_open = hdd_open, |
| 3317 | .ndo_stop = hdd_stop, |
| 3318 | .ndo_uninit = hdd_uninit, |
| 3319 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3320 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3321 | .ndo_get_stats = hdd_get_stats, |
| 3322 | .ndo_do_ioctl = hdd_ioctl, |
| 3323 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3324 | .ndo_select_queue = hdd_select_queue, |
| 3325 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3326 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | #endif |
| 3328 | }; |
| 3329 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3330 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3331 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3332 | .ndo_open = hdd_mon_open, |
| 3333 | .ndo_stop = hdd_stop, |
| 3334 | .ndo_get_stats = hdd_get_stats, |
| 3335 | }; |
| 3336 | |
| 3337 | /** |
| 3338 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3339 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3340 | * Return: None |
| 3341 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3342 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3344 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3345 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3346 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3347 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3348 | } |
| 3349 | |
| 3350 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3351 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3352 | * @hdd_ctx: global hdd context |
| 3353 | * @macAddr: mac address to assign to the interface |
| 3354 | * @name: User-visible name of the interface |
| 3355 | * |
| 3356 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3357 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3358 | * |
| 3359 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3360 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3361 | 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] | 3362 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3363 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3364 | const char *name) |
| 3365 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3366 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3367 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3368 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3369 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3370 | /* |
| 3371 | * cfg80211 initialization and registration.... |
| 3372 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3373 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3374 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3375 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3376 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3377 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3378 | hdd_mon_mode_ether_setup : ether_setup), |
| 3379 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3381 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3382 | |
| 3383 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3384 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3385 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3386 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3387 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3388 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3389 | sizeof(sta_ctx->conn_info.staId), |
| 3390 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3391 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3392 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3394 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3396 | qdf_status = qdf_event_create( |
| 3397 | &adapter->qdf_session_open_event); |
| 3398 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3399 | hdd_err("Session open QDF event init failed!"); |
| 3400 | free_netdev(adapter->dev); |
| 3401 | return NULL; |
| 3402 | } |
| 3403 | |
| 3404 | qdf_status = qdf_event_create( |
| 3405 | &adapter->qdf_session_close_event); |
| 3406 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3407 | hdd_err("Session close QDF event init failed!"); |
| 3408 | free_netdev(adapter->dev); |
| 3409 | return NULL; |
| 3410 | } |
| 3411 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3412 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3413 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3414 | init_completion(&adapter->linkup_event_var); |
| 3415 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3416 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3417 | init_completion(&adapter->sta_authorized_event); |
| 3418 | init_completion(&adapter->offchannel_tx_event); |
| 3419 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3420 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3422 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | |
| 3424 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3425 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3426 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3427 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3428 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3429 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3431 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3433 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3434 | |
| 3435 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3436 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3438 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3439 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3440 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3441 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | hdd_set_station_ops(adapter->dev); |
| 3443 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3444 | hdd_dev_setup_destructor(dev); |
| 3445 | dev->ieee80211_ptr = &adapter->wdev; |
| 3446 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3447 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3448 | adapter->wdev.netdev = dev; |
| 3449 | /* set dev's parent to underlying device */ |
| 3450 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3451 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3452 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3453 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3454 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | } |
| 3456 | |
| 3457 | return adapter; |
| 3458 | } |
| 3459 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3460 | 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] | 3461 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3462 | struct net_device *dev = adapter->dev; |
| 3463 | int ret; |
| 3464 | |
| 3465 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3466 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3467 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3468 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3469 | |
| 3470 | ret = dev_alloc_name(dev, dev->name); |
| 3471 | if (ret < 0) { |
| 3472 | hdd_err( |
| 3473 | "unable to get dev name: %s, err = 0x%x", |
| 3474 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3475 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3476 | } |
| 3477 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3478 | |
| 3479 | ret = register_netdevice(dev); |
| 3480 | if (ret) { |
| 3481 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3482 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3483 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | } |
| 3485 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3486 | ret = register_netdev(dev); |
| 3487 | if (ret) { |
| 3488 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3489 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3490 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3491 | } |
| 3492 | } |
| 3493 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3494 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3495 | EXIT(); |
| 3496 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3497 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | } |
| 3499 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3500 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3502 | struct hdd_adapter *adapter; |
| 3503 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3505 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3506 | if (!hdd_ctx) { |
| 3507 | hdd_err("Invalid HDD_CTX"); |
| 3508 | return QDF_STATUS_E_FAILURE; |
| 3509 | } |
| 3510 | |
| 3511 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3512 | if (NULL == adapter) { |
| 3513 | hdd_err("NULL adapter"); |
| 3514 | return QDF_STATUS_E_INVAL; |
| 3515 | } |
| 3516 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3517 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3518 | hdd_debug("session %d opened", adapter->session_id); |
| 3519 | |
| 3520 | return QDF_STATUS_SUCCESS; |
| 3521 | } |
| 3522 | |
| 3523 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3524 | { |
| 3525 | struct hdd_adapter *adapter; |
| 3526 | struct hdd_context *hdd_ctx; |
| 3527 | |
| 3528 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3529 | if (!hdd_ctx) { |
| 3530 | hdd_err("Invalid HDD_CTX"); |
| 3531 | return QDF_STATUS_E_FAILURE; |
| 3532 | } |
| 3533 | |
| 3534 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3535 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3536 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3537 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | } |
| 3539 | |
| 3540 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3541 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3542 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | } |
| 3544 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3545 | /* |
| 3546 | * For NAN Data interface, the close session results in the final |
| 3547 | * indication to the userspace |
| 3548 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3549 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3550 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3551 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3552 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3553 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3554 | /* |
| 3555 | * We can be blocked while waiting for scheduled work to be |
| 3556 | * flushed, and the adapter structure can potentially be freed, in |
| 3557 | * which case the magic will have been reset. So make sure the |
| 3558 | * magic is still good, and hence the adapter structure is still |
| 3559 | * valid, before signaling completion |
| 3560 | */ |
| 3561 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3562 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3563 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3564 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3565 | } |
| 3566 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3567 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3568 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3569 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3570 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3571 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3572 | if (QDF_IS_STATUS_ERROR(status)) |
| 3573 | return qdf_status_to_os_return(status); |
| 3574 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3575 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3576 | if (QDF_IS_STATUS_ERROR(status)) |
| 3577 | return qdf_status_to_os_return(status); |
| 3578 | |
| 3579 | if (wma_capability_enhanced_mcast_filter()) |
| 3580 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3581 | else |
| 3582 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3583 | |
| 3584 | return qdf_status_to_os_return(status); |
| 3585 | } |
| 3586 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3587 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3588 | { |
| 3589 | QDF_STATUS status; |
| 3590 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3591 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3592 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3593 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3594 | vdev_id = adapter->session_id; |
| 3595 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3596 | |
| 3597 | /* vdev created sanity check */ |
| 3598 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3599 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3600 | return -EINVAL; |
| 3601 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3602 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3603 | /* |
| 3604 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3605 | * it has already asserted. vdev can be released directly. |
| 3606 | */ |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3607 | if (cds_is_driver_recovering()) { |
| 3608 | hdd_debug("SSR: silently release the vdev for session-id: %d", |
| 3609 | adapter->session_id); |
| 3610 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3611 | goto release_vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3612 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3613 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3614 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3615 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3616 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3617 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3618 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3619 | hdd_err("failed to close sme session: %d", status); |
| 3620 | return qdf_status_to_os_return(status); |
| 3621 | } |
| 3622 | |
| 3623 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3624 | status = qdf_wait_for_event_completion( |
| 3625 | &adapter->qdf_session_close_event, |
| 3626 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3627 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3628 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3629 | hdd_ndp_session_end_handler(adapter); |
| 3630 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3631 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3632 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3633 | hdd_err("timed out waiting for close sme session: %u", status); |
| 3634 | return -ETIMEDOUT; |
| 3635 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3636 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
| 3637 | return -EINVAL; |
| 3638 | } else { |
| 3639 | hdd_err("Failed to close sme session (%u)", status); |
| 3640 | return -EINVAL; |
| 3641 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3642 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3643 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3644 | /* do vdev logical destroy via objmgr */ |
| 3645 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3646 | if (errno) { |
| 3647 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3648 | return errno; |
| 3649 | } |
| 3650 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3651 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3652 | errno = hdd_objmgr_release_vdev(adapter); |
| 3653 | if (errno) { |
| 3654 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3655 | return errno; |
| 3656 | } |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3657 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3658 | |
| 3659 | return 0; |
| 3660 | } |
| 3661 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3662 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3663 | struct sme_session_params *session_param, |
| 3664 | csr_roam_completeCallback callback, |
| 3665 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3666 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3667 | uint32_t type; |
| 3668 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3669 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3670 | |
| 3671 | /* determine vdev (sub)type */ |
| 3672 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3673 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3674 | hdd_err("failed to get vdev type: %d", status); |
| 3675 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3677 | session_param->sme_session_id = adapter->session_id; |
| 3678 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3679 | session_param->type_of_persona = type; |
| 3680 | session_param->subtype_of_persona = sub_type; |
| 3681 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3682 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3683 | session_param->callback = callback; |
| 3684 | session_param->callback_ctx = callback_ctx; |
| 3685 | |
| 3686 | return 0; |
| 3687 | } |
| 3688 | |
| 3689 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3690 | csr_roam_completeCallback callback, void *ctx) |
| 3691 | { |
| 3692 | QDF_STATUS status; |
| 3693 | int errno; |
| 3694 | struct hdd_context *hdd_ctx; |
| 3695 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3696 | |
| 3697 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3698 | |
| 3699 | /* do vdev create via objmgr */ |
| 3700 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3701 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3702 | if (errno) { |
| 3703 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3704 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3705 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3706 | |
| 3707 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3708 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3709 | if (QDF_STATUS_SUCCESS != status) { |
| 3710 | hdd_err("failed to reinit session open event"); |
| 3711 | return -EINVAL; |
| 3712 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3713 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3714 | callback, ctx); |
| 3715 | if (errno) { |
| 3716 | hdd_err("failed to populating SME params"); |
| 3717 | goto objmgr_vdev_destroy_procedure; |
| 3718 | } |
| 3719 | |
| 3720 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3721 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3722 | hdd_err("failed to open sme session: %d", status); |
| 3723 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3724 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3725 | } |
| 3726 | |
| 3727 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3728 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3729 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3730 | if (QDF_STATUS_SUCCESS != status) { |
| 3731 | if (adapter->qdf_session_open_event.force_set) { |
| 3732 | /* |
| 3733 | * SSR/PDR has caused shutdown, which has forcefully |
| 3734 | * set the event. Return without the closing session. |
| 3735 | */ |
| 3736 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3737 | hdd_err("Session open event forcefully set"); |
| 3738 | return -EINVAL; |
| 3739 | } else { |
| 3740 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3741 | hdd_err("Session failed to open within timeout period"); |
| 3742 | else |
| 3743 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3744 | status); |
| 3745 | errno = -ETIMEDOUT; |
| 3746 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3747 | goto hdd_vdev_destroy_procedure; |
| 3748 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3749 | } |
| 3750 | |
| 3751 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3752 | errno = hdd_vdev_ready(adapter); |
| 3753 | if (errno) { |
| 3754 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3755 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3756 | } |
| 3757 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3758 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3759 | |
| 3760 | return 0; |
| 3761 | |
| 3762 | /* |
| 3763 | * Due to legacy constraints, we need to destroy in the same order as |
| 3764 | * create. So, split error handling into 2 cases to accommodate. |
| 3765 | */ |
| 3766 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3767 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3768 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3769 | |
| 3770 | return errno; |
| 3771 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3772 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3773 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3774 | |
| 3775 | return errno; |
| 3776 | } |
| 3777 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3778 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3779 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3780 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3781 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3782 | QDF_STATUS status; |
| 3783 | int ret_val; |
| 3784 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3785 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3786 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3787 | 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] | 3788 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3789 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3790 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3791 | status = hdd_register_wext(adapter->dev); |
| 3792 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3793 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3794 | goto error_register_wext; |
| 3795 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3796 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3797 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 3798 | hdd_debug("Disabling Green AP"); |
| 3799 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, false); |
| 3800 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 3801 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3802 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3803 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3804 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3805 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3806 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 3807 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3808 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3809 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3810 | hdd_ctx->config->OperatingChannel; |
| 3811 | |
| 3812 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3813 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | |
| 3815 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3816 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3817 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3818 | status, status); |
| 3819 | goto error_init_txrx; |
| 3820 | } |
| 3821 | |
| 3822 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3823 | |
| 3824 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3825 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3826 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3827 | status, status); |
| 3828 | goto error_wmm_init; |
| 3829 | } |
| 3830 | |
| 3831 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3832 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3833 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3834 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3835 | hdd_ctx->config->enableSifsBurst, |
| 3836 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3837 | if (ret_val) |
| 3838 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3839 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3840 | /* |
| 3841 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3842 | * during that time, then as part of SSR init, do not enable |
| 3843 | * the LRO again. Keep the LRO state same as before SSR. |
| 3844 | */ |
| 3845 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3846 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3847 | |
| 3848 | /* rcpi info initialization */ |
| 3849 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3850 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3851 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | error_wmm_init: |
| 3854 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3855 | hdd_deinit_tx_rx(adapter); |
| 3856 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3857 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3859 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3860 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | return status; |
| 3862 | } |
| 3863 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3864 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3865 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3866 | * @hdd_ctx: global hdd context |
| 3867 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3868 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3869 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3870 | * |
| 3871 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3872 | * |
| 3873 | * Return: None. |
| 3874 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3875 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3876 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3877 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3878 | { |
| 3879 | ENTER_DEV(adapter->dev); |
| 3880 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3881 | if (adapter->dev) { |
| 3882 | if (rtnl_held) |
| 3883 | adapter->dev->wireless_handlers = NULL; |
| 3884 | else { |
| 3885 | rtnl_lock(); |
| 3886 | adapter->dev->wireless_handlers = NULL; |
| 3887 | rtnl_unlock(); |
| 3888 | } |
| 3889 | } |
| 3890 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3891 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3892 | hdd_deinit_tx_rx(adapter); |
| 3893 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3894 | } |
| 3895 | |
| 3896 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3897 | hdd_wmm_adapter_close(adapter); |
| 3898 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3899 | } |
| 3900 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3901 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3902 | EXIT(); |
| 3903 | } |
| 3904 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3905 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 3906 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3907 | bool rtnl_held) |
| 3908 | { |
| 3909 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3911 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3912 | case QDF_STA_MODE: |
| 3913 | case QDF_P2P_CLIENT_MODE: |
| 3914 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3915 | case QDF_IBSS_MODE: |
| 3916 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3917 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3918 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3919 | break; |
| 3920 | } |
| 3921 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3922 | case QDF_SAP_MODE: |
| 3923 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3924 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3925 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3926 | break; |
| 3927 | } |
| 3928 | |
| 3929 | default: |
| 3930 | break; |
| 3931 | } |
| 3932 | |
| 3933 | EXIT(); |
| 3934 | } |
| 3935 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3936 | 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] | 3937 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3938 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3939 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3940 | |
| 3941 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3942 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3943 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3944 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3945 | return; |
| 3946 | } |
| 3947 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3948 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3949 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 3950 | hdd_adapter_runtime_suspend_deinit(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3951 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3952 | /* |
| 3953 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3954 | * the driver is almost closed and cannot handle either control |
| 3955 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3956 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3957 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3958 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3959 | * the interface is closed and restricts any operations on that |
| 3960 | */ |
| 3961 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3962 | |
| 3963 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3964 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3965 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3966 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3967 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3968 | /* |
| 3969 | * Note that the adapter is no longer valid at this point |
| 3970 | * since the memory has been reclaimed |
| 3971 | */ |
| 3972 | } |
| 3973 | } |
| 3974 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3975 | 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] | 3976 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3977 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3978 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3979 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3980 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3981 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 3982 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3983 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3984 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3985 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3986 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3987 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3988 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3989 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3990 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3991 | /** |
| 3992 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3993 | * @hdd_ctx: HDD Context |
| 3994 | * @adapter: HDD Adapter |
| 3995 | * |
| 3996 | * This function set the FW Debug log level based on the INI. |
| 3997 | * |
| 3998 | * Return: None |
| 3999 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4000 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4001 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4002 | { |
| 4003 | uint8_t count = 0, numentries = 0, |
| 4004 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4005 | uint32_t value = 0; |
| 4006 | int ret; |
| 4007 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4008 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4009 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4010 | 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] | 4011 | return; |
| 4012 | } |
| 4013 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4014 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4015 | hdd_ctx->fw_log_settings.dl_type = |
| 4016 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4017 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4018 | WMI_DBGLOG_TYPE, |
| 4019 | hdd_ctx->config->enableFwLogType, |
| 4020 | DBG_CMD); |
| 4021 | if (ret != 0) |
| 4022 | hdd_err("Failed to enable FW log type ret %d", |
| 4023 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4024 | |
| 4025 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4026 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4027 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4028 | WMI_DBGLOG_LOG_LEVEL, |
| 4029 | hdd_ctx->config->enableFwLogLevel, |
| 4030 | DBG_CMD); |
| 4031 | if (ret != 0) |
| 4032 | hdd_err("Failed to enable FW log level ret %d", |
| 4033 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4034 | |
| 4035 | hdd_string_to_u8_array( |
| 4036 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4037 | moduleloglevel, |
| 4038 | &numentries, |
| 4039 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4040 | |
| 4041 | while (count < numentries) { |
| 4042 | /* |
| 4043 | * FW module log level input string looks like |
| 4044 | * below: |
| 4045 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4046 | * <Log Level>,... |
| 4047 | * For example: |
| 4048 | * gFwDebugModuleLoglevel= |
| 4049 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4050 | * Above input string means : |
| 4051 | * For FW module ID 1 enable log level 0 |
| 4052 | * For FW module ID 2 enable log level 1 |
| 4053 | * For FW module ID 3 enable log level 2 |
| 4054 | * For FW module ID 4 enable log level 3 |
| 4055 | * For FW module ID 5 enable log level 4 |
| 4056 | * For FW module ID 6 enable log level 5 |
| 4057 | * For FW module ID 7 enable log level 6 |
| 4058 | */ |
| 4059 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4060 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4061 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4062 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4063 | moduleloglevel[count], |
| 4064 | moduleloglevel[count + 1]); |
| 4065 | return; |
| 4066 | } |
| 4067 | |
| 4068 | value = moduleloglevel[count] << 16; |
| 4069 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4070 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4071 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4072 | value, DBG_CMD); |
| 4073 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4074 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4075 | value, ret); |
| 4076 | |
| 4077 | count += 2; |
| 4078 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4079 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4080 | } |
| 4081 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4082 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4083 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4084 | { |
| 4085 | } |
| 4086 | |
| 4087 | #endif |
| 4088 | |
| 4089 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4090 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4091 | * @adapter: HDD adapter |
| 4092 | * |
| 4093 | * Return: 0 on success or errno on failure |
| 4094 | */ |
| 4095 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4096 | { |
| 4097 | int ret_val; |
| 4098 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4099 | |
| 4100 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4101 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4102 | hdd_ctx->config->txchainmask1x1, |
| 4103 | hdd_ctx->config->rxchainmask1x1); |
| 4104 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4105 | hdd_ctx->config->dual_mac_feature_disable, |
| 4106 | hdd_ctx->config->tx_chain_mask_2g, |
| 4107 | hdd_ctx->config->rx_chain_mask_2g); |
| 4108 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4109 | hdd_ctx->config->tx_chain_mask_5g, |
| 4110 | hdd_ctx->config->rx_chain_mask_5g); |
| 4111 | |
| 4112 | if (hdd_ctx->config->enable2x2) { |
| 4113 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4114 | return 0; |
| 4115 | } |
| 4116 | |
| 4117 | if (hdd_ctx->config->txchainmask1x1) { |
| 4118 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4119 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4120 | hdd_ctx->config->txchainmask1x1, |
| 4121 | PDEV_CMD); |
| 4122 | if (ret_val) |
| 4123 | goto error; |
| 4124 | } |
| 4125 | |
| 4126 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4127 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4128 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4129 | hdd_ctx->config->rxchainmask1x1, |
| 4130 | PDEV_CMD); |
| 4131 | if (ret_val) |
| 4132 | goto error; |
| 4133 | } |
| 4134 | |
| 4135 | if (hdd_ctx->lte_coex_ant_share) { |
| 4136 | hdd_info("lte ant sharing enabled. skip per band chain mask"); |
| 4137 | return 0; |
| 4138 | } |
| 4139 | |
| 4140 | if (hdd_ctx->config->txchainmask1x1 || |
| 4141 | hdd_ctx->config->rxchainmask1x1) { |
| 4142 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4143 | return 0; |
| 4144 | } |
| 4145 | |
| 4146 | if (!hdd_ctx->config->dual_mac_feature_disable) { |
| 4147 | hdd_info("DBS enabled. skip per band chain mask"); |
| 4148 | return 0; |
| 4149 | } |
| 4150 | |
| 4151 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4152 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4153 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4154 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4155 | if (0 != ret_val) |
| 4156 | goto error; |
| 4157 | } |
| 4158 | |
| 4159 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4160 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4161 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4162 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4163 | if (0 != ret_val) |
| 4164 | goto error; |
| 4165 | } |
| 4166 | |
| 4167 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4168 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4169 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4170 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4171 | if (0 != ret_val) |
| 4172 | goto error; |
| 4173 | } |
| 4174 | |
| 4175 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4176 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4177 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4178 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4179 | if (0 != ret_val) |
| 4180 | goto error; |
| 4181 | } |
| 4182 | |
| 4183 | return 0; |
| 4184 | |
| 4185 | error: |
| 4186 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4187 | return -EINVAL; |
| 4188 | } |
| 4189 | |
| 4190 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4191 | * hdd_set_fw_params() - Set parameters to firmware |
| 4192 | * @adapter: HDD adapter |
| 4193 | * |
| 4194 | * This function Sets various parameters to fw once the |
| 4195 | * adapter is started. |
| 4196 | * |
| 4197 | * Return: 0 on success or errno on failure |
| 4198 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4199 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4200 | { |
| 4201 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4202 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4203 | |
| 4204 | ENTER_DEV(adapter->dev); |
| 4205 | |
| 4206 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4207 | if (!hdd_ctx) |
| 4208 | return -EINVAL; |
| 4209 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4210 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4211 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4212 | return 0; |
| 4213 | } |
| 4214 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4215 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4216 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4217 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4218 | if (ret) { |
| 4219 | hdd_err("Failed to set LPRx"); |
| 4220 | goto error; |
| 4221 | } |
| 4222 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4223 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4224 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4225 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4226 | hdd_ctx->config->upper_brssi_thresh); |
| 4227 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4228 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4229 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4230 | hdd_ctx->config->lower_brssi_thresh); |
| 4231 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4232 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4233 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4234 | hdd_ctx->config->enable_dtim_1chrx); |
| 4235 | } |
| 4236 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4237 | if (hdd_ctx->config->enable2x2) { |
| 4238 | hdd_debug("configuring 2x2 mode fw params"); |
| 4239 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4240 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4241 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4242 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4243 | PDEV_CMD); |
| 4244 | if (ret) { |
| 4245 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4246 | ret); |
| 4247 | goto error; |
| 4248 | } |
| 4249 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4250 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4251 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4252 | hdd_debug("configuring 1x1 mode fw params"); |
| 4253 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4254 | /* |
| 4255 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4256 | * we are passing two value |
| 4257 | * as param_id << 29 | param_value. |
| 4258 | * Below param_value = 0(disable) |
| 4259 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4260 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4261 | WMI_STA_SMPS_PARAM_CMDID, |
| 4262 | HDD_DTIM_1CHAIN_RX_ID << |
| 4263 | HDD_SMPS_PARAM_VALUE_S, |
| 4264 | VDEV_CMD); |
| 4265 | if (ret) { |
| 4266 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4267 | goto error; |
| 4268 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4269 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4270 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4271 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4272 | |
| 4273 | if (hdd_configure_chain_mask(adapter)) |
| 4274 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4275 | } |
| 4276 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4277 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4278 | WMI_PDEV_PARAM_HYST_EN, |
| 4279 | hdd_ctx->config->enableMemDeepSleep, |
| 4280 | PDEV_CMD); |
| 4281 | if (ret) { |
| 4282 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4283 | goto error; |
| 4284 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4285 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4286 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4287 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4288 | hdd_ctx->config->rts_profile, |
| 4289 | VDEV_CMD); |
| 4290 | if (ret) { |
| 4291 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4292 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4293 | } |
| 4294 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4295 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4296 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4297 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4298 | GEN_VDEV_PARAM_AMSDU, |
| 4299 | hdd_ctx->config->max_amsdu_num, |
| 4300 | GEN_CMD); |
| 4301 | if (ret != 0) { |
| 4302 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4303 | goto error; |
| 4304 | } |
| 4305 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4306 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4307 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4308 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4309 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4310 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4311 | error: |
| 4312 | return -EINVAL; |
| 4313 | } |
| 4314 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4315 | /** |
| 4316 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4317 | * @hdd_ctx: global hdd context |
| 4318 | * @session_type: type of the interface to be created |
| 4319 | * @iface_name: User-visible name of the interface |
| 4320 | * @macAddr: MAC address to assign to the interface |
| 4321 | * @name_assign_type: the name of assign type of the netdev |
| 4322 | * @rtnl_held: the rtnl lock hold flag |
| 4323 | * |
| 4324 | * This function open and setup the hdd adpater according to the device |
| 4325 | * type request, assign the name, the mac address assigned, and then prepared |
| 4326 | * the hdd related parameters, queue, lock and ready to start. |
| 4327 | * |
| 4328 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4329 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4330 | 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] | 4331 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4332 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4333 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4334 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4335 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4336 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4337 | |
| 4338 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4339 | /* |
| 4340 | * Max limit reached on the number of vdevs configured by the |
| 4341 | * host. Return error |
| 4342 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4343 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4344 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4345 | return NULL; |
| 4346 | } |
| 4347 | |
| 4348 | if (macAddr == NULL) { |
| 4349 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4350 | 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] | 4351 | return NULL; |
| 4352 | } |
| 4353 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4354 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4355 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4356 | " already exists", |
| 4357 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4358 | return NULL; |
| 4359 | } |
| 4360 | |
| 4361 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4362 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4363 | /* Reset locally administered bit if the device mode is STA */ |
| 4364 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4365 | hdd_info("locally administered bit reset in sta mode: " |
| 4366 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4367 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4368 | case QDF_P2P_CLIENT_MODE: |
| 4369 | case QDF_P2P_DEVICE_MODE: |
| 4370 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4371 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4372 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4373 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4374 | name_assign_type, |
| 4375 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4376 | |
| 4377 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4378 | hdd_err("failed to allocate adapter for session %d", |
| 4379 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4380 | return NULL; |
| 4381 | } |
| 4382 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4383 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4384 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4385 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4386 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4387 | else if (QDF_MONITOR_MODE == session_type) |
| 4388 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4389 | else |
| 4390 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4391 | |
| 4392 | adapter->device_mode = session_type; |
| 4393 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4395 | /* |
| 4396 | * Workqueue which gets scheduled in IPv4 notification |
| 4397 | * callback |
| 4398 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4399 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4400 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4401 | |
| 4402 | #ifdef WLAN_NS_OFFLOAD |
| 4403 | /* |
| 4404 | * Workqueue which gets scheduled in IPv6 |
| 4405 | * notification callback. |
| 4406 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4407 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4408 | hdd_ipv6_notifier_work_queue); |
| 4409 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4410 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4411 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4412 | goto err_deinit_adapter_runtime_pm; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4413 | |
| 4414 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4415 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4417 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4418 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4419 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4420 | /* Initialize NAN Data Interface */ |
| 4421 | if (QDF_NDI_MODE == session_type) { |
| 4422 | status = hdd_init_nan_data_mode(adapter); |
| 4423 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4424 | goto err_deinit_adapter_runtime_pm; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4425 | } |
| 4426 | |
| 4427 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4428 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4429 | case QDF_P2P_GO_MODE: |
| 4430 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4431 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4432 | name_assign_type, |
| 4433 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4434 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4435 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4436 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4437 | return NULL; |
| 4438 | } |
| 4439 | |
| 4440 | adapter->wdev.iftype = |
| 4441 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4442 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4443 | NL80211_IFTYPE_P2P_GO; |
| 4444 | adapter->device_mode = session_type; |
| 4445 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4446 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4447 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4449 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4450 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4452 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4453 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4454 | |
| 4455 | /* |
| 4456 | * Workqueue which gets scheduled in IPv4 notification |
| 4457 | * callback |
| 4458 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4459 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4460 | hdd_ipv4_notifier_work_queue); |
| 4461 | |
| 4462 | #ifdef WLAN_NS_OFFLOAD |
| 4463 | /* |
| 4464 | * Workqueue which gets scheduled in IPv6 |
| 4465 | * notification callback. |
| 4466 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4467 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4468 | hdd_ipv6_notifier_work_queue); |
| 4469 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4471 | case QDF_FTM_MODE: |
| 4472 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4473 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4474 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4475 | if (NULL == adapter) { |
| 4476 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4477 | return NULL; |
| 4478 | } |
| 4479 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4480 | adapter->device_mode = session_type; |
| 4481 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4482 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4483 | goto err_deinit_adapter_runtime_pm; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4484 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4485 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4486 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4487 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4488 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4489 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4490 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4492 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4493 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4494 | return NULL; |
| 4495 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4496 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4497 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4498 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4499 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4500 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4501 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4502 | } |
| 4503 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4504 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | if (NULL != adapter) { |
| 4506 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4507 | adapter = NULL; |
| 4508 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4509 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4510 | return NULL; |
| 4511 | } |
| 4512 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4513 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4514 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4515 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4516 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4517 | /* Adapter successfully added. Increment the vdev count */ |
| 4518 | hdd_ctx->current_intf_count++; |
| 4519 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4520 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4521 | hdd_ctx->current_intf_count); |
| 4522 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4523 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4524 | } |
| 4525 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4526 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4527 | hdd_err("Interface %s wow debug_fs init failed", |
| 4528 | netdev_name(adapter->dev)); |
| 4529 | |
| 4530 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4531 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4532 | |
| 4533 | return adapter; |
| 4534 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4535 | err_deinit_adapter_runtime_pm: |
| 4536 | /* |
| 4537 | * For certain error cases that hdd_alloc_station_adapter() |
| 4538 | * is used to allocate the adapter. |
| 4539 | */ |
| 4540 | hdd_adapter_runtime_suspend_deinit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4541 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4542 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4543 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4544 | |
| 4545 | return NULL; |
| 4546 | } |
| 4547 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4548 | 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] | 4549 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4550 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4551 | /* |
| 4552 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4553 | * |
| 4554 | * The reason is to fix one race condition between |
| 4555 | * bus bandwidth work and cleaning up an adapter. |
| 4556 | * Under some conditions, it is possible for the bus bandwidth |
| 4557 | * work to access a particularly destroyed adapter, leading to |
| 4558 | * use-after-free. |
| 4559 | */ |
| 4560 | hdd_debug("wait for bus bw work to flush"); |
| 4561 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4562 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4563 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4564 | /* cleanup adapter */ |
| 4565 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4566 | adapter->device_mode); |
| 4567 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4568 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4570 | /* conditionally restart the bw timer */ |
| 4571 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4572 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4573 | /* Adapter removed. Decrement vdev count */ |
| 4574 | if (hdd_ctx->current_intf_count != 0) |
| 4575 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4576 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4577 | /* Fw will take care incase of concurrency */ |
| 4578 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4579 | } |
| 4580 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4581 | /** |
| 4582 | * hdd_close_all_adapters - Close all open adapters |
| 4583 | * @hdd_ctx: Hdd context |
| 4584 | * rtnl_held: True if RTNL lock held |
| 4585 | * |
| 4586 | * Close all open adapters. |
| 4587 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4588 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4589 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4590 | 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] | 4591 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4592 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4593 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4594 | |
| 4595 | ENTER(); |
| 4596 | |
| 4597 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4598 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4599 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4600 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4601 | adapter->mac_addr.bytes); |
| 4602 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4603 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4604 | /* Adapter removed. Decrement vdev count */ |
| 4605 | if (hdd_ctx->current_intf_count != 0) |
| 4606 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4607 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4608 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4609 | |
| 4610 | EXIT(); |
| 4611 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4612 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4613 | } |
| 4614 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4615 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4617 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4618 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4619 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4620 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4621 | case QDF_STA_MODE: |
| 4622 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4623 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4624 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4625 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4626 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4627 | break; |
| 4628 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4629 | case QDF_SAP_MODE: |
| 4630 | case QDF_P2P_GO_MODE: |
| 4631 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4632 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4633 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4634 | break; |
| 4635 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4636 | case QDF_FTM_MODE: |
| 4637 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4638 | default: |
| 4639 | /* |
| 4640 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4641 | * for these kind of devices |
| 4642 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4643 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4644 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4645 | return; |
| 4646 | } |
| 4647 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4648 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4649 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4650 | updateIE.ieBufferlength = 0; |
| 4651 | updateIE.pAdditionIEBuffer = NULL; |
| 4652 | updateIE.append = true; |
| 4653 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4654 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4655 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4656 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4657 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4658 | } |
| 4659 | } |
| 4660 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4661 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4662 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4663 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4664 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4665 | struct hdd_wext_state *pWextState = |
| 4666 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4667 | union iwreq_data wrqu; |
| 4668 | tSirUpdateIE updateIE; |
| 4669 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4670 | tsap_Config_t *sap_config; |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4671 | bool is_enabled = false; |
| 4672 | uint8_t ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4673 | |
| 4674 | ENTER(); |
| 4675 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4676 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4677 | wlan_hdd_netif_queue_control(adapter, |
| 4678 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4679 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4680 | /* |
| 4681 | * if this is the last active connection check & stop the |
| 4682 | * opportunistic timer first |
| 4683 | */ |
| 4684 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4685 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4686 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4687 | adapter->device_mode), NULL) == 1)) || |
| 4688 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4689 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4690 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4691 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4692 | case QDF_STA_MODE: |
| 4693 | case QDF_P2P_CLIENT_MODE: |
| 4694 | case QDF_IBSS_MODE: |
| 4695 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4696 | case QDF_NDI_MODE: |
| 4697 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4698 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4699 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4700 | hdd_is_connecting( |
| 4701 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4702 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4703 | /* |
| 4704 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4705 | * extract from ndi_ctx. |
| 4706 | */ |
| 4707 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4708 | qdf_ret_status = sme_roam_disconnect( |
| 4709 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4710 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4711 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4712 | else if (pWextState->roamProfile.BSSType == |
| 4713 | eCSR_BSS_TYPE_START_IBSS) |
| 4714 | qdf_ret_status = sme_roam_disconnect( |
| 4715 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4716 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4717 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4718 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4719 | qdf_ret_status = |
| 4720 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4721 | hdd_debug("Send disconnected event to userspace"); |
| 4722 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4723 | adapter->dev, true, |
| 4724 | WLAN_REASON_UNSPECIFIED); |
| 4725 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4726 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4727 | qdf_ret_status = sme_roam_disconnect( |
| 4728 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4729 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4730 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4731 | /* success implies disconnect command got |
| 4732 | * queued up successfully |
| 4733 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4734 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4735 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4736 | rc = wait_for_completion_timeout( |
| 4737 | &adapter->disconnect_comp_var, |
| 4738 | msecs_to_jiffies |
| 4739 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4740 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4741 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4742 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4743 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4744 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4745 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4746 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4747 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4748 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4749 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4750 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4751 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4752 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4753 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4754 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | |
| 4756 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4757 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | #endif |
| 4759 | |
| 4760 | hdd_deregister_tx_flow_control(adapter); |
| 4761 | |
| 4762 | #ifdef WLAN_NS_OFFLOAD |
| 4763 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4764 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4765 | #endif |
| 4766 | #endif |
| 4767 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4768 | if (adapter->device_mode == QDF_STA_MODE) |
| 4769 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4770 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4771 | |
| 4772 | if (wlan_hdd_try_disconnect(adapter)) { |
| 4773 | hdd_err("Error: Can't disconnect adapter"); |
| 4774 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4775 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4776 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4777 | ret = hdd_check_green_ap_enable(hdd_ctx, &is_enabled); |
| 4778 | if (!ret) { |
| 4779 | hdd_debug("Green AP enable status: %d", is_enabled); |
| 4780 | if (is_enabled) { |
| 4781 | hdd_debug("Enabling Green AP"); |
| 4782 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 4783 | true); |
| 4784 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 4785 | } |
| 4786 | } else { |
| 4787 | hdd_err("Failed to check if Green AP should be enabled or not"); |
| 4788 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4789 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4790 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | break; |
| 4792 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4793 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4794 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4795 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4796 | sap_config = &adapter->session.ap.sap_config; |
| 4797 | if (sap_config) |
| 4798 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4799 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4800 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4801 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4802 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4803 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4804 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4805 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4806 | cds_flush_delayed_work( |
| 4807 | &adapter->acs_pending_work); |
| 4808 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4809 | } |
| 4810 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4811 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4813 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4814 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4815 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4816 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4817 | |
| 4818 | hdd_deregister_tx_flow_control(adapter); |
| 4819 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4820 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4821 | mutex_lock(&hdd_ctx->sap_lock); |
| 4822 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4823 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4824 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | |
| 4826 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4827 | status = wlansap_stop_bss( |
| 4828 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4830 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4831 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4833 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4834 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4835 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4836 | qdf_wait_for_event_completion( |
| 4837 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4838 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4840 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4841 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4842 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4843 | } |
| 4844 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4845 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4846 | } |
| 4847 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4848 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4849 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4850 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4851 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4852 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4853 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4854 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4855 | updateIE.ieBufferlength = 0; |
| 4856 | updateIE.pAdditionIEBuffer = NULL; |
| 4857 | updateIE.append = false; |
| 4858 | updateIE.notify = false; |
| 4859 | /* Probe bcn reset */ |
| 4860 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4861 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4862 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4863 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4864 | } |
| 4865 | /* Assoc resp reset */ |
| 4866 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4867 | &updateIE, |
| 4868 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4869 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4870 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | } |
| 4872 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4873 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4874 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4875 | qdf_mem_free(adapter->session.ap.beacon); |
| 4876 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4877 | /* |
| 4878 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4879 | */ |
| 4880 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4881 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4882 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4883 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4884 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4885 | #endif |
| 4886 | |
| 4887 | #ifdef WLAN_NS_OFFLOAD |
| 4888 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4889 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4890 | #endif |
| 4891 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4892 | |
| 4893 | hdd_vdev_destroy(adapter); |
| 4894 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4895 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4897 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4898 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4899 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4900 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4901 | break; |
| 4902 | default: |
| 4903 | break; |
| 4904 | } |
| 4905 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4906 | if (adapter->scan_info.default_scan_ies) { |
| 4907 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 4908 | adapter->scan_info.default_scan_ies = NULL; |
| 4909 | } |
| 4910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4911 | EXIT(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4912 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4913 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4914 | } |
| 4915 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4916 | /** |
| 4917 | * hdd_deinit_all_adapters - deinit all adapters |
| 4918 | * @hdd_ctx: HDD context |
| 4919 | * @rtnl_held: True if RTNL lock held |
| 4920 | * |
| 4921 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4922 | 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] | 4923 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4924 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4925 | |
| 4926 | ENTER(); |
| 4927 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4928 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4929 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4930 | |
| 4931 | EXIT(); |
| 4932 | } |
| 4933 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4934 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4935 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4936 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4937 | |
| 4938 | ENTER(); |
| 4939 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4940 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4941 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4942 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4943 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4944 | |
| 4945 | EXIT(); |
| 4946 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4947 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4948 | } |
| 4949 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4950 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 4951 | struct hdd_adapter *adapter) |
| 4952 | { |
| 4953 | switch (adapter->device_mode) { |
| 4954 | case QDF_STA_MODE: |
| 4955 | case QDF_P2P_CLIENT_MODE: |
| 4956 | case QDF_IBSS_MODE: |
| 4957 | case QDF_P2P_DEVICE_MODE: |
| 4958 | case QDF_NDI_MODE: |
| 4959 | wlan_hdd_scan_abort(adapter); |
| 4960 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4961 | if (adapter->device_mode == QDF_STA_MODE) |
| 4962 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4963 | adapter->dev); |
| 4964 | break; |
| 4965 | case QDF_P2P_GO_MODE: |
| 4966 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4967 | break; |
| 4968 | case QDF_SAP_MODE: |
| 4969 | wlan_hdd_undo_acs(adapter); |
| 4970 | break; |
| 4971 | default: |
| 4972 | break; |
| 4973 | } |
| 4974 | } |
| 4975 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4976 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4977 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4978 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4979 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4980 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 4981 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4982 | |
| 4983 | ENTER(); |
| 4984 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4985 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4986 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4987 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 4988 | hdd_notice("[SSR] reset adapter with device mode %s(%d)", |
| 4989 | hdd_device_mode_to_string(adapter->device_mode), |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4990 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4991 | |
| 4992 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4993 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4994 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4995 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4996 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4997 | if (hdd_ctx->config->sap_internal_restart && |
| 4998 | adapter->device_mode == QDF_SAP_MODE) { |
| 4999 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5000 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5001 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5002 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5003 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5004 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5005 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5006 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5007 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5008 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5010 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5011 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5012 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5013 | adapter->session.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5014 | |
| 5015 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5016 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5017 | adapter->device_mode, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5019 | hdd_wmm_adapter_close(adapter); |
| 5020 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5021 | } |
| 5022 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5023 | if (adapter->device_mode == QDF_STA_MODE) |
| 5024 | hdd_clear_fils_connection_info(adapter); |
| 5025 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5026 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5027 | /* |
| 5028 | * If adapter is SAP, set session ID to invalid |
| 5029 | * since SAP session will be cleanup during SSR. |
| 5030 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5031 | wlansap_set_invalid_session( |
| 5032 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5033 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5034 | wlansap_cleanup_cac_timer( |
| 5035 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5036 | } |
| 5037 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5038 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5039 | if (adapter->device_mode == QDF_STA_MODE || |
| 5040 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5041 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5042 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5043 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5044 | |
| 5045 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5046 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5047 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5048 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5049 | if (adapter->sta_info[sta_id].in_use) { |
| 5050 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5051 | sta_id); |
| 5052 | hdd_softap_deregister_sta(adapter, |
| 5053 | sta_id); |
| 5054 | adapter->sta_info[sta_id].in_use = 0; |
| 5055 | } |
| 5056 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5057 | } |
| 5058 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5059 | /* Destroy vdev which will be recreated during reinit. */ |
| 5060 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5061 | } |
| 5062 | |
| 5063 | EXIT(); |
| 5064 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5065 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5066 | } |
| 5067 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5068 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5069 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5070 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5071 | bool close_modules = true; |
| 5072 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5073 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5074 | hdd_info("FTM mode, don't close the module"); |
| 5075 | return false; |
| 5076 | } |
| 5077 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5078 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5079 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5080 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5081 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5082 | close_modules = false; |
| 5083 | break; |
| 5084 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5085 | } |
| 5086 | |
| 5087 | return close_modules; |
| 5088 | } |
| 5089 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5090 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5091 | { |
| 5092 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5093 | return true; |
| 5094 | else |
| 5095 | return false; |
| 5096 | } |
| 5097 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5098 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5099 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5100 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5101 | struct ieee80211_channel *channel, |
| 5102 | const u8 *bssid, const u8 *ssid, |
| 5103 | size_t ssid_len) |
| 5104 | { |
| 5105 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5106 | ssid, ssid_len, |
| 5107 | WLAN_CAPABILITY_ESS, |
| 5108 | WLAN_CAPABILITY_ESS); |
| 5109 | } |
| 5110 | #else |
| 5111 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5112 | struct ieee80211_channel *channel, |
| 5113 | const u8 *bssid, const u8 *ssid, |
| 5114 | size_t ssid_len) |
| 5115 | { |
| 5116 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5117 | ssid, ssid_len, |
| 5118 | IEEE80211_BSS_TYPE_ESS, |
| 5119 | IEEE80211_PRIVACY_ANY); |
| 5120 | } |
| 5121 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5122 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5123 | #if defined CFG80211_CONNECT_BSS || \ |
| 5124 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5125 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5126 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5127 | /** |
| 5128 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5129 | * @timeout_reason: reason for connect timeout |
| 5130 | * |
| 5131 | * This function is used to convert host timeout |
| 5132 | * reason enum to kernel specific enum. |
| 5133 | * |
| 5134 | * Return: nl timeout enum |
| 5135 | */ |
| 5136 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5137 | tSirResultCodes timeout_reason) |
| 5138 | { |
| 5139 | switch (timeout_reason) { |
| 5140 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5141 | return NL80211_TIMEOUT_SCAN; |
| 5142 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5143 | return NL80211_TIMEOUT_AUTH; |
| 5144 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5145 | return NL80211_TIMEOUT_ASSOC; |
| 5146 | default: |
| 5147 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5148 | } |
| 5149 | } |
| 5150 | |
| 5151 | /** |
| 5152 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5153 | * @dev: network device |
| 5154 | * @bssid: bssid to which we want to associate |
| 5155 | * @timeout_reason: reason for connect timeout |
| 5156 | * |
| 5157 | * This API is used to send connection timeout reason to supplicant |
| 5158 | * |
| 5159 | * Return: void |
| 5160 | */ |
| 5161 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5162 | const u8 *bssid, |
| 5163 | tSirResultCodes timeout_reason) |
| 5164 | { |
| 5165 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5166 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5167 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5168 | |
| 5169 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5170 | nl_timeout_reason); |
| 5171 | } |
| 5172 | |
| 5173 | /** |
| 5174 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5175 | * @dev: network device |
| 5176 | * @bssid: bssid to which we want to associate |
| 5177 | * @req_ie: Request Information Element |
| 5178 | * @req_ie_len: len of the req IE |
| 5179 | * @resp_ie: Response IE |
| 5180 | * @resp_ie_len: len of ht response IE |
| 5181 | * @status: status |
| 5182 | * @gfp: Kernel Flag |
| 5183 | * @timeout_reason: reason for connect timeout |
| 5184 | * |
| 5185 | * Return: void |
| 5186 | */ |
| 5187 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5188 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5189 | size_t req_ie_len, const u8 *resp_ie, |
| 5190 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5191 | tSirResultCodes timeout_reason) |
| 5192 | { |
| 5193 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5194 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5195 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5196 | |
| 5197 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5198 | resp_ie, resp_ie_len, status, gfp, |
| 5199 | nl_timeout_reason); |
| 5200 | } |
| 5201 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5202 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5203 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5204 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5205 | const u8 *bssid, |
| 5206 | tSirResultCodes timeout_reason) |
| 5207 | { |
| 5208 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5209 | } |
| 5210 | #endif |
| 5211 | |
| 5212 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5213 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5214 | size_t req_ie_len, const u8 *resp_ie, |
| 5215 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5216 | tSirResultCodes timeout_reason) |
| 5217 | { |
| 5218 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5219 | resp_ie, resp_ie_len, status, gfp); |
| 5220 | } |
| 5221 | #endif |
| 5222 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5223 | /** |
| 5224 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5225 | * @dev: network device |
| 5226 | * @bssid: bssid to which we want to associate |
| 5227 | * @req_ie: Request Information Element |
| 5228 | * @req_ie_len: len of the req IE |
| 5229 | * @resp_ie: Response IE |
| 5230 | * @resp_ie_len: len of ht response IE |
| 5231 | * @status: status |
| 5232 | * @gfp: Kernel Flag |
| 5233 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5234 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5235 | * |
| 5236 | * The API is a wrapper to send connection status to supplicant |
| 5237 | * |
| 5238 | * Return: Void |
| 5239 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5240 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5241 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5242 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5243 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5244 | size_t req_ie_len, const u8 *resp_ie, |
| 5245 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5246 | bool connect_timeout, |
| 5247 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5248 | { |
| 5249 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5250 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5251 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5252 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5253 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5254 | } |
| 5255 | #else |
| 5256 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5257 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5258 | size_t req_ie_len, const u8 *resp_ie, |
| 5259 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5260 | bool connect_timeout, |
| 5261 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5262 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5263 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5264 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5265 | } |
| 5266 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5267 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5268 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5269 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5270 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5271 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5272 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5273 | /** |
| 5274 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5275 | * @fils_params: connect response to supplicant |
| 5276 | * @fils_kek: FILS kek |
| 5277 | * @fils_kek_len: FILS kek length |
| 5278 | * @pmk: FILS PMK |
| 5279 | * @pmk_len: FILS PMK length |
| 5280 | * @pmkid: PMKID |
| 5281 | * @fils_seq_num: FILS Seq number |
| 5282 | * |
| 5283 | * Return: None |
| 5284 | */ |
| 5285 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5286 | *fils_params, const uint8_t *fils_kek, |
| 5287 | size_t fils_kek_len, const uint8_t *pmk, |
| 5288 | size_t pmk_len, const uint8_t *pmkid, |
| 5289 | uint16_t fils_seq_num) |
| 5290 | { |
| 5291 | /* Increament seq number to be used for next FILS */ |
| 5292 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5293 | fils_params->update_erp_next_seq_num = true; |
| 5294 | fils_params->fils_kek = fils_kek; |
| 5295 | fils_params->fils_kek_len = fils_kek_len; |
| 5296 | fils_params->pmk = pmk; |
| 5297 | fils_params->pmk_len = pmk_len; |
| 5298 | fils_params->pmkid = pmkid; |
| 5299 | } |
| 5300 | #else |
| 5301 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5302 | *fils_params, const uint8_t |
| 5303 | *fils_kek, size_t fils_kek_len, |
| 5304 | const uint8_t *pmk, size_t pmk_len, |
| 5305 | const uint8_t *pmkid, |
| 5306 | uint16_t fils_seq_num) |
| 5307 | { } |
| 5308 | #endif |
| 5309 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5310 | void hdd_update_hlp_info(struct net_device *dev, |
| 5311 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5312 | { |
| 5313 | struct sk_buff *skb; |
| 5314 | uint16_t skb_len; |
| 5315 | struct llc_snap_hdr_t *llc_hdr; |
| 5316 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5317 | uint8_t *hlp_data; |
| 5318 | uint16_t hlp_data_len; |
| 5319 | struct fils_join_rsp_params *roam_fils_params |
| 5320 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5321 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5322 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5323 | if (!roam_fils_params) { |
| 5324 | hdd_err("FILS Roam Param NULL"); |
| 5325 | return; |
| 5326 | } |
| 5327 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5328 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5329 | hdd_err("FILS HLP Data NULL, len %d", |
| 5330 | roam_fils_params->hlp_data_len); |
| 5331 | return; |
| 5332 | } |
| 5333 | |
| 5334 | hlp_data = roam_fils_params->hlp_data; |
| 5335 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5336 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5337 | /* Calculate skb length */ |
| 5338 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5339 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5340 | if (skb == NULL) { |
| 5341 | hdd_err("HLP packet nbuf alloc fails"); |
| 5342 | return; |
| 5343 | } |
| 5344 | |
| 5345 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5346 | QDF_MAC_ADDR_SIZE); |
| 5347 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5348 | QDF_MAC_ADDR_SIZE); |
| 5349 | |
| 5350 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5351 | if (IS_SNAP(llc_hdr)) { |
| 5352 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5353 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5354 | } |
| 5355 | |
| 5356 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5357 | |
| 5358 | /* |
| 5359 | * This HLP packet is formed from HLP info encapsulated |
| 5360 | * in assoc response frame which is AEAD encrypted. |
| 5361 | * Hence, this checksum validation can be set unnecessary. |
| 5362 | * i.e. network layer need not worry about checksum. |
| 5363 | */ |
| 5364 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5365 | |
| 5366 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5367 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5368 | hdd_err("Sending HLP packet fails"); |
| 5369 | return; |
| 5370 | } |
| 5371 | hdd_debug("send HLP packet to netif successfully"); |
| 5372 | } |
| 5373 | |
| 5374 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5375 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5376 | * @dev: network device |
| 5377 | * @bssid: bssid to which we want to associate |
| 5378 | * @bss: cfg80211 bss info |
| 5379 | * @roam_info: information about connected bss |
| 5380 | * @req_ie: Request Information Element |
| 5381 | * @req_ie_len: len of the req IE |
| 5382 | * @resp_ie: Response IE |
| 5383 | * @resp_ie_len: len of ht response IE |
| 5384 | * @status: status |
| 5385 | * @gfp: allocation flags |
| 5386 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5387 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5388 | * |
| 5389 | * This API is used as wrapper to send FILS key/sequence number |
| 5390 | * params etc. to supplicant in case of FILS connection |
| 5391 | * |
| 5392 | * Return: None |
| 5393 | */ |
| 5394 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5395 | struct cfg80211_bss *bss, |
| 5396 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5397 | const u8 *req_ie, size_t req_ie_len, |
| 5398 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5399 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5400 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5401 | { |
| 5402 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5403 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5404 | struct fils_join_rsp_params *roam_fils_params = |
| 5405 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5406 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5407 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5408 | |
| 5409 | if (!roam_fils_params) { |
| 5410 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5411 | } else { |
| 5412 | fils_params.status = status; |
| 5413 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5414 | fils_params.timeout_reason = |
| 5415 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5416 | fils_params.req_ie = req_ie; |
| 5417 | fils_params.req_ie_len = req_ie_len; |
| 5418 | fils_params.resp_ie = resp_ie; |
| 5419 | fils_params.resp_ie_len = resp_ie_len; |
| 5420 | fils_params.bss = bss; |
| 5421 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5422 | roam_fils_params->kek_len, |
| 5423 | roam_fils_params->fils_pmk, |
| 5424 | roam_fils_params->fils_pmk_len, |
| 5425 | roam_fils_params->fils_pmkid, |
| 5426 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5427 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5428 | } |
| 5429 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5430 | fils_params.status, |
| 5431 | fils_params.fils_erp_next_seq_num); |
| 5432 | |
| 5433 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5434 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5435 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5436 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5437 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5438 | /* Clear all the FILS key info */ |
| 5439 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5440 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5441 | if (roam_fils_params) |
| 5442 | qdf_mem_free(roam_fils_params); |
| 5443 | roam_info->fils_join_rsp = NULL; |
| 5444 | } |
| 5445 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5446 | static inline void |
| 5447 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5448 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5449 | const u8 *req_ie, size_t req_ie_len, |
| 5450 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5451 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5452 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5453 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5454 | #endif |
| 5455 | #endif |
| 5456 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5457 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5458 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5459 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5460 | /** |
| 5461 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5462 | * supplicant. |
| 5463 | * @dev: network device |
| 5464 | * @bssid: bssid to which we want to associate |
| 5465 | * @bss: cfg80211 bss info |
| 5466 | * @roam_info: information about connected bss |
| 5467 | * @req_ie: Request Information Element |
| 5468 | * @req_ie_len: len of the req IE |
| 5469 | * @resp_ie: Response IE |
| 5470 | * @resp_ie_len: len of ht response IE |
| 5471 | * @status: status |
| 5472 | * @gfp: allocation flags |
| 5473 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5474 | * @timeout_reason: reason for connect timeout |
| 5475 | * |
| 5476 | * The API is a wrapper to send connection status to supplicant |
| 5477 | * |
| 5478 | * Return: 0 if success else failure |
| 5479 | */ |
| 5480 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5481 | const u8 *bssid, |
| 5482 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5483 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5484 | size_t req_ie_len, const u8 *resp_ie, |
| 5485 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5486 | bool connect_timeout, |
| 5487 | tSirResultCodes timeout_reason) |
| 5488 | { |
| 5489 | ENTER(); |
| 5490 | if (!roam_info || !roam_info->is_fils_connection) |
| 5491 | return -EINVAL; |
| 5492 | |
| 5493 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5494 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5495 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5496 | return 0; |
| 5497 | } |
| 5498 | #else |
| 5499 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5500 | const u8 *bssid, |
| 5501 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5502 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5503 | size_t req_ie_len, const u8 *resp_ie, |
| 5504 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5505 | bool connect_timeout, |
| 5506 | tSirResultCodes timeout_reason) |
| 5507 | { |
| 5508 | return -EINVAL; |
| 5509 | } |
| 5510 | #endif |
| 5511 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5512 | /** |
| 5513 | * hdd_connect_result() - API to send connection status to supplicant |
| 5514 | * @dev: network device |
| 5515 | * @bssid: bssid to which we want to associate |
| 5516 | * @roam_info: information about connected bss |
| 5517 | * @req_ie: Request Information Element |
| 5518 | * @req_ie_len: len of the req IE |
| 5519 | * @resp_ie: Response IE |
| 5520 | * @resp_ie_len: len of ht response IE |
| 5521 | * @status: status |
| 5522 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5523 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5524 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5525 | * |
| 5526 | * The API is a wrapper to send connection status to supplicant |
| 5527 | * and allow runtime suspend |
| 5528 | * |
| 5529 | * Return: Void |
| 5530 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5531 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5532 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5533 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5534 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5535 | bool connect_timeout, |
| 5536 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5537 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5538 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5539 | struct cfg80211_bss *bss = NULL; |
| 5540 | |
| 5541 | if (WLAN_STATUS_SUCCESS == status) { |
| 5542 | struct ieee80211_channel *chan; |
| 5543 | int freq; |
| 5544 | int chan_no = roam_info->pBssDesc->channelId; |
| 5545 | |
| 5546 | if (chan_no <= 14) |
| 5547 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5548 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5549 | else |
| 5550 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5551 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5552 | |
| 5553 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5554 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5555 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5556 | roam_info->u.pConnectedProfile->SSID.length); |
| 5557 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5558 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5559 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5560 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5561 | resp_ie_len, status, gfp, connect_timeout, |
| 5562 | timeout_reason) != 0) { |
| 5563 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5564 | req_ie_len, resp_ie, resp_ie_len, |
| 5565 | status, gfp, connect_timeout, timeout_reason); |
| 5566 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5567 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5568 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5569 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5570 | } |
| 5571 | #else |
| 5572 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5573 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5574 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5575 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5576 | bool connect_timeout, |
| 5577 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5578 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5579 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5580 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5581 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5582 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5583 | |
| 5584 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5585 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5586 | } |
| 5587 | #endif |
| 5588 | |
| 5589 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5590 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5591 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5592 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5593 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5594 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5595 | #endif |
| 5596 | eConnectionState connState; |
| 5597 | |
| 5598 | ENTER(); |
| 5599 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5600 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5601 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5602 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5603 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5604 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5605 | hdd_device_mode_to_string(adapter->device_mode), |
| 5606 | adapter->device_mode); |
| 5607 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5608 | hdd_wmm_init(adapter); |
| 5609 | |
| 5610 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5611 | case QDF_STA_MODE: |
| 5612 | case QDF_P2P_CLIENT_MODE: |
| 5613 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5614 | |
| 5615 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5616 | ->conn_info.connState; |
| 5617 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5618 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5619 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5620 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5621 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5622 | /* Indicate disconnect event to supplicant |
| 5623 | * if associated previously |
| 5624 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5625 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5626 | eConnectionState_IbssConnected == connState || |
| 5627 | eConnectionState_NotConnected == connState || |
| 5628 | eConnectionState_IbssDisconnected == connState || |
| 5629 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5630 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5631 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5633 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5634 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5635 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5636 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5637 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5638 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5639 | |
| 5640 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5641 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5642 | adapter->dev, false, |
| 5643 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5644 | } else if (eConnectionState_Connecting == connState) { |
| 5645 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5646 | * Indicate connect failure to supplicant if we |
| 5647 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5648 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5649 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5650 | NULL, 0, NULL, 0, |
| 5651 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5652 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5653 | } |
| 5654 | |
| 5655 | hdd_register_tx_flow_control(adapter, |
| 5656 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5657 | hdd_tx_resume_cb, |
| 5658 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5659 | |
| 5660 | break; |
| 5661 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5662 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5663 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5664 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5665 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5666 | break; |
| 5667 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5668 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5669 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5670 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5671 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5672 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5673 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5674 | /* event supplicant to restart */ |
| 5675 | cfg80211_del_sta(adapter->dev, |
| 5676 | (const u8 *)&bcastMac.bytes[0], |
| 5677 | GFP_KERNEL); |
| 5678 | #endif |
| 5679 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5680 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5681 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5682 | hdd_set_mon_rx_cb(adapter->dev); |
| 5683 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5684 | adapter->mon_bandwidth); |
| 5685 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5686 | default: |
| 5687 | break; |
| 5688 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5689 | /* |
| 5690 | * Action frame registered in one adapter which will |
| 5691 | * applicable to all interfaces |
| 5692 | */ |
| 5693 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5694 | } |
| 5695 | |
| 5696 | EXIT(); |
| 5697 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5698 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5699 | } |
| 5700 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5701 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5702 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5703 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5704 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5705 | qdf_list_node_t *node; |
| 5706 | |
| 5707 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5708 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5709 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5710 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5711 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5712 | |
| 5713 | if (QDF_IS_STATUS_ERROR(status)) |
| 5714 | return status; |
| 5715 | |
| 5716 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5717 | |
| 5718 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5719 | } |
| 5720 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5721 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5722 | struct hdd_adapter *current_adapter, |
| 5723 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5724 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5725 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5726 | qdf_list_node_t *node; |
| 5727 | |
| 5728 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5729 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5730 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5731 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5732 | ¤t_adapter->node, |
| 5733 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5734 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5735 | |
| 5736 | if (QDF_IS_STATUS_ERROR(status)) |
| 5737 | return status; |
| 5738 | |
| 5739 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5740 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5741 | return status; |
| 5742 | } |
| 5743 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5744 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5745 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5746 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5747 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5748 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5749 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5750 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5751 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5752 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | return status; |
| 5754 | } |
| 5755 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5756 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5757 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5758 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5759 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5760 | qdf_list_node_t *node; |
| 5761 | |
| 5762 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5763 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5764 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5765 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5766 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5767 | |
| 5768 | if (QDF_IS_STATUS_ERROR(status)) |
| 5769 | return status; |
| 5770 | |
| 5771 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5772 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5773 | return status; |
| 5774 | } |
| 5775 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5776 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5777 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5778 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5779 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5780 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5781 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5782 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5783 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5784 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5785 | return status; |
| 5786 | } |
| 5787 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5788 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5789 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5790 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5791 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5792 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5793 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5794 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5795 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5796 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5797 | return status; |
| 5798 | } |
| 5799 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5800 | 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] | 5801 | tSirMacAddr macAddr) |
| 5802 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5803 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5804 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5805 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5806 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5807 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5808 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5809 | } |
| 5810 | |
| 5811 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5812 | } |
| 5813 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5814 | 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] | 5815 | uint32_t vdev_id) |
| 5816 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5817 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5818 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5819 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5820 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5821 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5822 | } |
| 5823 | |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 5824 | hdd_err_ratelimited(RATE_LIMIT_ERROR_LOG, |
| 5825 | "vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5826 | |
| 5827 | return NULL; |
| 5828 | } |
| 5829 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5830 | /** |
| 5831 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5832 | * the sessionid |
| 5833 | * @hdd_ctx: hdd context. |
| 5834 | * @sme_session_id: sme session is for the adapter to get. |
| 5835 | * |
| 5836 | * This function is used to get the adapter with provided session id |
| 5837 | * |
| 5838 | * Return: adapter pointer if found |
| 5839 | * |
| 5840 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5841 | struct hdd_adapter * |
| 5842 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5843 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5844 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5845 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5846 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5847 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5848 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5849 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5850 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5851 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5852 | return NULL; |
| 5853 | } |
| 5854 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5855 | 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] | 5856 | const char *iface_name) |
| 5857 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5858 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5859 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5860 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5861 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5862 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5863 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5864 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5865 | return NULL; |
| 5866 | } |
| 5867 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5868 | /** |
| 5869 | * hdd_get_adapter() - to get adapter matching the mode |
| 5870 | * @hdd_ctx: hdd context |
| 5871 | * @mode: adapter mode |
| 5872 | * |
| 5873 | * This routine will return the pointer to adapter matching |
| 5874 | * with the passed mode. |
| 5875 | * |
| 5876 | * Return: pointer to adapter or null |
| 5877 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5878 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5879 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5880 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5881 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5882 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5883 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5884 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5885 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5886 | } |
| 5887 | |
| 5888 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5889 | } |
| 5890 | |
| 5891 | /** |
| 5892 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5893 | * @hdd_ctx: Pointer to the HDD context. |
| 5894 | * @mode: Device mode for which operating channel is required. |
| 5895 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5896 | * QDF_STA_MODE, |
| 5897 | * QDF_P2P_CLIENT_MODE, |
| 5898 | * QDF_SAP_MODE, |
| 5899 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5900 | * |
| 5901 | * This API returns the operating channel of the requested device mode |
| 5902 | * |
| 5903 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5904 | * not connected. |
| 5905 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5906 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5907 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5909 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5910 | uint8_t operatingChannel = 0; |
| 5911 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5912 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5913 | if (mode == adapter->device_mode) { |
| 5914 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5915 | case QDF_STA_MODE: |
| 5916 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5917 | if (hdd_conn_is_connected |
| 5918 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5919 | (adapter))) { |
| 5920 | operatingChannel = |
| 5921 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5922 | (adapter))->conn_info. |
| 5923 | operationChannel; |
| 5924 | } |
| 5925 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5926 | case QDF_SAP_MODE: |
| 5927 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | /* softap connection info */ |
| 5929 | if (test_bit |
| 5930 | (SOFTAP_BSS_STARTED, |
| 5931 | &adapter->event_flags)) |
| 5932 | operatingChannel = |
| 5933 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 5934 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5935 | break; |
| 5936 | default: |
| 5937 | break; |
| 5938 | } |
| 5939 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5940 | /* Found the device of interest. break the loop */ |
| 5941 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5942 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5944 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5945 | return operatingChannel; |
| 5946 | } |
| 5947 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5948 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5949 | hdd_ctx) |
| 5950 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5951 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5952 | |
| 5953 | ENTER(); |
| 5954 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5955 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5956 | if (adapter->device_mode == QDF_STA_MODE || |
| 5957 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5958 | adapter->device_mode == QDF_IBSS_MODE || |
| 5959 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5960 | adapter->device_mode == QDF_SAP_MODE || |
| 5961 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5962 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5963 | hdd_unregister_wext(adapter->dev); |
| 5964 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5965 | } |
| 5966 | |
| 5967 | EXIT(); |
| 5968 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5969 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5970 | } |
| 5971 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5972 | 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] | 5973 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5974 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5975 | |
| 5976 | ENTER(); |
| 5977 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5978 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5979 | if (adapter->device_mode == QDF_STA_MODE || |
| 5980 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5981 | adapter->device_mode == QDF_IBSS_MODE || |
| 5982 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5983 | adapter->device_mode == QDF_SAP_MODE || |
| 5984 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5985 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5986 | adapter->session_id, INVALID_SCAN_ID, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5987 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5988 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5989 | } |
| 5990 | |
| 5991 | EXIT(); |
| 5992 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5993 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5994 | } |
| 5995 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5996 | /** |
| 5997 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5998 | * adapters |
| 5999 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6000 | * |
| 6001 | * return: QDF_STATUS_SUCCESS |
| 6002 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6003 | 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] | 6004 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6005 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6006 | int err; |
| 6007 | |
| 6008 | ENTER(); |
| 6009 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6010 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6011 | if (adapter->device_mode == QDF_STA_MODE || |
| 6012 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6013 | adapter->device_mode == QDF_IBSS_MODE || |
| 6014 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6015 | adapter->device_mode == QDF_SAP_MODE || |
| 6016 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6017 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6018 | if (err) |
| 6019 | hdd_err("Unable to stop scheduled scan"); |
| 6020 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6021 | } |
| 6022 | |
| 6023 | EXIT(); |
| 6024 | |
| 6025 | return QDF_STATUS_SUCCESS; |
| 6026 | } |
| 6027 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6028 | #ifdef WLAN_NS_OFFLOAD |
| 6029 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6030 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6031 | * @hdd_ctx: Pointer to hdd context |
| 6032 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6033 | * Unregister for IPv6 address change notifications. |
| 6034 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6035 | * Return: None |
| 6036 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6037 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6038 | { |
| 6039 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6040 | } |
| 6041 | |
| 6042 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6043 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | * @hdd_ctx: Pointer to hdd context |
| 6045 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6046 | * Register for IPv6 address change notifications. |
| 6047 | * |
| 6048 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6050 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6051 | { |
| 6052 | int ret; |
| 6053 | |
| 6054 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6055 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6056 | if (ret) { |
| 6057 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6058 | goto out; |
| 6059 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6060 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6061 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6062 | out: |
| 6063 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6064 | } |
| 6065 | #else |
| 6066 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6067 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6068 | * @hdd_ctx: Pointer to hdd context |
| 6069 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6070 | * Unregister for IPv6 address change notifications. |
| 6071 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6072 | * Return: None |
| 6073 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6074 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6075 | { |
| 6076 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6077 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6078 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6079 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6080 | * @hdd_ctx: Pointer to hdd context |
| 6081 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6082 | * Register for IPv6 address change notifications. |
| 6083 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6084 | * Return: None |
| 6085 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6086 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6087 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6088 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6089 | } |
| 6090 | #endif |
| 6091 | |
| 6092 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6093 | * hdd_register_notifiers - Register netdev notifiers. |
| 6094 | * @hdd_ctx: HDD context |
| 6095 | * |
| 6096 | * Register netdev notifiers like IPv4 and IPv6. |
| 6097 | * |
| 6098 | * Return: 0 on success and errno on failure |
| 6099 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6100 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6101 | { |
| 6102 | int ret; |
| 6103 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6104 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6105 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6106 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6107 | |
| 6108 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6109 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6110 | if (ret) { |
| 6111 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6112 | goto unregister_ip6_notifier; |
| 6113 | } |
| 6114 | |
| 6115 | return 0; |
| 6116 | |
| 6117 | unregister_ip6_notifier: |
| 6118 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6119 | out: |
| 6120 | return ret; |
| 6121 | |
| 6122 | } |
| 6123 | |
| 6124 | /** |
| 6125 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6126 | * @hdd_ctx: HDD context |
| 6127 | * |
| 6128 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6129 | * |
| 6130 | * Return: None. |
| 6131 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6132 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6133 | { |
| 6134 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6135 | |
| 6136 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6137 | } |
| 6138 | |
| 6139 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6140 | * hdd_exit_netlink_services - Exit netlink services |
| 6141 | * @hdd_ctx: HDD context |
| 6142 | * |
| 6143 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6144 | * nl service. |
| 6145 | * |
| 6146 | * Return: None. |
| 6147 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6148 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6149 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6150 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6151 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6152 | ptt_sock_deactivate_svc(); |
| 6153 | |
| 6154 | nl_srv_exit(); |
| 6155 | } |
| 6156 | |
| 6157 | /** |
| 6158 | * hdd_init_netlink_services- Init netlink services |
| 6159 | * @hdd_ctx: HDD context |
| 6160 | * |
| 6161 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6162 | * nl service. |
| 6163 | * |
| 6164 | * Return: 0 on success and errno on failure. |
| 6165 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6166 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6167 | { |
| 6168 | int ret; |
| 6169 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6170 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6171 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6172 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6173 | goto out; |
| 6174 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6175 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6176 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6177 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6178 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6179 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6180 | goto err_nl_srv; |
| 6181 | } |
| 6182 | |
| 6183 | ret = ptt_sock_activate_svc(); |
| 6184 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6185 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6186 | goto err_nl_srv; |
| 6187 | } |
| 6188 | |
| 6189 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6190 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6191 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6192 | |
| 6193 | ret = cnss_diag_activate_service(); |
| 6194 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6195 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6196 | goto err_close_cesium; |
| 6197 | } |
| 6198 | |
| 6199 | return 0; |
| 6200 | |
| 6201 | err_close_cesium: |
| 6202 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6203 | ptt_sock_deactivate_svc(); |
| 6204 | err_nl_srv: |
| 6205 | nl_srv_exit(); |
| 6206 | out: |
| 6207 | return ret; |
| 6208 | } |
| 6209 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6210 | /** |
| 6211 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6212 | * @hdd_ctx: HDD context. |
| 6213 | * |
| 6214 | * Destroy RX wakelock. |
| 6215 | * |
| 6216 | * Return: None. |
| 6217 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6218 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6219 | { |
| 6220 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6221 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6222 | |
| 6223 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6224 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6225 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6226 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6227 | * Create RX wakelock. |
| 6228 | * |
| 6229 | * Return: None. |
| 6230 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6231 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6232 | { |
| 6233 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6234 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6235 | |
| 6236 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6237 | * hdd_context_deinit() - Deinitialize HDD context |
| 6238 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6239 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6240 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6241 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6242 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6243 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6244 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6245 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6246 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6247 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6248 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6249 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6250 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6251 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6252 | hdd_sap_context_destroy(hdd_ctx); |
| 6253 | |
| 6254 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6255 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6256 | hdd_scan_context_destroy(hdd_ctx); |
| 6257 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6258 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6259 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6260 | return 0; |
| 6261 | } |
| 6262 | |
| 6263 | /** |
| 6264 | * hdd_context_destroy() - Destroy HDD context |
| 6265 | * @hdd_ctx: HDD context to be destroyed. |
| 6266 | * |
| 6267 | * Free config and HDD context as well as destroy all the resources. |
| 6268 | * |
| 6269 | * Return: None |
| 6270 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6271 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6272 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6273 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6274 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6275 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6276 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6277 | hdd_context_deinit(hdd_ctx); |
| 6278 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6279 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6280 | hdd_ctx->config = NULL; |
| 6281 | |
| 6282 | wiphy_free(hdd_ctx->wiphy); |
| 6283 | } |
| 6284 | |
| 6285 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6286 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6287 | * |
| 6288 | * This function is used to destroy bug report lock |
| 6289 | * |
| 6290 | * Return: None |
| 6291 | */ |
| 6292 | static void wlan_destroy_bug_report_lock(void) |
| 6293 | { |
| 6294 | p_cds_contextType p_cds_context; |
| 6295 | |
| 6296 | p_cds_context = cds_get_global_context(); |
| 6297 | if (!p_cds_context) { |
| 6298 | hdd_err("cds context is NULL"); |
| 6299 | return; |
| 6300 | } |
| 6301 | |
| 6302 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6303 | } |
| 6304 | |
| 6305 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6306 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6307 | * @hdd_ctx: Pointer to the HDD Context |
| 6308 | * |
| 6309 | * This is the driver exit point (invoked during rmmod) |
| 6310 | * |
| 6311 | * Return: None |
| 6312 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6313 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6314 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6315 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6316 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6317 | |
| 6318 | ENTER(); |
| 6319 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6320 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6321 | |
| 6322 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6323 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6324 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | |
| 6326 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6327 | if (QDF_TIMER_STATE_RUNNING == |
| 6328 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6329 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6330 | } |
| 6331 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6332 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6333 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6334 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6335 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6336 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6337 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6338 | hdd_ctx->last_acs_channel_list = NULL; |
| 6339 | hdd_ctx->num_of_channels = 0; |
| 6340 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6342 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6343 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6344 | driver_status = hdd_ctx->driver_status; |
| 6345 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6346 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6347 | /* |
| 6348 | * Powersave Offload Case |
| 6349 | * Disable Idle Power Save Mode |
| 6350 | */ |
| 6351 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6352 | /* clear the scan queue in all the scenarios */ |
| 6353 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6355 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6356 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6357 | /* |
| 6358 | * Cancel any outstanding scan requests. We are about to close |
| 6359 | * all of our adapters, but an adapter structure is what SME |
| 6360 | * passes back to our callback function. Hence if there |
| 6361 | * are any outstanding scan requests then there is a |
| 6362 | * race condition between when the adapter is closed and |
| 6363 | * when the callback is invoked. We try to resolve that |
| 6364 | * race condition here by canceling any outstanding scans |
| 6365 | * before we close the adapters. |
| 6366 | * Note that the scans may be cancelled in an asynchronous |
| 6367 | * manner, so ideally there needs to be some kind of |
| 6368 | * synchronization. Rather than introduce a new |
| 6369 | * synchronization here, we will utilize the fact that we are |
| 6370 | * about to Request Full Power, and since that is synchronized, |
| 6371 | * the expectation is that by the time Request Full Power has |
| 6372 | * completed, all scans will be cancelled |
| 6373 | */ |
| 6374 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6375 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6376 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6377 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6378 | } |
| 6379 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6380 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6381 | |
Dustin Brown | 36e24e2 | 2017-12-21 12:34:13 -0800 | [diff] [blame] | 6382 | hdd_close_all_adapters(hdd_ctx, false); |
| 6383 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6384 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6385 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6386 | hdd_driver_memdump_deinit(); |
| 6387 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6388 | qdf_nbuf_deinit_replenish_timer(); |
| 6389 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6390 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6391 | hdd_info("Release wakelock for monitor mode!"); |
| 6392 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6393 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6394 | } |
| 6395 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6396 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6397 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6398 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6399 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6400 | /* |
| 6401 | * Close CDS |
| 6402 | * This frees pMac(HAL) context. There should not be any call |
| 6403 | * that requires pMac access after this. |
| 6404 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6405 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6406 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6407 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6408 | hdd_ipa_cleanup(hdd_ctx); |
| 6409 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6410 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6411 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6412 | /* |
| 6413 | * If there is re_init failure wiphy would have already de-registered |
| 6414 | * check the wiphy status before un-registering again |
| 6415 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6416 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6417 | wiphy_unregister(wiphy); |
| 6418 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6419 | hdd_lpass_notify_stop(hdd_ctx); |
| 6420 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6421 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6422 | hdd_exit_netlink_services(hdd_ctx); |
| 6423 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6424 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6425 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6426 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6427 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6428 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6429 | if (driver_status) |
| 6430 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6431 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6432 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6433 | } |
| 6434 | |
| 6435 | void __hdd_wlan_exit(void) |
| 6436 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6437 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6438 | |
| 6439 | ENTER(); |
| 6440 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6441 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6442 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6443 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6444 | EXIT(); |
| 6445 | return; |
| 6446 | } |
| 6447 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6448 | /* Do all the cleanup before deregistering the driver */ |
| 6449 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6450 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6451 | EXIT(); |
| 6452 | } |
| 6453 | |
| 6454 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6455 | /** |
| 6456 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6457 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6458 | * |
| 6459 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6460 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6461 | * scan information. |
| 6462 | * |
| 6463 | * Return: void |
| 6464 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6465 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6466 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6467 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6468 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6469 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6470 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6471 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6472 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6473 | hdd_ctx->last_acs_channel_list = NULL; |
| 6474 | hdd_ctx->num_of_channels = 0; |
| 6475 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6476 | |
| 6477 | if (!hdd_ctx->hHal) |
| 6478 | return; |
| 6479 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6480 | } |
| 6481 | #endif |
| 6482 | |
| 6483 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6484 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6485 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6486 | { |
| 6487 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6488 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6489 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6490 | |
| 6491 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6492 | |
| 6493 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6494 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6495 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6496 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6497 | if (!hdd_ctx->hHal) |
| 6498 | return -EINVAL; |
| 6499 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6500 | 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] | 6501 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6502 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6503 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6504 | return -EINVAL; |
| 6505 | } |
| 6506 | |
| 6507 | return 0; |
| 6508 | } |
| 6509 | #endif |
| 6510 | |
| 6511 | /** |
| 6512 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6513 | * @state: state |
| 6514 | * |
| 6515 | * This function notifies FW with modem power status |
| 6516 | * |
| 6517 | * Return: 0 if successful, error number otherwise |
| 6518 | */ |
| 6519 | int hdd_wlan_notify_modem_power_state(int state) |
| 6520 | { |
| 6521 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6522 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6523 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6524 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6525 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6526 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6527 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6528 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | if (!hdd_ctx->hHal) |
| 6531 | return -EINVAL; |
| 6532 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6533 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6534 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6535 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6536 | state); |
| 6537 | return -EINVAL; |
| 6538 | } |
| 6539 | return 0; |
| 6540 | } |
| 6541 | |
| 6542 | /** |
| 6543 | * |
| 6544 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6545 | * @adapter - Pointer to the HDD |
| 6546 | * |
| 6547 | * Return: None |
| 6548 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6549 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6550 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6551 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6552 | |
| 6553 | /* |
| 6554 | * Send ready indication to the HDD. This will kick off the MAC |
| 6555 | * into a 'running' state and should kick off an initial scan. |
| 6556 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6557 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6558 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6559 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6560 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6561 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | } |
| 6563 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6564 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6565 | } |
| 6566 | |
| 6567 | /* wake lock APIs for HDD */ |
| 6568 | void hdd_prevent_suspend(uint32_t reason) |
| 6569 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6570 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6571 | } |
| 6572 | |
| 6573 | void hdd_allow_suspend(uint32_t reason) |
| 6574 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6575 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6576 | } |
| 6577 | |
| 6578 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6579 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6580 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6581 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6582 | } |
| 6583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6585 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6586 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6587 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6588 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6589 | hdd_ctx->reg.alpha2, |
| 6590 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | } |
| 6592 | |
| 6593 | /** |
| 6594 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6595 | * @hdd_ctx: Pointer to the hdd context |
| 6596 | * |
| 6597 | * HDD function to know if hardware supports 5GHz |
| 6598 | * |
| 6599 | * Return: true if hardware supports 5GHz |
| 6600 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6601 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6603 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6604 | return true; |
| 6605 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6606 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6607 | return true; |
| 6608 | else |
| 6609 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6610 | } |
| 6611 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6612 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | { |
| 6614 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6615 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6616 | |
| 6617 | wiphy = hdd_ctx->wiphy; |
| 6618 | |
| 6619 | /* |
| 6620 | * The channel information in |
| 6621 | * wiphy needs to be initialized before wiphy registration |
| 6622 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6623 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6624 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6625 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6626 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6627 | } |
| 6628 | |
| 6629 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6630 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6631 | #else |
| 6632 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6633 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6634 | WIPHY_WOWLAN_DISCONNECT | |
| 6635 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6636 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6637 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6638 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6639 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6640 | |
| 6641 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6642 | WOW_MAX_FILTERS_PER_LIST); |
| 6643 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6644 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6645 | #endif |
| 6646 | |
| 6647 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6648 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6649 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6650 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6651 | return ret_val; |
| 6652 | } |
| 6653 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6654 | if (!hdd_ctx->reg_offload) |
| 6655 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6656 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6657 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6658 | } |
| 6659 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6660 | #ifdef MSM_PLATFORM |
| 6661 | /** |
| 6662 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6663 | * @hdd_ctx - handle to hdd context |
| 6664 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6665 | * |
| 6666 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6667 | * Stats show up in wlan driver logs. |
| 6668 | * |
| 6669 | * Returns: None |
| 6670 | */ |
| 6671 | static inline |
| 6672 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6673 | bool data_in_interval) |
| 6674 | { |
| 6675 | static u32 counter; |
| 6676 | static bool data_in_time_period; |
| 6677 | ol_txrx_pdev_handle pdev; |
| 6678 | |
| 6679 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6680 | return; |
| 6681 | |
| 6682 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6683 | if (!pdev) { |
| 6684 | hdd_err("pdev is NULL"); |
| 6685 | return; |
| 6686 | } |
| 6687 | |
| 6688 | counter++; |
| 6689 | if (data_in_interval) |
| 6690 | data_in_time_period = data_in_interval; |
| 6691 | |
| 6692 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6693 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6694 | if (data_in_time_period) { |
| 6695 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6696 | CDP_TXRX_PATH_STATS, |
| 6697 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6698 | wlan_hdd_display_netif_queue_history |
| 6699 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6700 | qdf_dp_trace_dump_stats(); |
| 6701 | } |
| 6702 | counter = 0; |
| 6703 | data_in_time_period = false; |
| 6704 | } |
| 6705 | } |
| 6706 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6707 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6708 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6709 | * @hdd_ctx - handle to hdd context |
| 6710 | * @tx_packets - transmit packet count |
| 6711 | * @rx_packets - receive packet count |
| 6712 | * |
| 6713 | * The function controls the bus bandwidth and dynamic control of |
| 6714 | * tcp delayed ack configuration |
| 6715 | * |
| 6716 | * Returns: None |
| 6717 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6718 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6719 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6720 | const uint64_t tx_packets, |
| 6721 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6723 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6724 | uint64_t temp_rx = 0; |
| 6725 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6726 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6727 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6728 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6729 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6730 | uint16_t index = 0; |
| 6731 | bool vote_level_change = false; |
| 6732 | bool rx_level_change = false; |
| 6733 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6734 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6735 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6736 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6737 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6738 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6739 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6740 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6741 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6742 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6744 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6745 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6746 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6747 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6748 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6749 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6750 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6751 | if (hdd_ctx->hbw_requested) { |
| 6752 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6753 | hdd_ctx->hbw_requested = false; |
| 6754 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6755 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6756 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6757 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6758 | if (!hdd_ctx->hbw_requested) { |
| 6759 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6760 | hdd_ctx->hbw_requested = true; |
| 6761 | } |
| 6762 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6763 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6764 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6765 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6766 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6767 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6768 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6769 | qdf_dp_trace_throttle_live_mode( |
| 6770 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6771 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6772 | /* fine-tuning parameters for RX Flows */ |
| 6773 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6774 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6775 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6776 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6777 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6778 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6779 | else |
| 6780 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6781 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6782 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6783 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6784 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6785 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6786 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6787 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6788 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6789 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6790 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6791 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6792 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6793 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 6794 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6795 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6796 | next_rx_level, temp_rx); |
| 6797 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6798 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6799 | /* Send throughput indication only if it is enabled. |
| 6800 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6801 | * to default delayed ack. Note that this will disable the |
| 6802 | * dynamic delayed ack mechanism across the system |
| 6803 | */ |
| 6804 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6805 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 6806 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 6807 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 6808 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 6809 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6810 | rx_tp_data.level = next_rx_level; |
| 6811 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6812 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 6813 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6814 | } |
| 6815 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6816 | /* fine-tuning parameters for TX Flows */ |
| 6817 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6818 | hdd_ctx->prev_tx = tx_packets; |
| 6819 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6820 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6821 | else |
| 6822 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6823 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6824 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6825 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6826 | next_tx_level, temp_tx); |
| 6827 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6828 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6829 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6830 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6831 | &next_tx_level, |
| 6832 | sizeof(next_tx_level)); |
| 6833 | } |
| 6834 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6835 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6836 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6837 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6838 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6839 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6840 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6841 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6842 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6843 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6844 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6845 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6846 | |
| 6847 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6848 | } |
| 6849 | |
| 6850 | #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] | 6851 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6852 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6853 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6854 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6855 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6856 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6857 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6858 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6859 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6860 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6861 | bool connected = false; |
| 6862 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6863 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6864 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6865 | return; |
| 6866 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 6867 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6868 | goto restart_timer; |
| 6869 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6870 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6871 | /* |
| 6872 | * Validate magic so we don't end up accessing |
| 6873 | * an invalid adapter. |
| 6874 | */ |
| 6875 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6876 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6877 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6878 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6879 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6880 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6881 | != eConnectionState_Associated) { |
| 6882 | |
| 6883 | continue; |
| 6884 | } |
| 6885 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6886 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6887 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 6888 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6889 | |
| 6890 | continue; |
| 6891 | } |
| 6892 | |
| 6893 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6894 | adapter->prev_tx_packets); |
| 6895 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6896 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6897 | |
| 6898 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6899 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6900 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6901 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6902 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6903 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6904 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6905 | &fwd_tx_packets, &fwd_rx_packets); |
| 6906 | if (ret == A_OK) { |
| 6907 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6908 | fwd_tx_packets, |
| 6909 | adapter->prev_fwd_tx_packets); |
| 6910 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6911 | fwd_tx_packets, |
| 6912 | adapter->prev_fwd_rx_packets); |
| 6913 | } |
| 6914 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6915 | |
| 6916 | total_rx += adapter->stats.rx_packets; |
| 6917 | total_tx += adapter->stats.tx_packets; |
| 6918 | |
| 6919 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6920 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6921 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6922 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6923 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6924 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6925 | connected = true; |
| 6926 | } |
| 6927 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6928 | /* add intra bss forwarded tx and rx packets */ |
| 6929 | tx_packets += fwd_tx_packets_diff; |
| 6930 | rx_packets += fwd_rx_packets_diff; |
| 6931 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6932 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6933 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6934 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6935 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6936 | if (adapter) { |
| 6937 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6938 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6939 | } |
| 6940 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6941 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6942 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6943 | return; |
| 6944 | } |
| 6945 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6946 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6947 | |
| 6948 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6949 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6950 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6951 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6952 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6953 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6954 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6955 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6956 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6957 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6958 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6959 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6960 | /** |
| 6961 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6962 | * @arg: Argument of timer function |
| 6963 | * |
| 6964 | * Schedule a workqueue in this function where all the processing is done. |
| 6965 | * |
| 6966 | * Return: None. |
| 6967 | */ |
| 6968 | static void __hdd_bus_bw_cbk(void *arg) |
| 6969 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6970 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6971 | |
| 6972 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6973 | return; |
| 6974 | |
| 6975 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6976 | } |
| 6977 | |
| 6978 | /** |
| 6979 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6980 | * @arg: Argument of timer function |
| 6981 | * |
| 6982 | * Return: None. |
| 6983 | */ |
| 6984 | static void hdd_bus_bw_cbk(void *arg) |
| 6985 | { |
| 6986 | cds_ssr_protect(__func__); |
| 6987 | __hdd_bus_bw_cbk(arg); |
| 6988 | cds_ssr_unprotect(__func__); |
| 6989 | } |
| 6990 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6991 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6992 | { |
| 6993 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6994 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6995 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6996 | hdd_ctx->bus_bw_timer_running = false; |
| 6997 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6998 | qdf_timer_init(NULL, |
| 6999 | &hdd_ctx->bus_bw_timer, |
| 7000 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7001 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7002 | |
| 7003 | return 0; |
| 7004 | } |
| 7005 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7006 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7007 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7008 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7009 | hdd_reset_tcp_delack(hdd_ctx); |
| 7010 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7011 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7012 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7013 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7014 | hdd_ctx->bus_bw_timer_running = false; |
| 7015 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7016 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7017 | |
| 7018 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7019 | { |
| 7020 | if (hdd_ctx) |
| 7021 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7022 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7024 | #endif |
| 7025 | |
| 7026 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7027 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7028 | * @hdd_ctx: hdd context |
| 7029 | * |
| 7030 | * Return: 0 for success or error code |
| 7031 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7032 | 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] | 7033 | { |
| 7034 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7035 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7036 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7037 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7038 | return -ENOMEM; |
| 7039 | } |
| 7040 | return 0; |
| 7041 | } |
| 7042 | |
| 7043 | /** |
| 7044 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7045 | * @hdd_ctx: hdd context |
| 7046 | * |
| 7047 | * Return: none |
| 7048 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7049 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7050 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7051 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7052 | return; |
| 7053 | |
| 7054 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7055 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7056 | } |
| 7057 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7058 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7059 | { |
| 7060 | switch (level) { |
| 7061 | /* initialize the wlan sub system */ |
| 7062 | case WLAN_SVC_TP_NONE: |
| 7063 | return "NONE"; |
| 7064 | case WLAN_SVC_TP_LOW: |
| 7065 | return "LOW"; |
| 7066 | case WLAN_SVC_TP_MEDIUM: |
| 7067 | return "MED"; |
| 7068 | case WLAN_SVC_TP_HIGH: |
| 7069 | return "HIGH"; |
| 7070 | default: |
| 7071 | return "INVAL"; |
| 7072 | } |
| 7073 | } |
| 7074 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7075 | |
| 7076 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7077 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7078 | * @hdd_ctx: hdd context |
| 7079 | * |
| 7080 | * Return: none |
| 7081 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7082 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7083 | { |
| 7084 | int i; |
| 7085 | |
| 7086 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7087 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7088 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7089 | 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] | 7090 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7091 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7092 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7093 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7094 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7095 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7096 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7097 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7098 | 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] | 7099 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7100 | #endif |
| 7101 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7102 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7103 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7104 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7105 | 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] | 7106 | |
| 7107 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7108 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7109 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7110 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7111 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7112 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7113 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7114 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7115 | convert_level_to_string( |
| 7116 | hdd_ctx->hdd_txrx_hist[i]. |
| 7117 | next_vote_level), |
| 7118 | convert_level_to_string( |
| 7119 | hdd_ctx->hdd_txrx_hist[i]. |
| 7120 | next_rx_level), |
| 7121 | convert_level_to_string( |
| 7122 | hdd_ctx->hdd_txrx_hist[i]. |
| 7123 | next_tx_level)); |
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 | } |
| 7126 | |
| 7127 | /** |
| 7128 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7129 | * @hdd_ctx: hdd context |
| 7130 | * |
| 7131 | * Return: none |
| 7132 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7133 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7134 | { |
| 7135 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7136 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7137 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | } |
| 7139 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7140 | /* length of the netif queue log needed per adapter */ |
| 7141 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7142 | |
| 7143 | /** |
| 7144 | * |
| 7145 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7146 | * @hdd_ctx: hdd context |
| 7147 | * |
| 7148 | * Return: none |
| 7149 | */ |
| 7150 | static void |
| 7151 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7152 | { |
| 7153 | int adapter_num = 0; |
| 7154 | int i; |
| 7155 | int bytes_written; |
| 7156 | u32 tbytes; |
| 7157 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7158 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
| 7159 | char comb_log_str[(ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1]; |
| 7160 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7161 | |
| 7162 | bytes_written = 0; |
| 7163 | qdf_mem_set(comb_log_str, 0, sizeof(comb_log_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7164 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7165 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7166 | curr_time = qdf_system_ticks(); |
| 7167 | total = curr_time - adapter->start_time; |
| 7168 | delta = curr_time - adapter->last_time; |
| 7169 | |
| 7170 | if (adapter->pause_map) { |
| 7171 | pause = adapter->total_pause_time + delta; |
| 7172 | unpause = adapter->total_unpause_time; |
| 7173 | } else { |
| 7174 | unpause = adapter->total_unpause_time + delta; |
| 7175 | pause = adapter->total_pause_time; |
| 7176 | } |
| 7177 | |
| 7178 | tbytes = 0; |
| 7179 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7180 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7181 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7182 | continue; |
| 7183 | tbytes += |
| 7184 | snprintf( |
| 7185 | &temp_str[tbytes], |
| 7186 | (tbytes >= sizeof(temp_str) ? |
| 7187 | 0 : sizeof(temp_str) - tbytes), |
| 7188 | "%d(%d,%d) ", |
| 7189 | i, |
| 7190 | adapter->queue_oper_stats[i]. |
| 7191 | pause_count, |
| 7192 | adapter->queue_oper_stats[i]. |
| 7193 | unpause_count); |
| 7194 | } |
| 7195 | if (tbytes >= sizeof(temp_str)) |
| 7196 | hdd_warn("log truncated"); |
| 7197 | |
| 7198 | bytes_written += snprintf(&comb_log_str[bytes_written], |
| 7199 | bytes_written >= sizeof(comb_log_str) ? 0 : |
| 7200 | sizeof(comb_log_str) - bytes_written, |
| 7201 | "[%d %d] (%d) %u/%ums %s|", |
| 7202 | adapter->session_id, adapter->device_mode, |
| 7203 | adapter->pause_map, |
| 7204 | qdf_system_ticks_to_msecs(pause), |
| 7205 | qdf_system_ticks_to_msecs(total), |
| 7206 | temp_str); |
| 7207 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7208 | adapter_num++; |
| 7209 | } |
| 7210 | |
| 7211 | /* using QDF_TRACE to avoid printing function name */ |
| 7212 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7213 | "STATS |%s", comb_log_str); |
| 7214 | |
| 7215 | if (bytes_written >= sizeof(comb_log_str)) |
| 7216 | hdd_warn("log string truncated"); |
| 7217 | } |
| 7218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7219 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7220 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7221 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7222 | * |
| 7223 | * Return: none |
| 7224 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7225 | void |
| 7226 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7227 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7228 | { |
| 7229 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7230 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7231 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7232 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7233 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7234 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7235 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7236 | return; |
| 7237 | } |
| 7238 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7239 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7240 | hdd_debug("Netif queue operation statistics:"); |
| 7241 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7242 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7243 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7244 | curr_time = qdf_system_ticks(); |
| 7245 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7246 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7247 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7248 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7249 | unpause = adapter->total_unpause_time; |
| 7250 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7251 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7252 | pause = adapter->total_pause_time; |
| 7253 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7254 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7255 | qdf_system_ticks_to_msecs(total), |
| 7256 | qdf_system_ticks_to_msecs(pause), |
| 7257 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7258 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7259 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7260 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7261 | qdf_time_t pause_delta = 0; |
| 7262 | |
| 7263 | if (adapter->pause_map & (1 << i)) |
| 7264 | pause_delta = delta; |
| 7265 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7266 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7267 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7268 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7269 | hdd_reason_type_to_string(i), |
| 7270 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7271 | adapter->queue_oper_stats[i].unpause_count, |
| 7272 | qdf_system_ticks_to_msecs( |
| 7273 | adapter->queue_oper_stats[i].total_pause_time + |
| 7274 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7275 | } |
| 7276 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7277 | hdd_debug("Netif queue operation history:"); |
| 7278 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7279 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7280 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7281 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7282 | |
| 7283 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7284 | /* using hdd_log to avoid printing function name */ |
| 7285 | if (adapter->queue_oper_history[i].time == 0) |
| 7286 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7287 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7288 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 7289 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7290 | adapter->queue_oper_history[i].time), |
| 7291 | hdd_action_type_to_string( |
| 7292 | adapter->queue_oper_history[i].netif_action), |
| 7293 | hdd_reason_type_to_string( |
| 7294 | adapter->queue_oper_history[i].netif_reason), |
| 7295 | adapter->queue_oper_history[i].pause_map); |
| 7296 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7297 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7298 | } |
| 7299 | |
| 7300 | /** |
| 7301 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7302 | * @hdd_ctx: hdd context |
| 7303 | * |
| 7304 | * Return: none |
| 7305 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7306 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7307 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7308 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7309 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7310 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7311 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7312 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7313 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7314 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7315 | adapter->history_index = 0; |
| 7316 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7317 | adapter->total_pause_time = 0; |
| 7318 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7319 | } |
| 7320 | } |
| 7321 | |
| 7322 | /** |
| 7323 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7324 | * @halHandle: Hal handle |
| 7325 | * @pContext: Pointer to the context |
| 7326 | * @sessionId: Session ID |
| 7327 | * @scanId: Scan ID |
| 7328 | * @status: Status |
| 7329 | * |
| 7330 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7331 | * the scan results |
| 7332 | * |
| 7333 | * 11d scan is done during driver load and is a passive scan on all |
| 7334 | * channels supported by the device, 11d scans may find some APs on |
| 7335 | * frequencies which are forbidden to be used in the regulatory domain |
| 7336 | * the device is operating in. If these APs are notified to the supplicant |
| 7337 | * it may try to connect to these APs, thus flush out all the scan results |
| 7338 | * which are present in SME after 11d scan is done. |
| 7339 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7340 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7341 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7342 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7343 | uint8_t sessionId, uint32_t scanId, |
| 7344 | eCsrScanStatus status) |
| 7345 | { |
| 7346 | ENTER(); |
| 7347 | |
| 7348 | sme_scan_flush_result(halHandle); |
| 7349 | |
| 7350 | EXIT(); |
| 7351 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7352 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7353 | } |
| 7354 | |
| 7355 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7356 | /** |
| 7357 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7358 | * @hdd_ctx: hdd global context |
| 7359 | * |
| 7360 | * Return: none |
| 7361 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7362 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7363 | { |
| 7364 | uint8_t i; |
| 7365 | |
| 7366 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7367 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7368 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7369 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7370 | } |
| 7371 | } |
| 7372 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7373 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7374 | { |
| 7375 | } |
| 7376 | #endif |
| 7377 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7378 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7379 | /** |
| 7380 | * 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] | 7381 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7382 | * @enable: enable or disable this behaviour |
| 7383 | * |
| 7384 | * Return: int |
| 7385 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7386 | 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] | 7387 | { |
| 7388 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7389 | struct wow_pulse_mode wow_pulse_set_info; |
| 7390 | QDF_STATUS status; |
| 7391 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7392 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7393 | |
| 7394 | if (false == phddctx->config->wow_pulse_support) |
| 7395 | return 0; |
| 7396 | |
| 7397 | /* prepare the request to send to SME */ |
| 7398 | if (enable == true) { |
| 7399 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7400 | wow_pulse_set_info.wow_pulse_pin = |
| 7401 | pcfg_ini->wow_pulse_pin; |
| 7402 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7403 | pcfg_ini->wow_pulse_interval_low; |
| 7404 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7405 | pcfg_ini->wow_pulse_interval_high; |
| 7406 | } else { |
| 7407 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7408 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7409 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7410 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7411 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7412 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7413 | wow_pulse_set_info.wow_pulse_enable, |
| 7414 | wow_pulse_set_info.wow_pulse_pin, |
| 7415 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7416 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7417 | |
| 7418 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7419 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7420 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7421 | return -EIO; |
| 7422 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7423 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7424 | return 0; |
| 7425 | } |
| 7426 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7427 | 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] | 7428 | { |
| 7429 | return 0; |
| 7430 | } |
| 7431 | #endif |
| 7432 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7433 | #ifdef WLAN_FEATURE_FASTPATH |
| 7434 | /** |
| 7435 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7436 | * @hdd_cfg: hdd config |
| 7437 | * @context: lower layer context |
| 7438 | * |
| 7439 | * Return: none |
| 7440 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7441 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7442 | void *context) |
| 7443 | { |
| 7444 | if (hdd_cfg->fastpath_enable) |
| 7445 | hif_enable_fastpath(context); |
| 7446 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7447 | #endif |
| 7448 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7449 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7450 | /** |
| 7451 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7452 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7453 | * @level: thermal level |
| 7454 | * |
| 7455 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7456 | * than 0, and restore the original data path when throttle level is 0 |
| 7457 | * |
| 7458 | * Return: none |
| 7459 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7460 | 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] | 7461 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7462 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7463 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7464 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7465 | if (level > THROTTLE_LEVEL_0) |
| 7466 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7467 | else |
| 7468 | /* restore original concurrency mode */ |
| 7469 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7470 | } |
| 7471 | |
| 7472 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7473 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7474 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7475 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7476 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7477 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7478 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7479 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7480 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7481 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7482 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7483 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7484 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7485 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7486 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7487 | struct sir_pcl_list pcl; |
| 7488 | QDF_STATUS status; |
| 7489 | uint32_t i, j; |
| 7490 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7491 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7492 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7493 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7494 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7495 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7496 | if (!hdd_ctx) { |
| 7497 | hdd_err("invalid HDD context"); |
| 7498 | return INVALID_CHANNEL_ID; |
| 7499 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7500 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7501 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7502 | if (!hal_handle) { |
| 7503 | hdd_err("invalid HAL handle"); |
| 7504 | return INVALID_CHANNEL_ID; |
| 7505 | } |
| 7506 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7507 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7508 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7509 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7510 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7511 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7512 | hdd_err("Get PCL failed"); |
| 7513 | return INVALID_CHANNEL_ID; |
| 7514 | } |
| 7515 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7516 | /* |
| 7517 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7518 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7519 | * try to choose a safe channel from acs range. |
| 7520 | */ |
| 7521 | if (!pcl.pcl_len) |
| 7522 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7523 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7524 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7525 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7526 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7527 | |
| 7528 | /* PCL already takes unsafe channel into account */ |
| 7529 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7530 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7531 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7532 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7533 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7534 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7535 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7536 | return pcl.pcl_list[i]; |
| 7537 | } |
| 7538 | } |
| 7539 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7540 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7541 | |
| 7542 | /* Try for safe channel from all valid channel */ |
| 7543 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7544 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7545 | &pcl.pcl_len); |
| 7546 | if (ret) { |
| 7547 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7548 | return INVALID_CHANNEL_ID; |
| 7549 | } |
| 7550 | |
| 7551 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7552 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7553 | found = false; |
| 7554 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7555 | if (pcl.pcl_list[i] == |
| 7556 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7557 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7558 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7559 | break; |
| 7560 | } |
| 7561 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7562 | |
| 7563 | if (found) |
| 7564 | continue; |
| 7565 | |
| 7566 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7567 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7568 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7569 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7570 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7571 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7572 | } |
| 7573 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7574 | |
| 7575 | return INVALID_CHANNEL_ID; |
| 7576 | } |
| 7577 | |
| 7578 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7579 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7580 | * @adapter: AP adapter |
| 7581 | * @channel: Channel |
| 7582 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7583 | * Moves the SAP interface by invoking the function which |
| 7584 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7585 | * |
| 7586 | * Return: None |
| 7587 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7588 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7589 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7590 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7591 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7592 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7593 | |
| 7594 | if (!adapter) { |
| 7595 | hdd_err("invalid adapter"); |
| 7596 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7598 | |
| 7599 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7600 | |
| 7601 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7602 | if (!hal_handle) { |
| 7603 | hdd_err("invalid HAL handle"); |
| 7604 | return; |
| 7605 | } |
| 7606 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7607 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7608 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7609 | hdd_ap_ctx->sap_config.channel = channel; |
| 7610 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7611 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7612 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7613 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7614 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7615 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7616 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7617 | hdd_ap_ctx->sap_config.channel, |
| 7618 | hdd_ap_ctx->sap_config.sec_ch, |
| 7619 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7620 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7621 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7622 | adapter->session_id, channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7623 | hdd_ap_ctx->sap_config.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7624 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7625 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7626 | 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] | 7627 | { |
| 7628 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7629 | int status; |
| 7630 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7631 | |
| 7632 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7633 | |
| 7634 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7635 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7636 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7637 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7638 | } |
| 7639 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7640 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7641 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7642 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7643 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7644 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7645 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7646 | hdd_err("failed to start external acs timer"); |
| 7647 | return -ENOSPC; |
| 7648 | } |
| 7649 | /* Update config to application */ |
| 7650 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7651 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7652 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7653 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7654 | } |
| 7655 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7656 | /** |
| 7657 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7658 | * @hdd_ctx: hdd context pointer |
| 7659 | * |
| 7660 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7661 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7662 | * sap. User space on LTE coex indication restart driver. |
| 7663 | * |
| 7664 | * Return - none |
| 7665 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7666 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7667 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7668 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7669 | uint32_t i; |
| 7670 | bool found = false; |
| 7671 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7672 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7673 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7674 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7675 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7676 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7677 | adapter->device_mode, |
| 7678 | adapter->session.ap.sap_config. |
| 7679 | acs_cfg.acs_mode); |
| 7680 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7681 | } |
| 7682 | |
| 7683 | found = false; |
| 7684 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7685 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7686 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7687 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7688 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7689 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7690 | break; |
| 7691 | } |
| 7692 | } |
| 7693 | |
| 7694 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7695 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7696 | adapter->session.ap.operating_channel); |
| 7697 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7698 | } |
| 7699 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7700 | if (hdd_ctxt->config->vendor_acs_support && |
| 7701 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7702 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7703 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7704 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7705 | } else |
| 7706 | restart_chan = |
| 7707 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7708 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7709 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7710 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7711 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7712 | /* |
| 7713 | * SAP restart due to unsafe channel. While |
| 7714 | * restarting the SAP, make sure to clear |
| 7715 | * acs_channel, channel to reset to |
| 7716 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7717 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7718 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7719 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7720 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7721 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7722 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7723 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7724 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7725 | hdd_debug("driver to start sap: %d", |
| 7726 | hdd_ctxt->config->sap_internal_restart); |
| 7727 | if (hdd_ctxt->config->sap_internal_restart) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7728 | hdd_switch_sap_channel(adapter, restart_chan); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7729 | else |
| 7730 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7731 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7732 | } |
| 7733 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7734 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7735 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7736 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7737 | * @hdd_ctx: HDD global context |
| 7738 | * |
| 7739 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7740 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7741 | * down to the lower layers. Then subscribe to subsequent channel |
| 7742 | * avoidance events. |
| 7743 | * |
| 7744 | * Return: None |
| 7745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7746 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7747 | { |
| 7748 | uint16_t unsafe_channel_count; |
| 7749 | int index; |
| 7750 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7751 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7752 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7753 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7754 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7755 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7756 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7757 | hdd_ctx->unsafe_channel_count); |
| 7758 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7759 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7760 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7761 | |
| 7762 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7763 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7764 | hdd_ctx->unsafe_channel_list[index]); |
| 7765 | |
| 7766 | } |
| 7767 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7768 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7769 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7770 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7771 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7772 | { |
| 7773 | uint8_t restart_chan; |
| 7774 | |
| 7775 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7776 | if (!restart_chan) { |
| 7777 | hdd_alert("fail to restart SAP"); |
| 7778 | return; |
| 7779 | } |
| 7780 | |
| 7781 | /* SAP restart due to unsafe channel. While restarting |
| 7782 | * the SAP, make sure to clear acs_channel, channel to |
| 7783 | * reset to 0. Otherwise these settings will override |
| 7784 | * the ACS while restart. |
| 7785 | */ |
| 7786 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7787 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7788 | |
| 7789 | hdd_debug("sending coex indication"); |
| 7790 | |
| 7791 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7792 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7793 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7794 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7795 | |
| 7796 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7797 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7798 | { |
| 7799 | uint32_t size; |
| 7800 | uint16_t *unsafe_list; |
| 7801 | uint16_t chan_count; |
| 7802 | |
| 7803 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7804 | return -EINVAL; |
| 7805 | |
| 7806 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7807 | NUM_CHANNELS); |
| 7808 | if (chan_count) { |
| 7809 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7810 | unsafe_list = qdf_mem_malloc(size); |
| 7811 | if (!unsafe_list) { |
| 7812 | hdd_err("No memory for unsafe chan list size%d", |
| 7813 | size); |
| 7814 | return -ENOMEM; |
| 7815 | } |
| 7816 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7817 | } else { |
| 7818 | unsafe_list = NULL; |
| 7819 | } |
| 7820 | |
| 7821 | *local_unsafe_list = unsafe_list; |
| 7822 | *local_unsafe_list_count = chan_count; |
| 7823 | |
| 7824 | return 0; |
| 7825 | } |
| 7826 | |
| 7827 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7828 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7829 | { |
| 7830 | int i, j; |
| 7831 | |
| 7832 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7833 | return true; |
| 7834 | if (local_unsafe_list_count == 0) |
| 7835 | return false; |
| 7836 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7837 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7838 | if (local_unsafe_list[i] == |
| 7839 | hdd_ctx->unsafe_channel_list[j]) |
| 7840 | break; |
| 7841 | if (j >= local_unsafe_list_count) |
| 7842 | break; |
| 7843 | } |
| 7844 | if (i >= local_unsafe_list_count) { |
| 7845 | hdd_info("unsafe chan list same"); |
| 7846 | return false; |
| 7847 | } |
| 7848 | |
| 7849 | return true; |
| 7850 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7851 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7852 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7853 | { |
| 7854 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7855 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7856 | 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] | 7857 | { |
| 7858 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7859 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7860 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7861 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7862 | { |
| 7863 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7864 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7865 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7866 | |
| 7867 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7868 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7869 | * user space |
| 7870 | * @frame_ind: Management frame data to be informed. |
| 7871 | * |
| 7872 | * This function is used to indicate management frame to |
| 7873 | * user space |
| 7874 | * |
| 7875 | * Return: None |
| 7876 | * |
| 7877 | */ |
| 7878 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7879 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7880 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7881 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7882 | int i; |
| 7883 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7884 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7885 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7886 | |
| 7887 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7888 | return; |
| 7889 | |
| 7890 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7891 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7892 | adapter = |
| 7893 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7894 | if (adapter) |
| 7895 | break; |
| 7896 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 7897 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 7898 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7899 | if ((NULL != adapter) && |
| 7900 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 7901 | __hdd_indicate_mgmt_frame(adapter, |
| 7902 | frame_ind->frame_len, |
| 7903 | frame_ind->frameBuf, |
| 7904 | frame_ind->frameType, |
| 7905 | frame_ind->rxChan, |
| 7906 | frame_ind->rxRssi); |
| 7907 | } |
| 7908 | } |
| 7909 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7910 | } else { |
| 7911 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7912 | frame_ind->sessionId); |
| 7913 | } |
| 7914 | |
| 7915 | if ((NULL != adapter) && |
| 7916 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7917 | __hdd_indicate_mgmt_frame(adapter, |
| 7918 | frame_ind->frame_len, |
| 7919 | frame_ind->frameBuf, |
| 7920 | frame_ind->frameType, |
| 7921 | frame_ind->rxChan, |
| 7922 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7923 | } |
| 7924 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7925 | void hdd_acs_response_timeout_handler(void *context) |
| 7926 | { |
| 7927 | struct hdd_external_acs_timer_context *timer_context = |
| 7928 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7929 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7930 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7931 | uint8_t reason; |
| 7932 | |
| 7933 | ENTER(); |
| 7934 | if (!timer_context) { |
| 7935 | hdd_err("invlaid timer context"); |
| 7936 | return; |
| 7937 | } |
| 7938 | adapter = timer_context->adapter; |
| 7939 | reason = timer_context->reason; |
| 7940 | |
| 7941 | |
| 7942 | if ((!adapter) || |
| 7943 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7944 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7945 | return; |
| 7946 | } |
| 7947 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7948 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7949 | return; |
| 7950 | |
| 7951 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7952 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7953 | else |
| 7954 | return; |
| 7955 | |
| 7956 | hdd_err("ACS timeout happened for %s reason %d", |
| 7957 | adapter->dev->name, reason); |
| 7958 | switch (reason) { |
| 7959 | /* SAP init case */ |
| 7960 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7961 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7962 | false); |
| 7963 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7964 | break; |
| 7965 | /* DFS detected on current channel */ |
| 7966 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7967 | wlan_sap_update_next_channel( |
| 7968 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7969 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7970 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7971 | break; |
| 7972 | /* LTE coex event on current channel */ |
| 7973 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7974 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7975 | break; |
| 7976 | default: |
| 7977 | hdd_info("invalid reason for timer invoke"); |
| 7978 | |
| 7979 | } |
| 7980 | } |
| 7981 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7982 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7983 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7984 | * @hdd_ctx: HDD context |
| 7985 | * |
| 7986 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7987 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7988 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7989 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7990 | static QDF_STATUS wlan_hdd_disable_all_dual_mac_features(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7991 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7992 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7993 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7994 | |
| 7995 | if (!hdd_ctx) { |
| 7996 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7997 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7998 | } |
| 7999 | |
| 8000 | cfg.scan_config = 0; |
| 8001 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8002 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8003 | |
| 8004 | hdd_debug("Disabling all dual mac features..."); |
| 8005 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8006 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8007 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8008 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 8009 | return status; |
| 8010 | } |
| 8011 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8012 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8013 | } |
| 8014 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 8015 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8016 | wlan_hdd_update_dbs_scan_and_fw_mode_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 8017 | { |
| 8018 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 8019 | QDF_STATUS status; |
| 8020 | |
| 8021 | if (!hdd_ctx) { |
| 8022 | hdd_err("HDD context is NULL"); |
| 8023 | return QDF_STATUS_E_FAILURE; |
| 8024 | } |
| 8025 | |
| 8026 | cfg.scan_config = 0; |
| 8027 | cfg.fw_mode_config = 0; |
| 8028 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 8029 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 8030 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 8031 | &cfg.fw_mode_config, |
| 8032 | hdd_ctx->config->dual_mac_feature_disable); |
| 8033 | |
| 8034 | if (status != QDF_STATUS_SUCCESS) { |
| 8035 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 8036 | status); |
| 8037 | return status; |
| 8038 | } |
| 8039 | |
| 8040 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 8041 | cfg.scan_config, cfg.fw_mode_config); |
| 8042 | |
| 8043 | status = sme_soc_set_dual_mac_config(cfg); |
| 8044 | if (status != QDF_STATUS_SUCCESS) { |
| 8045 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 8046 | return status; |
| 8047 | } |
| 8048 | |
| 8049 | return QDF_STATUS_SUCCESS; |
| 8050 | } |
| 8051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8052 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8053 | * hdd_override_ini_config - Override INI config |
| 8054 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8055 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8056 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8057 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8058 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8059 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8060 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8061 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8062 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8063 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8064 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8065 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8066 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8067 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8068 | if (0 == enable_11d || 1 == enable_11d) { |
| 8069 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8070 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8071 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8072 | |
| 8073 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 8074 | hdd_ctx->config->IpaConfig = 0; |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8075 | |
| 8076 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8077 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8078 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8079 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8080 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8081 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8082 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8083 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8084 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8085 | /** |
| 8086 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8087 | * @hdd_ctx - HDD context |
| 8088 | * |
| 8089 | * Set trace level for each module based on INI config. |
| 8090 | * |
| 8091 | * Return: None |
| 8092 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8093 | 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] | 8094 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8095 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8096 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8097 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8098 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8099 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8100 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8101 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8102 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8103 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8104 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8105 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8106 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8107 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8108 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8109 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8110 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8111 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8112 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8113 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8114 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8115 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8116 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8117 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8118 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8119 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8120 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8121 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8122 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8123 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8124 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8125 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8126 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8127 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8128 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8129 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8130 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8131 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8132 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8133 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8134 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8135 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8136 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8137 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8138 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 8139 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8140 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8141 | } |
| 8142 | |
| 8143 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8144 | * hdd_context_init() - Initialize HDD context |
| 8145 | * @hdd_ctx: HDD context. |
| 8146 | * |
| 8147 | * Initialize HDD context along with all the feature specific contexts. |
| 8148 | * |
| 8149 | * return: 0 on success and errno on failure. |
| 8150 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8151 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8152 | { |
| 8153 | int ret; |
| 8154 | |
| 8155 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8156 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8157 | |
| 8158 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8159 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8160 | |
| 8161 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8162 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8163 | |
| 8164 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8165 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8166 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8167 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8168 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8169 | |
| 8170 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8171 | |
| 8172 | ret = hdd_scan_context_init(hdd_ctx); |
| 8173 | if (ret) |
| 8174 | goto list_destroy; |
| 8175 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8176 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8177 | |
| 8178 | ret = hdd_sap_context_init(hdd_ctx); |
| 8179 | if (ret) |
| 8180 | goto scan_destroy; |
| 8181 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8182 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8183 | |
| 8184 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8185 | |
| 8186 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8187 | hdd_ctx->config); |
| 8188 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8189 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8190 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8191 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8192 | "monitor_mode_wakelock"); |
| 8193 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8194 | return 0; |
| 8195 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8196 | sap_destroy: |
| 8197 | hdd_sap_context_destroy(hdd_ctx); |
| 8198 | |
| 8199 | scan_destroy: |
| 8200 | hdd_scan_context_destroy(hdd_ctx); |
| 8201 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8202 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8203 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8204 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8205 | return ret; |
| 8206 | } |
| 8207 | |
| 8208 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8209 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8210 | * @hdd_ctx: pointer to hdd context |
| 8211 | * |
| 8212 | * Return: status of initialization |
| 8213 | * 0 - success |
| 8214 | * negative value - failure |
| 8215 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8216 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8217 | { |
| 8218 | int ret; |
| 8219 | |
| 8220 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8221 | return 0; |
| 8222 | |
| 8223 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8224 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8225 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8226 | return -EINVAL; |
| 8227 | } |
| 8228 | |
| 8229 | /* parse ini string probe req oui */ |
| 8230 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8231 | if (ret) { |
| 8232 | hdd_err("parsing error: disable ie whitelisting"); |
| 8233 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8234 | } |
| 8235 | |
| 8236 | return ret; |
| 8237 | } |
| 8238 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8239 | |
| 8240 | /** |
| 8241 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8242 | * @priv: pointer to hdd context |
| 8243 | * |
| 8244 | * This function is invoked when the timer waiting for the interface change |
| 8245 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8246 | * |
| 8247 | * Return: void |
| 8248 | */ |
| 8249 | static void hdd_iface_change_callback(void *priv) |
| 8250 | { |
| 8251 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8252 | int ret; |
| 8253 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8254 | |
| 8255 | if (status) |
| 8256 | return; |
| 8257 | |
| 8258 | ENTER(); |
| 8259 | hdd_debug("Interface change timer expired close the modules!"); |
| 8260 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8261 | if (ret) |
| 8262 | hdd_err("Failed to stop modules"); |
| 8263 | EXIT(); |
| 8264 | } |
| 8265 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8266 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8267 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8268 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8269 | * |
| 8270 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8271 | * wiphy allocation and then context is initialized. |
| 8272 | * |
| 8273 | * Return: HDD context on success and ERR_PTR on failure |
| 8274 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8275 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8276 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8277 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8278 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8279 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8280 | |
| 8281 | ENTER(); |
| 8282 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8283 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8284 | if (hdd_ctx == NULL) { |
| 8285 | ret = -ENOMEM; |
| 8286 | goto err_out; |
| 8287 | } |
| 8288 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8289 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8290 | hdd_iface_change_callback, |
| 8291 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8292 | |
| 8293 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8294 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8295 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8296 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8297 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8298 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8299 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8300 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8301 | ret = -ENOMEM; |
| 8302 | goto err_free_hdd_context; |
| 8303 | } |
| 8304 | |
| 8305 | /* Read and parse the qcom_cfg.ini file */ |
| 8306 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8307 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8308 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8309 | WLAN_INI_FILE); |
| 8310 | ret = -EINVAL; |
| 8311 | goto err_free_config; |
| 8312 | } |
| 8313 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8314 | ie_whitelist_attrs_init(hdd_ctx); |
| 8315 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8316 | hdd_debug("setting timer multiplier: %u", |
| 8317 | hdd_ctx->config->timer_multiplier); |
| 8318 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8319 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8320 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8321 | if (hdd_ctx->config->fhostNSOffload) |
| 8322 | hdd_ctx->ns_offload_enable = true; |
| 8323 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8324 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8325 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8326 | hdd_override_ini_config(hdd_ctx); |
| 8327 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8328 | ret = hdd_context_init(hdd_ctx); |
| 8329 | |
| 8330 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8331 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8332 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8333 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8334 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8335 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8336 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8337 | goto skip_multicast_logging; |
| 8338 | |
| 8339 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8340 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8341 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8342 | if (ret) |
| 8343 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8344 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8345 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8346 | if (ret) |
| 8347 | goto err_deinit_txrx_histogram; |
| 8348 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 8349 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 8350 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8351 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8352 | skip_multicast_logging: |
| 8353 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8354 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8355 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8356 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8357 | EXIT(); |
| 8358 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8359 | return hdd_ctx; |
| 8360 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8361 | err_deinit_txrx_histogram: |
| 8362 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8363 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8364 | err_deinit_hdd_context: |
| 8365 | hdd_context_deinit(hdd_ctx); |
| 8366 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8367 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8368 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8369 | |
| 8370 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8371 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8372 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8373 | |
| 8374 | err_out: |
| 8375 | return ERR_PTR(ret); |
| 8376 | } |
| 8377 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8378 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8379 | /** |
| 8380 | * hdd_open_p2p_interface - Open P2P interface |
| 8381 | * @hdd_ctx: HDD context |
| 8382 | * @rtnl_held: True if RTNL lock held |
| 8383 | * |
| 8384 | * Open P2P interface during probe. This function called to open the P2P |
| 8385 | * interface at probe along with STA interface. |
| 8386 | * |
| 8387 | * Return: 0 on success and errno on failure |
| 8388 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8389 | 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] | 8390 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8391 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8392 | uint8_t *p2p_dev_addr; |
| 8393 | |
| 8394 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8395 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8396 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8397 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8398 | sizeof(tSirMacAddr)); |
| 8399 | |
| 8400 | /* |
| 8401 | * Generate the P2P Device Address. This consists of |
| 8402 | * the device's primary MAC address with the locally |
| 8403 | * administered bit set. |
| 8404 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8405 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8406 | } else { |
| 8407 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8408 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8409 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8410 | return -ENOSPC; |
| 8411 | } |
| 8412 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8413 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8414 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8415 | } |
| 8416 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8417 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8418 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8419 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8420 | |
| 8421 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8422 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8423 | return -ENOSPC; |
| 8424 | } |
| 8425 | |
| 8426 | return 0; |
| 8427 | } |
| 8428 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8429 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8430 | bool rtnl_held) |
| 8431 | { |
| 8432 | return 0; |
| 8433 | } |
| 8434 | #endif |
| 8435 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8436 | 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] | 8437 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8438 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8439 | int ret = 0; |
| 8440 | |
| 8441 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8442 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8443 | NET_NAME_UNKNOWN, rtnl_held); |
| 8444 | if (adapter == NULL) { |
| 8445 | hdd_err("Failed to open 802.11p interface"); |
| 8446 | ret = -ENOSPC; |
| 8447 | } |
| 8448 | |
| 8449 | return ret; |
| 8450 | } |
| 8451 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8452 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8453 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8454 | * @adapter: HDD adapter |
| 8455 | * |
| 8456 | * This function initializes the adapter for the station mode. |
| 8457 | * |
| 8458 | * Return: 0 on success or errno on failure. |
| 8459 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8460 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8461 | { |
| 8462 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8463 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8464 | |
| 8465 | ENTER_DEV(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8466 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8467 | hdd_err("session is already opened, %d", |
| 8468 | adapter->session_id); |
| 8469 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8470 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8471 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8472 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8473 | if (ret) { |
| 8474 | hdd_err("failed to create vdev: %d", ret); |
| 8475 | return ret; |
| 8476 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8477 | status = hdd_init_station_mode(adapter); |
| 8478 | |
| 8479 | if (QDF_STATUS_SUCCESS != status) { |
| 8480 | hdd_err("Error Initializing station mode: %d", status); |
| 8481 | return qdf_status_to_os_return(status); |
| 8482 | } |
| 8483 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8484 | hdd_register_tx_flow_control(adapter, |
| 8485 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8486 | hdd_tx_resume_cb, |
| 8487 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8488 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8489 | EXIT(); |
| 8490 | return 0; |
| 8491 | } |
| 8492 | |
| 8493 | /** |
| 8494 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8495 | * @adapter: HDD adapter |
| 8496 | * |
| 8497 | * This function initializes the adapter for the AP mode. |
| 8498 | * |
| 8499 | * Return: 0 on success errno on failure. |
| 8500 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8501 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8502 | { |
| 8503 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8504 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8505 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8506 | |
| 8507 | ENTER(); |
| 8508 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8509 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8510 | hdd_err("session is already opened, %d", |
| 8511 | adapter->session_id); |
| 8512 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8513 | } |
| 8514 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8515 | * In SSR case no need to create new sap context. |
| 8516 | * Otherwise create sap context first and then create |
| 8517 | * vdev as while creating the vdev, driver needs to |
| 8518 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8519 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8520 | if (adapter->session.ap.sap_context) { |
| 8521 | is_ssr = true; |
| 8522 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8523 | hdd_err("sap creation failed"); |
| 8524 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8525 | } |
| 8526 | |
| 8527 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8528 | adapter->session.ap.sap_context); |
| 8529 | if (ret) { |
| 8530 | hdd_err("failed to create vdev, status:%d", ret); |
| 8531 | hdd_sap_destroy_ctx(adapter); |
| 8532 | return ret; |
| 8533 | } |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8534 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8535 | |
| 8536 | if (QDF_STATUS_SUCCESS != status) { |
| 8537 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8538 | return qdf_status_to_os_return(status); |
| 8539 | } |
| 8540 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8541 | hdd_register_tx_flow_control(adapter, |
| 8542 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8543 | hdd_softap_tx_resume_cb, |
| 8544 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8545 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8546 | EXIT(); |
| 8547 | return 0; |
| 8548 | } |
| 8549 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8550 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8551 | bool rtnl_held) |
| 8552 | { |
| 8553 | struct hdd_adapter *adapter; |
| 8554 | |
| 8555 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8556 | hdd_ctx->config->enableConcurrentSTA, |
| 8557 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8558 | NET_NAME_UNKNOWN, rtnl_held); |
| 8559 | |
| 8560 | if (!adapter) |
| 8561 | return -ENOSPC; |
| 8562 | |
| 8563 | return 0; |
| 8564 | } |
| 8565 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8566 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8567 | * hdd_open_interfaces - Open all required interfaces |
| 8568 | * hdd_ctx: HDD context |
| 8569 | * rtnl_held: True if RTNL lock is held |
| 8570 | * |
| 8571 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8572 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8573 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8574 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8575 | 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] | 8576 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8577 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8578 | int ret; |
| 8579 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8580 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8581 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8582 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8583 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8584 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8585 | |
| 8586 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8587 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8588 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8589 | if (!adapter) { |
| 8590 | hdd_err("open adapter failed"); |
| 8591 | return -ENOSPC; |
| 8592 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8593 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8594 | return 0; |
| 8595 | } |
| 8596 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8597 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8598 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8599 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8600 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8601 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8602 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8603 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8604 | |
| 8605 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8606 | return -ENOSPC; |
| 8607 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8608 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8609 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8610 | if (ret) |
| 8611 | hdd_err("Cannot create concurrent STA interface"); |
| 8612 | } |
| 8613 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8614 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8615 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8616 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8617 | |
| 8618 | /* Open 802.11p Interface */ |
| 8619 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8620 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8621 | if (ret) |
| 8622 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8623 | } |
| 8624 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8625 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8626 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8627 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8628 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8629 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8630 | } |
| 8631 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8632 | /** |
| 8633 | * hdd_update_country_code - Update country code |
| 8634 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8635 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8636 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8637 | * |
| 8638 | * Return: 0 on success and errno on failure |
| 8639 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8640 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8641 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8642 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8643 | return 0; |
| 8644 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8645 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8646 | } |
| 8647 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8648 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8649 | /** |
| 8650 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8651 | * @cds_cfg: CDS Configuration |
| 8652 | * @hdd_ctx: Pointer to hdd context |
| 8653 | * |
| 8654 | * Return: none |
| 8655 | */ |
| 8656 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8657 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8658 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8659 | { |
| 8660 | cds_cfg->tx_flow_stop_queue_th = |
| 8661 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8662 | cds_cfg->tx_flow_start_queue_offset = |
| 8663 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8664 | } |
| 8665 | #else |
| 8666 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8667 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8668 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8669 | { |
| 8670 | } |
| 8671 | #endif |
| 8672 | |
| 8673 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8674 | /** |
| 8675 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8676 | * @cds_cfg: CDS Configuration |
| 8677 | * @hdd_ctx: Pointer to hdd context |
| 8678 | * |
| 8679 | * Return: none |
| 8680 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8681 | 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] | 8682 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8683 | { |
| 8684 | cds_cfg->ra_ratelimit_interval = |
| 8685 | hdd_ctx->config->RArateLimitInterval; |
| 8686 | cds_cfg->is_ra_ratelimit_enabled = |
| 8687 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8688 | } |
| 8689 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8690 | 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] | 8691 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8692 | { |
| 8693 | } |
| 8694 | #endif |
| 8695 | |
| 8696 | /** |
| 8697 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8698 | * @hdd_ctx: HDD Context |
| 8699 | * |
| 8700 | * Return: 0 for Success, errno on failure |
| 8701 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8702 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8703 | { |
| 8704 | struct cds_config_info *cds_cfg; |
| 8705 | |
| 8706 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8707 | if (!cds_cfg) { |
| 8708 | hdd_err("failed to allocate cds config"); |
| 8709 | return -ENOMEM; |
| 8710 | } |
| 8711 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8712 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8713 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8714 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8715 | cds_cfg->powersave_offload_enabled = |
| 8716 | hdd_ctx->config->enablePowersaveOffload; |
| 8717 | } else { |
| 8718 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8719 | PS_QPOWER_NODEEPSLEEP) || |
| 8720 | (hdd_ctx->config->enablePowersaveOffload == |
| 8721 | PS_LEGACY_NODEEPSLEEP)) |
| 8722 | cds_cfg->powersave_offload_enabled = |
| 8723 | PS_LEGACY_NODEEPSLEEP; |
| 8724 | else |
| 8725 | cds_cfg->powersave_offload_enabled = |
| 8726 | PS_LEGACY_DEEPSLEEP; |
| 8727 | hdd_info("Qpower disabled in cds config, %d", |
| 8728 | cds_cfg->powersave_offload_enabled); |
| 8729 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8730 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8731 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8732 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8733 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8734 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8735 | |
| 8736 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8737 | * ns offload and others. Currently 1st bit is used for arp |
| 8738 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8739 | */ |
| 8740 | if (hdd_ctx->config->fhostArpOffload) |
| 8741 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8742 | if (hdd_ctx->config->fhostNSOffload) |
| 8743 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8744 | |
| 8745 | /* |
| 8746 | * Copy the DFS Phyerr Filtering Offload status. |
| 8747 | * This parameter reflects the value of the |
| 8748 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8749 | */ |
| 8750 | cds_cfg->dfs_phyerr_filter_offload = |
| 8751 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8752 | if (hdd_ctx->config->ssdp) |
| 8753 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8754 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8755 | cds_cfg->force_target_assert_enabled = |
| 8756 | hdd_ctx->config->crash_inject_enabled; |
| 8757 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8758 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8759 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8760 | |
| 8761 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8762 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8763 | |
| 8764 | cds_cfg->ap_disable_intrabss_fwd = |
| 8765 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8766 | |
| 8767 | cds_cfg->dfs_pri_multiplier = |
| 8768 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8769 | cds_cfg->reorder_offload = |
| 8770 | hdd_ctx->config->reorderOffloadSupport; |
| 8771 | |
| 8772 | /* IPA micro controller data path offload resource config item */ |
| 8773 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8774 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8775 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8776 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8777 | hdd_ctx->config->IpaUcTxBufCount); |
| 8778 | hdd_ctx->config->IpaUcTxBufCount = |
| 8779 | rounddown_pow_of_two( |
| 8780 | hdd_ctx->config->IpaUcTxBufCount); |
| 8781 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8782 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8783 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8784 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8785 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8786 | hdd_ctx->config->IpaUcTxBufCount); |
| 8787 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8788 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8789 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8790 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8791 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8792 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8793 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8794 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8795 | rounddown_pow_of_two( |
| 8796 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8797 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8798 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8799 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8800 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8801 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8802 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8803 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8804 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8805 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8806 | cds_cfg->uc_tx_partition_base = |
| 8807 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8808 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8809 | |
| 8810 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8811 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8812 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8813 | cds_cfg->ce_classify_enabled = |
| 8814 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8815 | cds_cfg->bpf_packet_filter_enable = |
| 8816 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8817 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8818 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8819 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8820 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8821 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8822 | cds_cfg->max_msdus_per_rxinorderind = |
| 8823 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8824 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8825 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8826 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8827 | 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] | 8828 | cds_cfg->auto_power_save_fail_mode = |
| 8829 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8830 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8831 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8832 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8833 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8834 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8835 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8836 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8837 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8838 | cds_init_ini_config(cds_cfg); |
| 8839 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8840 | |
| 8841 | exit: |
| 8842 | qdf_mem_free(cds_cfg); |
| 8843 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8844 | } |
| 8845 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8846 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8847 | * hdd_update_user_config() - API to update user configuration |
| 8848 | * parameters to obj mgr which are used by multiple components |
| 8849 | * @hdd_ctx: HDD Context |
| 8850 | * |
| 8851 | * Return: 0 for Success, errno on failure |
| 8852 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8853 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8854 | { |
| 8855 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8856 | |
| 8857 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8858 | if (user_config == NULL) { |
| 8859 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8860 | return -ENOMEM; |
| 8861 | } |
| 8862 | |
| 8863 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8864 | user_config->dual_mac_feature_disable = |
| 8865 | hdd_ctx->config->dual_mac_feature_disable; |
| 8866 | user_config->indoor_channel_support = |
| 8867 | hdd_ctx->config->indoor_channel_support; |
| 8868 | user_config->is_11d_support_enabled = |
| 8869 | hdd_ctx->config->Is11dSupportEnabled; |
| 8870 | user_config->is_11h_support_enabled = |
| 8871 | hdd_ctx->config->Is11hSupportEnabled; |
| 8872 | user_config->optimize_chan_avoid_event = |
| 8873 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8874 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8875 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8876 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8877 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8878 | |
| 8879 | qdf_mem_free(user_config); |
| 8880 | return 0; |
| 8881 | } |
| 8882 | |
| 8883 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8884 | * hdd_init_thermal_info - Initialize thermal level |
| 8885 | * @hdd_ctx: HDD context |
| 8886 | * |
| 8887 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8888 | * which would be called when a configured thermal threshold is hit. |
| 8889 | * |
| 8890 | * Return: 0 on success and errno on failure |
| 8891 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8892 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8893 | { |
| 8894 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8895 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8896 | |
| 8897 | thermal_param.smeThermalMgmtEnabled = |
| 8898 | hdd_ctx->config->thermalMitigationEnable; |
| 8899 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8900 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8901 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8902 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8903 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8904 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8905 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8906 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8907 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8908 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8909 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8910 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8911 | hdd_ctx->config->thermalTempMinLevel0; |
| 8912 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8913 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8914 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8915 | hdd_ctx->config->thermalTempMinLevel1; |
| 8916 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8917 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8918 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8919 | hdd_ctx->config->thermalTempMinLevel2; |
| 8920 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8921 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8922 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8923 | hdd_ctx->config->thermalTempMinLevel3; |
| 8924 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8925 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8926 | |
| 8927 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8928 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8929 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8930 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8931 | |
| 8932 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8933 | hdd_set_thermal_level_cb); |
| 8934 | |
| 8935 | return 0; |
| 8936 | |
| 8937 | } |
| 8938 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8939 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8940 | /** |
| 8941 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8942 | * |
| 8943 | * Hold RTNL lock |
| 8944 | * |
| 8945 | * Return: True if held and false otherwise |
| 8946 | */ |
| 8947 | static inline bool hdd_hold_rtnl_lock(void) |
| 8948 | { |
| 8949 | rtnl_lock(); |
| 8950 | return true; |
| 8951 | } |
| 8952 | |
| 8953 | /** |
| 8954 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8955 | * |
| 8956 | * Release RTNL lock |
| 8957 | * |
| 8958 | * Return: None |
| 8959 | */ |
| 8960 | static inline void hdd_release_rtnl_lock(void) |
| 8961 | { |
| 8962 | rtnl_unlock(); |
| 8963 | } |
| 8964 | #else |
| 8965 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8966 | static inline void hdd_release_rtnl_lock(void) { } |
| 8967 | #endif |
| 8968 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8969 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8970 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8971 | /* MAX iwpriv command support */ |
| 8972 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8973 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8974 | #define MAX_PKTLOG_SIZE 16 |
| 8975 | |
| 8976 | /** |
| 8977 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8978 | * @hdd_ctx: hdd context |
| 8979 | * @set_value2: pktlog buffer size value |
| 8980 | * |
| 8981 | * |
| 8982 | * Return: 0 for success or error. |
| 8983 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8984 | 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] | 8985 | { |
| 8986 | struct sir_wifi_start_log start_log = { 0 }; |
| 8987 | QDF_STATUS status; |
| 8988 | |
| 8989 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8990 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8991 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8992 | start_log.user_triggered = 1; |
| 8993 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8994 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8995 | |
| 8996 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8997 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8998 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8999 | EXIT(); |
| 9000 | return -EINVAL; |
| 9001 | } |
| 9002 | |
| 9003 | return 0; |
| 9004 | } |
| 9005 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9006 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9007 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9008 | * @hdd_ctx: hdd context |
| 9009 | * |
| 9010 | * Return: 0 for success or error. |
| 9011 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9012 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9013 | { |
| 9014 | struct sir_wifi_start_log start_log; |
| 9015 | QDF_STATUS status; |
| 9016 | |
| 9017 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9018 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9019 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9020 | start_log.user_triggered = 1; |
| 9021 | start_log.size = 0; |
| 9022 | start_log.is_pktlog_buff_clear = true; |
| 9023 | |
| 9024 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9025 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9026 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 9027 | EXIT(); |
| 9028 | return -EINVAL; |
| 9029 | } |
| 9030 | |
| 9031 | return 0; |
| 9032 | } |
| 9033 | |
| 9034 | |
| 9035 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9036 | * hdd_process_pktlog_command() - process pktlog command |
| 9037 | * @hdd_ctx: hdd context |
| 9038 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9039 | * @set_value2: pktlog buffer size value |
| 9040 | * |
| 9041 | * This function process pktlog command. |
| 9042 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9043 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9044 | * |
| 9045 | * Return: 0 for success or error. |
| 9046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9047 | 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] | 9048 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9049 | { |
| 9050 | int ret; |
| 9051 | bool enable; |
| 9052 | uint8_t user_triggered = 0; |
| 9053 | |
| 9054 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9055 | if (0 != ret) |
| 9056 | return ret; |
| 9057 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9058 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9059 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9060 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9061 | hdd_err("invalid pktlog value %d", set_value); |
| 9062 | return -EINVAL; |
| 9063 | } |
| 9064 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9065 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9066 | if (set_value2 <= 0) { |
| 9067 | hdd_err("invalid pktlog size %d", set_value2); |
| 9068 | return -EINVAL; |
| 9069 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9070 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9071 | return -EINVAL; |
| 9072 | } |
| 9073 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9074 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9075 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9076 | } |
| 9077 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9078 | /* |
| 9079 | * set_value = 0 then disable packetlog |
| 9080 | * set_value = 1 enable packetlog forcefully |
| 9081 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9082 | * enable packetlog with AUTO type. |
| 9083 | */ |
| 9084 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9085 | true : false; |
| 9086 | |
| 9087 | if (1 == set_value) { |
| 9088 | enable = true; |
| 9089 | user_triggered = 1; |
| 9090 | } |
| 9091 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9092 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9093 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9094 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9095 | /** |
| 9096 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9097 | * @hdd_ctx: HDD context |
| 9098 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9099 | * @user_triggered: triggered through iwpriv |
| 9100 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9101 | * |
| 9102 | * Return: 0 on success; error number otherwise |
| 9103 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9104 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9105 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9106 | { |
| 9107 | struct sir_wifi_start_log start_log; |
| 9108 | QDF_STATUS status; |
| 9109 | |
| 9110 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9111 | start_log.verbose_level = |
| 9112 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9113 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9114 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9115 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9116 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9117 | /* |
| 9118 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9119 | * commands. Host uses this flag to decide whether to send pktlog |
| 9120 | * disable command to fw without sending pktlog enable command |
| 9121 | * previously. For eg, If vendor sends pktlog disable command without |
| 9122 | * sending pktlog enable command, then host discards the packet |
| 9123 | * but for iwpriv command, host will send it to fw. |
| 9124 | */ |
| 9125 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9126 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9127 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9128 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 9129 | EXIT(); |
| 9130 | return -EINVAL; |
| 9131 | } |
| 9132 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9133 | if (enable == true) |
| 9134 | hdd_ctx->is_pktlog_enabled = 1; |
| 9135 | else |
| 9136 | hdd_ctx->is_pktlog_enabled = 0; |
| 9137 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9138 | return 0; |
| 9139 | } |
| 9140 | #endif /* REMOVE_PKT_LOG */ |
| 9141 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9142 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9143 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9144 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9145 | * @dev: Device Pointer |
| 9146 | * @num: Number of Valid Mac address |
| 9147 | * |
| 9148 | * Return: Pointer to MAC address buffer |
| 9149 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9150 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9151 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9152 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9153 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9154 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9155 | |
| 9156 | /** |
| 9157 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9158 | * @hdd_ctx: HDD Context |
| 9159 | * @num: Number of random mac addresses needed |
| 9160 | * |
| 9161 | * Generate random addresses using bit manipulation on the base mac address |
| 9162 | * |
| 9163 | * Return: None |
| 9164 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9165 | 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] | 9166 | { |
| 9167 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9168 | uint32_t iter; |
| 9169 | struct hdd_config *ini = hdd_ctx->config; |
| 9170 | uint8_t *buf = NULL; |
| 9171 | uint8_t macaddr_b3, tmp_br3; |
| 9172 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9173 | |
| 9174 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9175 | buf = ini->intfMacAddr[iter].bytes; |
| 9176 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9177 | macaddr_b3 = buf[3]; |
| 9178 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9179 | INTF_MACADDR_MASK; |
| 9180 | macaddr_b3 += tmp_br3; |
| 9181 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9182 | buf[0] |= 0x02; |
| 9183 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9184 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9185 | } |
| 9186 | } |
| 9187 | |
| 9188 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9189 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9190 | * @hdd_ctx: HDD Context |
| 9191 | * |
| 9192 | * API to get mac addresses from platform driver and update the driver |
| 9193 | * structures and configure FW with the base mac address. |
| 9194 | * Return: int |
| 9195 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9196 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9197 | { |
| 9198 | uint32_t no_of_mac_addr, iter; |
| 9199 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9200 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9201 | uint8_t *addr, *buf; |
| 9202 | struct device *dev = hdd_ctx->parent_dev; |
| 9203 | struct hdd_config *ini = hdd_ctx->config; |
| 9204 | tSirMacAddr mac_addr; |
| 9205 | QDF_STATUS status; |
| 9206 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9207 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9208 | |
| 9209 | if (no_of_mac_addr == 0 || !addr) { |
| 9210 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9211 | return -EINVAL; |
| 9212 | } |
| 9213 | |
| 9214 | if (no_of_mac_addr > max_mac_addr) |
| 9215 | no_of_mac_addr = max_mac_addr; |
| 9216 | |
| 9217 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9218 | |
| 9219 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9220 | buf = ini->intfMacAddr[iter].bytes; |
| 9221 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9222 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9223 | } |
| 9224 | |
| 9225 | status = sme_set_custom_mac_addr(mac_addr); |
| 9226 | |
| 9227 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9228 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9229 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9230 | if (no_of_mac_addr < max_mac_addr) |
| 9231 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9232 | no_of_mac_addr); |
| 9233 | return 0; |
| 9234 | } |
| 9235 | |
| 9236 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9237 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9238 | * @hdd_ctx: HDD Context |
| 9239 | * |
| 9240 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9241 | * will generate its own MAC and update it to FW. |
| 9242 | * |
| 9243 | * Return: 0 for success |
| 9244 | * Non-zero error code for failure |
| 9245 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9246 | 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] | 9247 | { |
| 9248 | tSirMacAddr customMacAddr; |
| 9249 | QDF_STATUS status; |
| 9250 | |
| 9251 | qdf_mem_copy(&customMacAddr, |
| 9252 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9253 | sizeof(tSirMacAddr)); |
| 9254 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9255 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9256 | return -EAGAIN; |
| 9257 | return 0; |
| 9258 | } |
| 9259 | |
| 9260 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9261 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9262 | * @hdd_ctx: HDD Context |
| 9263 | * |
| 9264 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9265 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9266 | * wlan_mac.bin to update HW MAC addresses. |
| 9267 | * |
| 9268 | * Return: None |
| 9269 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9270 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9271 | { |
| 9272 | QDF_STATUS status; |
| 9273 | int ret; |
| 9274 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9275 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9276 | if (ret == 0) |
| 9277 | return; |
| 9278 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9279 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9280 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9281 | |
| 9282 | status = hdd_update_mac_config(hdd_ctx); |
| 9283 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9284 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9285 | return; |
| 9286 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9287 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9288 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9289 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9290 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9291 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9292 | if (ret != 0) { |
| 9293 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9294 | QDF_ASSERT(ret); |
| 9295 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9296 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9297 | } |
| 9298 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9299 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9300 | { |
| 9301 | int vdev_id = 0; |
| 9302 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9303 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9304 | int vpdev = PDEV_CMD; |
| 9305 | int ret; |
| 9306 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9307 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9308 | if (ret) |
| 9309 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9310 | |
| 9311 | return ret; |
| 9312 | } |
| 9313 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9314 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9315 | { |
| 9316 | int vdev_id = 0; |
| 9317 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9318 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9319 | int vpdev = PDEV_CMD; |
| 9320 | int ret; |
| 9321 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9322 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9323 | if (ret) |
| 9324 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9325 | ret); |
| 9326 | |
| 9327 | return ret; |
| 9328 | } |
| 9329 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9330 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9331 | { |
| 9332 | int vdev_id = 0; |
| 9333 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9334 | int value = hdd_ctx->config->ani_enabled; |
| 9335 | int vpdev = PDEV_CMD; |
| 9336 | int ret; |
| 9337 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9338 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9339 | if (ret) |
| 9340 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9341 | |
| 9342 | return ret; |
| 9343 | } |
| 9344 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9345 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9346 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9347 | * @hdd_ctx: HDD context |
| 9348 | * |
| 9349 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9350 | * |
| 9351 | * Return: 0 on success and errno on failure. |
| 9352 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9353 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9354 | { |
| 9355 | int ret; |
| 9356 | QDF_STATUS status; |
| 9357 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9358 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9359 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9360 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9361 | /* |
| 9362 | * Set 802.11p config |
| 9363 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9364 | * parameter is set in CSR when we init the channel list. This should |
| 9365 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9366 | * domain. |
| 9367 | */ |
| 9368 | hdd_set_dot11p_config(hdd_ctx); |
| 9369 | |
| 9370 | /* |
| 9371 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9372 | * The cfg download must occur before we update the SME config |
| 9373 | * since the SME config operation must access the cfg database |
| 9374 | */ |
| 9375 | status = hdd_set_sme_config(hdd_ctx); |
| 9376 | |
| 9377 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9378 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9379 | ret = qdf_status_to_os_return(status); |
| 9380 | goto out; |
| 9381 | } |
| 9382 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9383 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9384 | if (QDF_STATUS_SUCCESS != status) { |
| 9385 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9386 | ret = qdf_status_to_os_return(status); |
| 9387 | goto out; |
| 9388 | } |
| 9389 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9390 | 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] | 9391 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9392 | PDEV_CMD); |
| 9393 | if (0 != ret) { |
| 9394 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9395 | goto out; |
| 9396 | } |
| 9397 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9398 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9399 | if (ret) |
| 9400 | goto out; |
| 9401 | |
| 9402 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9403 | if (ret) |
| 9404 | goto out; |
| 9405 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9406 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9407 | if (ret) |
| 9408 | goto out; |
| 9409 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9410 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9411 | hdd_ctx->config->arp_ac_category, |
| 9412 | PDEV_CMD); |
| 9413 | if (0 != ret) { |
| 9414 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9415 | hdd_ctx->config->arp_ac_category, ret); |
| 9416 | goto out; |
| 9417 | } |
| 9418 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9419 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9420 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9421 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9422 | ret = qdf_status_to_os_return(status); |
| 9423 | goto out; |
| 9424 | } |
| 9425 | |
| 9426 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9427 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9428 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9429 | ret = -EINVAL; |
| 9430 | goto out; |
| 9431 | } |
| 9432 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9433 | /* |
| 9434 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9435 | * Remove this once self sta is added as part of session open. |
| 9436 | */ |
| 9437 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9438 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9439 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9440 | |
| 9441 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9442 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9443 | hal_status, hal_status); |
| 9444 | ret = -EINVAL; |
| 9445 | goto out; |
| 9446 | } |
| 9447 | |
| 9448 | hdd_init_channel_avoidance(hdd_ctx); |
| 9449 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9450 | /* update enable sap mandatory chan list */ |
| 9451 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9452 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9453 | out: |
| 9454 | return ret; |
| 9455 | } |
| 9456 | |
| 9457 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9458 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9459 | * @context_ptr - hdd context pointer |
| 9460 | * @event_ptr - event structure pointer |
| 9461 | * |
| 9462 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9463 | * event back to supplicant to notify the stop reason. |
| 9464 | * |
| 9465 | * Return: None |
| 9466 | */ |
| 9467 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9468 | void *event_ptr) |
| 9469 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9470 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9471 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9472 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9473 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9474 | |
| 9475 | ENTER(); |
| 9476 | |
| 9477 | if (hdd_ctx == NULL) { |
| 9478 | hdd_err("Invalid HDD context pointer"); |
| 9479 | return; |
| 9480 | } |
| 9481 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9482 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9483 | if (!adapter) { |
| 9484 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9485 | evt->vdev_id); |
| 9486 | return; |
| 9487 | } |
| 9488 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9489 | vendor_event = |
| 9490 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9491 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9492 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9493 | GFP_KERNEL); |
| 9494 | |
| 9495 | if (!vendor_event) { |
| 9496 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9497 | return; |
| 9498 | } |
| 9499 | |
| 9500 | if (nla_put_u32(vendor_event, |
| 9501 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9502 | evt->reason_code)) { |
| 9503 | hdd_err("nla put failed"); |
| 9504 | kfree_skb(vendor_event); |
| 9505 | return; |
| 9506 | } |
| 9507 | |
| 9508 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9509 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9510 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9511 | } |
| 9512 | |
| 9513 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9514 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9515 | * @hdd_ctx: HDD context |
| 9516 | * |
| 9517 | * This function sends the adaptive dwell time config configuration to the |
| 9518 | * firmware via WMA |
| 9519 | * |
| 9520 | * Return: 0 - success, < 0 - failure |
| 9521 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9522 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9523 | { |
| 9524 | QDF_STATUS status; |
| 9525 | struct adaptive_dwelltime_params dwelltime_params; |
| 9526 | |
| 9527 | dwelltime_params.is_enabled = |
| 9528 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9529 | dwelltime_params.dwelltime_mode = |
| 9530 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9531 | dwelltime_params.lpf_weight = |
| 9532 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9533 | dwelltime_params.passive_mon_intval = |
| 9534 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9535 | dwelltime_params.wifi_act_threshold = |
| 9536 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9537 | |
| 9538 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9539 | &dwelltime_params); |
| 9540 | |
| 9541 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9542 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9543 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9544 | return -EAGAIN; |
| 9545 | } |
| 9546 | return 0; |
| 9547 | } |
| 9548 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9549 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9550 | { |
| 9551 | QDF_STATUS status; |
| 9552 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9553 | uint32_t i = 0; |
| 9554 | uint8_t count = 0, numentries = 0; |
| 9555 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9556 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9557 | |
| 9558 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9559 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9560 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9561 | return -EINVAL; |
| 9562 | |
| 9563 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9564 | dbs_scan_config, &numentries, |
| 9565 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9566 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9567 | |
| 9568 | hdd_info("numentries %hu", numentries); |
| 9569 | if (!numentries) { |
| 9570 | hdd_info("Donot send scan_selection_config"); |
| 9571 | return 0; |
| 9572 | } |
| 9573 | |
| 9574 | /* hdd_set_fw_log_params */ |
| 9575 | dbs_scan_params.num_clients = 0; |
| 9576 | while (count < (numentries - 2)) { |
| 9577 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9578 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9579 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9580 | dbs_scan_config[count + 2]; |
| 9581 | dbs_scan_params.num_clients++; |
| 9582 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9583 | dbs_scan_params.module_id[i], |
| 9584 | dbs_scan_params.num_dbs_scans[i], |
| 9585 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9586 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9587 | i++; |
| 9588 | } |
| 9589 | |
| 9590 | dbs_scan_params.pdev_id = 0; |
| 9591 | |
| 9592 | hdd_debug("clients:%d pdev:%d", |
| 9593 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9594 | |
| 9595 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9596 | &dbs_scan_params); |
| 9597 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9598 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9599 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9600 | return -EAGAIN; |
| 9601 | } |
| 9602 | return 0; |
| 9603 | } |
| 9604 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9605 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9606 | /** |
| 9607 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9608 | * @hdd_ctx: HDD context |
| 9609 | * |
| 9610 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9611 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9612 | * |
| 9613 | * Return: 0 on success and errno on failure. |
| 9614 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9615 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9616 | { |
| 9617 | QDF_STATUS status; |
| 9618 | |
| 9619 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9620 | return 0; |
| 9621 | |
| 9622 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9623 | wlan_hdd_auto_shutdown_cb); |
| 9624 | if (status != QDF_STATUS_SUCCESS) |
| 9625 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9626 | status); |
| 9627 | |
| 9628 | return qdf_status_to_os_return(status); |
| 9629 | } |
| 9630 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9631 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9632 | { |
| 9633 | return 0; |
| 9634 | } |
| 9635 | #endif |
| 9636 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9637 | static QDF_STATUS hdd_set_dbs_scan_and_fw_mode_cfg(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9638 | { |
| 9639 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9640 | |
| 9641 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9642 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9643 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9644 | if (status != QDF_STATUS_SUCCESS) |
| 9645 | hdd_err("Failed to disable dual mac features"); |
| 9646 | break; |
| 9647 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9648 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9649 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9650 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9651 | if (status != QDF_STATUS_SUCCESS) |
| 9652 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9653 | break; |
| 9654 | default: |
| 9655 | break; |
| 9656 | } |
| 9657 | |
| 9658 | return status; |
| 9659 | } |
| 9660 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9661 | /** |
| 9662 | * hdd_features_init() - Init features |
| 9663 | * @hdd_ctx: HDD context |
| 9664 | * @adapter: Primary adapter context |
| 9665 | * |
| 9666 | * Initialize features and their feature context after WLAN firmware is up. |
| 9667 | * |
| 9668 | * Return: 0 on success and errno on failure. |
| 9669 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9670 | 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] | 9671 | { |
| 9672 | tSirTxPowerLimit hddtxlimit; |
| 9673 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9674 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9675 | int ret; |
| 9676 | |
| 9677 | ENTER(); |
| 9678 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9679 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9680 | if (ret) { |
| 9681 | hdd_err("Failed to update country code: %d", ret); |
| 9682 | goto out; |
| 9683 | } |
| 9684 | |
| 9685 | /* FW capabilities received, Set the Dot11 mode */ |
| 9686 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9687 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9688 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9689 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9690 | |
| 9691 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9692 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9693 | else |
| 9694 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9695 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9696 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9697 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9698 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9699 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9700 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9701 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9702 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9703 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9704 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9705 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9706 | if (hdd_lro_init(hdd_ctx)) |
| 9707 | hdd_err("Unable to initialize LRO in fw"); |
| 9708 | |
| 9709 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9710 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9711 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9712 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9713 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9714 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9715 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9716 | if (ret) { |
| 9717 | hdd_err("Error while initializing thermal information"); |
| 9718 | goto deregister_frames; |
| 9719 | } |
| 9720 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9721 | /** |
| 9722 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9723 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9724 | * device up. |
| 9725 | */ |
| 9726 | if (cds_is_driver_recovering()) { |
| 9727 | if (hdd_ctx->is_pktlog_enabled) |
| 9728 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9729 | } else if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9730 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9731 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9732 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9733 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9734 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9735 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9736 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9737 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9738 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9739 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9740 | ret = hdd_register_cb(hdd_ctx); |
| 9741 | if (ret) { |
| 9742 | hdd_err("Failed to register HDD callbacks!"); |
| 9743 | goto deregister_frames; |
| 9744 | } |
| 9745 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9746 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9747 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9748 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9749 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9750 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9751 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9752 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9753 | status = sme_enable_disable_chanavoidind_event( |
| 9754 | hdd_ctx->hHal, 0); |
| 9755 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9756 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9757 | goto deregister_cb; |
| 9758 | } |
| 9759 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9760 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9761 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9762 | band_pref_params.rssi_boost_threshold_5g = |
| 9763 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9764 | band_pref_params.rssi_boost_factor_5g = |
| 9765 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9766 | band_pref_params.max_rssi_boost_5g = |
| 9767 | hdd_ctx->config->max_rssi_boost_5g; |
| 9768 | band_pref_params.rssi_penalize_threshold_5g = |
| 9769 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9770 | band_pref_params.rssi_penalize_factor_5g = |
| 9771 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9772 | band_pref_params.max_rssi_penalize_5g = |
| 9773 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9774 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9775 | } |
| 9776 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9777 | /* register P2P Listen Offload event callback */ |
| 9778 | if (wma_is_p2p_lo_capable()) |
| 9779 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9780 | wlan_hdd_p2p_lo_event_callback); |
| 9781 | |
| 9782 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9783 | |
| 9784 | if (ret) |
| 9785 | goto deregister_cb; |
| 9786 | |
| 9787 | EXIT(); |
| 9788 | return 0; |
| 9789 | |
| 9790 | deregister_cb: |
| 9791 | hdd_deregister_cb(hdd_ctx); |
| 9792 | deregister_frames: |
| 9793 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9794 | out: |
| 9795 | return -EINVAL; |
| 9796 | |
| 9797 | } |
| 9798 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9799 | /** |
| 9800 | * hdd_features_deinit() - Deinit features |
| 9801 | * @hdd_ctx: HDD context |
| 9802 | * |
| 9803 | * De-Initialize features and their feature context. |
| 9804 | * |
| 9805 | * Return: none. |
| 9806 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9807 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9808 | { |
| 9809 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9810 | } |
| 9811 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9812 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9813 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9814 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9815 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9816 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9817 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9818 | 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] | 9819 | { |
| 9820 | QDF_STATUS status; |
| 9821 | |
| 9822 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9823 | wlan_cfg80211_inform_bss_frame, |
| 9824 | SCAN_CB_TYPE_INFORM_BCN); |
| 9825 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9826 | hdd_err("failed with status code %08d [x%08x]", |
| 9827 | status, status); |
| 9828 | return status; |
| 9829 | } |
| 9830 | |
| 9831 | return QDF_STATUS_SUCCESS; |
| 9832 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9833 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9834 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9835 | * hdd_configure_cds() - Configure cds modules |
| 9836 | * @hdd_ctx: HDD context |
| 9837 | * @adapter: Primary adapter context |
| 9838 | * |
| 9839 | * Enable Cds modules after WLAN firmware is up. |
| 9840 | * |
| 9841 | * Return: 0 on success and errno on failure. |
| 9842 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9843 | 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] | 9844 | { |
| 9845 | int ret; |
| 9846 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9847 | int set_value; |
| 9848 | uint32_t num_abg_tx_chains = 0; |
| 9849 | uint32_t num_11b_tx_chains = 0; |
| 9850 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9851 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9852 | |
| 9853 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9854 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9855 | hdd_ctx->config->sifs_burst_duration; |
| 9856 | |
| 9857 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9858 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9859 | set_value, PDEV_CMD); |
| 9860 | } |
| 9861 | |
| 9862 | if (hdd_ctx->config->is_force_1x1) |
| 9863 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9864 | 1, PDEV_CMD); |
| 9865 | /* set chip power save failure detected callback */ |
| 9866 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9867 | hdd_chip_pwr_save_fail_detected_cb); |
| 9868 | |
| 9869 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9870 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9871 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9872 | set_value, PDEV_CMD); |
| 9873 | } |
| 9874 | |
| 9875 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9876 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9877 | sme_cli_set_command(0, |
| 9878 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9879 | set_value, PDEV_CMD); |
| 9880 | } |
| 9881 | |
| 9882 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9883 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9884 | sme_cli_set_command(0, |
| 9885 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9886 | set_value, PDEV_CMD); |
| 9887 | } |
| 9888 | |
| 9889 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9890 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9891 | if (!hdd_ctx->config->enable2x2) { |
| 9892 | if (num_11b_tx_chains > 1) |
| 9893 | num_11b_tx_chains = 1; |
| 9894 | if (num_11ag_tx_chains > 1) |
| 9895 | num_11ag_tx_chains = 1; |
| 9896 | } |
| 9897 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9898 | num_11b_tx_chains); |
| 9899 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9900 | num_11ag_tx_chains); |
| 9901 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9902 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9903 | |
| 9904 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9905 | if (ret) { |
| 9906 | hdd_err("Failed to pre-configure cds"); |
| 9907 | goto out; |
| 9908 | } |
| 9909 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9910 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9911 | * IPA module before configuring them to FW. Sequence required as crash |
| 9912 | * observed otherwise. |
| 9913 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9914 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9915 | hdd_err("Failed to setup pipes"); |
| 9916 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9917 | } |
| 9918 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9919 | /* |
| 9920 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9921 | * else |
| 9922 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9923 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9924 | |
| 9925 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9926 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9927 | goto out; |
| 9928 | } |
| 9929 | |
| 9930 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9931 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9932 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9933 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9934 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9935 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9936 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9937 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9938 | goto cds_disable; |
| 9939 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9940 | |
| 9941 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9942 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9943 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9944 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9945 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9946 | 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] | 9947 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9948 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9949 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9950 | goto cds_disable; |
| 9951 | } |
| 9952 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 9953 | if (ucfg_green_ap_enable_egap(hdd_ctx->hdd_pdev)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9954 | hdd_debug("enhance green ap is not enabled"); |
| 9955 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9956 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9957 | hdd_debug("Failed to set wow pulse"); |
| 9958 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9959 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9960 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9961 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9962 | |
| 9963 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9964 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9965 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9966 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9967 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9968 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9969 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9970 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9971 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9972 | out: |
| 9973 | return -EINVAL; |
| 9974 | } |
| 9975 | |
| 9976 | /** |
| 9977 | * hdd_deconfigure_cds() -De-Configure cds |
| 9978 | * @hdd_ctx: HDD context |
| 9979 | * |
| 9980 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9981 | * |
| 9982 | * Return: 0 on success and errno on failure. |
| 9983 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9984 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9985 | { |
| 9986 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9987 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9988 | |
| 9989 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9990 | |
| 9991 | /* De-init features */ |
| 9992 | hdd_features_deinit(hdd_ctx); |
| 9993 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9994 | /* De-register the SME callbacks */ |
| 9995 | hdd_deregister_cb(hdd_ctx); |
| 9996 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9997 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9998 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9999 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10000 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10001 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10002 | } |
| 10003 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 10004 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 10005 | hdd_err("Failed to disconnect pipes"); |
| 10006 | ret = -EINVAL; |
| 10007 | } |
| 10008 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10009 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10010 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10011 | } |
| 10012 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10013 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10014 | static void hdd_deregister_policy_manager_callback( |
| 10015 | struct wlan_objmgr_psoc *psoc) |
| 10016 | { |
| 10017 | if (QDF_STATUS_SUCCESS != |
| 10018 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10019 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10020 | } |
| 10021 | } |
| 10022 | #else |
| 10023 | static void hdd_deregister_policy_manager_callback( |
| 10024 | struct wlan_objmgr_psoc *psoc) |
| 10025 | { |
| 10026 | } |
| 10027 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10028 | |
| 10029 | /** |
| 10030 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10031 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10032 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10033 | * |
| 10034 | * This function maintains the driver state machine it will be invoked from |
| 10035 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10036 | * shall perform the stopping/closing of the modules. |
| 10037 | * |
| 10038 | * Return: 0 for success; non-zero for failure |
| 10039 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10040 | 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] | 10041 | { |
| 10042 | void *hif_ctx; |
| 10043 | qdf_device_t qdf_ctx; |
| 10044 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10045 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10046 | bool is_recovery_stop = cds_is_driver_recovering(); |
| 10047 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10048 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10049 | |
| 10050 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10051 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10052 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10053 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10054 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10055 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10056 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10057 | if (!qdf_ctx) { |
| 10058 | hdd_err("QDF device context NULL"); |
| 10059 | return -EINVAL; |
| 10060 | } |
| 10061 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10062 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10063 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10064 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10065 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10066 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10067 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10068 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10069 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10070 | |
| 10071 | cds_print_external_threads(); |
| 10072 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10073 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10074 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10075 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10076 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10077 | hdd_prevent_suspend_timeout( |
| 10078 | hdd_ctx->config->iface_change_wait_time, |
| 10079 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10080 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10081 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10082 | return 0; |
| 10083 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10084 | } |
| 10085 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10086 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10087 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10088 | /* free user wowl patterns */ |
| 10089 | hdd_free_user_wowl_ptrns(); |
| 10090 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10091 | switch (hdd_ctx->driver_status) { |
| 10092 | case DRIVER_MODULES_UNINITIALIZED: |
| 10093 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10094 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10095 | case DRIVER_MODULES_CLOSED: |
| 10096 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10097 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10098 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10099 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10100 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10101 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10102 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10103 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10104 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10105 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10106 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10107 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10108 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10109 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10110 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10111 | |
| 10112 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10113 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10114 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10115 | break; |
| 10116 | default: |
| 10117 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10118 | hdd_ctx->driver_status); |
| 10119 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10120 | ret = -EINVAL; |
| 10121 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10122 | } |
| 10123 | |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10124 | hdd_debug("Closing CDS modules!"); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10125 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10126 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10127 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10128 | qdf_status); |
| 10129 | ret = -EINVAL; |
| 10130 | QDF_ASSERT(0); |
| 10131 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10132 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10133 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10134 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10135 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10136 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10137 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10138 | ret = -EINVAL; |
| 10139 | QDF_ASSERT(0); |
| 10140 | } |
| 10141 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10142 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10143 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10144 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10145 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10146 | QDF_ASSERT(0); |
| 10147 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10148 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame^] | 10149 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10150 | if (ret) { |
| 10151 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10152 | QDF_ASSERT(0); |
| 10153 | } |
| 10154 | |
| 10155 | /* |
| 10156 | * Reset total mac phy during module stop such that during |
| 10157 | * next module start same psoc is used to populate new service |
| 10158 | * ready data |
| 10159 | */ |
| 10160 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
| 10161 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10162 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10163 | if (!hif_ctx) { |
| 10164 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10165 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10166 | } |
| 10167 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10168 | if (hdd_ctx->target_hw_name) { |
| 10169 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10170 | hdd_ctx->target_hw_name = NULL; |
| 10171 | } |
| 10172 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10173 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10174 | |
| 10175 | ol_cds_free(); |
| 10176 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10177 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10178 | ret = pld_power_off(qdf_ctx->dev); |
| 10179 | if (ret) |
| 10180 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10181 | ret); |
| 10182 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10183 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10184 | /* many adapter resources are not freed by design in SSR case */ |
| 10185 | if (!is_recovery_stop) |
| 10186 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10187 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10188 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10189 | /* Once the firmware sequence is completed reset this flag */ |
| 10190 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10191 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10192 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10193 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10194 | done: |
| 10195 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10196 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10197 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10198 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10199 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10200 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10201 | EXIT(); |
| 10202 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10203 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10204 | } |
| 10205 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10206 | |
| 10207 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10208 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10209 | * @buf: buffer pointer |
| 10210 | * @size: size of buffer to be filled |
| 10211 | * |
| 10212 | * This function is used to dump state information of hdd layer |
| 10213 | * |
| 10214 | * Return: None |
| 10215 | */ |
| 10216 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10217 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10218 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10219 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10220 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10221 | uint16_t len = 0; |
| 10222 | char *buf = *buf_ptr; |
| 10223 | |
| 10224 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10225 | if (!hdd_ctx) { |
| 10226 | hdd_err("Failed to get hdd context "); |
| 10227 | return; |
| 10228 | } |
| 10229 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10230 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10231 | |
| 10232 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10233 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10234 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10235 | "\n is_scheduler_suspended %d", |
| 10236 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10237 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10238 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10239 | if (adapter->dev) |
| 10240 | len += scnprintf(buf + len, *size - len, |
| 10241 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10242 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10243 | "\n device_mode: %d", adapter->device_mode); |
| 10244 | switch (adapter->device_mode) { |
| 10245 | case QDF_STA_MODE: |
| 10246 | case QDF_P2P_CLIENT_MODE: |
| 10247 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10248 | len += scnprintf(buf + len, *size - len, |
| 10249 | "\n connState: %d", |
| 10250 | hdd_sta_ctx->conn_info.connState); |
| 10251 | break; |
| 10252 | |
| 10253 | default: |
| 10254 | break; |
| 10255 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10256 | } |
| 10257 | |
| 10258 | *size -= len; |
| 10259 | *buf_ptr += len; |
| 10260 | } |
| 10261 | |
| 10262 | /** |
| 10263 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10264 | * to print hdd state information |
| 10265 | * |
| 10266 | * Return: None |
| 10267 | */ |
| 10268 | static void hdd_register_debug_callback(void) |
| 10269 | { |
| 10270 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10271 | } |
| 10272 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10273 | /* |
| 10274 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10275 | * |
| 10276 | * This function is used to create bug report lock |
| 10277 | * |
| 10278 | * Return: None |
| 10279 | */ |
| 10280 | static void wlan_init_bug_report_lock(void) |
| 10281 | { |
| 10282 | p_cds_contextType p_cds_context; |
| 10283 | |
| 10284 | p_cds_context = cds_get_global_context(); |
| 10285 | if (!p_cds_context) { |
| 10286 | hdd_err("cds context is NULL"); |
| 10287 | return; |
| 10288 | } |
| 10289 | |
| 10290 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10291 | } |
| 10292 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10293 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10294 | { |
| 10295 | |
| 10296 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10297 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10298 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10299 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10300 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10301 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10302 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10303 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10304 | |
| 10305 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10306 | &num_entries, sizeof(config_params)); |
| 10307 | |
| 10308 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10309 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10310 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10311 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10312 | else if (bw_compute_interval > 1000) { |
| 10313 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10314 | thresh_time_limit = 1; |
| 10315 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10316 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10317 | |
| 10318 | switch (num_entries) { |
| 10319 | case 4: |
| 10320 | proto_bitmap = config_params[3]; |
| 10321 | case 3: |
| 10322 | verbosity = config_params[2]; |
| 10323 | case 2: |
| 10324 | thresh = config_params[1]; |
| 10325 | case 1: |
| 10326 | live_mode = config_params[0]; |
| 10327 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10328 | 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] | 10329 | live_mode, thresh, thresh_time_limit, |
| 10330 | verbosity, proto_bitmap); |
| 10331 | }; |
| 10332 | |
| 10333 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10334 | verbosity, proto_bitmap); |
| 10335 | |
| 10336 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10337 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10338 | * hdd_wlan_startup() - HDD init function |
| 10339 | * @dev: Pointer to the underlying device |
| 10340 | * |
| 10341 | * This is the driver startup code executed once a WLAN device has been detected |
| 10342 | * |
| 10343 | * Return: 0 for success, < 0 for failure |
| 10344 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10345 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10346 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10347 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10348 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10349 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10350 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10351 | |
| 10352 | ENTER(); |
| 10353 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10354 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10355 | |
| 10356 | if (IS_ERR(hdd_ctx)) |
| 10357 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10358 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10359 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10360 | DEFAULT_PSOC_ID); |
| 10361 | if (ret) { |
| 10362 | hdd_err("Psoc creation fails!"); |
| 10363 | QDF_BUG(0); |
| 10364 | goto err_hdd_free_context; |
| 10365 | } |
| 10366 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10367 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10368 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10369 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10370 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10371 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10372 | hdd_request_manager_init(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10373 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10374 | hdd_driver_memdump_init(); |
| 10375 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10376 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10377 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10378 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10379 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10380 | } |
| 10381 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10382 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10383 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10384 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10385 | |
| 10386 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10387 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10388 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10389 | } |
| 10390 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10391 | ret = hdd_wiphy_init(hdd_ctx); |
| 10392 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10393 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10394 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10395 | } |
| 10396 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10397 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10398 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10399 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10400 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10401 | goto err_wiphy_unregister; |
| 10402 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 10403 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10404 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10405 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10406 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10407 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10408 | if (ret) { |
| 10409 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10410 | goto err_ipa_cleanup; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10411 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10412 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10413 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10414 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10415 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10416 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10417 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10418 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10419 | } |
| 10420 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10421 | hdd_release_rtnl_lock(); |
| 10422 | rtnl_held = false; |
| 10423 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10424 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10425 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10426 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10427 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10428 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10429 | hdd_skip_acs_scan_timer_handler, |
| 10430 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10431 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10432 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10433 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10434 | #endif |
| 10435 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10436 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10437 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10438 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10439 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10440 | if (hdd_ctx->rps) |
| 10441 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10442 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10443 | ret = hdd_register_notifiers(hdd_ctx); |
| 10444 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10445 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10446 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10447 | status = wlansap_global_init(); |
| 10448 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10449 | hdd_unregister_notifiers(hdd_ctx); |
| 10450 | goto err_close_adapters; |
| 10451 | } |
| 10452 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10453 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10454 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10455 | else |
| 10456 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10457 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10458 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10459 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10460 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10461 | hdd_prevent_suspend_timeout( |
| 10462 | hdd_ctx->config->iface_change_wait_time, |
| 10463 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10464 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10465 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10466 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10467 | goto success; |
| 10468 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10469 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10470 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10471 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10472 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10473 | if (rtnl_held) |
| 10474 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10475 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10476 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10477 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10478 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10479 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10480 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10481 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10482 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10483 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10484 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10485 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10486 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10487 | err_memdump_deinit: |
| 10488 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10489 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10490 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10491 | hdd_exit_netlink_services(hdd_ctx); |
| 10492 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10493 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10494 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10495 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10496 | if (cds_is_fw_down()) |
| 10497 | hdd_err("Not setting the complete event as fw is down"); |
| 10498 | else |
| 10499 | hdd_start_complete(ret); |
| 10500 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10501 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10502 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10503 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10504 | |
| 10505 | success: |
| 10506 | EXIT(); |
| 10507 | return 0; |
| 10508 | } |
| 10509 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10510 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10511 | * hdd_wlan_update_target_info() - update target type info |
| 10512 | * @hdd_ctx: HDD context |
| 10513 | * @context: hif context |
| 10514 | * |
| 10515 | * Update target info received from firmware in hdd context |
| 10516 | * Return:None |
| 10517 | */ |
| 10518 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10519 | 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] | 10520 | { |
| 10521 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10522 | |
| 10523 | if (!tgt_info) { |
| 10524 | hdd_err("Target info is Null"); |
| 10525 | return; |
| 10526 | } |
| 10527 | |
| 10528 | hdd_ctx->target_type = tgt_info->target_type; |
| 10529 | } |
| 10530 | |
| 10531 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10532 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10533 | * received from the firmware |
| 10534 | * @data: pointer to adapter. |
| 10535 | * @rsp: pointer to data received from FW. |
| 10536 | * |
| 10537 | * This is called when wlan driver received response event for |
| 10538 | * get arp stats to firmware. |
| 10539 | * |
| 10540 | * Return: None |
| 10541 | */ |
| 10542 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10543 | { |
| 10544 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10545 | struct hdd_nud_stats_context *context; |
| 10546 | int status; |
| 10547 | struct hdd_adapter *adapter = NULL; |
| 10548 | |
| 10549 | ENTER(); |
| 10550 | |
| 10551 | if (!rsp) { |
| 10552 | hdd_err("data is null"); |
| 10553 | return; |
| 10554 | } |
| 10555 | |
| 10556 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10557 | if (0 != status) |
| 10558 | return; |
| 10559 | |
| 10560 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10561 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10562 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10563 | return; |
| 10564 | } |
| 10565 | |
| 10566 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10567 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10568 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10569 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10570 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10571 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10572 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10573 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10574 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10575 | rsp->ba_session_establishment_status); |
| 10576 | |
| 10577 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10578 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10579 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10580 | adapter->dad |= rsp->dad_detected; |
| 10581 | adapter->con_status = rsp->connect_status; |
| 10582 | |
| 10583 | spin_lock(&hdd_context_lock); |
| 10584 | context = &hdd_ctx->nud_stats_context; |
| 10585 | complete(&context->response_event); |
| 10586 | spin_unlock(&hdd_context_lock); |
| 10587 | |
| 10588 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10589 | } |
| 10590 | |
| 10591 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10592 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10593 | * @hdd_ctx: HDD context |
| 10594 | * |
| 10595 | * Register the HDD callbacks to CDS/SME. |
| 10596 | * |
| 10597 | * Return: 0 for success or Error code for failure |
| 10598 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10599 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10600 | { |
| 10601 | QDF_STATUS status; |
| 10602 | int ret = 0; |
| 10603 | |
| 10604 | ENTER(); |
| 10605 | |
| 10606 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10607 | |
| 10608 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10609 | hdd_send_oem_data_rsp_msg); |
| 10610 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10611 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10612 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10613 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10614 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10615 | wlan_hdd_cfg80211_nan_callback); |
| 10616 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10617 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10618 | |
| 10619 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10620 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10621 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10622 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10623 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10624 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10625 | hdd_rssi_threshold_breached); |
| 10626 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10627 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10628 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10629 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10630 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10631 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10632 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10633 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10634 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10635 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10636 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10637 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10638 | hdd_lost_link_info_cb); |
| 10639 | /* print error and not block the startup process */ |
| 10640 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10641 | hdd_err("set lost link info callback failed"); |
| 10642 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10643 | ret = hdd_register_data_stall_detect_cb(); |
| 10644 | if (ret) { |
| 10645 | hdd_err("Register data stall detect detect callback failed."); |
| 10646 | return ret; |
| 10647 | } |
| 10648 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10649 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10650 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10651 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10652 | hdd_set_connection_in_progress, |
| 10653 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10654 | |
| 10655 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10656 | hdd_update_cca_info_cb); |
| 10657 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10658 | hdd_err("set congestion callback failed"); |
| 10659 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10660 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10661 | hdd_bt_activity_cb); |
| 10662 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10663 | hdd_err("set bt activity info callback failed"); |
| 10664 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10665 | EXIT(); |
| 10666 | |
| 10667 | return ret; |
| 10668 | } |
| 10669 | |
| 10670 | /** |
| 10671 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10672 | * @hdd_ctx: HDD context |
| 10673 | * |
| 10674 | * De-Register the HDD callbacks to CDS/SME. |
| 10675 | * |
| 10676 | * Return: void |
| 10677 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10678 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10679 | { |
| 10680 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10681 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10682 | |
| 10683 | ENTER(); |
| 10684 | |
| 10685 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10686 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10687 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10688 | status); |
| 10689 | |
| 10690 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10691 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10692 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10693 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10694 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10695 | |
| 10696 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10697 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10698 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10699 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10700 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10701 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10702 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10703 | if (ret) |
| 10704 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10705 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10706 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10707 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10708 | |
| 10709 | EXIT(); |
| 10710 | } |
| 10711 | |
| 10712 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10713 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10714 | * @adapter: Pointer to the HDD |
| 10715 | * @enable: bool value |
| 10716 | * |
| 10717 | * This to take counter measure to handle deauth req from HDD |
| 10718 | * |
| 10719 | * Return: None |
| 10720 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10721 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10722 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10723 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10724 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10725 | |
| 10726 | ENTER(); |
| 10727 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10728 | /* Ignore request to deauth bcmc station */ |
| 10729 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10730 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10731 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10732 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10733 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10734 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10735 | |
| 10736 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10737 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10738 | } |
| 10739 | |
| 10740 | /** |
| 10741 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10742 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10743 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10744 | * |
| 10745 | * This to take counter measure to handle deauth req from HDD |
| 10746 | * |
| 10747 | * Return: None |
| 10748 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10749 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10750 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10751 | { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10752 | struct sir_peer_sta_info peer_sta_info; |
| 10753 | struct hdd_station_info *stainfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10754 | ENTER(); |
| 10755 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10756 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10757 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10758 | return; |
| 10759 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10760 | wlan_hdd_get_peer_rssi(adapter, &pDelStaParams->peerMacAddr, |
| 10761 | &peer_sta_info); |
| 10762 | stainfo = hdd_get_stainfo(adapter->cache_sta_info, |
| 10763 | pDelStaParams->peerMacAddr); |
| 10764 | if (stainfo) { |
| 10765 | stainfo->rssi = peer_sta_info.info[0].rssi; |
| 10766 | stainfo->tx_rate = peer_sta_info.info[0].tx_rate; |
| 10767 | stainfo->rx_rate = peer_sta_info.info[0].rx_rate; |
| 10768 | } |
| 10769 | |
| 10770 | stainfo->reason_code = pDelStaParams->reason_code; |
| 10771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10772 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10773 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10774 | } |
| 10775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10776 | /** |
| 10777 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10778 | * @hdd_ctx: HDD Context |
| 10779 | * |
| 10780 | * API to find if there is any STA or P2P-Client is connected |
| 10781 | * |
| 10782 | * Return: true if connected; false otherwise |
| 10783 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10784 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10785 | { |
| 10786 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10787 | } |
| 10788 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10789 | /** |
| 10790 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10791 | * @adapter: HDD adapter pointer |
| 10792 | * |
| 10793 | * This function loop through each adapter and disable roaming on each STA |
| 10794 | * device mode except the input adapter. |
| 10795 | * |
| 10796 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10797 | * disable. |
| 10798 | * |
| 10799 | * Return: None |
| 10800 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10801 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10802 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10803 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10804 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10805 | |
| 10806 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10807 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10808 | QDF_STA_MODE == adapter->device_mode && |
| 10809 | policy_mgr_is_sta_active_connection_exists( |
| 10810 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10811 | hdd_debug("Connect received on STA session Id(%d)", |
| 10812 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10813 | /* |
| 10814 | * Loop through adapter and disable roaming for each STA device |
| 10815 | * mode except the input adapter. |
| 10816 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10817 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10818 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10819 | adapter->session_id != adapterIdx->session_id) { |
| 10820 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10821 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10822 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10823 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10824 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10825 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10826 | } |
| 10827 | } |
| 10828 | } |
| 10829 | |
| 10830 | /** |
| 10831 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10832 | * @adapter: HDD adapter pointer |
| 10833 | * |
| 10834 | * This function loop through each adapter and enable roaming on each STA |
| 10835 | * device mode except the input adapter. |
| 10836 | * Note: On the input adapter no need to enable roaming because link got |
| 10837 | * disconnected on this. |
| 10838 | * |
| 10839 | * Return: None |
| 10840 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10841 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10842 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10843 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10844 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10845 | |
| 10846 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10847 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10848 | QDF_STA_MODE == adapter->device_mode && |
| 10849 | policy_mgr_is_sta_active_connection_exists( |
| 10850 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10851 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10852 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10853 | /* |
| 10854 | * Loop through adapter and enable roaming for each STA device |
| 10855 | * mode except the input adapter. |
| 10856 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10857 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10858 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10859 | adapter->session_id != adapterIdx->session_id) { |
| 10860 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10861 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10862 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10863 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10864 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10865 | REASON_CONNECT); |
| 10866 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10867 | } |
| 10868 | } |
| 10869 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10870 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10871 | /** |
| 10872 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10873 | * @skb: sk buffer pointer |
| 10874 | * |
| 10875 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10876 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10877 | * |
| 10878 | * Return: None |
| 10879 | */ |
| 10880 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10881 | { |
| 10882 | #ifdef CNSS_GENL |
| 10883 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10884 | #else |
| 10885 | nl_srv_bcast(skb); |
| 10886 | #endif |
| 10887 | } |
| 10888 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10889 | 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] | 10890 | { |
| 10891 | struct sk_buff *skb; |
| 10892 | struct nlmsghdr *nlh; |
| 10893 | tAniMsgHdr *ani_hdr; |
| 10894 | void *nl_data = NULL; |
| 10895 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10896 | struct radio_index_tlv *radio_info; |
| 10897 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10898 | |
| 10899 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10900 | flags = GFP_ATOMIC; |
| 10901 | |
| 10902 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10903 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10904 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10905 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10906 | |
| 10907 | nlh = (struct nlmsghdr *)skb->data; |
| 10908 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10909 | nlh->nlmsg_flags = 0; |
| 10910 | nlh->nlmsg_seq = 0; |
| 10911 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10912 | |
| 10913 | ani_hdr = NLMSG_DATA(nlh); |
| 10914 | ani_hdr->type = type; |
| 10915 | |
| 10916 | switch (type) { |
| 10917 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10918 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10919 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10920 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10921 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10922 | ani_hdr->length = 0; |
| 10923 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10924 | break; |
| 10925 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10926 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10927 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10928 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10929 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10930 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10931 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10932 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10933 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 10934 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10935 | ani_hdr->length = len; |
| 10936 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10937 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10938 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10939 | break; |
| 10940 | |
| 10941 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10942 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10943 | type); |
| 10944 | kfree_skb(skb); |
| 10945 | return; |
| 10946 | } |
| 10947 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10948 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10949 | * Add radio index at the end of the svc event in TLV format |
| 10950 | * to maintain the backward compatibility with userspace |
| 10951 | * applications. |
| 10952 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10953 | |
| 10954 | tlv_len = 0; |
| 10955 | |
| 10956 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10957 | < WLAN_NL_MAX_PAYLOAD) { |
| 10958 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10959 | sizeof(*ani_hdr) + len); |
| 10960 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10961 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10962 | radio_info->radio = radio; |
| 10963 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10964 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10965 | "Added radio index tlv - radio index %d", |
| 10966 | radio_info->radio); |
| 10967 | } |
| 10968 | |
| 10969 | nlh->nlmsg_len += tlv_len; |
| 10970 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10971 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10972 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10973 | } |
| 10974 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10975 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10976 | void wlan_hdd_auto_shutdown_cb(void) |
| 10977 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10978 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10979 | |
| 10980 | if (!hdd_ctx) |
| 10981 | return; |
| 10982 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10983 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10984 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10985 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10986 | } |
| 10987 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10988 | 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] | 10989 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10990 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10991 | bool ap_connected = false, sta_connected = false; |
| 10992 | tHalHandle hal_handle; |
| 10993 | |
| 10994 | hal_handle = hdd_ctx->hHal; |
| 10995 | if (hal_handle == NULL) |
| 10996 | return; |
| 10997 | |
| 10998 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10999 | return; |
| 11000 | |
| 11001 | if (enable == false) { |
| 11002 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11003 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11004 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11005 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11006 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11007 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11008 | return; |
| 11009 | } |
| 11010 | |
| 11011 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11012 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11013 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11014 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11015 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11016 | conn_info.connState == |
| 11017 | eConnectionState_Associated) { |
| 11018 | sta_connected = true; |
| 11019 | break; |
| 11020 | } |
| 11021 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11022 | |
| 11023 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11024 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11025 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11026 | ap_connected = true; |
| 11027 | break; |
| 11028 | } |
| 11029 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11030 | } |
| 11031 | } |
| 11032 | |
| 11033 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11034 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11035 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11036 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11037 | |
| 11038 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11039 | hdd_ctx->config->WlanAutoShutdown) |
| 11040 | != QDF_STATUS_SUCCESS) |
| 11041 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11042 | else |
| 11043 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 11044 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11045 | } |
| 11046 | #endif |
| 11047 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11048 | struct hdd_adapter * |
| 11049 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11050 | bool check_start_bss) |
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(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11053 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11054 | |
| 11055 | con_sap_adapter = NULL; |
| 11056 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11057 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11058 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11059 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11060 | adapter != this_sap_adapter) { |
| 11061 | if (check_start_bss) { |
| 11062 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11063 | &adapter->event_flags)) { |
| 11064 | con_sap_adapter = adapter; |
| 11065 | break; |
| 11066 | } |
| 11067 | } else { |
| 11068 | con_sap_adapter = adapter; |
| 11069 | break; |
| 11070 | } |
| 11071 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11072 | } |
| 11073 | |
| 11074 | return con_sap_adapter; |
| 11075 | } |
| 11076 | |
| 11077 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11078 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11079 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11080 | return adapter->device_mode == QDF_STA_MODE || |
| 11081 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11082 | } |
| 11083 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11084 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11085 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11086 | return adapter->device_mode == QDF_SAP_MODE || |
| 11087 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11088 | } |
| 11089 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11090 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11091 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11092 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11093 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11094 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11095 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11096 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11097 | conn_info.connState == eConnectionState_Associated) { |
| 11098 | return true; |
| 11099 | } |
| 11100 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11101 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11102 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11103 | return true; |
| 11104 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11105 | } |
| 11106 | |
| 11107 | return false; |
| 11108 | } |
| 11109 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11110 | 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] | 11111 | { |
| 11112 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11113 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11114 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11115 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11116 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11117 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11118 | return is_running; |
| 11119 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11120 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11121 | 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] | 11122 | { |
| 11123 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11124 | hdd_ctx->bus_bw_timer_running = true; |
| 11125 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11126 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11127 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11128 | } |
| 11129 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11130 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11131 | { |
| 11132 | ENTER(); |
| 11133 | |
| 11134 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11135 | hdd_debug("Bandwidth compute timer already started"); |
| 11136 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11137 | } |
| 11138 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11139 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11140 | |
| 11141 | EXIT(); |
| 11142 | } |
| 11143 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11144 | 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] | 11145 | { |
| 11146 | ENTER(); |
| 11147 | |
| 11148 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11149 | hdd_debug("Bandwidth compute timer already started"); |
| 11150 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11151 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11152 | |
| 11153 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11154 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11155 | |
| 11156 | EXIT(); |
| 11157 | } |
| 11158 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11159 | 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] | 11160 | { |
| 11161 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 11162 | |
| 11163 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11164 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11165 | hdd_ctx->bus_bw_timer_running = false; |
| 11166 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11167 | |
| 11168 | hdd_reset_tcp_delack(hdd_ctx); |
| 11169 | } |
| 11170 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11171 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11172 | { |
| 11173 | ENTER(); |
| 11174 | |
| 11175 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11176 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11177 | return; |
| 11178 | } |
| 11179 | |
| 11180 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11181 | |
| 11182 | EXIT(); |
| 11183 | } |
| 11184 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11185 | 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] | 11186 | { |
| 11187 | ENTER(); |
| 11188 | |
| 11189 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11190 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11191 | return; |
| 11192 | } |
| 11193 | |
| 11194 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11195 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11196 | |
| 11197 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11198 | } |
| 11199 | #endif |
| 11200 | |
| 11201 | /** |
| 11202 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11203 | * and sta's operating channel. |
| 11204 | * @sta_adapter: Describe the first argument to foobar. |
| 11205 | * @ap_adapter: Describe the second argument to foobar. |
| 11206 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11207 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11208 | * set this flag to true else false. |
| 11209 | * |
| 11210 | * This function checks the sap's operating channel and sta's operating channel. |
| 11211 | * if both are same then it will return false else it will restart the sap in |
| 11212 | * sta's channel and return true. |
| 11213 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11214 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11215 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11216 | QDF_STATUS |
| 11217 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11218 | struct hdd_adapter *ap_adapter, |
| 11219 | tCsrRoamProfile *roam_profile, |
| 11220 | tScanResultHandle *scan_cache, |
| 11221 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11222 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11223 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11224 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11225 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11226 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11227 | *concurrent_chnl_same = true; |
| 11228 | |
| 11229 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11230 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11231 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11232 | scan_cache, |
| 11233 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11234 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11235 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11236 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11237 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11238 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11239 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11240 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11241 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11242 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11243 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11244 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11245 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11246 | } |
| 11247 | } |
| 11248 | } else { |
| 11249 | /* |
| 11250 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11251 | * failed so we have to stop the SAP to avoid any channel |
| 11252 | * discrepancy between SAP's channel and STA's channel. |
| 11253 | * Return the status as failure so caller function could know |
| 11254 | * that scan look up is failed. |
| 11255 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11256 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11257 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11258 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11259 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11260 | } |
| 11261 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11262 | /** |
| 11263 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11264 | * @ap_adapter: SAP adapter |
| 11265 | * |
| 11266 | * This function will process the stopping of sap adapter. |
| 11267 | * |
| 11268 | * Return: None |
| 11269 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11270 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11271 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11272 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11273 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11274 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11275 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11276 | |
| 11277 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11278 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11279 | return; |
| 11280 | } |
| 11281 | |
| 11282 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11283 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11284 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11285 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11286 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11287 | mutex_lock(&hdd_ctx->sap_lock); |
| 11288 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11289 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11290 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11291 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11292 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11293 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11294 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11295 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11296 | qdf_stop_bss_event, |
| 11297 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11298 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11299 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11300 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11301 | return; |
| 11302 | } |
| 11303 | } |
| 11304 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11305 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11306 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11307 | ap_adapter->session_id); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11308 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11309 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11310 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11311 | } |
| 11312 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11313 | } |
| 11314 | |
| 11315 | /** |
| 11316 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11317 | * @ap_adapter: SAP adapter |
| 11318 | * |
| 11319 | * This function will process the starting of sap adapter. |
| 11320 | * |
| 11321 | * Return: None |
| 11322 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11323 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11324 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11325 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11326 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11327 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11328 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11329 | tsap_Config_t *sap_config; |
| 11330 | |
| 11331 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11332 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11333 | return; |
| 11334 | } |
| 11335 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11336 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11337 | hdd_err("SoftAp role has not been enabled"); |
| 11338 | return; |
| 11339 | } |
| 11340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11341 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11342 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11343 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11344 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11346 | mutex_lock(&hdd_ctx->sap_lock); |
| 11347 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11348 | goto end; |
| 11349 | |
| 11350 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11351 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11352 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 11353 | goto end; |
| 11354 | } |
| 11355 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11356 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11357 | 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] | 11358 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11359 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11360 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11361 | goto end; |
| 11362 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11363 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11364 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11365 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11366 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11367 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11368 | goto end; |
| 11369 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11370 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11371 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 11372 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11373 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11374 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11375 | ap_adapter->session_id); |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11376 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11377 | |
| 11378 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11379 | end: |
| 11380 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11381 | /* SAP context and beacon cleanup will happen during driver unload |
| 11382 | * in hdd_stop_adapter |
| 11383 | */ |
| 11384 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11385 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11386 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11387 | |
| 11388 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11389 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11390 | * mac scan config |
| 11391 | * @status: Status of set antenna mode |
| 11392 | * |
| 11393 | * Callback on setting the dual mac configuration |
| 11394 | * |
| 11395 | * Return: None |
| 11396 | */ |
| 11397 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11398 | enum set_antenna_mode_status status) |
| 11399 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11400 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11401 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11402 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11403 | |
| 11404 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11405 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11406 | return; |
| 11407 | |
| 11408 | /* Signal the completion of set dual mac config */ |
| 11409 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11410 | } |
| 11411 | |
| 11412 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11413 | * hdd_get_fw_version() - Get FW version |
| 11414 | * @hdd_ctx: pointer to HDD context. |
| 11415 | * @major_spid: FW version - major spid. |
| 11416 | * @minor_spid: FW version - minor spid |
| 11417 | * @ssid: FW version - ssid |
| 11418 | * @crmid: FW version - crmid |
| 11419 | * |
| 11420 | * This function is called to get the firmware build version stored |
| 11421 | * as part of the HDD context |
| 11422 | * |
| 11423 | * Return: None |
| 11424 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11425 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11426 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11427 | uint32_t *siid, uint32_t *crmid) |
| 11428 | { |
| 11429 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11430 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11431 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11432 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11433 | } |
| 11434 | |
| 11435 | #ifdef QCA_CONFIG_SMP |
| 11436 | /** |
| 11437 | * wlan_hdd_get_cpu() - get cpu_index |
| 11438 | * |
| 11439 | * Return: cpu_index |
| 11440 | */ |
| 11441 | int wlan_hdd_get_cpu(void) |
| 11442 | { |
| 11443 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11445 | put_cpu(); |
| 11446 | return cpu_index; |
| 11447 | } |
| 11448 | #endif |
| 11449 | |
| 11450 | /** |
| 11451 | * hdd_get_fwpath() - get framework path |
| 11452 | * |
| 11453 | * This function is used to get the string written by |
| 11454 | * userspace to start the wlan driver |
| 11455 | * |
| 11456 | * Return: string |
| 11457 | */ |
| 11458 | const char *hdd_get_fwpath(void) |
| 11459 | { |
| 11460 | return fwpath.string; |
| 11461 | } |
| 11462 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11463 | static int hdd_qdf_print_init(void) |
| 11464 | { |
| 11465 | int qdf_print_idx; |
| 11466 | QDF_STATUS status; |
| 11467 | |
| 11468 | status = qdf_print_setup(); |
| 11469 | if (status != QDF_STATUS_SUCCESS) { |
| 11470 | pr_err("qdf_print_setup failed\n"); |
| 11471 | return -EINVAL; |
| 11472 | } |
| 11473 | |
| 11474 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11475 | |
| 11476 | if (qdf_print_idx < 0) { |
| 11477 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11478 | qdf_print_idx); |
| 11479 | return -EINVAL; |
| 11480 | } |
| 11481 | |
| 11482 | qdf_set_pidx(qdf_print_idx); |
| 11483 | |
| 11484 | return 0; |
| 11485 | } |
| 11486 | |
| 11487 | static void hdd_qdf_print_deinit(void) |
| 11488 | { |
| 11489 | int qdf_print_idx; |
| 11490 | |
| 11491 | qdf_print_idx = qdf_get_pidx(); |
| 11492 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11493 | } |
| 11494 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11495 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11496 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11497 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11498 | * This function initilizes CDS global context with the help of cds_init. This |
| 11499 | * has to be the first function called after probe to get a valid global |
| 11500 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11501 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11502 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11503 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11504 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11505 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11506 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11507 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11508 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11509 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11510 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11511 | hdd_err("Failed to allocate CDS context"); |
| 11512 | ret = -ENOMEM; |
| 11513 | goto err_out; |
| 11514 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11515 | |
| 11516 | wlan_init_bug_report_lock(); |
| 11517 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11518 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11519 | wlan_logging_sock_init_svc(); |
| 11520 | #endif |
| 11521 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11522 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11523 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11524 | QDF_TIMER_TYPE_SW); |
| 11525 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11526 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11527 | hdd_qdf_print_init(); |
| 11528 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11529 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11530 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11531 | err_out: |
| 11532 | return ret; |
| 11533 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11534 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11535 | /** |
| 11536 | * hdd_deinit() - Deinitialize Driver |
| 11537 | * |
| 11538 | * This function frees CDS global context with the help of cds_deinit. This |
| 11539 | * has to be the last function call in remove callback to free the global |
| 11540 | * context. |
| 11541 | */ |
| 11542 | void hdd_deinit(void) |
| 11543 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11544 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11545 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11546 | wlan_destroy_bug_report_lock(); |
| 11547 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11548 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11549 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11550 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11551 | wlan_logging_sock_deinit_svc(); |
| 11552 | #endif |
| 11553 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11554 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11555 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11556 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11557 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11558 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11559 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11560 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11561 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11562 | struct file *file) |
| 11563 | { |
| 11564 | return 0; |
| 11565 | } |
| 11566 | |
| 11567 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11568 | const char __user *user_buf, |
| 11569 | size_t count, |
| 11570 | loff_t *f_pos) |
| 11571 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11572 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11573 | static const char wlan_off_str[] = "OFF"; |
| 11574 | static const char wlan_on_str[] = "ON"; |
| 11575 | int ret; |
| 11576 | unsigned long rc; |
| 11577 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11578 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11579 | pr_err("Failed to read buffer\n"); |
| 11580 | return -EINVAL; |
| 11581 | } |
| 11582 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11583 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11584 | pr_debug("Wifi turning off from UI\n"); |
| 11585 | goto exit; |
| 11586 | } |
| 11587 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11588 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11589 | pr_err("Invalid value received from framework"); |
| 11590 | goto exit; |
| 11591 | } |
| 11592 | |
| 11593 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11594 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11595 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11596 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11597 | if (!rc) { |
| 11598 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11599 | ret = -EINVAL; |
| 11600 | hdd_start_complete(ret); |
| 11601 | return ret; |
| 11602 | } |
| 11603 | |
| 11604 | hdd_start_complete(0); |
| 11605 | } |
| 11606 | |
| 11607 | exit: |
| 11608 | return count; |
| 11609 | } |
| 11610 | |
| 11611 | |
| 11612 | const struct file_operations wlan_hdd_state_fops = { |
| 11613 | .owner = THIS_MODULE, |
| 11614 | .open = wlan_hdd_state_ctrl_param_open, |
| 11615 | .write = wlan_hdd_state_ctrl_param_write, |
| 11616 | }; |
| 11617 | |
| 11618 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11619 | { |
| 11620 | unsigned int wlan_hdd_state_major = 0; |
| 11621 | int ret; |
| 11622 | struct device *dev; |
| 11623 | |
| 11624 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11625 | |
| 11626 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11627 | if (ret) { |
| 11628 | pr_err("Failed to register qcwlanstate"); |
| 11629 | goto dev_alloc_err; |
| 11630 | } |
| 11631 | wlan_hdd_state_major = MAJOR(device); |
| 11632 | |
| 11633 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11634 | if (IS_ERR(class)) { |
| 11635 | pr_err("wlan_hdd_state class_create error"); |
| 11636 | goto class_err; |
| 11637 | } |
| 11638 | |
| 11639 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11640 | if (IS_ERR(dev)) { |
| 11641 | pr_err("wlan_hdd_statedevice_create error"); |
| 11642 | goto err_class_destroy; |
| 11643 | } |
| 11644 | |
| 11645 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11646 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11647 | if (ret) { |
| 11648 | pr_err("Failed to add cdev error"); |
| 11649 | goto cdev_add_err; |
| 11650 | } |
| 11651 | |
| 11652 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11653 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11654 | |
| 11655 | return 0; |
| 11656 | |
| 11657 | cdev_add_err: |
| 11658 | device_destroy(class, device); |
| 11659 | err_class_destroy: |
| 11660 | class_destroy(class); |
| 11661 | class_err: |
| 11662 | unregister_chrdev_region(device, dev_num); |
| 11663 | dev_alloc_err: |
| 11664 | return -ENODEV; |
| 11665 | } |
| 11666 | |
| 11667 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11668 | { |
| 11669 | cdev_del(&wlan_hdd_state_cdev); |
| 11670 | device_destroy(class, device); |
| 11671 | class_destroy(class); |
| 11672 | unregister_chrdev_region(device, dev_num); |
| 11673 | |
| 11674 | pr_info("Device node unregistered"); |
| 11675 | } |
| 11676 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11677 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11678 | * component_init - API to init cld component's |
| 11679 | * |
| 11680 | * Return: None |
| 11681 | */ |
| 11682 | static void component_init(void) |
| 11683 | { |
| 11684 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11685 | disa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11686 | } |
| 11687 | |
| 11688 | /** |
| 11689 | * component_deinit - API to deinit cld component's |
| 11690 | * |
| 11691 | * Return: None |
| 11692 | */ |
| 11693 | static void component_deinit(void) |
| 11694 | { |
| 11695 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11696 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11697 | } |
| 11698 | |
| 11699 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11700 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11701 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11702 | } |
| 11703 | |
| 11704 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11705 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11706 | disa_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11707 | } |
| 11708 | |
| 11709 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11710 | * __hdd_module_init - Module init helper |
| 11711 | * |
| 11712 | * Module init helper function used by both module and static driver. |
| 11713 | * |
| 11714 | * Return: 0 for success, errno on failure |
| 11715 | */ |
| 11716 | static int __hdd_module_init(void) |
| 11717 | { |
| 11718 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11719 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11720 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11721 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11722 | g_wlan_driver_version, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11723 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11724 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11725 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11726 | if (ret) { |
| 11727 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11728 | goto err_dev_state; |
| 11729 | } |
| 11730 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11731 | pld_init(); |
| 11732 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11733 | ret = hdd_init(); |
| 11734 | if (ret) { |
| 11735 | pr_err("hdd_init failed %x\n", ret); |
| 11736 | goto err_hdd_init; |
| 11737 | } |
| 11738 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11739 | dispatcher_init(); |
| 11740 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11741 | /* Ensure to call post objmgr init */ |
| 11742 | component_init(); |
| 11743 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11744 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11745 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11746 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11747 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11748 | ret = wlan_hdd_register_driver(); |
| 11749 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11750 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11751 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11752 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11753 | } |
| 11754 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11755 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11756 | |
| 11757 | return 0; |
| 11758 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11759 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11760 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11761 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11762 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11763 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11764 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11765 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11766 | wlan_hdd_state_ctrl_param_destroy(); |
| 11767 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11768 | return ret; |
| 11769 | } |
| 11770 | |
| 11771 | /** |
| 11772 | * __hdd_module_exit - Module exit helper |
| 11773 | * |
| 11774 | * Module exit helper function used by both module and static driver. |
| 11775 | */ |
| 11776 | static void __hdd_module_exit(void) |
| 11777 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11778 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11779 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11780 | QWLAN_VERSIONSTR); |
| 11781 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11782 | hdd_wait_for_recovery_completion(); |
| 11783 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11784 | wlan_hdd_unregister_driver(); |
| 11785 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11786 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11787 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11788 | /* Ensure to call prior to objmgr deinit */ |
| 11789 | component_deinit(); |
| 11790 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11791 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11792 | |
| 11793 | hdd_sysfs_destroy_version_interface(); |
| 11794 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11795 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11796 | pld_deinit(); |
| 11797 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11798 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11799 | } |
| 11800 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11801 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11802 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11803 | * wlan_boot_cb() - Wlan boot callback |
| 11804 | * @kobj: object whose directory we're creating the link in. |
| 11805 | * @attr: attribute the user is interacting with |
| 11806 | * @buff: the buffer containing the user data |
| 11807 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11808 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11809 | * This callback is invoked when the fs is ready to start the |
| 11810 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11811 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11812 | * 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] | 11813 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11814 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11815 | struct kobj_attribute *attr, |
| 11816 | const char *buf, |
| 11817 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11818 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11819 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11820 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11821 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11822 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11823 | } |
| 11824 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11825 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11826 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11827 | return -EIO; |
| 11828 | } |
| 11829 | |
| 11830 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11831 | |
| 11832 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11833 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11834 | |
| 11835 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11836 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11837 | * |
| 11838 | * Return: None |
| 11839 | * |
| 11840 | */ |
| 11841 | static void hdd_sysfs_cleanup(void) |
| 11842 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11843 | /* remove from group */ |
| 11844 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11845 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11846 | wlan_loader->attr_group); |
| 11847 | |
| 11848 | /* unlink the object from parent */ |
| 11849 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11850 | |
| 11851 | /* free the object */ |
| 11852 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11853 | |
| 11854 | kfree(wlan_loader->attr_group); |
| 11855 | kfree(wlan_loader); |
| 11856 | |
| 11857 | wlan_loader = NULL; |
| 11858 | } |
| 11859 | |
| 11860 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11861 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11862 | * ready |
| 11863 | * |
| 11864 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11865 | * when the filesystem is ready. |
| 11866 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11867 | * QDF API cannot be used here since this function is called even before |
| 11868 | * initializing WLAN driver. |
| 11869 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11870 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11871 | */ |
| 11872 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11873 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11874 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11875 | |
| 11876 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11877 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11878 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11879 | |
| 11880 | wlan_loader->boot_wlan_obj = NULL; |
| 11881 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11882 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11883 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11884 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11885 | |
| 11886 | wlan_loader->loaded_state = 0; |
| 11887 | wlan_loader->attr_group->attrs = attrs; |
| 11888 | |
| 11889 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11890 | kernel_kobj); |
| 11891 | if (!wlan_loader->boot_wlan_obj) { |
| 11892 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11893 | goto error_return; |
| 11894 | } |
| 11895 | |
| 11896 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11897 | wlan_loader->attr_group); |
| 11898 | if (ret) { |
| 11899 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11900 | goto error_return; |
| 11901 | } |
| 11902 | |
| 11903 | return 0; |
| 11904 | |
| 11905 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11906 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11907 | |
| 11908 | return ret; |
| 11909 | } |
| 11910 | |
| 11911 | /** |
| 11912 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11913 | * |
| 11914 | * Return: 0 on success or errno on failure |
| 11915 | */ |
| 11916 | static int wlan_deinit_sysfs(void) |
| 11917 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11918 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11919 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11920 | return -EINVAL; |
| 11921 | } |
| 11922 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11923 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11924 | return 0; |
| 11925 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11926 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11927 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11928 | |
| 11929 | #ifdef MODULE |
| 11930 | /** |
| 11931 | * __hdd_module_init - Module init helper |
| 11932 | * |
| 11933 | * Module init helper function used by both module and static driver. |
| 11934 | * |
| 11935 | * Return: 0 for success, errno on failure |
| 11936 | */ |
| 11937 | static int hdd_module_init(void) |
| 11938 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11939 | if (__hdd_module_init()) { |
| 11940 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11941 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11942 | } |
| 11943 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11944 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11945 | } |
| 11946 | #else |
| 11947 | static int __init hdd_module_init(void) |
| 11948 | { |
| 11949 | int ret = -EINVAL; |
| 11950 | |
| 11951 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11952 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11953 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11954 | |
| 11955 | return ret; |
| 11956 | } |
| 11957 | #endif |
| 11958 | |
| 11959 | |
| 11960 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11961 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11962 | * hdd_module_exit() - Exit function |
| 11963 | * |
| 11964 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11965 | * |
| 11966 | * Return: None |
| 11967 | */ |
| 11968 | static void __exit hdd_module_exit(void) |
| 11969 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11970 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11971 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11972 | #else |
| 11973 | static void __exit hdd_module_exit(void) |
| 11974 | { |
| 11975 | __hdd_module_exit(); |
| 11976 | wlan_deinit_sysfs(); |
| 11977 | } |
| 11978 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11979 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11980 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11981 | { |
| 11982 | return param_set_copystring(kmessage, kp); |
| 11983 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11984 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11985 | /** |
| 11986 | * is_con_mode_valid() check con mode is valid or not |
| 11987 | * @mode: global con mode |
| 11988 | * |
| 11989 | * Return: TRUE on success FALSE on failure |
| 11990 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11991 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11992 | { |
| 11993 | switch (mode) { |
| 11994 | case QDF_GLOBAL_MONITOR_MODE: |
| 11995 | case QDF_GLOBAL_FTM_MODE: |
| 11996 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11997 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11998 | return true; |
| 11999 | default: |
| 12000 | return false; |
| 12001 | } |
| 12002 | } |
| 12003 | |
| 12004 | /** |
| 12005 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12006 | * @mode: global con mode |
| 12007 | * |
| 12008 | * Return: adapter mode |
| 12009 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12010 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12011 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12012 | { |
| 12013 | |
| 12014 | switch (mode) { |
| 12015 | case QDF_GLOBAL_MISSION_MODE: |
| 12016 | return QDF_STA_MODE; |
| 12017 | case QDF_GLOBAL_MONITOR_MODE: |
| 12018 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12019 | case QDF_GLOBAL_EPPING_MODE: |
| 12020 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12021 | case QDF_GLOBAL_FTM_MODE: |
| 12022 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12023 | case QDF_GLOBAL_QVIT_MODE: |
| 12024 | return QDF_QVIT_MODE; |
| 12025 | default: |
| 12026 | return QDF_MAX_NO_OF_MODE; |
| 12027 | } |
| 12028 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12029 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12030 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12031 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12032 | { |
| 12033 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12034 | return; |
| 12035 | |
| 12036 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12037 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12038 | hdd_info("Release wakelock for monitor mode!"); |
| 12039 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12040 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12041 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12042 | case QDF_GLOBAL_FTM_MODE: |
| 12043 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 12044 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12045 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12046 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12047 | break; |
| 12048 | default: |
| 12049 | break; |
| 12050 | } |
| 12051 | } |
| 12052 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12053 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12054 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12055 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12056 | int driver_status; |
| 12057 | |
| 12058 | driver_status = hdd_ctx->driver_status; |
| 12059 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12060 | switch (curr_mode) { |
| 12061 | case QDF_GLOBAL_MISSION_MODE: |
| 12062 | case QDF_GLOBAL_MONITOR_MODE: |
| 12063 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12064 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12065 | hdd_close_all_adapters(hdd_ctx, false); |
| 12066 | break; |
| 12067 | case QDF_GLOBAL_EPPING_MODE: |
| 12068 | epping_disable(); |
| 12069 | epping_close(); |
| 12070 | break; |
| 12071 | default: |
| 12072 | return; |
| 12073 | } |
| 12074 | } |
| 12075 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12076 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12077 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12078 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12079 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12080 | int ret = 0; |
| 12081 | bool rtnl_held; |
| 12082 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12083 | QDF_STATUS status; |
| 12084 | |
| 12085 | if (!qdf_dev) { |
| 12086 | hdd_err("qdf device context is Null return!"); |
| 12087 | return -EINVAL; |
| 12088 | } |
| 12089 | |
| 12090 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12091 | switch (mode) { |
| 12092 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12093 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12094 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12095 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12096 | break; |
| 12097 | case QDF_GLOBAL_FTM_MODE: |
| 12098 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12099 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12100 | NET_NAME_UNKNOWN, rtnl_held); |
| 12101 | if (adapter == NULL) |
| 12102 | ret = -EINVAL; |
| 12103 | break; |
| 12104 | case QDF_GLOBAL_MONITOR_MODE: |
| 12105 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12106 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12107 | NET_NAME_UNKNOWN, rtnl_held); |
| 12108 | if (adapter == NULL) |
| 12109 | ret = -EINVAL; |
| 12110 | break; |
| 12111 | case QDF_GLOBAL_EPPING_MODE: |
| 12112 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12113 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12114 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12115 | ret = -EINVAL; |
| 12116 | break; |
| 12117 | } |
| 12118 | ret = epping_enable(qdf_dev->dev); |
| 12119 | if (ret) { |
| 12120 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12121 | epping_close(); |
| 12122 | } |
| 12123 | break; |
| 12124 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12125 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12126 | ret = -ENOTSUPP; |
| 12127 | break; |
| 12128 | } |
| 12129 | hdd_release_rtnl_lock(); |
| 12130 | rtnl_held = false; |
| 12131 | return ret; |
| 12132 | } |
| 12133 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12134 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12135 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12136 | * @kmessage: con mode name on which driver to be bring up |
| 12137 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12138 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12139 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12140 | * This function is invoked when user updates con mode using sys entry, |
| 12141 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12142 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12143 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12144 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12145 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12146 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12147 | { |
| 12148 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12149 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12150 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12151 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12152 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12153 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12154 | hdd_info("con_mode handler: %s", kmessage); |
| 12155 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12156 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12157 | if (ret) |
| 12158 | return ret; |
| 12159 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12160 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12161 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12162 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12163 | if (ret) { |
| 12164 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12165 | goto reset_flags; |
| 12166 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12167 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12168 | if (!is_con_mode_valid(new_con_mode)) { |
| 12169 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12170 | ret = -EINVAL; |
| 12171 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12172 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12173 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12174 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12175 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12176 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12177 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12178 | ret = 0; |
| 12179 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12180 | } |
| 12181 | |
Sourav Mohapatra | 3bc5e98 | 2017-11-24 15:53:49 +0530 | [diff] [blame] | 12182 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12183 | hdd_warn("Waiting for monitor mode: External threads are active"); |
| 12184 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12185 | /* ensure adapters are stopped */ |
| 12186 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12187 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12188 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12189 | if (ret) { |
| 12190 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12191 | goto reset_flags; |
| 12192 | } |
| 12193 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12194 | /* Cleanup present mode before switching to new mode */ |
| 12195 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12196 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12197 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12198 | |
| 12199 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12200 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12201 | if (ret) { |
| 12202 | hdd_err("Failed to register for new mode"); |
| 12203 | goto reset_flags; |
| 12204 | } |
| 12205 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12206 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12207 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12208 | hdd_err("invalid adapter"); |
| 12209 | ret = -EINVAL; |
| 12210 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12211 | } |
| 12212 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12213 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12214 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12215 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12216 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12217 | } |
| 12218 | |
| 12219 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12220 | if (ret) { |
| 12221 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12222 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12223 | } |
| 12224 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12225 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12226 | if (hdd_start_adapter(adapter)) { |
| 12227 | hdd_err("Failed to start %s adapter", kmessage); |
| 12228 | ret = -EINVAL; |
| 12229 | goto reset_flags; |
| 12230 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12231 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12232 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12233 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12234 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12235 | } |
| 12236 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12237 | /* con_mode is a global module parameter */ |
| 12238 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12239 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12240 | ret = 0; |
| 12241 | |
| 12242 | reset_flags: |
| 12243 | cds_set_load_in_progress(false); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12244 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12245 | return ret; |
| 12246 | } |
| 12247 | |
| 12248 | |
| 12249 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12250 | { |
| 12251 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12252 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12253 | |
| 12254 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12255 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12256 | if (ret) |
| 12257 | return ret; |
| 12258 | |
| 12259 | cds_ssr_protect(__func__); |
| 12260 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12261 | cds_ssr_unprotect(__func__); |
| 12262 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12263 | return ret; |
| 12264 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12265 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12266 | static int con_mode_handler_ftm(const char *kmessage, |
| 12267 | struct kernel_param *kp) |
| 12268 | { |
| 12269 | int ret; |
| 12270 | |
| 12271 | ret = param_set_int(kmessage, kp); |
| 12272 | |
| 12273 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12274 | pr_err("Only FTM mode supported!"); |
| 12275 | return -ENOTSUPP; |
| 12276 | } |
| 12277 | |
| 12278 | hdd_set_conparam(con_mode_ftm); |
| 12279 | con_mode = con_mode_ftm; |
| 12280 | |
| 12281 | return ret; |
| 12282 | } |
| 12283 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12284 | static int con_mode_handler_monitor(const char *kmessage, |
| 12285 | struct kernel_param *kp) |
| 12286 | { |
| 12287 | int ret; |
| 12288 | |
| 12289 | ret = param_set_int(kmessage, kp); |
| 12290 | |
| 12291 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12292 | pr_err("Only Monitor mode supported!"); |
| 12293 | return -ENOTSUPP; |
| 12294 | } |
| 12295 | |
| 12296 | hdd_set_conparam(con_mode_monitor); |
| 12297 | con_mode = con_mode_monitor; |
| 12298 | |
| 12299 | return ret; |
| 12300 | } |
| 12301 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12302 | /** |
| 12303 | * hdd_get_conparam() - driver exit point |
| 12304 | * |
| 12305 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12306 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12307 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12308 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12309 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12310 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12311 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12312 | } |
| 12313 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12314 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12315 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12316 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12317 | } |
| 12318 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12319 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12320 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12321 | * @hdd_ctx: HDD context |
| 12322 | * |
| 12323 | * Cleans up the pre cac interface, if it exists |
| 12324 | * |
| 12325 | * Return: None |
| 12326 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12327 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12328 | { |
| 12329 | uint8_t session_id; |
| 12330 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12331 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12332 | |
| 12333 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12334 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12335 | hdd_err("failed to get pre cac vdev id"); |
| 12336 | return; |
| 12337 | } |
| 12338 | |
| 12339 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12340 | if (!precac_adapter) { |
| 12341 | hdd_err("invalid pre cac adapater"); |
| 12342 | return; |
| 12343 | } |
| 12344 | |
| 12345 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12346 | wlan_hdd_sap_pre_cac_failure, |
| 12347 | (void *)precac_adapter); |
| 12348 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12349 | |
| 12350 | } |
| 12351 | |
| 12352 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12353 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12354 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12355 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12356 | * Return: void |
| 12357 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12358 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12359 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12360 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12361 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12362 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12363 | if (!ol_ctx) |
| 12364 | return; |
| 12365 | |
| 12366 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12367 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12368 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12369 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12370 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12371 | |
| 12372 | ol_init_ini_config(ol_ctx, &cfg); |
| 12373 | } |
| 12374 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12375 | #ifdef FEATURE_RUNTIME_PM |
| 12376 | /** |
| 12377 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12378 | * @hdd_ctx: hdd context |
| 12379 | * @cfg: pointer to the configuration memory being populated |
| 12380 | * |
| 12381 | * Return: void |
| 12382 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12383 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12384 | struct hif_config_info *cfg) |
| 12385 | { |
| 12386 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12387 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12388 | } |
| 12389 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12390 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12391 | struct hif_config_info *cfg) |
| 12392 | { |
| 12393 | } |
| 12394 | #endif |
| 12395 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12396 | /** |
| 12397 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12398 | * @hdd_ctx: HDD Context |
| 12399 | * |
| 12400 | * Return: void |
| 12401 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12402 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12403 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12404 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12405 | struct hif_config_info cfg; |
| 12406 | |
| 12407 | if (!scn) |
| 12408 | return; |
| 12409 | |
| 12410 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12411 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12412 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12413 | |
| 12414 | if (hdd_ctx->config->prevent_link_down) |
| 12415 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12416 | } |
| 12417 | |
| 12418 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12419 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12420 | * datapath |
| 12421 | * @hdd_ctx: HDD Context |
| 12422 | * |
| 12423 | * Return: 0 for success/errno for failure |
| 12424 | */ |
| 12425 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12426 | { |
| 12427 | struct cdp_config_params params; |
| 12428 | QDF_STATUS status; |
| 12429 | |
| 12430 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12431 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12432 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12433 | params.tx_flow_stop_queue_threshold = |
| 12434 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12435 | params.tx_flow_start_queue_offset = |
| 12436 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12437 | #endif |
| 12438 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12439 | params.napi_enable = hdd_ctx->napi_enable; |
| 12440 | params.tcp_udp_checksumoffload = |
| 12441 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12442 | |
| 12443 | status = cdp_update_config_parameters( |
| 12444 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12445 | ¶ms); |
| 12446 | if (status) { |
| 12447 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 12448 | "%s: Failed to attach config parameters", __func__); |
| 12449 | return status; |
| 12450 | } |
| 12451 | |
| 12452 | return 0; |
| 12453 | } |
| 12454 | |
| 12455 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12456 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12457 | * @hdd_ctx: HDD Context |
| 12458 | * |
| 12459 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12460 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12461 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12462 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12463 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12464 | int ret; |
| 12465 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12466 | hdd_update_ol_config(hdd_ctx); |
| 12467 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12468 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12469 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12470 | else |
| 12471 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12472 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12473 | |
| 12474 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12475 | } |
| 12476 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12477 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12478 | /** |
| 12479 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12480 | * @psoc_cfg: pmo psoc Configuration |
| 12481 | * @hdd_ctx: Pointer to hdd context |
| 12482 | * |
| 12483 | * Return: none |
| 12484 | */ |
| 12485 | static inline void hdd_ra_populate_pmo_config( |
| 12486 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12487 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12488 | { |
| 12489 | psoc_cfg->ra_ratelimit_interval = |
| 12490 | hdd_ctx->config->RArateLimitInterval; |
| 12491 | psoc_cfg->ra_ratelimit_enable = |
| 12492 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12493 | } |
| 12494 | #else |
| 12495 | static inline void hdd_ra_populate_pmo_config( |
| 12496 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12497 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12498 | { |
| 12499 | } |
| 12500 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12501 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12502 | /** |
| 12503 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12504 | * @hdd_ctx: HDD context |
| 12505 | * |
| 12506 | * Return: void |
| 12507 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12508 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12509 | { |
| 12510 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12511 | struct pmo_psoc_cfg psoc_cfg; |
| 12512 | QDF_STATUS status; |
| 12513 | |
| 12514 | /* |
| 12515 | * Value of hdd_ctx->wowEnable can be, |
| 12516 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12517 | * 1 - Enable magic pattern match on all interfaces. |
| 12518 | * 2 - Enable pattern byte match on all interfaces. |
| 12519 | * 3 - Enable both magic patter and pattern byte match on |
| 12520 | * all interfaces. |
| 12521 | */ |
| 12522 | psoc_cfg.magic_ptrn_enable = |
| 12523 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12524 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12525 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12526 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12527 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12528 | psoc_cfg.bpf_enable = |
| 12529 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12530 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12531 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12532 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12533 | if (hdd_ctx->config->fhostNSOffload) |
| 12534 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12535 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12536 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12537 | psoc_cfg.active_mode_offload = |
| 12538 | hdd_ctx->config->active_mode_offload; |
| 12539 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12540 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12541 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12542 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12543 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12544 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12545 | psoc_cfg.power_save_mode = |
| 12546 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12547 | psoc_cfg.auto_power_save_fail_mode = |
| 12548 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12549 | |
| 12550 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12551 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12552 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Rajeev Kumar | d1a7ac4 | 2017-11-08 14:54:22 -0800 | [diff] [blame] | 12553 | status = ucfg_pmo_update_psoc_config(psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12554 | if (status != QDF_STATUS_SUCCESS) { |
| 12555 | hdd_err("failed pmo psoc configuration"); |
| 12556 | return -EINVAL; |
| 12557 | } |
| 12558 | |
| 12559 | return 0; |
| 12560 | } |
| 12561 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12562 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12563 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12564 | struct hdd_config *cfg) |
| 12565 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12566 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12567 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12568 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12569 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12570 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12571 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12572 | pno_cfg->channel_prediction_full_scan = |
| 12573 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12574 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12575 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12576 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12577 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12578 | } |
| 12579 | #else |
| 12580 | static inline void |
| 12581 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12582 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12583 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12584 | } |
| 12585 | #endif |
| 12586 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12587 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12588 | struct hdd_config *cfg) |
| 12589 | { |
| 12590 | uint8_t i = 0; |
| 12591 | |
| 12592 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12593 | if (!ie_whitelist->white_list) |
| 12594 | return; |
| 12595 | |
| 12596 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12597 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12598 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12599 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12600 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12601 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12602 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12603 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12604 | |
| 12605 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12606 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12607 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12608 | } |
| 12609 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12610 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12611 | { |
| 12612 | uint8_t i, score; |
| 12613 | |
| 12614 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12615 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12616 | if (score > MAX_INDEX_SCORE) |
| 12617 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12618 | MAX_INDEX_SCORE, i); |
| 12619 | } |
| 12620 | |
| 12621 | return per_index_score; |
| 12622 | } |
| 12623 | |
| 12624 | /** |
| 12625 | * hdd_update_score_config - API to update candidate scoring related params |
| 12626 | * configuration parameters |
| 12627 | * @score_config: score config to update |
| 12628 | * @cfg: config params |
| 12629 | * |
| 12630 | * Return: 0 if success else err |
| 12631 | */ |
| 12632 | static void hdd_update_score_config( |
| 12633 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12634 | { |
| 12635 | int total_weight; |
| 12636 | |
| 12637 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12638 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12639 | score_config->weight_cfg.vht_caps_weightage = |
| 12640 | cfg->vht_caps_weightage; |
| 12641 | score_config->weight_cfg.he_caps_weightage = |
| 12642 | cfg->he_caps_weightage; |
| 12643 | score_config->weight_cfg.chan_width_weightage = |
| 12644 | cfg->chan_width_weightage; |
| 12645 | score_config->weight_cfg.chan_band_weightage = |
| 12646 | cfg->chan_band_weightage; |
| 12647 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12648 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12649 | cfg->beamforming_cap_weightage; |
| 12650 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12651 | score_config->weight_cfg.channel_congestion_weightage = |
| 12652 | cfg->channel_congestion_weightage; |
| 12653 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12654 | |
| 12655 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12656 | score_config->weight_cfg.ht_caps_weightage + |
| 12657 | score_config->weight_cfg.vht_caps_weightage + |
| 12658 | score_config->weight_cfg.he_caps_weightage + |
| 12659 | score_config->weight_cfg.chan_width_weightage + |
| 12660 | score_config->weight_cfg.chan_band_weightage + |
| 12661 | score_config->weight_cfg.nss_weightage + |
| 12662 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12663 | score_config->weight_cfg.pcl_weightage + |
| 12664 | score_config->weight_cfg.channel_congestion_weightage + |
| 12665 | score_config->weight_cfg.oce_wan_weightage; |
| 12666 | |
| 12667 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12668 | hdd_err("total weight is greater than %d fallback to default values", |
| 12669 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12670 | |
| 12671 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12672 | score_config->weight_cfg.ht_caps_weightage = |
| 12673 | HT_CAPABILITY_WEIGHTAGE; |
| 12674 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12675 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12676 | score_config->weight_cfg.chan_width_weightage = |
| 12677 | CHAN_WIDTH_WEIGHTAGE; |
| 12678 | score_config->weight_cfg.chan_band_weightage = |
| 12679 | CHAN_BAND_WEIGHTAGE; |
| 12680 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12681 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12682 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12683 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12684 | score_config->weight_cfg.channel_congestion_weightage = |
| 12685 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12686 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12687 | } |
| 12688 | |
| 12689 | score_config->bandwidth_weight_per_index = |
| 12690 | hdd_limit_max_per_index_score( |
| 12691 | cfg->bandwidth_weight_per_index); |
| 12692 | score_config->nss_weight_per_index = |
| 12693 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12694 | score_config->band_weight_per_index = |
| 12695 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12696 | |
| 12697 | score_config->rssi_score.best_rssi_threshold = |
| 12698 | cfg->best_rssi_threshold; |
| 12699 | score_config->rssi_score.good_rssi_threshold = |
| 12700 | cfg->good_rssi_threshold; |
| 12701 | score_config->rssi_score.bad_rssi_threshold = |
| 12702 | cfg->bad_rssi_threshold; |
| 12703 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12704 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12705 | score_config->rssi_score.good_rssi_bucket_size = |
| 12706 | cfg->good_rssi_bucket_size; |
| 12707 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12708 | cfg->bad_rssi_bucket_size; |
| 12709 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12710 | cfg->rssi_pref_5g_rssi_thresh; |
| 12711 | |
| 12712 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12713 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12714 | hdd_limit_max_per_index_score( |
| 12715 | cfg->esp_qbss_score_slots3_to_0); |
| 12716 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12717 | hdd_limit_max_per_index_score( |
| 12718 | cfg->esp_qbss_score_slots7_to_4); |
| 12719 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12720 | hdd_limit_max_per_index_score( |
| 12721 | cfg->esp_qbss_score_slots11_to_8); |
| 12722 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12723 | hdd_limit_max_per_index_score( |
| 12724 | cfg->esp_qbss_score_slots15_to_12); |
| 12725 | |
| 12726 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12727 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12728 | hdd_limit_max_per_index_score( |
| 12729 | cfg->oce_wan_score_slots3_to_0); |
| 12730 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12731 | hdd_limit_max_per_index_score( |
| 12732 | cfg->oce_wan_score_slots7_to_4); |
| 12733 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12734 | hdd_limit_max_per_index_score( |
| 12735 | cfg->oce_wan_score_slots11_to_8); |
| 12736 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12737 | hdd_limit_max_per_index_score( |
| 12738 | cfg->oce_wan_score_slots15_to_12); |
| 12739 | |
| 12740 | |
| 12741 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12742 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12743 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12744 | |
| 12745 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12746 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12747 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12748 | score_config->he_cap = 1; |
| 12749 | |
| 12750 | if (score_config->he_cap || |
| 12751 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12752 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12753 | score_config->vht_cap = 1; |
| 12754 | |
| 12755 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12756 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12757 | score_config->ht_cap = 1; |
| 12758 | |
| 12759 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12760 | score_config->vht_24G_cap = 1; |
| 12761 | |
| 12762 | if (cfg->enableTxBF) |
| 12763 | score_config->beamformee_cap = 1; |
| 12764 | |
| 12765 | } |
| 12766 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12767 | /** |
| 12768 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12769 | * @hdd_ctx: HDD context |
| 12770 | * |
| 12771 | * Return: 0 if success else err |
| 12772 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12773 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12774 | { |
| 12775 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12776 | struct scan_user_cfg scan_cfg; |
| 12777 | struct hdd_config *cfg = hdd_ctx->config; |
| 12778 | QDF_STATUS status; |
| 12779 | |
| 12780 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12781 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12782 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12783 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12784 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12785 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12786 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12787 | /* convert to ms */ |
| 12788 | scan_cfg.scan_cache_aging_time = |
| 12789 | cfg->scanAgingTimeout * 1000; |
| 12790 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12791 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12792 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12793 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12794 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12795 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12796 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12797 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12798 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12799 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12800 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12801 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12802 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12803 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12804 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12805 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12806 | if (status != QDF_STATUS_SUCCESS) { |
| 12807 | hdd_err("failed pmo psoc configuration"); |
| 12808 | return -EINVAL; |
| 12809 | } |
| 12810 | |
| 12811 | return 0; |
| 12812 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12813 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12814 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12815 | { |
| 12816 | int ret; |
| 12817 | |
| 12818 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12819 | if (ret) |
| 12820 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12821 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12822 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12823 | if (ret) |
| 12824 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12825 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12826 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12827 | if (ret) |
| 12828 | return ret; |
| 12829 | |
| 12830 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12831 | |
| 12832 | return ret; |
| 12833 | } |
| 12834 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12835 | /** |
| 12836 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12837 | * @mode : cfg80211 DFS mode |
| 12838 | * |
| 12839 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12840 | */ |
| 12841 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12842 | { |
| 12843 | switch (mode) { |
| 12844 | case DFS_MODE_ENABLE: |
| 12845 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12846 | case DFS_MODE_DISABLE: |
| 12847 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12848 | case DFS_MODE_DEPRIORITIZE: |
| 12849 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12850 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12851 | hdd_debug("ACS dfs mode is NONE"); |
| 12852 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12853 | } |
| 12854 | } |
| 12855 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12856 | /** |
| 12857 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12858 | * @hddctx: pointer to hdd context |
| 12859 | * @set_value: enable/disable |
| 12860 | * |
| 12861 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12862 | * Host(even though it is duplicate). When Host send vendor command |
| 12863 | * disable,FW doesn't perform any action. Whenever any change in |
| 12864 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12865 | * |
| 12866 | * return - 0 on success, appropriate error values on failure. |
| 12867 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12868 | 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] | 12869 | { |
| 12870 | QDF_STATUS status; |
| 12871 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12872 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12873 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12874 | |
| 12875 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12876 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12877 | return -EINVAL; |
| 12878 | } |
| 12879 | |
| 12880 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12881 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12882 | hdd_err("Failed to send chan avoid command to SME"); |
| 12883 | return -EINVAL; |
| 12884 | } |
| 12885 | return 0; |
| 12886 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12887 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12888 | /** |
| 12889 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12890 | * @value: value to set |
| 12891 | * |
| 12892 | * This function will set the passed value to roaming in progress flag. |
| 12893 | * |
| 12894 | * Return: None |
| 12895 | */ |
| 12896 | void hdd_set_roaming_in_progress(bool value) |
| 12897 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12898 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12899 | |
| 12900 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12901 | if (!hdd_ctx) { |
| 12902 | hdd_err("HDD context is NULL"); |
| 12903 | return; |
| 12904 | } |
| 12905 | |
| 12906 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12907 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12908 | } |
| 12909 | |
| 12910 | /** |
| 12911 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12912 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12913 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12914 | * 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] | 12915 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12916 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12917 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12918 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12919 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12920 | |
| 12921 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12922 | if (!hdd_ctx) { |
| 12923 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12924 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12925 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12926 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12927 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12928 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12929 | hdd_ctx->roaming_in_progress); |
| 12930 | |
| 12931 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12932 | } |
| 12933 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12934 | /** |
| 12935 | * hdd_is_connection_in_progress() - check if connection is in |
| 12936 | * progress |
| 12937 | * @session_id: session id |
| 12938 | * @reason: scan reject reason |
| 12939 | * |
| 12940 | * Go through each adapter and check if Connection is in progress |
| 12941 | * |
| 12942 | * Return: true if connection is in progress else false |
| 12943 | */ |
| 12944 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12945 | enum scan_reject_states *reason) |
| 12946 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12947 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12948 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12949 | uint8_t sta_id = 0; |
| 12950 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12951 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12952 | |
| 12953 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12954 | if (!hdd_ctx) { |
| 12955 | hdd_err("HDD context is NULL"); |
| 12956 | return false; |
| 12957 | } |
| 12958 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12959 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12960 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12961 | hdd_device_mode_to_string(adapter->device_mode), |
| 12962 | adapter->device_mode); |
| 12963 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12964 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12965 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12966 | && (eConnectionState_Connecting == |
| 12967 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12968 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12969 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12970 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12971 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12972 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12973 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12974 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12975 | } |
| 12976 | return true; |
| 12977 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12978 | /* |
| 12979 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12980 | * hdd_is_roaming_in_progress is for LFR3 |
| 12981 | */ |
| 12982 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12983 | sme_neighbor_middle_of_roaming( |
| 12984 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12985 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12986 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12987 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12988 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12989 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12990 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12991 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12992 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12993 | } |
| 12994 | return true; |
| 12995 | } |
| 12996 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12997 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12998 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12999 | hdd_sta_ctx = |
| 13000 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13001 | if ((eConnectionState_Associated == |
| 13002 | hdd_sta_ctx->conn_info.connState) |
| 13003 | && (false == |
| 13004 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 13005 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13006 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13007 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13008 | " is in middle of WPS/EAPOL exchange.", |
| 13009 | MAC_ADDR_ARRAY(sta_mac)); |
| 13010 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13011 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13012 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13013 | } |
| 13014 | return true; |
| 13015 | } |
| 13016 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13017 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13018 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13019 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13020 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13021 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13022 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13023 | continue; |
| 13024 | |
| 13025 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13026 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13027 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13028 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13029 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13030 | MAC_ADDR_ARRAY(sta_mac)); |
| 13031 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13032 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13033 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13034 | } |
| 13035 | return true; |
| 13036 | } |
| 13037 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13038 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13039 | return true; |
| 13040 | } |
| 13041 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13042 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13043 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13044 | return false; |
| 13045 | } |
| 13046 | |
| 13047 | /** |
| 13048 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13049 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13050 | * |
| 13051 | * Return: None |
| 13052 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13053 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13054 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13055 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13056 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13057 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13058 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13059 | tsap_Config_t *sap_config; |
| 13060 | void *sap_ctx; |
| 13061 | |
| 13062 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13063 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13064 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13065 | |
| 13066 | mutex_lock(&hdd_ctx->sap_lock); |
| 13067 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13068 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13069 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13070 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13071 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13072 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13073 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13074 | qdf_stop_bss_event, |
| 13075 | SME_CMD_TIMEOUT_VALUE); |
| 13076 | |
| 13077 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13078 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13079 | goto end; |
| 13080 | } |
| 13081 | } |
| 13082 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13083 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13084 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13085 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13086 | |
| 13087 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13088 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13089 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13090 | eUPDATE_IE_ALL); |
| 13091 | goto end; |
| 13092 | } |
| 13093 | |
| 13094 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13095 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13096 | sap_config, |
| 13097 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13098 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13099 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13100 | eUPDATE_IE_ALL); |
| 13101 | goto end; |
| 13102 | } |
| 13103 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13104 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13105 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13106 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13107 | SME_CMD_TIMEOUT_VALUE); |
| 13108 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13109 | eUPDATE_IE_ALL); |
| 13110 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13111 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13112 | goto end; |
| 13113 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13114 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13115 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 13116 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13117 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13118 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13119 | ap_adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13120 | } |
| 13121 | end: |
| 13122 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13123 | } |
| 13124 | |
| 13125 | /** |
| 13126 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13127 | * with non dfs acs |
| 13128 | * |
| 13129 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13130 | * |
| 13131 | * Return: None |
| 13132 | */ |
| 13133 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13134 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13135 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13136 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13137 | cds_context_type *cds_ctx; |
| 13138 | |
| 13139 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13140 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13141 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13142 | return; |
| 13143 | } |
| 13144 | |
| 13145 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13146 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13147 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13148 | return; |
| 13149 | } |
| 13150 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13151 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13152 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13153 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13154 | return; |
| 13155 | } |
| 13156 | |
| 13157 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13158 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13159 | &ap_adapter->event_flags) && |
| 13160 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13161 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13162 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13163 | 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] | 13164 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13165 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13166 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13167 | acs_cfg.acs_mode = true; |
| 13168 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13169 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13170 | } |
| 13171 | } |
| 13172 | |
| 13173 | /** |
| 13174 | * hdd_set_connection_in_progress() - to set the connection in |
| 13175 | * progress flag |
| 13176 | * @value: value to set |
| 13177 | * |
| 13178 | * This function will set the passed value to connection in progress flag. |
| 13179 | * If value is previously being set to true then no need to set it again. |
| 13180 | * |
| 13181 | * Return: true if value is being set correctly and false otherwise. |
| 13182 | */ |
| 13183 | bool hdd_set_connection_in_progress(bool value) |
| 13184 | { |
| 13185 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13186 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13187 | |
| 13188 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13189 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13190 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13191 | return false; |
| 13192 | } |
| 13193 | |
| 13194 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13195 | /* |
| 13196 | * if the value is set to true previously and if someone is |
| 13197 | * trying to make it true again then it could be some race |
| 13198 | * condition being triggered. Avoid this situation by returning |
| 13199 | * false |
| 13200 | */ |
| 13201 | if (hdd_ctx->connection_in_progress && value) |
| 13202 | status = false; |
| 13203 | else |
| 13204 | hdd_ctx->connection_in_progress = value; |
| 13205 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13206 | return status; |
| 13207 | } |
| 13208 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13209 | 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] | 13210 | { |
| 13211 | if (!adapter) { |
| 13212 | hdd_err("Invalid adapter"); |
| 13213 | return -EINVAL; |
| 13214 | } |
| 13215 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13216 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13217 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13218 | set_value, VDEV_CMD); |
| 13219 | return 0; |
| 13220 | |
| 13221 | } |
| 13222 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13223 | 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] | 13224 | { |
| 13225 | if (!adapter) { |
| 13226 | hdd_err("Invalid adapter"); |
| 13227 | return -EINVAL; |
| 13228 | } |
| 13229 | |
| 13230 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13231 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13232 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13233 | set_value, VDEV_CMD); |
| 13234 | return 0; |
| 13235 | } |
| 13236 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13237 | 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] | 13238 | *psoc, uint8_t vdev_id) |
| 13239 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13240 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13241 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13242 | |
| 13243 | /* |
| 13244 | * Currently PSOC is not being used. But this logic will |
| 13245 | * change once we have the converged implementation of |
| 13246 | * HDD context per PSOC in place. This would break if |
| 13247 | * multiple vdev objects reuse the vdev id. |
| 13248 | */ |
| 13249 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13250 | if (!adapter) |
| 13251 | hdd_err("Get adapter by vdev id failed"); |
| 13252 | |
| 13253 | return adapter; |
| 13254 | } |
| 13255 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13256 | 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] | 13257 | int8_t *rssi, int8_t *snr) |
| 13258 | { |
| 13259 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 13260 | struct hdd_wext_state *wext_state = |
| 13261 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13262 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 13263 | |
| 13264 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 13265 | profile, bssid, rssi, snr); |
| 13266 | if (QDF_STATUS_SUCCESS != status) { |
| 13267 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13268 | return -EINVAL; |
| 13269 | } |
| 13270 | |
| 13271 | return 0; |
| 13272 | } |
| 13273 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13274 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13275 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13276 | * @adapter - HDD adapter |
| 13277 | * @tos - type of service |
| 13278 | * @status - status of the traffic |
| 13279 | * |
| 13280 | * Return: 0 on success and non zero value on failure |
| 13281 | */ |
| 13282 | |
| 13283 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13284 | bool is_tos_active) |
| 13285 | { |
| 13286 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13287 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13288 | uint32_t max_off_chan_time = 0; |
| 13289 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13290 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13291 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13292 | |
| 13293 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13294 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13295 | |
| 13296 | if (ret < 0) { |
| 13297 | hdd_err("failed to set limit off chan params"); |
| 13298 | return ret; |
| 13299 | } |
| 13300 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13301 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13302 | |
| 13303 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13304 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13305 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13306 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13307 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13308 | if (adapter->active_ac) { |
| 13309 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13310 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13311 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13312 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13313 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13314 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13315 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13316 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13317 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13318 | PM_LATENCY); |
| 13319 | } else { |
| 13320 | /*ignore this command if only BE/BK is active */ |
| 13321 | is_tos_active = false; |
| 13322 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13323 | hdd_ctx->config->conc_system_pref); |
| 13324 | } |
| 13325 | } else { |
| 13326 | /* No active tos */ |
| 13327 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13328 | hdd_ctx->config->conc_system_pref); |
| 13329 | } |
| 13330 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13331 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13332 | is_tos_active, max_off_chan_time, |
| 13333 | hdd_ctx->config->nRestTimeConc, true); |
| 13334 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13335 | hdd_err("failed to set limit off chan params"); |
| 13336 | ret = -EINVAL; |
| 13337 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13338 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13339 | return ret; |
| 13340 | } |
| 13341 | |
| 13342 | /** |
| 13343 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13344 | * @adapter - HDD adapter |
| 13345 | * |
| 13346 | * Return: 0 on success and non zero value on failure |
| 13347 | */ |
| 13348 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13349 | { |
| 13350 | struct hdd_context *hdd_ctx; |
| 13351 | int ret; |
| 13352 | QDF_STATUS status; |
| 13353 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13354 | |
| 13355 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13356 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13357 | if (ret < 0) |
| 13358 | return ret; |
| 13359 | |
| 13360 | /* set the system preferece to default */ |
| 13361 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13362 | hdd_ctx->config->conc_system_pref); |
| 13363 | |
| 13364 | /* clear the bitmap */ |
| 13365 | adapter->active_ac = 0; |
| 13366 | |
| 13367 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13368 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13369 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13370 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13371 | false, 0, 0, false); |
| 13372 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13373 | hdd_err("failed to reset limit off chan params"); |
| 13374 | ret = -EINVAL; |
| 13375 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13376 | |
| 13377 | return ret; |
| 13378 | } |
| 13379 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13380 | /** |
| 13381 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13382 | * @drv_op: Enum indicating driver op |
| 13383 | * |
| 13384 | * Return: none |
| 13385 | */ |
| 13386 | void hdd_start_driver_ops_timer(int drv_op) |
| 13387 | { |
| 13388 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13389 | switch (drv_op) { |
| 13390 | case eHDD_DRV_OP_PROBE: |
| 13391 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13392 | break; |
| 13393 | case eHDD_DRV_OP_REMOVE: |
| 13394 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13395 | break; |
| 13396 | case eHDD_DRV_OP_SHUTDOWN: |
| 13397 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13398 | break; |
| 13399 | case eHDD_DRV_OP_REINIT: |
| 13400 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13401 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13402 | case eHDD_DRV_OP_IFF_UP: |
| 13403 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13404 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13405 | } |
| 13406 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13407 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13408 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13409 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13410 | } |
| 13411 | |
| 13412 | /** |
| 13413 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13414 | * |
| 13415 | * Return: none |
| 13416 | */ |
| 13417 | void hdd_stop_driver_ops_timer(void) |
| 13418 | { |
| 13419 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13420 | } |
| 13421 | |
| 13422 | /** |
| 13423 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13424 | * inactivity timer |
| 13425 | * |
| 13426 | * Return: None |
| 13427 | */ |
| 13428 | void hdd_drv_ops_inactivity_handler(void) |
| 13429 | { |
| 13430 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13431 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13432 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13433 | if (hdd_drv_ops_task) { |
| 13434 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13435 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13436 | } else { |
| 13437 | hdd_err("hdd_drv_ops_task is null"); |
| 13438 | } |
| 13439 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13440 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13441 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13442 | sizeof("shutdown"))) |
| 13443 | QDF_BUG(0); |
| 13444 | |
| 13445 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13446 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13447 | else |
| 13448 | QDF_BUG(0); |
| 13449 | } |
| 13450 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13451 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13452 | { |
| 13453 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13454 | |
| 13455 | if (!hdd_ctx) |
| 13456 | return; |
| 13457 | |
| 13458 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13459 | } |
| 13460 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13461 | /** |
| 13462 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13463 | * @struct hdd_context *hdd_ctx |
| 13464 | * @struct hdd_adapter *padapter |
| 13465 | * @bool enble |
| 13466 | * |
| 13467 | * Return: none |
| 13468 | */ |
| 13469 | void hdd_set_rx_mode_rps(bool enable) |
| 13470 | { |
| 13471 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13472 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13473 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13474 | |
| 13475 | if (adapter && hdd_ctx && |
| 13476 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13477 | if (enable && !cds_cfg->rps_enabled) |
| 13478 | hdd_send_rps_ind(adapter); |
| 13479 | else if (!enable && cds_cfg->rps_enabled) |
| 13480 | hdd_send_rps_disable_ind(adapter); |
| 13481 | } |
| 13482 | } |
| 13483 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13484 | /* Register the module init/exit functions */ |
| 13485 | module_init(hdd_module_init); |
| 13486 | module_exit(hdd_module_exit); |
| 13487 | |
| 13488 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13489 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13490 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13491 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13492 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13493 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13494 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13495 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13496 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13497 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13498 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13499 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13500 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13501 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13502 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13503 | |
| 13504 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13505 | |
| 13506 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13507 | |
| 13508 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |