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 | /** |
| 376 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 377 | * @adapter: HDD adapter |
| 378 | * @chan_number: Channel number |
| 379 | * @chan_bw: Bandwidth |
| 380 | * |
| 381 | * Checks if the given bandwidth is valid for the given channel number. |
| 382 | * |
| 383 | * Return: 0 for success, non-zero for failure |
| 384 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 385 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 386 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 387 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 388 | { |
| 389 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 390 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 391 | bool found = false; |
| 392 | tHalHandle hal; |
| 393 | |
| 394 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 395 | if (!hal) { |
| 396 | hdd_err("Invalid HAL context"); |
| 397 | return -EINVAL; |
| 398 | } |
| 399 | |
| 400 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 401 | hdd_err("No valid channel list"); |
| 402 | return -EOPNOTSUPP; |
| 403 | } |
| 404 | |
| 405 | for (i = 0; i < len; i++) { |
| 406 | if (chan[i] == chan_number) { |
| 407 | found = true; |
| 408 | break; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | if (found == false) { |
| 413 | hdd_err("Channel not in driver's valid channel list"); |
| 414 | return -EOPNOTSUPP; |
| 415 | } |
| 416 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 417 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 418 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 419 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 420 | return -EINVAL; |
| 421 | } |
| 422 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 423 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 424 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 425 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 426 | return -EINVAL; |
| 427 | } |
| 428 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 429 | (chan_bw != CH_WIDTH_MAX)) { |
| 430 | hdd_err("Only BW20 possible on channel 14"); |
| 431 | return -EINVAL; |
| 432 | } |
| 433 | } |
| 434 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 435 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 436 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 437 | (chan_bw != CH_WIDTH_MAX)) { |
| 438 | hdd_err("Only BW20 possible on channel 165"); |
| 439 | return -EINVAL; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | return 0; |
| 444 | } |
| 445 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 446 | /** |
| 447 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 448 | * |
| 449 | * Block the unloading of the driver (or) interface up until the |
| 450 | * cds recovery is completed |
| 451 | * |
| 452 | * Return: true for recovery completion else false |
| 453 | */ |
| 454 | static bool hdd_wait_for_recovery_completion(void) |
| 455 | { |
| 456 | int retry = 0; |
| 457 | |
| 458 | /* Wait for recovery to complete */ |
| 459 | while (cds_is_driver_recovering()) { |
| 460 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 461 | hdd_err("Recovery in progress; wait here!!!"); |
| 462 | msleep(1000); |
| 463 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 464 | hdd_err("SSR never completed, error"); |
| 465 | /* |
| 466 | * Trigger the bug_on in the internal builds, in the |
| 467 | * customer builds self-recovery will be enabled |
| 468 | * in those cases just return error. |
| 469 | */ |
| 470 | if (cds_is_self_recovery_enabled()) |
| 471 | return false; |
| 472 | QDF_BUG(0); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | hdd_info("Recovery completed successfully!"); |
| 477 | return true; |
| 478 | } |
| 479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 480 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 481 | unsigned long state, void *data) |
| 482 | { |
| 483 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 484 | struct netdev_notifier_info *dev_notif_info = data; |
| 485 | struct net_device *dev = dev_notif_info->dev; |
| 486 | #else |
| 487 | struct net_device *dev = data; |
| 488 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 489 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 490 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 491 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 492 | ENTER_DEV(dev); |
| 493 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | /* Make sure that this callback corresponds to our device. */ |
| 495 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 496 | return NOTIFY_DONE; |
| 497 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 498 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 499 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 500 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 501 | return NOTIFY_DONE; |
| 502 | } |
| 503 | |
| 504 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 505 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 506 | return NOTIFY_DONE; |
| 507 | } |
| 508 | |
| 509 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 510 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 511 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 512 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 513 | return NOTIFY_DONE; |
| 514 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 515 | |
| 516 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 517 | hdd_err("%s: Driver module is closed", __func__); |
| 518 | return NOTIFY_DONE; |
| 519 | } |
| 520 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 521 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 522 | return NOTIFY_DONE; |
| 523 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 524 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 525 | dev->name, state); |
| 526 | |
| 527 | switch (state) { |
| 528 | case NETDEV_REGISTER: |
| 529 | break; |
| 530 | |
| 531 | case NETDEV_UNREGISTER: |
| 532 | break; |
| 533 | |
| 534 | case NETDEV_UP: |
| 535 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 536 | break; |
| 537 | |
| 538 | case NETDEV_DOWN: |
| 539 | break; |
| 540 | |
| 541 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 542 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 543 | complete(&adapter->linkup_event_var); |
| 544 | break; |
| 545 | |
| 546 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 547 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 548 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 549 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 550 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 551 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 552 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 553 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 554 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 555 | /* |
| 556 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 557 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 558 | * flag after which driver does not send the cfg80211_scan_done. |
| 559 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 560 | */ |
| 561 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | break; |
| 563 | |
| 564 | default: |
| 565 | break; |
| 566 | } |
| 567 | |
| 568 | return NOTIFY_DONE; |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 573 | * @nb: pointer to notifier block |
| 574 | * @state: state |
| 575 | * @ndev: ndev pointer |
| 576 | * |
| 577 | * Return: 0 on success, error number otherwise. |
| 578 | */ |
| 579 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 580 | unsigned long state, |
| 581 | void *ndev) |
| 582 | { |
| 583 | int ret; |
| 584 | |
| 585 | cds_ssr_protect(__func__); |
| 586 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 587 | cds_ssr_unprotect(__func__); |
| 588 | |
| 589 | return ret; |
| 590 | } |
| 591 | |
| 592 | struct notifier_block hdd_netdev_notifier = { |
| 593 | .notifier_call = hdd_netdev_notifier_call, |
| 594 | }; |
| 595 | |
| 596 | /* variable to hold the insmod parameters */ |
| 597 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 598 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 599 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 600 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 601 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 602 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 603 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 605 | /** |
| 606 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 607 | * @ch_width: NL channel width |
| 608 | * |
| 609 | * Converts the NL channel width to the driver's internal representation |
| 610 | * |
| 611 | * Return: Converted channel width. In case of non matching NL channel width, |
| 612 | * CH_WIDTH_MAX will be returned. |
| 613 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 614 | 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] | 615 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 616 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 617 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 618 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 619 | switch (ch_width) { |
| 620 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 621 | case NL80211_CHAN_WIDTH_20: |
| 622 | return CH_WIDTH_20MHZ; |
| 623 | case NL80211_CHAN_WIDTH_40: |
| 624 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 625 | case NL80211_CHAN_WIDTH_80: |
| 626 | return CH_WIDTH_80MHZ; |
| 627 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 628 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 629 | return CH_WIDTH_80P80MHZ; |
| 630 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 631 | return CH_WIDTH_160MHZ; |
| 632 | else |
| 633 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 634 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 635 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 636 | return CH_WIDTH_160MHZ; |
| 637 | else |
| 638 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 639 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 640 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 641 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 642 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 643 | default: |
| 644 | hdd_err("Invalid channel width %d, setting to default", |
| 645 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 646 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 647 | } |
| 648 | } |
| 649 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 650 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 651 | * @hal: handler to HAL |
| 652 | * @channel: channel id |
| 653 | * @bw_offset: bandwidth offset |
| 654 | * |
| 655 | * Function invokes sme api to find the operating class |
| 656 | * |
| 657 | * Return: operating class |
| 658 | */ |
| 659 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 660 | uint8_t bw_offset) |
| 661 | { |
| 662 | uint8_t opclass = 0; |
| 663 | |
| 664 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 665 | return opclass; |
| 666 | } |
| 667 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 668 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 669 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 670 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 671 | * @bitmask: Bitmask of log levels to be enabled |
| 672 | * |
| 673 | * Called immediately after the cfg.ini is read in order to configure |
| 674 | * the desired trace levels. |
| 675 | * |
| 676 | * Return: None |
| 677 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 678 | 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] | 679 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 680 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 681 | int qdf_print_idx = -1; |
| 682 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 683 | /* |
| 684 | * if the bitmask is the default value, then a bitmask was not |
| 685 | * specified in cfg.ini, so leave the logging level alone (it |
| 686 | * will remain at the "compiled in" default value) |
| 687 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 688 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 689 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 690 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 691 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 692 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 693 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 694 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 695 | QDF_TRACE_LEVEL_NONE, 0); |
| 696 | |
| 697 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 698 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 700 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 701 | while (0 != bitmask) { |
| 702 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 703 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 704 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 705 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 706 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 707 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 708 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 709 | level++; |
| 710 | bitmask >>= 1; |
| 711 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 712 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 716 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 717 | * @hdd_ctx: HDD context pointer |
| 718 | * |
| 719 | * Return: 0 if the context is valid. Error code otherwise |
| 720 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 721 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 722 | { |
| 723 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 724 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 725 | return -ENODEV; |
| 726 | } |
| 727 | |
| 728 | if (cds_is_driver_recovering()) { |
| 729 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 730 | (void *)_RET_IP_, cds_get_driver_state()); |
| 731 | return -EAGAIN; |
| 732 | } |
| 733 | |
| 734 | if (hdd_ctx->start_modules_in_progress || |
| 735 | hdd_ctx->stop_modules_in_progress) { |
| 736 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 737 | (void *)_RET_IP_); |
| 738 | return -EAGAIN; |
| 739 | } |
| 740 | |
| 741 | return 0; |
| 742 | } |
| 743 | |
| 744 | |
| 745 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 746 | * wlan_hdd_validate_context() - check the HDD context |
| 747 | * @hdd_ctx: HDD context pointer |
| 748 | * |
| 749 | * Return: 0 if the context is valid. Error code otherwise |
| 750 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 751 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 752 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 754 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 755 | return -ENODEV; |
| 756 | } |
| 757 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 758 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 759 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 760 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 761 | return -EAGAIN; |
| 762 | } |
| 763 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 764 | if (cds_is_load_or_unload_in_progress()) { |
| 765 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 766 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 768 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 769 | |
| 770 | if (hdd_ctx->start_modules_in_progress || |
| 771 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 772 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 773 | (void *)_RET_IP_); |
| 774 | return -EAGAIN; |
| 775 | } |
| 776 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 777 | if (cds_is_driver_in_bad_state()) { |
| 778 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 779 | (void *)_RET_IP_, cds_get_driver_state()); |
| 780 | return -ENODEV; |
| 781 | } |
| 782 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | return 0; |
| 784 | } |
| 785 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 786 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 787 | { |
| 788 | if (!adapter) { |
| 789 | hdd_err("adapter is null"); |
| 790 | return -EINVAL; |
| 791 | } |
| 792 | |
| 793 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 794 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 795 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 796 | return -EINVAL; |
| 797 | } |
| 798 | |
| 799 | if (!adapter->dev) { |
| 800 | hdd_err("adapter net_device is null"); |
| 801 | return -EINVAL; |
| 802 | } |
| 803 | |
| 804 | if (!(adapter->dev->flags & IFF_UP)) { |
| 805 | hdd_info("adapter net_device is not up"); |
| 806 | return -EAGAIN; |
| 807 | } |
| 808 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 809 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 810 | hdd_info("adapter session is not open"); |
| 811 | return -EAGAIN; |
| 812 | } |
| 813 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 814 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 815 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 816 | return -EINVAL; |
| 817 | } |
| 818 | |
| 819 | return 0; |
| 820 | } |
| 821 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 823 | * wlan_hdd_validate_modules_state() - Check modules status |
| 824 | * @hdd_ctx: HDD context pointer |
| 825 | * |
| 826 | * Check's the driver module's state and returns true if the |
| 827 | * modules are enabled returns false if modules are closed. |
| 828 | * |
| 829 | * Return: True if modules are enabled or false. |
| 830 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 831 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 832 | { |
| 833 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 834 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 835 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 836 | hdd_notice("Modules not enabled, Present status: %d", |
| 837 | hdd_ctx->driver_status); |
| 838 | return false; |
| 839 | } |
| 840 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 841 | return true; |
| 842 | } |
| 843 | |
| 844 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | * 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] | 846 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | * |
| 848 | * This function sets the IBSS power save config parameters to WMA |
| 849 | * which will send it to firmware if FW supports IBSS power save |
| 850 | * before vdev start. |
| 851 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 852 | * 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] | 853 | * on failure. |
| 854 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 855 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 856 | { |
| 857 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 858 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | |
| 860 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 861 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 862 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | } |
| 864 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 865 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 867 | hdd_ctx->config->ibssATIMWinSize, |
| 868 | VDEV_CMD); |
| 869 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 870 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 871 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 872 | } |
| 873 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 874 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 875 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 876 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 877 | VDEV_CMD); |
| 878 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 879 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 880 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 881 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 882 | } |
| 883 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 884 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 885 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 886 | hdd_ctx->config-> |
| 887 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 888 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 889 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 890 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 891 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 892 | } |
| 893 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 894 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 895 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 896 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 897 | VDEV_CMD); |
| 898 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 899 | 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] | 900 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 901 | } |
| 902 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 903 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 904 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 905 | hdd_ctx->config->ibssInactivityCount, |
| 906 | VDEV_CMD); |
| 907 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 908 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 909 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 910 | } |
| 911 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 912 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 913 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 914 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 915 | VDEV_CMD); |
| 916 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 917 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 918 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 919 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | } |
| 921 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 922 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 923 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 924 | hdd_ctx->config->ibssPsWarmupTime, |
| 925 | VDEV_CMD); |
| 926 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 927 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 928 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 929 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 930 | } |
| 931 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 932 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 933 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 934 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 935 | VDEV_CMD); |
| 936 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 937 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 938 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 939 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 940 | } |
| 941 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 942 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 943 | } |
| 944 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 945 | #ifdef FEATURE_RUNTIME_PM |
| 946 | /** |
| 947 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 948 | * @hdd_ctx: HDD context |
| 949 | * |
| 950 | * Return: None |
| 951 | */ |
| 952 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 953 | { |
| 954 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 955 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 956 | qdf_runtime_lock_init(&ctx->dfs); |
| 957 | |
| 958 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 959 | } |
| 960 | |
| 961 | /** |
| 962 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 963 | * @hdd_ctx: HDD Context |
| 964 | * |
| 965 | * Return: None |
| 966 | */ |
| 967 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 968 | { |
| 969 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 970 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 971 | qdf_runtime_lock_deinit(&ctx->dfs); |
| 972 | |
| 973 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 974 | } |
| 975 | |
| 976 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
| 977 | { |
| 978 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 979 | |
| 980 | qdf_runtime_lock_init(&ctx->connect); |
| 981 | } |
| 982 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 983 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 984 | { |
| 985 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 986 | |
| 987 | qdf_runtime_lock_deinit(&ctx->connect); |
| 988 | } |
| 989 | #else /* FEATURE_RUNTIME_PM */ |
| 990 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 991 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
| 992 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 993 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 994 | #endif /* FEATURE_RUNTIME_PM */ |
| 995 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 996 | #define INTF_MACADDR_MASK 0x7 |
| 997 | |
| 998 | /** |
| 999 | * hdd_update_macaddr() - update mac address |
| 1000 | * @config: hdd configuration |
| 1001 | * @hw_macaddr: mac address |
| 1002 | * |
| 1003 | * Mac address for multiple virtual interface is found as following |
| 1004 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1005 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1006 | * define the mac address for the remaining interfaces and locally |
| 1007 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1008 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1009 | * interface). |
| 1010 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1011 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1012 | * |
| 1013 | * Return: None |
| 1014 | */ |
| 1015 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1016 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1017 | { |
| 1018 | int8_t i; |
| 1019 | uint8_t macaddr_b3, tmp_br3; |
| 1020 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1021 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1022 | QDF_MAC_ADDR_SIZE); |
| 1023 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1024 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1025 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1026 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1027 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1028 | INTF_MACADDR_MASK; |
| 1029 | macaddr_b3 += tmp_br3; |
| 1030 | |
| 1031 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1032 | * mac address range before collision |
| 1033 | */ |
| 1034 | macaddr_b3 ^= (1 << 7); |
| 1035 | |
| 1036 | /* Set locally administered bit */ |
| 1037 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1038 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1039 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | MAC_ADDRESS_STR, i, |
| 1041 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1042 | } |
| 1043 | } |
| 1044 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1045 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1046 | { |
| 1047 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1048 | struct tdls_start_params tdls_cfg; |
| 1049 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1050 | struct hdd_config *cfg = hdd_ctx->config; |
| 1051 | QDF_STATUS status; |
| 1052 | |
| 1053 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1054 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1055 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1056 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1057 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1058 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1059 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1060 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1061 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1062 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1063 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1064 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1065 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1066 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1067 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1068 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1069 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1070 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1071 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1072 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1073 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1074 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1075 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1076 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1077 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1078 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1079 | (cfg->fTDLSExternalControl ? |
| 1080 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1081 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1082 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1083 | |
| 1084 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1085 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1086 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1087 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1088 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1089 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1090 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1091 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 1092 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 1093 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 1094 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
| 1095 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1096 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1097 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1098 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1099 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1100 | |
| 1101 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1102 | if (status != QDF_STATUS_SUCCESS) { |
| 1103 | hdd_err("failed pmo psoc configuration"); |
| 1104 | return -EINVAL; |
| 1105 | } |
| 1106 | |
| 1107 | hdd_ctx->tdls_umac_comp_active = true; |
| 1108 | /* enable napier specific tdls data path */ |
| 1109 | hdd_ctx->tdls_nap_active = true; |
| 1110 | |
| 1111 | return 0; |
| 1112 | } |
| 1113 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1114 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1115 | struct wma_tgt_services *cfg) |
| 1116 | { |
| 1117 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1118 | |
| 1119 | /* Set up UAPSD */ |
| 1120 | config->apUapsdEnabled &= cfg->uapsd; |
| 1121 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1122 | /* 11AX mode support */ |
| 1123 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1124 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1125 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1126 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1127 | /* 11AC mode support */ |
| 1128 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1129 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1130 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | |
| 1132 | /* ARP offload: override user setting if invalid */ |
| 1133 | config->fhostArpOffload &= cfg->arp_offload; |
| 1134 | |
| 1135 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1136 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1137 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1138 | if (cfg->pno_offload) |
| 1139 | config->PnoOffload = true; |
| 1140 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1141 | #ifdef FEATURE_WLAN_TDLS |
| 1142 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1143 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1144 | cfg->en_tdls_offchan; |
| 1145 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1146 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1147 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1148 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1149 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1150 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1152 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1153 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1154 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1155 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1156 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1157 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1158 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1159 | |
| 1160 | } |
| 1161 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1162 | /** |
| 1163 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1164 | * @hdd_ctx: HDD context |
| 1165 | * |
| 1166 | * Sets the Nss per vdev type based on INI |
| 1167 | * |
| 1168 | * Return: None |
| 1169 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1170 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1171 | { |
| 1172 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1173 | uint8_t max_supp_nss = 1; |
| 1174 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1175 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1176 | max_supp_nss = 2; |
| 1177 | |
| 1178 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1179 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1180 | |
| 1181 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1182 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1185 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1186 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1187 | * @hdd_ctx: HDD context |
| 1188 | * |
| 1189 | * Updates wiphy vhtcap fields |
| 1190 | * |
| 1191 | * Return: None |
| 1192 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1193 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1194 | { |
| 1195 | struct ieee80211_supported_band *band_5g = |
| 1196 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1197 | uint32_t val; |
| 1198 | |
| 1199 | if (!band_5g) { |
| 1200 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1201 | return; |
| 1202 | } |
| 1203 | |
| 1204 | val = hdd_ctx->config->txBFCsnValue; |
| 1205 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1206 | |
| 1207 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1208 | band_5g->vht_cap.cap |= |
| 1209 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1210 | |
| 1211 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1212 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1213 | } |
| 1214 | |
| 1215 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1216 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1217 | * @hdd_ctx: HDD context |
| 1218 | * |
| 1219 | * Sets the DBS capability as per INI and firmware capability |
| 1220 | * |
| 1221 | * Return: None |
| 1222 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1223 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1224 | { |
| 1225 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1226 | uint8_t hw_dbs_capable = 0; |
| 1227 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1228 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1229 | ((cfg_ini->dual_mac_feature_disable == |
| 1230 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1231 | (cfg_ini->dual_mac_feature_disable == |
| 1232 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1233 | hw_dbs_capable = 1; |
| 1234 | |
| 1235 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1236 | } |
| 1237 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1238 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | struct wma_tgt_ht_cap *cfg) |
| 1240 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1241 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | uint32_t value, val32; |
| 1243 | uint16_t val16; |
| 1244 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1245 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1246 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1247 | uint8_t enable_tx_stbc; |
| 1248 | |
| 1249 | /* check and update RX STBC */ |
| 1250 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1251 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1252 | |
| 1253 | /* get the MPDU density */ |
| 1254 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1255 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1256 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1257 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | value = 0; |
| 1259 | } |
| 1260 | |
| 1261 | /* |
| 1262 | * MPDU density: |
| 1263 | * override user's setting if value is larger |
| 1264 | * than the one supported by target |
| 1265 | */ |
| 1266 | if (value > cfg->mpdu_density) { |
| 1267 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1268 | cfg->mpdu_density); |
| 1269 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1270 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1271 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | /* get the HT capability info */ |
| 1275 | 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] | 1276 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1277 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1278 | return; |
| 1279 | } |
| 1280 | val16 = (uint16_t) val32; |
| 1281 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1282 | |
| 1283 | /* Set the LDPC capability */ |
| 1284 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1285 | |
| 1286 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1287 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1288 | |
| 1289 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1290 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1291 | |
| 1292 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1293 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1294 | |
| 1295 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1296 | |
| 1297 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1298 | pconfig->enable2x2 = 1; |
| 1299 | } else { |
| 1300 | pconfig->enable2x2 = 0; |
| 1301 | enable_tx_stbc = 0; |
| 1302 | |
| 1303 | /* 1x1 */ |
| 1304 | /* Update Rx Highest Long GI data Rate */ |
| 1305 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1306 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1307 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1308 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1309 | 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] | 1310 | } |
| 1311 | |
| 1312 | /* Update Tx Highest Long GI data Rate */ |
| 1313 | if (sme_cfg_set_int |
| 1314 | (hdd_ctx->hHal, |
| 1315 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1316 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1317 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1318 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1319 | } |
| 1320 | } |
| 1321 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1322 | enable_tx_stbc = 0; |
| 1323 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1324 | |
| 1325 | val32 = val16; |
| 1326 | 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] | 1327 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1328 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1330 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1331 | 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] | 1332 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1333 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1334 | |
| 1335 | if (pconfig->enable2x2) { |
| 1336 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1337 | mcs_set[value] = |
| 1338 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1339 | |
| 1340 | status = |
| 1341 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1342 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1343 | mcs_set, |
| 1344 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1345 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1346 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1347 | } |
| 1348 | } |
| 1349 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1350 | } |
| 1351 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1352 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1353 | struct wma_tgt_vht_cap *cfg) |
| 1354 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1355 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1356 | uint32_t value = 0; |
| 1357 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1358 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1359 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1360 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1361 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1362 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1363 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1365 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1366 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1367 | return; |
| 1368 | } |
| 1369 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | /* Get the current MPDU length */ |
| 1371 | status = |
| 1372 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1373 | &value); |
| 1374 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1375 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1376 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1377 | value = 0; |
| 1378 | } |
| 1379 | |
| 1380 | /* |
| 1381 | * VHT max MPDU length: |
| 1382 | * override if user configured value is too high |
| 1383 | * that the target cannot support |
| 1384 | */ |
| 1385 | if (value > cfg->vht_max_mpdu) { |
| 1386 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1387 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1388 | cfg->vht_max_mpdu); |
| 1389 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1390 | if (status == QDF_STATUS_E_FAILURE) |
| 1391 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1392 | } |
| 1393 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1394 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1395 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1396 | |
| 1397 | if (pconfig->enable2x2) |
| 1398 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1399 | |
| 1400 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1401 | QDF_STATUS_E_FAILURE) { |
| 1402 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1403 | } |
| 1404 | |
| 1405 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1406 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1407 | if (pconfig->enable2x2) |
| 1408 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1409 | |
| 1410 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1411 | QDF_STATUS_E_FAILURE) { |
| 1412 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1413 | } |
| 1414 | |
| 1415 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1416 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1417 | if (pconfig->enable2x2) |
| 1418 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1419 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1420 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1421 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1422 | |
| 1423 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1424 | QDF_STATUS_E_FAILURE) { |
| 1425 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1426 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1427 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1428 | 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] | 1429 | &value); |
| 1430 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1431 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1432 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1433 | value = 0; |
| 1434 | } |
| 1435 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1436 | /* Set HW RX LDPC capability */ |
| 1437 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1438 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1439 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1440 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1441 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1442 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1443 | if (status == QDF_STATUS_E_FAILURE) |
| 1444 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1445 | } |
| 1446 | |
| 1447 | /* Get current GI 80 value */ |
| 1448 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1449 | &value); |
| 1450 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1451 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1452 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1453 | value = 0; |
| 1454 | } |
| 1455 | |
| 1456 | /* set the Guard interval 80MHz */ |
| 1457 | if (value && !cfg->vht_short_gi_80) { |
| 1458 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1459 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1460 | cfg->vht_short_gi_80); |
| 1461 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1462 | if (status == QDF_STATUS_E_FAILURE) |
| 1463 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1464 | } |
| 1465 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | /* Get VHT TX STBC cap */ |
| 1467 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1468 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1469 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1470 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1471 | value = 0; |
| 1472 | } |
| 1473 | |
| 1474 | /* VHT TX STBC cap */ |
| 1475 | if (value && !cfg->vht_tx_stbc) { |
| 1476 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1477 | cfg->vht_tx_stbc); |
| 1478 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1479 | if (status == QDF_STATUS_E_FAILURE) |
| 1480 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1481 | } |
| 1482 | |
| 1483 | /* Get VHT RX STBC cap */ |
| 1484 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1485 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1486 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1487 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | value = 0; |
| 1489 | } |
| 1490 | |
| 1491 | /* VHT RX STBC cap */ |
| 1492 | if (value && !cfg->vht_rx_stbc) { |
| 1493 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1494 | cfg->vht_rx_stbc); |
| 1495 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1496 | if (status == QDF_STATUS_E_FAILURE) |
| 1497 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1498 | } |
| 1499 | |
| 1500 | /* Get VHT SU Beamformer cap */ |
| 1501 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1502 | &value); |
| 1503 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1504 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1505 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1506 | value = 0; |
| 1507 | } |
| 1508 | |
| 1509 | /* set VHT SU Beamformer cap */ |
| 1510 | if (value && !cfg->vht_su_bformer) { |
| 1511 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1512 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1513 | cfg->vht_su_bformer); |
| 1514 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1515 | if (status == QDF_STATUS_E_FAILURE) |
| 1516 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | /* check and update SU BEAMFORMEE capabality */ |
| 1520 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1521 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1522 | |
| 1523 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1524 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1525 | pconfig->enableTxBF); |
| 1526 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1527 | if (status == QDF_STATUS_E_FAILURE) |
| 1528 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | |
| 1530 | /* Get VHT MU Beamformer cap */ |
| 1531 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1532 | &value); |
| 1533 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1534 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1535 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | value = 0; |
| 1537 | } |
| 1538 | |
| 1539 | /* set VHT MU Beamformer cap */ |
| 1540 | if (value && !cfg->vht_mu_bformer) { |
| 1541 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1542 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1543 | cfg->vht_mu_bformer); |
| 1544 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1545 | if (status == QDF_STATUS_E_FAILURE) |
| 1546 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1547 | } |
| 1548 | |
| 1549 | /* Get VHT MU Beamformee cap */ |
| 1550 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1551 | &value); |
| 1552 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1553 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1554 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | value = 0; |
| 1556 | } |
| 1557 | |
| 1558 | /* set VHT MU Beamformee cap */ |
| 1559 | if (value && !cfg->vht_mu_bformee) { |
| 1560 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1561 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1562 | cfg->vht_mu_bformee); |
| 1563 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1564 | if (status == QDF_STATUS_E_FAILURE) |
| 1565 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1566 | } |
| 1567 | |
| 1568 | /* Get VHT MAX AMPDU Len exp */ |
| 1569 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1570 | &value); |
| 1571 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1572 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1573 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1574 | value = 0; |
| 1575 | } |
| 1576 | |
| 1577 | /* |
| 1578 | * VHT max AMPDU len exp: |
| 1579 | * override if user configured value is too high |
| 1580 | * that the target cannot support. |
| 1581 | * Even though Rome publish ampdu_len=7, it can |
| 1582 | * only support 4 because of some h/w bug. |
| 1583 | */ |
| 1584 | |
| 1585 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1586 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1587 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1588 | cfg->vht_max_ampdu_len_exp); |
| 1589 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1590 | if (status == QDF_STATUS_E_FAILURE) |
| 1591 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | /* Get VHT TXOP PS CAP */ |
| 1595 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1596 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1597 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1598 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | value = 0; |
| 1600 | } |
| 1601 | |
| 1602 | /* set VHT TXOP PS cap */ |
| 1603 | if (value && !cfg->vht_txop_ps) { |
| 1604 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1605 | cfg->vht_txop_ps); |
| 1606 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1607 | if (status == QDF_STATUS_E_FAILURE) |
| 1608 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1609 | } |
| 1610 | |
| 1611 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1612 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1613 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1614 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1615 | else |
| 1616 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1617 | |
| 1618 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1619 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1620 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1621 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1622 | VHT_CAP_160_AND_80P80_SUPP); |
| 1623 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1624 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | band_5g->vht_cap.cap |= |
| 1626 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1627 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1628 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1629 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1630 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1631 | VHT_CAP_160_SUPP); |
| 1632 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1633 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1634 | band_5g->vht_cap.cap |= |
| 1635 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1636 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1637 | } |
| 1638 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1639 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1640 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1641 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1642 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1643 | &value); |
| 1644 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1645 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1646 | value = 0; |
| 1647 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1648 | /* set the Guard interval 160MHz */ |
| 1649 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1650 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1651 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1652 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1653 | |
| 1654 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1655 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1656 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1657 | |
| 1658 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1659 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1660 | |
| 1661 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1662 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1663 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1664 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1665 | |
| 1666 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1667 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1668 | |
| 1669 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1670 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1671 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1672 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1673 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1674 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1675 | |
| 1676 | band_5g->vht_cap.cap |= |
| 1677 | (cfg->vht_max_ampdu_len_exp << |
| 1678 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1679 | |
| 1680 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1681 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1682 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1683 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1684 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1685 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1686 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1687 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1688 | |
| 1689 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1690 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1691 | |
| 1692 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1694 | /** |
| 1695 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1696 | * @hdd_ctx: Pointer to the HDD context |
| 1697 | * |
| 1698 | * Auto-generate mac address using device serial number. |
| 1699 | * Keep the first 3 bytes of OUI as before and replace |
| 1700 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1701 | * |
| 1702 | * Return: 0 for success |
| 1703 | * Non zero failure code for errors |
| 1704 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1705 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1706 | { |
| 1707 | unsigned int serialno = 0; |
| 1708 | struct qdf_mac_addr mac_addr = { |
| 1709 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1710 | }; |
| 1711 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1712 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1713 | if (serialno == 0) |
| 1714 | return -EINVAL; |
| 1715 | |
| 1716 | serialno &= 0x00ffffff; |
| 1717 | |
| 1718 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1719 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1720 | mac_addr.bytes[5] = serialno & 0xff; |
| 1721 | |
| 1722 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1723 | return 0; |
| 1724 | } |
| 1725 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1726 | /** |
| 1727 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1728 | * configuration to cfg_ini in HDD |
| 1729 | * @hdd_ctx: Pointer to hdd_ctx |
| 1730 | * @cfg: target configuration |
| 1731 | * |
| 1732 | * Return: None |
| 1733 | */ |
| 1734 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1735 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1736 | struct wma_tgt_cfg *cfg) |
| 1737 | { |
| 1738 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1739 | } |
| 1740 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1741 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1742 | struct wma_tgt_cfg *cfg) |
| 1743 | { |
| 1744 | } |
| 1745 | #endif |
| 1746 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1747 | uint8_t hdd_check_green_ap_enable(struct hdd_context *hdd_ctx, |
| 1748 | bool *is_enabled) |
| 1749 | { |
| 1750 | struct hdd_config *cfg; |
| 1751 | uint32_t concurrency_mode; |
| 1752 | |
| 1753 | cfg = hdd_ctx->config; |
| 1754 | if (!cfg) { |
| 1755 | hdd_err("NULL hdd config"); |
| 1756 | return -EINVAL; |
| 1757 | } |
| 1758 | |
| 1759 | concurrency_mode = policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc); |
| 1760 | |
| 1761 | if (cfg->enable2x2 && cfg->enableGreenAP) { |
| 1762 | if ((concurrency_mode & (1 << QDF_SAP_MODE)) && |
| 1763 | !(concurrency_mode & (~(1 << QDF_SAP_MODE)))) |
| 1764 | *is_enabled = true; |
| 1765 | } |
| 1766 | return 0; |
| 1767 | } |
| 1768 | |
| 1769 | static int hdd_update_green_ap_config(struct hdd_context *hdd_ctx) |
| 1770 | { |
| 1771 | struct green_ap_user_cfg green_ap_cfg; |
| 1772 | struct hdd_config *cfg = hdd_ctx->config; |
| 1773 | QDF_STATUS status; |
| 1774 | |
| 1775 | green_ap_cfg.host_enable_egap = cfg->enable_egap; |
| 1776 | green_ap_cfg.egap_inactivity_time = cfg->egap_inact_time; |
| 1777 | green_ap_cfg.egap_wait_time = cfg->egap_wait_time; |
| 1778 | green_ap_cfg.egap_feature_flags = cfg->egap_feature_flag; |
| 1779 | |
| 1780 | status = ucfg_green_ap_update_user_config(hdd_ctx->hdd_pdev, |
| 1781 | &green_ap_cfg); |
| 1782 | if (status != QDF_STATUS_SUCCESS) { |
| 1783 | hdd_err("failed to update green ap user configuration"); |
| 1784 | return -EINVAL; |
| 1785 | } |
| 1786 | |
| 1787 | return 0; |
| 1788 | } |
| 1789 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1790 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1791 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1792 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1793 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1794 | struct wma_tgt_cfg *cfg = param; |
| 1795 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1796 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1797 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1798 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1799 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1800 | if (ret) { |
| 1801 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1802 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1803 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1804 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1805 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1806 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1807 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1808 | ret = hdd_update_green_ap_config(hdd_ctx); |
| 1809 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1810 | if (cds_cfg) { |
| 1811 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1812 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1813 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1814 | cds_cfg->sub_20_channel_width = |
| 1815 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1816 | } else { |
| 1817 | cds_cfg->sub_20_channel_width = |
| 1818 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1819 | } |
| 1820 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1821 | |
| 1822 | /* first store the INI band capability */ |
| 1823 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1824 | |
| 1825 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1826 | hdd_ctx->is_fils_roaming_supported = |
| 1827 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1828 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1829 | /* |
| 1830 | * now overwrite the target band capability with INI |
| 1831 | * setting if INI setting is a subset |
| 1832 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1833 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1834 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1835 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1836 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1837 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1838 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1839 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1840 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1841 | } |
| 1842 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1843 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1844 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1845 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1846 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1847 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1848 | } |
| 1849 | |
| 1850 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1851 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1852 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1853 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1854 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1856 | static struct qdf_mac_addr default_mac_addr = { |
| 1857 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1858 | }; |
| 1859 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1860 | &default_mac_addr)) { |
| 1861 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1862 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1863 | MAC_ADDRESS_STR, |
| 1864 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1865 | intfMacAddr[0].bytes)); |
| 1866 | } else { |
| 1867 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1868 | MAC_ADDRESS_STR, |
| 1869 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1870 | intfMacAddr[0].bytes)); |
| 1871 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1872 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1873 | } |
| 1874 | |
| 1875 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1876 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1877 | |
| 1878 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1879 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1880 | hdd_lpass_target_config(hdd_ctx, cfg); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1881 | ucfg_green_ap_target_config(hdd_ctx->hdd_pdev, cfg->egap_support); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1882 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1883 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1884 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1885 | |
| 1886 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1887 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1888 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1889 | if (cfg->services.en_11ax) { |
| 1890 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1891 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1892 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1893 | |
| 1894 | hdd_update_vdev_nss(hdd_ctx); |
| 1895 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1896 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1897 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1898 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1899 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1900 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1901 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1902 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1903 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1904 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1905 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1906 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1907 | hdd_ctx->current_antenna_mode); |
| 1908 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1909 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1910 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1911 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1912 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1913 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1914 | if ((hdd_ctx->config->txBFCsnValue > |
| 1915 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1916 | !cfg->tx_bfee_8ss_enabled) |
| 1917 | hdd_ctx->config->txBFCsnValue = |
| 1918 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1919 | |
| 1920 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1921 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1922 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1923 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1924 | |
| 1925 | |
| 1926 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1927 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1928 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1929 | |
| 1930 | /* |
| 1931 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1932 | */ |
| 1933 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1934 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1935 | /* |
| 1936 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1937 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1938 | * configure the STA mode wow pattern. |
| 1939 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1940 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1941 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1942 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1943 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1944 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1945 | /* |
| 1946 | * This needs to be done after HDD pdev is created and stored since |
| 1947 | * it will access the HDD pdev object lock. |
| 1948 | */ |
| 1949 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1950 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1951 | /* Configure NAN datapath features */ |
| 1952 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1953 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 1954 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | } |
| 1956 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1957 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1959 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1960 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1961 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1962 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1963 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1964 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1965 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1966 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1968 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1969 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1970 | |
| 1971 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1972 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1973 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 1974 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1975 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 1976 | true; |
| 1977 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1978 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1979 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1980 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1981 | |
| 1982 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1983 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | |
| 1985 | /** |
| 1986 | * hdd_is_valid_mac_address() - validate MAC address |
| 1987 | * @pMacAddr: Pointer to the input MAC address |
| 1988 | * |
| 1989 | * This function validates whether the given MAC address is valid or not |
| 1990 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1991 | * where X is the hexa decimal digit character and separated by ':' |
| 1992 | * This algorithm works even if MAC address is not separated by ':' |
| 1993 | * |
| 1994 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1995 | * digits and a separator colon : appears in the input string only after |
| 1996 | * an even number of hex digits. |
| 1997 | * |
| 1998 | * Return: 1 for valid and 0 for invalid |
| 1999 | */ |
| 2000 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2001 | { |
| 2002 | int xdigit = 0; |
| 2003 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2004 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2005 | while (*pMacAddr) { |
| 2006 | if (isxdigit(*pMacAddr)) { |
| 2007 | xdigit++; |
| 2008 | } else if (':' == *pMacAddr) { |
| 2009 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2010 | break; |
| 2011 | |
| 2012 | ++separator; |
| 2013 | } else { |
| 2014 | /* Invalid MAC found */ |
| 2015 | return 0; |
| 2016 | } |
| 2017 | ++pMacAddr; |
| 2018 | } |
| 2019 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2020 | } |
| 2021 | |
| 2022 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2023 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2024 | * @dev: Handle to struct net_device to be updated. |
| 2025 | * |
| 2026 | * Return: None |
| 2027 | */ |
| 2028 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2029 | { |
| 2030 | dev->header_ops = NULL; |
| 2031 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2032 | dev->hard_header_len = ETH_HLEN; |
| 2033 | dev->mtu = ETH_DATA_LEN; |
| 2034 | dev->addr_len = ETH_ALEN; |
| 2035 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2036 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2037 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2038 | |
| 2039 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2040 | } |
| 2041 | |
| 2042 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2043 | * __hdd__mon_open() - HDD Open function |
| 2044 | * @dev: Pointer to net_device structure |
| 2045 | * |
| 2046 | * This is called in response to ifconfig up |
| 2047 | * |
| 2048 | * Return: 0 for success; non-zero for failure |
| 2049 | */ |
| 2050 | static int __hdd_mon_open(struct net_device *dev) |
| 2051 | { |
| 2052 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2053 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2054 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2055 | |
| 2056 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2057 | |
| 2058 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2059 | if (ret) |
| 2060 | return ret; |
| 2061 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2062 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2063 | |
| 2064 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2065 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2066 | if (ret) { |
| 2067 | hdd_err("Failed to start WLAN modules return"); |
| 2068 | return ret; |
| 2069 | } |
| 2070 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2071 | |
| 2072 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2073 | ret = hdd_start_adapter(adapter); |
| 2074 | if (ret) { |
| 2075 | hdd_err("Failed to start adapter :%d", |
| 2076 | adapter->device_mode); |
| 2077 | return ret; |
| 2078 | } |
| 2079 | hdd_err("hdd_start_adapters() successful !"); |
| 2080 | } |
| 2081 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2082 | } |
| 2083 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2084 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2085 | |
| 2086 | if (!ret) |
| 2087 | ret = hdd_enable_monitor_mode(dev); |
| 2088 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2089 | return ret; |
| 2090 | } |
| 2091 | |
| 2092 | /** |
| 2093 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2094 | * @dev: Pointer to net_device structure |
| 2095 | * |
| 2096 | * This is called in response to ifconfig up |
| 2097 | * |
| 2098 | * Return: 0 for success; non-zero for failure |
| 2099 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2100 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2101 | { |
| 2102 | int ret; |
| 2103 | |
| 2104 | cds_ssr_protect(__func__); |
| 2105 | ret = __hdd_mon_open(dev); |
| 2106 | cds_ssr_unprotect(__func__); |
| 2107 | |
| 2108 | return ret; |
| 2109 | } |
| 2110 | |
| 2111 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2112 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2113 | * @adapter: pointer to HDD adapter |
| 2114 | * |
| 2115 | * This function is called to start the device specific adapter for |
| 2116 | * the mode passed in the adapter's device_mode. |
| 2117 | * |
| 2118 | * Return: 0 for success; non-zero for failure |
| 2119 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2120 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2121 | { |
| 2122 | |
| 2123 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2124 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2125 | |
| 2126 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2127 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2128 | |
| 2129 | switch (device_mode) { |
| 2130 | case QDF_P2P_CLIENT_MODE: |
| 2131 | case QDF_P2P_DEVICE_MODE: |
| 2132 | case QDF_OCB_MODE: |
| 2133 | case QDF_STA_MODE: |
| 2134 | case QDF_MONITOR_MODE: |
| 2135 | ret = hdd_start_station_adapter(adapter); |
| 2136 | if (ret) |
| 2137 | goto err_start_adapter; |
| 2138 | break; |
| 2139 | case QDF_P2P_GO_MODE: |
| 2140 | case QDF_SAP_MODE: |
| 2141 | ret = hdd_start_ap_adapter(adapter); |
| 2142 | if (ret) |
| 2143 | goto err_start_adapter; |
| 2144 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2145 | case QDF_IBSS_MODE: |
| 2146 | /* |
| 2147 | * For IBSS interface is initialized as part of |
| 2148 | * hdd_init_station_mode() |
| 2149 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2150 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2151 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2152 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2153 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2154 | default: |
| 2155 | hdd_err("Invalid session type %d", device_mode); |
| 2156 | QDF_ASSERT(0); |
| 2157 | goto err_start_adapter; |
| 2158 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2159 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2160 | if (hdd_set_fw_params(adapter)) |
| 2161 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2162 | |
| 2163 | /* |
| 2164 | * Action frame registered in one adapter which will |
| 2165 | * applicable to all interfaces |
| 2166 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2167 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2168 | if (ret < 0) { |
| 2169 | hdd_err("Failed to register frames - ret %d", ret); |
| 2170 | goto err_start_adapter; |
| 2171 | } |
| 2172 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2173 | exit_with_success: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2174 | EXIT(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2175 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2176 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2177 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2178 | err_start_adapter: |
| 2179 | return -EINVAL; |
| 2180 | } |
| 2181 | |
| 2182 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2183 | * hdd_enable_power_management() - API to Enable Power Management |
| 2184 | * |
| 2185 | * API invokes Bus Interface Layer power management functionality |
| 2186 | * |
| 2187 | * Return: None |
| 2188 | */ |
| 2189 | static void hdd_enable_power_management(void) |
| 2190 | { |
| 2191 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2192 | |
| 2193 | if (!hif_ctx) { |
| 2194 | hdd_err("Bus Interface Context is Invalid"); |
| 2195 | return; |
| 2196 | } |
| 2197 | |
| 2198 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2199 | } |
| 2200 | |
| 2201 | /** |
| 2202 | * hdd_disable_power_management() - API to disable Power Management |
| 2203 | * |
| 2204 | * API disable Bus Interface Layer Power management functionality |
| 2205 | * |
| 2206 | * Return: None |
| 2207 | */ |
| 2208 | static void hdd_disable_power_management(void) |
| 2209 | { |
| 2210 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2211 | |
| 2212 | if (!hif_ctx) { |
| 2213 | hdd_err("Bus Interface Context is Invalid"); |
| 2214 | return; |
| 2215 | } |
| 2216 | |
| 2217 | hif_disable_power_management(hif_ctx); |
| 2218 | } |
| 2219 | |
| 2220 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2221 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2222 | * |
| 2223 | * API to update the HW and SW information in the driver |
| 2224 | * |
| 2225 | * Return: None |
| 2226 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2227 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2228 | { |
| 2229 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2230 | size_t target_hw_name_len; |
| 2231 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2232 | |
| 2233 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2234 | if (!hif_sc) { |
| 2235 | hdd_err("HIF context is NULL"); |
| 2236 | return; |
| 2237 | } |
| 2238 | |
| 2239 | /* |
| 2240 | * target hw version/revision would only be retrieved after firmware |
| 2241 | * download |
| 2242 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2243 | hif_get_hw_info(hif_sc, |
| 2244 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2245 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2246 | &target_hw_name); |
| 2247 | |
| 2248 | if (hdd_ctx->target_hw_name) |
| 2249 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2250 | |
| 2251 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2252 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2253 | if (hdd_ctx->target_hw_name) |
| 2254 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2255 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2256 | |
| 2257 | /* Get the wlan hw/fw version */ |
| 2258 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2259 | } |
| 2260 | |
| 2261 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2262 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2263 | * @hdd_ctx: Pointer to hdd context |
| 2264 | * |
| 2265 | * Return: none |
| 2266 | */ |
| 2267 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2268 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2269 | { |
| 2270 | uint8_t num_entries = 0; |
| 2271 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2272 | uint8_t *tx_sched_wrr_ac; |
| 2273 | int i; |
| 2274 | cds_context_type *cds_ctx; |
| 2275 | |
| 2276 | if (NULL == hdd_ctx) |
| 2277 | return; |
| 2278 | |
| 2279 | if (NULL == hdd_ctx->config) { |
| 2280 | /* Do nothing if hdd_ctx is invalid */ |
| 2281 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2282 | return; |
| 2283 | } |
| 2284 | |
| 2285 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2286 | |
| 2287 | if (!cds_ctx) { |
| 2288 | hdd_err("Invalid CDS Context"); |
| 2289 | return; |
| 2290 | } |
| 2291 | |
| 2292 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2293 | switch (i) { |
| 2294 | case OL_TX_WMM_AC_BE: |
| 2295 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2296 | break; |
| 2297 | case OL_TX_WMM_AC_BK: |
| 2298 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2299 | break; |
| 2300 | case OL_TX_WMM_AC_VI: |
| 2301 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2302 | break; |
| 2303 | case OL_TX_WMM_AC_VO: |
| 2304 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2305 | break; |
| 2306 | default: |
| 2307 | tx_sched_wrr_ac = NULL; |
| 2308 | break; |
| 2309 | } |
| 2310 | |
| 2311 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2312 | tx_sched_wrr_param, |
| 2313 | &num_entries, |
| 2314 | sizeof(tx_sched_wrr_param)); |
| 2315 | |
| 2316 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2317 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2318 | tx_sched_wrr_param[0]; |
| 2319 | cds_ctx->ac_specs[i].credit_threshold = |
| 2320 | tx_sched_wrr_param[1]; |
| 2321 | cds_ctx->ac_specs[i].send_limit = |
| 2322 | tx_sched_wrr_param[2]; |
| 2323 | cds_ctx->ac_specs[i].credit_reserve = |
| 2324 | tx_sched_wrr_param[3]; |
| 2325 | cds_ctx->ac_specs[i].discard_weight = |
| 2326 | tx_sched_wrr_param[4]; |
| 2327 | } |
| 2328 | |
| 2329 | num_entries = 0; |
| 2330 | } |
| 2331 | } |
| 2332 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2333 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2334 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2335 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2336 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2337 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2338 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2339 | |
| 2340 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2341 | if (!adapter) { |
| 2342 | hdd_err("Adapter is NULL"); |
| 2343 | return PM_MAX_NUM_OF_MODE; |
| 2344 | } |
| 2345 | |
| 2346 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2347 | adapter->device_mode); |
| 2348 | } |
| 2349 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2350 | static void hdd_register_policy_manager_callback( |
| 2351 | struct wlan_objmgr_psoc *psoc) |
| 2352 | { |
| 2353 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2354 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2355 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2356 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2357 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2358 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2359 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2360 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2361 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2362 | if (QDF_STATUS_SUCCESS != |
| 2363 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2364 | hdd_err("HDD callback registration with policy manager failed"); |
| 2365 | } |
| 2366 | } |
| 2367 | #else |
| 2368 | static void hdd_register_policy_manager_callback( |
| 2369 | struct wlan_objmgr_psoc *psoc) |
| 2370 | { |
| 2371 | } |
| 2372 | #endif |
| 2373 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2374 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2375 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2376 | { |
| 2377 | struct nan_callbacks cb_obj = {0}; |
| 2378 | |
| 2379 | cb_obj.ndi_open = hdd_ndi_open; |
| 2380 | cb_obj.ndi_close = hdd_ndi_close; |
| 2381 | cb_obj.ndi_start = hdd_ndi_start; |
| 2382 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2383 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2384 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2385 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2386 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2387 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2388 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2389 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2390 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2391 | } |
| 2392 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2393 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2394 | { |
| 2395 | } |
| 2396 | #endif |
| 2397 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2398 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2399 | /** |
| 2400 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2401 | * |
| 2402 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2403 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2404 | * |
| 2405 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2406 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2407 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2408 | * fixed. |
| 2409 | * |
| 2410 | * Return: None |
| 2411 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2412 | static void hdd_check_for_leaks(void) |
| 2413 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2414 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2415 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2416 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2417 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2418 | } |
| 2419 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2420 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2421 | #else |
| 2422 | static inline void hdd_check_for_leaks(void) {} |
| 2423 | |
| 2424 | #define hdd_debug_domain_set(domain) |
| 2425 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2426 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2427 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2428 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2429 | * @hdd_ctx: HDD context |
| 2430 | * @adapter: HDD adapter |
| 2431 | * @reinit: flag to indicate from SSR or normal path |
| 2432 | * |
| 2433 | * This function maintains the driver state machine it will be invoked from |
| 2434 | * startup, reinit and change interface. Depending on the driver state shall |
| 2435 | * perform the opening of the modules. |
| 2436 | * |
| 2437 | * Return: 0 for success; non-zero for failure |
| 2438 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2439 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2440 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2441 | bool reinit) |
| 2442 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2443 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2444 | qdf_device_t qdf_dev; |
| 2445 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2446 | bool unint = false; |
| 2447 | void *hif_ctx; |
| 2448 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2449 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2450 | |
| 2451 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2452 | if (!qdf_dev) { |
| 2453 | hdd_err("QDF Device Context is Invalid return"); |
| 2454 | return -EINVAL; |
| 2455 | } |
| 2456 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2457 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2458 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2459 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2460 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2461 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2462 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2463 | hdd_info("Driver modules already Enabled"); |
| 2464 | EXIT(); |
| 2465 | return 0; |
| 2466 | } |
| 2467 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2468 | hdd_ctx->start_modules_in_progress = true; |
| 2469 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2470 | switch (hdd_ctx->driver_status) { |
| 2471 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2472 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2473 | unint = true; |
| 2474 | /* Fall through dont add break here */ |
| 2475 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2476 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2477 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2478 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2479 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2480 | if (!reinit && !unint) { |
| 2481 | ret = pld_power_on(qdf_dev->dev); |
| 2482 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2483 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2484 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2485 | goto release_lock; |
| 2486 | } |
| 2487 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2488 | |
| 2489 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2490 | hdd_ctx->config->enable_fw_log); |
| 2491 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2492 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2493 | qdf_dev->bus_type, |
| 2494 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2495 | HIF_ENABLE_TYPE_PROBE); |
| 2496 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2497 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2498 | goto power_down; |
| 2499 | } |
| 2500 | |
| 2501 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2502 | if (!hif_ctx) { |
| 2503 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2504 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2505 | goto power_down; |
| 2506 | } |
| 2507 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2508 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2509 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2510 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2511 | status); |
| 2512 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2513 | goto hif_close; |
| 2514 | } |
| 2515 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2516 | ret = hdd_update_config(hdd_ctx); |
| 2517 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2518 | hdd_err("Failed to update configuration; errno: %d", |
| 2519 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2520 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2521 | } |
| 2522 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2523 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2524 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2525 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2526 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2527 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2528 | ret = qdf_status_to_os_return(status); |
| 2529 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2530 | } |
| 2531 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2532 | /* initalize components configurations after psoc open */ |
| 2533 | ret = hdd_update_components_config(hdd_ctx); |
| 2534 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2535 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2536 | ret); |
| 2537 | goto close; |
| 2538 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2539 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2540 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2541 | hdd_err("Failed to Open cds post open; status: %d", |
| 2542 | status); |
| 2543 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2544 | goto close; |
| 2545 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2546 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2547 | /* |
| 2548 | * NAN compoenet requires certian operations like, open adapter, |
| 2549 | * close adapter, etc. to be initiated by HDD, for those |
| 2550 | * register HDD callbacks with UMAC's NAN componenet. |
| 2551 | */ |
| 2552 | hdd_nan_register_callbacks(hdd_ctx); |
| 2553 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2554 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2555 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2556 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2557 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2558 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2559 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2560 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2561 | } |
| 2562 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2563 | hdd_register_policy_manager_callback( |
| 2564 | hdd_ctx->hdd_psoc); |
| 2565 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2566 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2567 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2568 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2569 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2570 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2571 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2572 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2573 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2574 | hdd_ftm_mc_process_msg); |
| 2575 | break; |
| 2576 | } |
| 2577 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2578 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2579 | break; |
| 2580 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2581 | |
| 2582 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2583 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2584 | if (ret) { |
| 2585 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2586 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2587 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2588 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2589 | } |
| 2590 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2591 | /* Fall through dont add break here */ |
| 2592 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2593 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2594 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2595 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2596 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2597 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2598 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2599 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2600 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2601 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2602 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2603 | break; |
| 2604 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2605 | |
| 2606 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2607 | if (ret) { |
| 2608 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2609 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2610 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2611 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2612 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2613 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2614 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2615 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2616 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2617 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2618 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2619 | default: |
| 2620 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2621 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2622 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2623 | goto release_lock; |
| 2624 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2625 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2626 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2627 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2628 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2629 | EXIT(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2630 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2631 | return 0; |
| 2632 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2633 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2634 | cds_post_disable(); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2635 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2636 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2637 | cds_txrx_free: |
| 2638 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2639 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2640 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2641 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2642 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2643 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2644 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2645 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2646 | deinit_config: |
| 2647 | cds_deinit_ini_config(); |
| 2648 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2649 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2650 | ol_cds_free(); |
| 2651 | |
| 2652 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2653 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2654 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2655 | power_down: |
| 2656 | if (!reinit && !unint) |
| 2657 | pld_power_off(qdf_dev->dev); |
| 2658 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2659 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2660 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2661 | |
| 2662 | /* many adapter resources are not freed by design in SSR case */ |
| 2663 | if (!reinit) |
| 2664 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2665 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2666 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2667 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2668 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2669 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2670 | } |
| 2671 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2672 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2673 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2674 | { |
| 2675 | int ret = os_if_wifi_pos_register_nl(); |
| 2676 | |
| 2677 | if (ret) |
| 2678 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2679 | |
| 2680 | return ret; |
| 2681 | } |
| 2682 | |
| 2683 | static int hdd_deactivate_wifi_pos(void) |
| 2684 | { |
| 2685 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2686 | |
| 2687 | if (ret) |
| 2688 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2689 | |
| 2690 | return ret; |
| 2691 | } |
| 2692 | |
| 2693 | /** |
| 2694 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2695 | * @hdd_ctx: hdd context |
| 2696 | * |
| 2697 | * Return: status of operation |
| 2698 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2699 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2700 | { |
| 2701 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2702 | struct hdd_config *cfg = hdd_ctx->config; |
| 2703 | |
| 2704 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2705 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2706 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2707 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2708 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2709 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2710 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2711 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2712 | } |
| 2713 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2714 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2715 | { |
| 2716 | return oem_activate_service(hdd_ctx); |
| 2717 | } |
| 2718 | |
| 2719 | static int hdd_deactivate_wifi_pos(void) |
| 2720 | { |
| 2721 | return 0; |
| 2722 | } |
| 2723 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2724 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2725 | { |
| 2726 | } |
| 2727 | #endif |
| 2728 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2729 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2730 | * __hdd_open() - HDD Open function |
| 2731 | * @dev: Pointer to net_device structure |
| 2732 | * |
| 2733 | * This is called in response to ifconfig up |
| 2734 | * |
| 2735 | * Return: 0 for success; non-zero for failure |
| 2736 | */ |
| 2737 | static int __hdd_open(struct net_device *dev) |
| 2738 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2739 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2740 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2741 | int ret; |
| 2742 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2743 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2744 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2745 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2746 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2747 | /* Nothing to be done if device is unloading */ |
| 2748 | if (cds_is_driver_unloading()) { |
| 2749 | hdd_err("Driver is unloading can not open the hdd"); |
| 2750 | return -EBUSY; |
| 2751 | } |
| 2752 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2753 | if (cds_is_driver_recovering()) { |
| 2754 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2755 | return -EBUSY; |
| 2756 | } |
| 2757 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2758 | mutex_lock(&hdd_init_deinit_lock); |
| 2759 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2760 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2761 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2762 | /* |
| 2763 | * This scenario can be hit in cases where in the wlan driver after |
| 2764 | * registering the netdevices and there is a failure in driver |
| 2765 | * initialization. So return error gracefully because the netdevices |
| 2766 | * will be de-registered as part of the load failure. |
| 2767 | */ |
| 2768 | |
| 2769 | if (!cds_is_driver_loaded()) { |
| 2770 | hdd_err("Failed to start the wlan driver!!"); |
| 2771 | ret = -EIO; |
| 2772 | goto err_hdd_hdd_init_deinit_lock; |
| 2773 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2774 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2775 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2776 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2777 | if (ret) { |
| 2778 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2779 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2780 | } |
| 2781 | |
| 2782 | |
| 2783 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2784 | ret = hdd_start_adapter(adapter); |
| 2785 | if (ret) { |
| 2786 | hdd_err("Failed to start adapter :%d", |
| 2787 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2788 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | } |
| 2790 | } |
| 2791 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2792 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2793 | 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] | 2794 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2795 | /* Enable TX queues only when we are connected */ |
| 2796 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2797 | WLAN_START_ALL_NETIF_QUEUE, |
| 2798 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2799 | } |
| 2800 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2801 | /* Enable carrier and transmit queues for NDI */ |
| 2802 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2803 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2804 | wlan_hdd_netif_queue_control(adapter, |
| 2805 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2806 | WLAN_CONTROL_PATH); |
| 2807 | } |
| 2808 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2809 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2810 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2811 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2812 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2813 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2814 | return ret; |
| 2815 | } |
| 2816 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2817 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2818 | /** |
| 2819 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2820 | * @dev: Pointer to net_device structure |
| 2821 | * |
| 2822 | * This is called in response to ifconfig up |
| 2823 | * |
| 2824 | * Return: 0 for success; non-zero for failure |
| 2825 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2826 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2827 | { |
| 2828 | int ret; |
| 2829 | |
| 2830 | cds_ssr_protect(__func__); |
| 2831 | ret = __hdd_open(dev); |
| 2832 | cds_ssr_unprotect(__func__); |
| 2833 | |
| 2834 | return ret; |
| 2835 | } |
| 2836 | |
| 2837 | /** |
| 2838 | * __hdd_stop() - HDD stop function |
| 2839 | * @dev: Pointer to net_device structure |
| 2840 | * |
| 2841 | * This is called in response to ifconfig down |
| 2842 | * |
| 2843 | * Return: 0 for success; non-zero for failure |
| 2844 | */ |
| 2845 | static int __hdd_stop(struct net_device *dev) |
| 2846 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2847 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2848 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2849 | int ret; |
| 2850 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2851 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2852 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2853 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2854 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2855 | |
| 2856 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2857 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2858 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2859 | |
| 2860 | /* Nothing to be done if the interface is not opened */ |
| 2861 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2862 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2863 | return -ENODEV; |
| 2864 | } |
| 2865 | |
| 2866 | /* Make sure the interface is marked as closed */ |
| 2867 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2868 | |
| 2869 | hdd_debug("Disabling Auto Power save timer"); |
| 2870 | sme_ps_disable_auto_ps_timer( |
| 2871 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2872 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2873 | |
| 2874 | /* |
| 2875 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2876 | * be called on that interface |
| 2877 | */ |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 2878 | hdd_notice("Disabling queues, adapter device mode: %s(%d)", |
| 2879 | hdd_device_mode_to_string(adapter->device_mode), |
| 2880 | adapter->device_mode); |
| 2881 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2882 | wlan_hdd_netif_queue_control(adapter, |
| 2883 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2884 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2885 | |
| 2886 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2887 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2888 | * bursty in nature and depends on the need to transfer. The service |
| 2889 | * layer may down the interface after the usage and up again when |
| 2890 | * required. In some sense, the NDI is expected to be available |
| 2891 | * (like SAP) iface until NDI delete request is issued by the service |
| 2892 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2893 | * interface (NDI). |
| 2894 | */ |
| 2895 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2896 | return 0; |
| 2897 | |
| 2898 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2899 | * The interface is marked as down for outside world (aka kernel) |
| 2900 | * But the driver is pretty much alive inside. The driver needs to |
| 2901 | * tear down the existing connection on the netdev (session) |
| 2902 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2903 | * for this interface. The call also needs to wait until the above |
| 2904 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2905 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2906 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2907 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2908 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2909 | |
| 2910 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2911 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2912 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2913 | |
| 2914 | /* |
| 2915 | * Find if any iface is up. If any iface is up then can't put device to |
| 2916 | * sleep/power save mode |
| 2917 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2918 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2919 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2920 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 2921 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2922 | hdd_prevent_suspend_timeout( |
| 2923 | hdd_ctx->config->iface_change_wait_time, |
| 2924 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2925 | } |
| 2926 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2927 | EXIT(); |
| 2928 | return 0; |
| 2929 | } |
| 2930 | |
| 2931 | /** |
| 2932 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2933 | * @dev: pointer to net_device structure |
| 2934 | * |
| 2935 | * This is called in response to ifconfig down |
| 2936 | * |
| 2937 | * Return: 0 for success and error number for failure |
| 2938 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2939 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2940 | { |
| 2941 | int ret; |
| 2942 | |
| 2943 | cds_ssr_protect(__func__); |
| 2944 | ret = __hdd_stop(dev); |
| 2945 | cds_ssr_unprotect(__func__); |
| 2946 | |
| 2947 | return ret; |
| 2948 | } |
| 2949 | |
| 2950 | /** |
| 2951 | * __hdd_uninit() - HDD uninit function |
| 2952 | * @dev: Pointer to net_device structure |
| 2953 | * |
| 2954 | * This is called during the netdev unregister to uninitialize all data |
| 2955 | * associated with the device |
| 2956 | * |
| 2957 | * Return: None |
| 2958 | */ |
| 2959 | static void __hdd_uninit(struct net_device *dev) |
| 2960 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2961 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2962 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2963 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2964 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2965 | |
| 2966 | do { |
| 2967 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2968 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2969 | break; |
| 2970 | } |
| 2971 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2972 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2973 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2974 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2975 | break; |
| 2976 | } |
| 2977 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2978 | if (dev != adapter->dev) |
| 2979 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2980 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2981 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2982 | |
| 2983 | /* after uninit our adapter structure will no longer be valid */ |
| 2984 | adapter->dev = NULL; |
| 2985 | adapter->magic = 0; |
| 2986 | } while (0); |
| 2987 | |
| 2988 | EXIT(); |
| 2989 | } |
| 2990 | |
| 2991 | /** |
| 2992 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2993 | * @dev: pointer to net_device structure |
| 2994 | * |
| 2995 | * This is called during the netdev unregister to uninitialize all data |
| 2996 | * associated with the device |
| 2997 | * |
| 2998 | * Return: none |
| 2999 | */ |
| 3000 | static void hdd_uninit(struct net_device *dev) |
| 3001 | { |
| 3002 | cds_ssr_protect(__func__); |
| 3003 | __hdd_uninit(dev); |
| 3004 | cds_ssr_unprotect(__func__); |
| 3005 | } |
| 3006 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3007 | static int hdd_open_cesium_nl_sock(void) |
| 3008 | { |
| 3009 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3010 | struct netlink_kernel_cfg cfg = { |
| 3011 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3012 | .input = NULL |
| 3013 | }; |
| 3014 | #endif |
| 3015 | int ret = 0; |
| 3016 | |
| 3017 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3018 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3019 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3020 | THIS_MODULE, |
| 3021 | #endif |
| 3022 | &cfg); |
| 3023 | #else |
| 3024 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3025 | WLAN_NLINK_MCAST_GRP_ID, |
| 3026 | NULL, NULL, THIS_MODULE); |
| 3027 | #endif |
| 3028 | |
| 3029 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3030 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3031 | ret = -ECONNREFUSED; |
| 3032 | } |
| 3033 | |
| 3034 | return ret; |
| 3035 | } |
| 3036 | |
| 3037 | static void hdd_close_cesium_nl_sock(void) |
| 3038 | { |
| 3039 | if (NULL != cesium_nl_srv_sock) { |
| 3040 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3041 | cesium_nl_srv_sock = NULL; |
| 3042 | } |
| 3043 | } |
| 3044 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3045 | /** |
| 3046 | * __hdd_set_mac_address() - set the user specified mac address |
| 3047 | * @dev: Pointer to the net device. |
| 3048 | * @addr: Pointer to the sockaddr. |
| 3049 | * |
| 3050 | * This function sets the user specified mac address using |
| 3051 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3052 | * |
| 3053 | * Return: 0 for success, non zero for failure |
| 3054 | */ |
| 3055 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3056 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3057 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3058 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3060 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3061 | int ret; |
| 3062 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3063 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3064 | |
| 3065 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3066 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3067 | if (0 != ret) |
| 3068 | return ret; |
| 3069 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3070 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3071 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3072 | |
| 3073 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3074 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3075 | } |
| 3076 | |
| 3077 | /** |
| 3078 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3079 | * function from SSR |
| 3080 | * @dev: pointer to net_device structure |
| 3081 | * @addr: Pointer to the sockaddr |
| 3082 | * |
| 3083 | * This function sets the user specified mac address using |
| 3084 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3085 | * |
| 3086 | * Return: 0 for success. |
| 3087 | */ |
| 3088 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3089 | { |
| 3090 | int ret; |
| 3091 | |
| 3092 | cds_ssr_protect(__func__); |
| 3093 | ret = __hdd_set_mac_address(dev, addr); |
| 3094 | cds_ssr_unprotect(__func__); |
| 3095 | |
| 3096 | return ret; |
| 3097 | } |
| 3098 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3099 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3100 | { |
| 3101 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3102 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3103 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3104 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3105 | break; |
| 3106 | } |
| 3107 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3108 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3109 | return NULL; |
| 3110 | |
| 3111 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3112 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3113 | } |
| 3114 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3115 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3116 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3117 | { |
| 3118 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3119 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3120 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3121 | if (!memcmp(releaseAddr, |
| 3122 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3123 | 6)) { |
| 3124 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3125 | break; |
| 3126 | } |
| 3127 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3128 | } |
| 3129 | |
| 3130 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3131 | /** |
| 3132 | * __hdd_set_multicast_list() - set the multicast address list |
| 3133 | * @dev: Pointer to the WLAN device. |
| 3134 | * @skb: Pointer to OS packet (sk_buff). |
| 3135 | * |
| 3136 | * This funciton sets the multicast address list. |
| 3137 | * |
| 3138 | * Return: None |
| 3139 | */ |
| 3140 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3141 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3142 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | int i = 0, status; |
| 3144 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3145 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3146 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3147 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3148 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3149 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3150 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3151 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3152 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3153 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3154 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3155 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3156 | goto out; |
| 3157 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3158 | status = hdd_validate_adapter(adapter); |
| 3159 | if (status) |
| 3160 | goto out; |
| 3161 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3162 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3163 | hdd_err("%s: Driver module is closed", __func__); |
| 3164 | return; |
| 3165 | } |
| 3166 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3167 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3168 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3169 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3170 | goto out; |
| 3171 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3173 | /* Delete already configured multicast address list */ |
| 3174 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3175 | hdd_info("clear previously configured MC address list"); |
| 3176 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3177 | pmo_mc_list_change_notify); |
| 3178 | } |
| 3179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3181 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3182 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3183 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | } else { |
| 3185 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3186 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3187 | 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] | 3188 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3189 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3190 | pmo_mc_list_change_notify); |
| 3191 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3192 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3193 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3194 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3195 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3196 | if (i == mc_count) |
| 3197 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3198 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3199 | 0, ETH_ALEN); |
| 3200 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3201 | ha->addr, ETH_ALEN); |
| 3202 | hdd_info("mlist[%d] = %pM", i, |
| 3203 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | i++; |
| 3205 | } |
| 3206 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3207 | |
| 3208 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3209 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3210 | mc_list_request->count = mc_count; |
| 3211 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3212 | if (status == 0) { |
| 3213 | hdd_enable_mc_addr_filtering(adapter, |
| 3214 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3216 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3217 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3218 | out: |
| 3219 | if (mc_list_request) |
| 3220 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3221 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | } |
| 3223 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3224 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3225 | /** |
| 3226 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3227 | * @dev: pointer to net_device |
| 3228 | * |
| 3229 | * Return: none |
| 3230 | */ |
| 3231 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3232 | { |
| 3233 | cds_ssr_protect(__func__); |
| 3234 | __hdd_set_multicast_list(dev); |
| 3235 | cds_ssr_unprotect(__func__); |
| 3236 | } |
| 3237 | #endif |
| 3238 | |
| 3239 | /** |
| 3240 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3241 | * @dev: Pointer to the WLAN device. |
| 3242 | * @skb: Pointer to OS packet (sk_buff). |
| 3243 | * |
| 3244 | * This function is registered with the Linux OS for network |
| 3245 | * core to decide which queue to use first. |
| 3246 | * |
| 3247 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3248 | */ |
| 3249 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3250 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3251 | , void *accel_priv |
| 3252 | #endif |
| 3253 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3254 | , select_queue_fallback_t fallback |
| 3255 | #endif |
| 3256 | ) |
| 3257 | { |
| 3258 | return hdd_wmm_select_queue(dev, skb); |
| 3259 | } |
| 3260 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3261 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | .ndo_open = hdd_open, |
| 3263 | .ndo_stop = hdd_stop, |
| 3264 | .ndo_uninit = hdd_uninit, |
| 3265 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3266 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3267 | .ndo_get_stats = hdd_get_stats, |
| 3268 | .ndo_do_ioctl = hdd_ioctl, |
| 3269 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3270 | .ndo_select_queue = hdd_select_queue, |
| 3271 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | #endif |
| 3274 | }; |
| 3275 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3276 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3277 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3278 | .ndo_open = hdd_mon_open, |
| 3279 | .ndo_stop = hdd_stop, |
| 3280 | .ndo_get_stats = hdd_get_stats, |
| 3281 | }; |
| 3282 | |
| 3283 | /** |
| 3284 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3285 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3286 | * Return: None |
| 3287 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3288 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3290 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3291 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3292 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3293 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3294 | } |
| 3295 | |
| 3296 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3297 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3298 | * @hdd_ctx: global hdd context |
| 3299 | * @macAddr: mac address to assign to the interface |
| 3300 | * @name: User-visible name of the interface |
| 3301 | * |
| 3302 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3303 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3304 | * |
| 3305 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3306 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3307 | 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] | 3308 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3309 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3310 | const char *name) |
| 3311 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3312 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3313 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3314 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3315 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | /* |
| 3317 | * cfg80211 initialization and registration.... |
| 3318 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3319 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3320 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3321 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3323 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3324 | hdd_mon_mode_ether_setup : ether_setup), |
| 3325 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3326 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3327 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | |
| 3329 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3330 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3331 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3332 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3333 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3334 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3335 | sizeof(sta_ctx->conn_info.staId), |
| 3336 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3337 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3338 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3340 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3342 | qdf_status = qdf_event_create( |
| 3343 | &adapter->qdf_session_open_event); |
| 3344 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3345 | hdd_err("Session open QDF event init failed!"); |
| 3346 | free_netdev(adapter->dev); |
| 3347 | return NULL; |
| 3348 | } |
| 3349 | |
| 3350 | qdf_status = qdf_event_create( |
| 3351 | &adapter->qdf_session_close_event); |
| 3352 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3353 | hdd_err("Session close QDF event init failed!"); |
| 3354 | free_netdev(adapter->dev); |
| 3355 | return NULL; |
| 3356 | } |
| 3357 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3358 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3359 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3360 | init_completion(&adapter->linkup_event_var); |
| 3361 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3362 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3363 | init_completion(&adapter->sta_authorized_event); |
| 3364 | init_completion(&adapter->offchannel_tx_event); |
| 3365 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3366 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3367 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3368 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | |
| 3370 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3371 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3372 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3373 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3374 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3375 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3376 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3377 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3378 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3379 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | |
| 3381 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3382 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3384 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3385 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3386 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3387 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3388 | hdd_set_station_ops(adapter->dev); |
| 3389 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3390 | hdd_dev_setup_destructor(dev); |
| 3391 | dev->ieee80211_ptr = &adapter->wdev; |
| 3392 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3394 | adapter->wdev.netdev = dev; |
| 3395 | /* set dev's parent to underlying device */ |
| 3396 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3397 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3398 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3399 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3400 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3401 | } |
| 3402 | |
| 3403 | return adapter; |
| 3404 | } |
| 3405 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3406 | 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] | 3407 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3408 | struct net_device *dev = adapter->dev; |
| 3409 | int ret; |
| 3410 | |
| 3411 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3412 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3413 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3414 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3415 | |
| 3416 | ret = dev_alloc_name(dev, dev->name); |
| 3417 | if (ret < 0) { |
| 3418 | hdd_err( |
| 3419 | "unable to get dev name: %s, err = 0x%x", |
| 3420 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3421 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3422 | } |
| 3423 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3424 | |
| 3425 | ret = register_netdevice(dev); |
| 3426 | if (ret) { |
| 3427 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3428 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3429 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | } |
| 3431 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3432 | ret = register_netdev(dev); |
| 3433 | if (ret) { |
| 3434 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3435 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3436 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | } |
| 3438 | } |
| 3439 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3440 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3441 | EXIT(); |
| 3442 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3443 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | } |
| 3445 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3446 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3447 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3448 | struct hdd_adapter *adapter; |
| 3449 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3451 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3452 | if (!hdd_ctx) { |
| 3453 | hdd_err("Invalid HDD_CTX"); |
| 3454 | return QDF_STATUS_E_FAILURE; |
| 3455 | } |
| 3456 | |
| 3457 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3458 | if (NULL == adapter) { |
| 3459 | hdd_err("NULL adapter"); |
| 3460 | return QDF_STATUS_E_INVAL; |
| 3461 | } |
| 3462 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3463 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3464 | hdd_debug("session %d opened", adapter->session_id); |
| 3465 | |
| 3466 | return QDF_STATUS_SUCCESS; |
| 3467 | } |
| 3468 | |
| 3469 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3470 | { |
| 3471 | struct hdd_adapter *adapter; |
| 3472 | struct hdd_context *hdd_ctx; |
| 3473 | |
| 3474 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3475 | if (!hdd_ctx) { |
| 3476 | hdd_err("Invalid HDD_CTX"); |
| 3477 | return QDF_STATUS_E_FAILURE; |
| 3478 | } |
| 3479 | |
| 3480 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3481 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3482 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3483 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | } |
| 3485 | |
| 3486 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3487 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3488 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | } |
| 3490 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3491 | /* |
| 3492 | * For NAN Data interface, the close session results in the final |
| 3493 | * indication to the userspace |
| 3494 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3495 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3496 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3497 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | /* |
| 3501 | * We can be blocked while waiting for scheduled work to be |
| 3502 | * flushed, and the adapter structure can potentially be freed, in |
| 3503 | * which case the magic will have been reset. So make sure the |
| 3504 | * magic is still good, and hence the adapter structure is still |
| 3505 | * valid, before signaling completion |
| 3506 | */ |
| 3507 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3508 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3509 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3510 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3511 | } |
| 3512 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3513 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3514 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3515 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3516 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3517 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3518 | if (QDF_IS_STATUS_ERROR(status)) |
| 3519 | return qdf_status_to_os_return(status); |
| 3520 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3521 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3522 | if (QDF_IS_STATUS_ERROR(status)) |
| 3523 | return qdf_status_to_os_return(status); |
| 3524 | |
| 3525 | if (wma_capability_enhanced_mcast_filter()) |
| 3526 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3527 | else |
| 3528 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3529 | |
| 3530 | return qdf_status_to_os_return(status); |
| 3531 | } |
| 3532 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3533 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3534 | { |
| 3535 | QDF_STATUS status; |
| 3536 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3537 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3538 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3539 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3540 | vdev_id = adapter->session_id; |
| 3541 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3542 | |
| 3543 | /* vdev created sanity check */ |
| 3544 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3545 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3546 | return -EINVAL; |
| 3547 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3548 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3549 | /* |
| 3550 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3551 | * it has already asserted. vdev can be released directly. |
| 3552 | */ |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3553 | if (cds_is_driver_recovering()) { |
| 3554 | hdd_debug("SSR: silently release the vdev for session-id: %d", |
| 3555 | adapter->session_id); |
| 3556 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3557 | goto release_vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3558 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3559 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3560 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3561 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3562 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3563 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3564 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3565 | hdd_err("failed to close sme session: %d", status); |
| 3566 | return qdf_status_to_os_return(status); |
| 3567 | } |
| 3568 | |
| 3569 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3570 | status = qdf_wait_for_event_completion( |
| 3571 | &adapter->qdf_session_close_event, |
| 3572 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3573 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3574 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3575 | hdd_ndp_session_end_handler(adapter); |
| 3576 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3577 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3578 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3579 | hdd_err("timed out waiting for close sme session: %u", status); |
| 3580 | return -ETIMEDOUT; |
| 3581 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3582 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
| 3583 | return -EINVAL; |
| 3584 | } else { |
| 3585 | hdd_err("Failed to close sme session (%u)", status); |
| 3586 | return -EINVAL; |
| 3587 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3588 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3589 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3590 | /* do vdev logical destroy via objmgr */ |
| 3591 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3592 | if (errno) { |
| 3593 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3594 | return errno; |
| 3595 | } |
| 3596 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3597 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3598 | errno = hdd_objmgr_release_vdev(adapter); |
| 3599 | if (errno) { |
| 3600 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3601 | return errno; |
| 3602 | } |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3603 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3604 | |
| 3605 | return 0; |
| 3606 | } |
| 3607 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3608 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3609 | struct sme_session_params *session_param, |
| 3610 | csr_roam_completeCallback callback, |
| 3611 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3612 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3613 | uint32_t type; |
| 3614 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3615 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3616 | |
| 3617 | /* determine vdev (sub)type */ |
| 3618 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3619 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3620 | hdd_err("failed to get vdev type: %d", status); |
| 3621 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3623 | session_param->sme_session_id = adapter->session_id; |
| 3624 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3625 | session_param->type_of_persona = type; |
| 3626 | session_param->subtype_of_persona = sub_type; |
| 3627 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3628 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3629 | session_param->callback = callback; |
| 3630 | session_param->callback_ctx = callback_ctx; |
| 3631 | |
| 3632 | return 0; |
| 3633 | } |
| 3634 | |
| 3635 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3636 | csr_roam_completeCallback callback, void *ctx) |
| 3637 | { |
| 3638 | QDF_STATUS status; |
| 3639 | int errno; |
| 3640 | struct hdd_context *hdd_ctx; |
| 3641 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3642 | |
| 3643 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3644 | |
| 3645 | /* do vdev create via objmgr */ |
| 3646 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3647 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3648 | if (errno) { |
| 3649 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3650 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3651 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3652 | |
| 3653 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3654 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3655 | if (QDF_STATUS_SUCCESS != status) { |
| 3656 | hdd_err("failed to reinit session open event"); |
| 3657 | return -EINVAL; |
| 3658 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3659 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3660 | callback, ctx); |
| 3661 | if (errno) { |
| 3662 | hdd_err("failed to populating SME params"); |
| 3663 | goto objmgr_vdev_destroy_procedure; |
| 3664 | } |
| 3665 | |
| 3666 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3667 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3668 | hdd_err("failed to open sme session: %d", status); |
| 3669 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3670 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3671 | } |
| 3672 | |
| 3673 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3674 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3675 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3676 | if (QDF_STATUS_SUCCESS != status) { |
| 3677 | if (adapter->qdf_session_open_event.force_set) { |
| 3678 | /* |
| 3679 | * SSR/PDR has caused shutdown, which has forcefully |
| 3680 | * set the event. Return without the closing session. |
| 3681 | */ |
| 3682 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3683 | hdd_err("Session open event forcefully set"); |
| 3684 | return -EINVAL; |
| 3685 | } else { |
| 3686 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3687 | hdd_err("Session failed to open within timeout period"); |
| 3688 | else |
| 3689 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3690 | status); |
| 3691 | errno = -ETIMEDOUT; |
| 3692 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3693 | goto hdd_vdev_destroy_procedure; |
| 3694 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3698 | errno = hdd_vdev_ready(adapter); |
| 3699 | if (errno) { |
| 3700 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3701 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3702 | } |
| 3703 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3704 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3705 | |
| 3706 | return 0; |
| 3707 | |
| 3708 | /* |
| 3709 | * Due to legacy constraints, we need to destroy in the same order as |
| 3710 | * create. So, split error handling into 2 cases to accommodate. |
| 3711 | */ |
| 3712 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3713 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3714 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3715 | |
| 3716 | return errno; |
| 3717 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3718 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3719 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3720 | |
| 3721 | return errno; |
| 3722 | } |
| 3723 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3724 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3725 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3726 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3727 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3728 | QDF_STATUS status; |
| 3729 | int ret_val; |
| 3730 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3731 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3732 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3733 | 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] | 3734 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3735 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3737 | status = hdd_register_wext(adapter->dev); |
| 3738 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3739 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | goto error_register_wext; |
| 3741 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3742 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 3744 | hdd_debug("Disabling Green AP"); |
| 3745 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, false); |
| 3746 | wlan_green_ap_stop(hdd_ctx->hdd_pdev); |
| 3747 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3748 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3749 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3750 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3751 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3752 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 3753 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3754 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3755 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | hdd_ctx->config->OperatingChannel; |
| 3757 | |
| 3758 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3759 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3760 | |
| 3761 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3762 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3763 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3764 | status, status); |
| 3765 | goto error_init_txrx; |
| 3766 | } |
| 3767 | |
| 3768 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3769 | |
| 3770 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3771 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3772 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3773 | status, status); |
| 3774 | goto error_wmm_init; |
| 3775 | } |
| 3776 | |
| 3777 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3778 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3779 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3781 | hdd_ctx->config->enableSifsBurst, |
| 3782 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3783 | if (ret_val) |
| 3784 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3785 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3786 | /* |
| 3787 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3788 | * during that time, then as part of SSR init, do not enable |
| 3789 | * the LRO again. Keep the LRO state same as before SSR. |
| 3790 | */ |
| 3791 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3792 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3793 | |
| 3794 | /* rcpi info initialization */ |
| 3795 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3796 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3797 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3798 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | error_wmm_init: |
| 3800 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3801 | hdd_deinit_tx_rx(adapter); |
| 3802 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3803 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3804 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3805 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3807 | return status; |
| 3808 | } |
| 3809 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3810 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3811 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3812 | * @hdd_ctx: global hdd context |
| 3813 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3814 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3815 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3816 | * |
| 3817 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3818 | * |
| 3819 | * Return: None. |
| 3820 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3821 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3822 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3823 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3824 | { |
| 3825 | ENTER_DEV(adapter->dev); |
| 3826 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3827 | if (adapter->dev) { |
| 3828 | if (rtnl_held) |
| 3829 | adapter->dev->wireless_handlers = NULL; |
| 3830 | else { |
| 3831 | rtnl_lock(); |
| 3832 | adapter->dev->wireless_handlers = NULL; |
| 3833 | rtnl_unlock(); |
| 3834 | } |
| 3835 | } |
| 3836 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3837 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3838 | hdd_deinit_tx_rx(adapter); |
| 3839 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3840 | } |
| 3841 | |
| 3842 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3843 | hdd_wmm_adapter_close(adapter); |
| 3844 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3845 | } |
| 3846 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3847 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3848 | EXIT(); |
| 3849 | } |
| 3850 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3851 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 3852 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | bool rtnl_held) |
| 3854 | { |
| 3855 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3857 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3858 | case QDF_STA_MODE: |
| 3859 | case QDF_P2P_CLIENT_MODE: |
| 3860 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3861 | case QDF_IBSS_MODE: |
| 3862 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3863 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3864 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3865 | break; |
| 3866 | } |
| 3867 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3868 | case QDF_SAP_MODE: |
| 3869 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3870 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3871 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | break; |
| 3873 | } |
| 3874 | |
| 3875 | default: |
| 3876 | break; |
| 3877 | } |
| 3878 | |
| 3879 | EXIT(); |
| 3880 | } |
| 3881 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3882 | 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] | 3883 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3884 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3885 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | |
| 3887 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3888 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3889 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3890 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3891 | return; |
| 3892 | } |
| 3893 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3894 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3895 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 3896 | hdd_adapter_runtime_suspend_deinit(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3897 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3898 | /* |
| 3899 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3900 | * the driver is almost closed and cannot handle either control |
| 3901 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3902 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3903 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3904 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3905 | * the interface is closed and restricts any operations on that |
| 3906 | */ |
| 3907 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3908 | |
| 3909 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3910 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3911 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3912 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3913 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | /* |
| 3915 | * Note that the adapter is no longer valid at this point |
| 3916 | * since the memory has been reclaimed |
| 3917 | */ |
| 3918 | } |
| 3919 | } |
| 3920 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3921 | 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] | 3922 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3923 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3924 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3925 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3926 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3927 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 3928 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3929 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3930 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3931 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3932 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3933 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3934 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3935 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3936 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3937 | /** |
| 3938 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3939 | * @hdd_ctx: HDD Context |
| 3940 | * @adapter: HDD Adapter |
| 3941 | * |
| 3942 | * This function set the FW Debug log level based on the INI. |
| 3943 | * |
| 3944 | * Return: None |
| 3945 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3946 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3947 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3948 | { |
| 3949 | uint8_t count = 0, numentries = 0, |
| 3950 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3951 | uint32_t value = 0; |
| 3952 | int ret; |
| 3953 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3954 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3955 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3956 | 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] | 3957 | return; |
| 3958 | } |
| 3959 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3960 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3961 | hdd_ctx->fw_log_settings.dl_type = |
| 3962 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3963 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3964 | WMI_DBGLOG_TYPE, |
| 3965 | hdd_ctx->config->enableFwLogType, |
| 3966 | DBG_CMD); |
| 3967 | if (ret != 0) |
| 3968 | hdd_err("Failed to enable FW log type ret %d", |
| 3969 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3970 | |
| 3971 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3972 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3973 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3974 | WMI_DBGLOG_LOG_LEVEL, |
| 3975 | hdd_ctx->config->enableFwLogLevel, |
| 3976 | DBG_CMD); |
| 3977 | if (ret != 0) |
| 3978 | hdd_err("Failed to enable FW log level ret %d", |
| 3979 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3980 | |
| 3981 | hdd_string_to_u8_array( |
| 3982 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3983 | moduleloglevel, |
| 3984 | &numentries, |
| 3985 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3986 | |
| 3987 | while (count < numentries) { |
| 3988 | /* |
| 3989 | * FW module log level input string looks like |
| 3990 | * below: |
| 3991 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3992 | * <Log Level>,... |
| 3993 | * For example: |
| 3994 | * gFwDebugModuleLoglevel= |
| 3995 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3996 | * Above input string means : |
| 3997 | * For FW module ID 1 enable log level 0 |
| 3998 | * For FW module ID 2 enable log level 1 |
| 3999 | * For FW module ID 3 enable log level 2 |
| 4000 | * For FW module ID 4 enable log level 3 |
| 4001 | * For FW module ID 5 enable log level 4 |
| 4002 | * For FW module ID 6 enable log level 5 |
| 4003 | * For FW module ID 7 enable log level 6 |
| 4004 | */ |
| 4005 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4006 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4007 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4008 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4009 | moduleloglevel[count], |
| 4010 | moduleloglevel[count + 1]); |
| 4011 | return; |
| 4012 | } |
| 4013 | |
| 4014 | value = moduleloglevel[count] << 16; |
| 4015 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4016 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4017 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4018 | value, DBG_CMD); |
| 4019 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4020 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4021 | value, ret); |
| 4022 | |
| 4023 | count += 2; |
| 4024 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4025 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4026 | } |
| 4027 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4028 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4029 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4030 | { |
| 4031 | } |
| 4032 | |
| 4033 | #endif |
| 4034 | |
| 4035 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4036 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4037 | * @adapter: HDD adapter |
| 4038 | * |
| 4039 | * Return: 0 on success or errno on failure |
| 4040 | */ |
| 4041 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4042 | { |
| 4043 | int ret_val; |
| 4044 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4045 | |
| 4046 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4047 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4048 | hdd_ctx->config->txchainmask1x1, |
| 4049 | hdd_ctx->config->rxchainmask1x1); |
| 4050 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4051 | hdd_ctx->config->dual_mac_feature_disable, |
| 4052 | hdd_ctx->config->tx_chain_mask_2g, |
| 4053 | hdd_ctx->config->rx_chain_mask_2g); |
| 4054 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4055 | hdd_ctx->config->tx_chain_mask_5g, |
| 4056 | hdd_ctx->config->rx_chain_mask_5g); |
| 4057 | |
| 4058 | if (hdd_ctx->config->enable2x2) { |
| 4059 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4060 | return 0; |
| 4061 | } |
| 4062 | |
| 4063 | if (hdd_ctx->config->txchainmask1x1) { |
| 4064 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4065 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4066 | hdd_ctx->config->txchainmask1x1, |
| 4067 | PDEV_CMD); |
| 4068 | if (ret_val) |
| 4069 | goto error; |
| 4070 | } |
| 4071 | |
| 4072 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4073 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4074 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4075 | hdd_ctx->config->rxchainmask1x1, |
| 4076 | PDEV_CMD); |
| 4077 | if (ret_val) |
| 4078 | goto error; |
| 4079 | } |
| 4080 | |
| 4081 | if (hdd_ctx->lte_coex_ant_share) { |
| 4082 | hdd_info("lte ant sharing enabled. skip per band chain mask"); |
| 4083 | return 0; |
| 4084 | } |
| 4085 | |
| 4086 | if (hdd_ctx->config->txchainmask1x1 || |
| 4087 | hdd_ctx->config->rxchainmask1x1) { |
| 4088 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4089 | return 0; |
| 4090 | } |
| 4091 | |
| 4092 | if (!hdd_ctx->config->dual_mac_feature_disable) { |
| 4093 | hdd_info("DBS enabled. skip per band chain mask"); |
| 4094 | return 0; |
| 4095 | } |
| 4096 | |
| 4097 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4098 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4099 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4100 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4101 | if (0 != ret_val) |
| 4102 | goto error; |
| 4103 | } |
| 4104 | |
| 4105 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4106 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4107 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4108 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4109 | if (0 != ret_val) |
| 4110 | goto error; |
| 4111 | } |
| 4112 | |
| 4113 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4114 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4115 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4116 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4117 | if (0 != ret_val) |
| 4118 | goto error; |
| 4119 | } |
| 4120 | |
| 4121 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4122 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4123 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4124 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4125 | if (0 != ret_val) |
| 4126 | goto error; |
| 4127 | } |
| 4128 | |
| 4129 | return 0; |
| 4130 | |
| 4131 | error: |
| 4132 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4133 | return -EINVAL; |
| 4134 | } |
| 4135 | |
| 4136 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4137 | * hdd_set_fw_params() - Set parameters to firmware |
| 4138 | * @adapter: HDD adapter |
| 4139 | * |
| 4140 | * This function Sets various parameters to fw once the |
| 4141 | * adapter is started. |
| 4142 | * |
| 4143 | * Return: 0 on success or errno on failure |
| 4144 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4145 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4146 | { |
| 4147 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4148 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4149 | |
| 4150 | ENTER_DEV(adapter->dev); |
| 4151 | |
| 4152 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4153 | if (!hdd_ctx) |
| 4154 | return -EINVAL; |
| 4155 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4156 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4157 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4158 | return 0; |
| 4159 | } |
| 4160 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4161 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4162 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4163 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4164 | if (ret) { |
| 4165 | hdd_err("Failed to set LPRx"); |
| 4166 | goto error; |
| 4167 | } |
| 4168 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4169 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4170 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4171 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4172 | hdd_ctx->config->upper_brssi_thresh); |
| 4173 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4174 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4175 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4176 | hdd_ctx->config->lower_brssi_thresh); |
| 4177 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4178 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4179 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4180 | hdd_ctx->config->enable_dtim_1chrx); |
| 4181 | } |
| 4182 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4183 | if (hdd_ctx->config->enable2x2) { |
| 4184 | hdd_debug("configuring 2x2 mode fw params"); |
| 4185 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4186 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4187 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4188 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4189 | PDEV_CMD); |
| 4190 | if (ret) { |
| 4191 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4192 | ret); |
| 4193 | goto error; |
| 4194 | } |
| 4195 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4196 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4197 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4198 | hdd_debug("configuring 1x1 mode fw params"); |
| 4199 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4200 | /* |
| 4201 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4202 | * we are passing two value |
| 4203 | * as param_id << 29 | param_value. |
| 4204 | * Below param_value = 0(disable) |
| 4205 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4206 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4207 | WMI_STA_SMPS_PARAM_CMDID, |
| 4208 | HDD_DTIM_1CHAIN_RX_ID << |
| 4209 | HDD_SMPS_PARAM_VALUE_S, |
| 4210 | VDEV_CMD); |
| 4211 | if (ret) { |
| 4212 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4213 | goto error; |
| 4214 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4215 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4216 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4217 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4218 | |
| 4219 | if (hdd_configure_chain_mask(adapter)) |
| 4220 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4221 | } |
| 4222 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4223 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4224 | WMI_PDEV_PARAM_HYST_EN, |
| 4225 | hdd_ctx->config->enableMemDeepSleep, |
| 4226 | PDEV_CMD); |
| 4227 | if (ret) { |
| 4228 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4229 | goto error; |
| 4230 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4231 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4232 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4233 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4234 | hdd_ctx->config->rts_profile, |
| 4235 | VDEV_CMD); |
| 4236 | if (ret) { |
| 4237 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4238 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4239 | } |
| 4240 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4241 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4242 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4243 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4244 | GEN_VDEV_PARAM_AMSDU, |
| 4245 | hdd_ctx->config->max_amsdu_num, |
| 4246 | GEN_CMD); |
| 4247 | if (ret != 0) { |
| 4248 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4249 | goto error; |
| 4250 | } |
| 4251 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4252 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4253 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4254 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4255 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4256 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4257 | error: |
| 4258 | return -EINVAL; |
| 4259 | } |
| 4260 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4261 | /** |
| 4262 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4263 | * @hdd_ctx: global hdd context |
| 4264 | * @session_type: type of the interface to be created |
| 4265 | * @iface_name: User-visible name of the interface |
| 4266 | * @macAddr: MAC address to assign to the interface |
| 4267 | * @name_assign_type: the name of assign type of the netdev |
| 4268 | * @rtnl_held: the rtnl lock hold flag |
| 4269 | * |
| 4270 | * This function open and setup the hdd adpater according to the device |
| 4271 | * type request, assign the name, the mac address assigned, and then prepared |
| 4272 | * the hdd related parameters, queue, lock and ready to start. |
| 4273 | * |
| 4274 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4275 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4276 | 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] | 4277 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4278 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4279 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4280 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4281 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4282 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4283 | |
| 4284 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4285 | /* |
| 4286 | * Max limit reached on the number of vdevs configured by the |
| 4287 | * host. Return error |
| 4288 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4289 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4290 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4291 | return NULL; |
| 4292 | } |
| 4293 | |
| 4294 | if (macAddr == NULL) { |
| 4295 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4296 | 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] | 4297 | return NULL; |
| 4298 | } |
| 4299 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4300 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4301 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4302 | " already exists", |
| 4303 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | return NULL; |
| 4305 | } |
| 4306 | |
| 4307 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4308 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4309 | /* Reset locally administered bit if the device mode is STA */ |
| 4310 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4311 | hdd_info("locally administered bit reset in sta mode: " |
| 4312 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4313 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4314 | case QDF_P2P_CLIENT_MODE: |
| 4315 | case QDF_P2P_DEVICE_MODE: |
| 4316 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4317 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4318 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4319 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4320 | name_assign_type, |
| 4321 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4322 | |
| 4323 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4324 | hdd_err("failed to allocate adapter for session %d", |
| 4325 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | return NULL; |
| 4327 | } |
| 4328 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4329 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4330 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4331 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4332 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4333 | else if (QDF_MONITOR_MODE == session_type) |
| 4334 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4335 | else |
| 4336 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4337 | |
| 4338 | adapter->device_mode = session_type; |
| 4339 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | /* |
| 4342 | * Workqueue which gets scheduled in IPv4 notification |
| 4343 | * callback |
| 4344 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4345 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4346 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4347 | |
| 4348 | #ifdef WLAN_NS_OFFLOAD |
| 4349 | /* |
| 4350 | * Workqueue which gets scheduled in IPv6 |
| 4351 | * notification callback. |
| 4352 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4353 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4354 | hdd_ipv6_notifier_work_queue); |
| 4355 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4356 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4357 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4358 | goto err_deinit_adapter_runtime_pm; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4359 | |
| 4360 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4361 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4362 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4363 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4364 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4365 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4366 | /* Initialize NAN Data Interface */ |
| 4367 | if (QDF_NDI_MODE == session_type) { |
| 4368 | status = hdd_init_nan_data_mode(adapter); |
| 4369 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4370 | goto err_deinit_adapter_runtime_pm; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4371 | } |
| 4372 | |
| 4373 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4374 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4375 | case QDF_P2P_GO_MODE: |
| 4376 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4377 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4378 | name_assign_type, |
| 4379 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4380 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4381 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4382 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4383 | return NULL; |
| 4384 | } |
| 4385 | |
| 4386 | adapter->wdev.iftype = |
| 4387 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4388 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4389 | NL80211_IFTYPE_P2P_GO; |
| 4390 | adapter->device_mode = session_type; |
| 4391 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4392 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4393 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4395 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4396 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4397 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4398 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4399 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4400 | |
| 4401 | /* |
| 4402 | * Workqueue which gets scheduled in IPv4 notification |
| 4403 | * callback |
| 4404 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4405 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4406 | hdd_ipv4_notifier_work_queue); |
| 4407 | |
| 4408 | #ifdef WLAN_NS_OFFLOAD |
| 4409 | /* |
| 4410 | * Workqueue which gets scheduled in IPv6 |
| 4411 | * notification callback. |
| 4412 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4413 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4414 | hdd_ipv6_notifier_work_queue); |
| 4415 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4416 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4417 | case QDF_FTM_MODE: |
| 4418 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4419 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4420 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4421 | if (NULL == adapter) { |
| 4422 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4423 | return NULL; |
| 4424 | } |
| 4425 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4426 | adapter->device_mode = session_type; |
| 4427 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4428 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4429 | goto err_deinit_adapter_runtime_pm; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4430 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4431 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4432 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4433 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4434 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4435 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4436 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4437 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4438 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4439 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4440 | return NULL; |
| 4441 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4442 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4443 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4444 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4445 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4446 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4447 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | } |
| 4449 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4450 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | if (NULL != adapter) { |
| 4452 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4453 | adapter = NULL; |
| 4454 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4455 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4456 | return NULL; |
| 4457 | } |
| 4458 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4459 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4460 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4461 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4462 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4463 | /* Adapter successfully added. Increment the vdev count */ |
| 4464 | hdd_ctx->current_intf_count++; |
| 4465 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4466 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | hdd_ctx->current_intf_count); |
| 4468 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4469 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | } |
| 4471 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4472 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4473 | hdd_err("Interface %s wow debug_fs init failed", |
| 4474 | netdev_name(adapter->dev)); |
| 4475 | |
| 4476 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4477 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4478 | |
| 4479 | return adapter; |
| 4480 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4481 | err_deinit_adapter_runtime_pm: |
| 4482 | /* |
| 4483 | * For certain error cases that hdd_alloc_station_adapter() |
| 4484 | * is used to allocate the adapter. |
| 4485 | */ |
| 4486 | hdd_adapter_runtime_suspend_deinit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4487 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4488 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4489 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | |
| 4491 | return NULL; |
| 4492 | } |
| 4493 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4494 | 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] | 4495 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4496 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4497 | /* |
| 4498 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4499 | * |
| 4500 | * The reason is to fix one race condition between |
| 4501 | * bus bandwidth work and cleaning up an adapter. |
| 4502 | * Under some conditions, it is possible for the bus bandwidth |
| 4503 | * work to access a particularly destroyed adapter, leading to |
| 4504 | * use-after-free. |
| 4505 | */ |
| 4506 | hdd_debug("wait for bus bw work to flush"); |
| 4507 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4508 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4510 | /* cleanup adapter */ |
| 4511 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4512 | adapter->device_mode); |
| 4513 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4514 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4516 | /* conditionally restart the bw timer */ |
| 4517 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4518 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4519 | /* Adapter removed. Decrement vdev count */ |
| 4520 | if (hdd_ctx->current_intf_count != 0) |
| 4521 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4522 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4523 | /* Fw will take care incase of concurrency */ |
| 4524 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | } |
| 4526 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4527 | /** |
| 4528 | * hdd_close_all_adapters - Close all open adapters |
| 4529 | * @hdd_ctx: Hdd context |
| 4530 | * rtnl_held: True if RTNL lock held |
| 4531 | * |
| 4532 | * Close all open adapters. |
| 4533 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4534 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4535 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4536 | 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] | 4537 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4538 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4539 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4540 | |
| 4541 | ENTER(); |
| 4542 | |
| 4543 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4544 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4545 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4546 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4547 | adapter->mac_addr.bytes); |
| 4548 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4549 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4550 | /* Adapter removed. Decrement vdev count */ |
| 4551 | if (hdd_ctx->current_intf_count != 0) |
| 4552 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4553 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4554 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4555 | |
| 4556 | EXIT(); |
| 4557 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4558 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | } |
| 4560 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4561 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4562 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4563 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4564 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4565 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4566 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4567 | case QDF_STA_MODE: |
| 4568 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4570 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4571 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4572 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | break; |
| 4574 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4575 | case QDF_SAP_MODE: |
| 4576 | case QDF_P2P_GO_MODE: |
| 4577 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4578 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4579 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4580 | break; |
| 4581 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4582 | case QDF_FTM_MODE: |
| 4583 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4584 | default: |
| 4585 | /* |
| 4586 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4587 | * for these kind of devices |
| 4588 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4589 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4590 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4591 | return; |
| 4592 | } |
| 4593 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4594 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4595 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4596 | updateIE.ieBufferlength = 0; |
| 4597 | updateIE.pAdditionIEBuffer = NULL; |
| 4598 | updateIE.append = true; |
| 4599 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4600 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4601 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4602 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4603 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4604 | } |
| 4605 | } |
| 4606 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4607 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4608 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4609 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4610 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4611 | struct hdd_wext_state *pWextState = |
| 4612 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4613 | union iwreq_data wrqu; |
| 4614 | tSirUpdateIE updateIE; |
| 4615 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4616 | tsap_Config_t *sap_config; |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4617 | bool is_enabled = false; |
| 4618 | uint8_t ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4619 | |
| 4620 | ENTER(); |
| 4621 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4622 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4623 | wlan_hdd_netif_queue_control(adapter, |
| 4624 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4625 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4626 | /* |
| 4627 | * if this is the last active connection check & stop the |
| 4628 | * opportunistic timer first |
| 4629 | */ |
| 4630 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4631 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4632 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4633 | adapter->device_mode), NULL) == 1)) || |
| 4634 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4635 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4636 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4637 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4638 | case QDF_STA_MODE: |
| 4639 | case QDF_P2P_CLIENT_MODE: |
| 4640 | case QDF_IBSS_MODE: |
| 4641 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4642 | case QDF_NDI_MODE: |
| 4643 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4644 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4645 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4646 | hdd_is_connecting( |
| 4647 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4648 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4649 | /* |
| 4650 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4651 | * extract from ndi_ctx. |
| 4652 | */ |
| 4653 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4654 | qdf_ret_status = sme_roam_disconnect( |
| 4655 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4656 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4657 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4658 | else if (pWextState->roamProfile.BSSType == |
| 4659 | eCSR_BSS_TYPE_START_IBSS) |
| 4660 | qdf_ret_status = sme_roam_disconnect( |
| 4661 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4662 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4663 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4664 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4665 | qdf_ret_status = |
| 4666 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4667 | hdd_debug("Send disconnected event to userspace"); |
| 4668 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4669 | adapter->dev, true, |
| 4670 | WLAN_REASON_UNSPECIFIED); |
| 4671 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4672 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4673 | qdf_ret_status = sme_roam_disconnect( |
| 4674 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4675 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4676 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4677 | /* success implies disconnect command got |
| 4678 | * queued up successfully |
| 4679 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4680 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4681 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4682 | rc = wait_for_completion_timeout( |
| 4683 | &adapter->disconnect_comp_var, |
| 4684 | msecs_to_jiffies |
| 4685 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4686 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4687 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4688 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4689 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4690 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4691 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4692 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4693 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4694 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4695 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4696 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4697 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4698 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4699 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4700 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4701 | |
| 4702 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4703 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | #endif |
| 4705 | |
| 4706 | hdd_deregister_tx_flow_control(adapter); |
| 4707 | |
| 4708 | #ifdef WLAN_NS_OFFLOAD |
| 4709 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4710 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4711 | #endif |
| 4712 | #endif |
| 4713 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4714 | if (adapter->device_mode == QDF_STA_MODE) |
| 4715 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4716 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4717 | |
| 4718 | if (wlan_hdd_try_disconnect(adapter)) { |
| 4719 | hdd_err("Error: Can't disconnect adapter"); |
| 4720 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4721 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4722 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4723 | ret = hdd_check_green_ap_enable(hdd_ctx, &is_enabled); |
| 4724 | if (!ret) { |
| 4725 | hdd_debug("Green AP enable status: %d", is_enabled); |
| 4726 | if (is_enabled) { |
| 4727 | hdd_debug("Enabling Green AP"); |
| 4728 | ucfg_green_ap_set_ps_config(hdd_ctx->hdd_pdev, |
| 4729 | true); |
| 4730 | wlan_green_ap_start(hdd_ctx->hdd_pdev); |
| 4731 | } |
| 4732 | } else { |
| 4733 | hdd_err("Failed to check if Green AP should be enabled or not"); |
| 4734 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4735 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 4736 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4737 | break; |
| 4738 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4739 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4740 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4741 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4742 | sap_config = &adapter->session.ap.sap_config; |
| 4743 | if (sap_config) |
| 4744 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4745 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4746 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4747 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4748 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4749 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4750 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4751 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4752 | cds_flush_delayed_work( |
| 4753 | &adapter->acs_pending_work); |
| 4754 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4755 | } |
| 4756 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4757 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4759 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4760 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4761 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4762 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4763 | |
| 4764 | hdd_deregister_tx_flow_control(adapter); |
| 4765 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4766 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4767 | mutex_lock(&hdd_ctx->sap_lock); |
| 4768 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4769 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4770 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4771 | |
| 4772 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4773 | status = wlansap_stop_bss( |
| 4774 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4775 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4776 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4777 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4778 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4779 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4780 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4781 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4782 | qdf_wait_for_event_completion( |
| 4783 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4784 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4786 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4787 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4788 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4789 | } |
| 4790 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4791 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4792 | } |
| 4793 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4794 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4795 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4796 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4797 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4798 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4799 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4800 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4801 | updateIE.ieBufferlength = 0; |
| 4802 | updateIE.pAdditionIEBuffer = NULL; |
| 4803 | updateIE.append = false; |
| 4804 | updateIE.notify = false; |
| 4805 | /* Probe bcn reset */ |
| 4806 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4807 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4808 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4809 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4810 | } |
| 4811 | /* Assoc resp reset */ |
| 4812 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4813 | &updateIE, |
| 4814 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4815 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4816 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4817 | } |
| 4818 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4819 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4821 | qdf_mem_free(adapter->session.ap.beacon); |
| 4822 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4823 | /* |
| 4824 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4825 | */ |
| 4826 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4827 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4828 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4829 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4830 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4831 | #endif |
| 4832 | |
| 4833 | #ifdef WLAN_NS_OFFLOAD |
| 4834 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4835 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4836 | #endif |
| 4837 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4838 | |
| 4839 | hdd_vdev_destroy(adapter); |
| 4840 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4841 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4842 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4843 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4844 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4845 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4846 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4847 | break; |
| 4848 | default: |
| 4849 | break; |
| 4850 | } |
| 4851 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4852 | if (adapter->scan_info.default_scan_ies) { |
| 4853 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 4854 | adapter->scan_info.default_scan_ies = NULL; |
| 4855 | } |
| 4856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4857 | EXIT(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4858 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4859 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | } |
| 4861 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4862 | /** |
| 4863 | * hdd_deinit_all_adapters - deinit all adapters |
| 4864 | * @hdd_ctx: HDD context |
| 4865 | * @rtnl_held: True if RTNL lock held |
| 4866 | * |
| 4867 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4868 | 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] | 4869 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4870 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4871 | |
| 4872 | ENTER(); |
| 4873 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4874 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4875 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4876 | |
| 4877 | EXIT(); |
| 4878 | } |
| 4879 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4880 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4881 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4882 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | |
| 4884 | ENTER(); |
| 4885 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4886 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4887 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4888 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4889 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4890 | |
| 4891 | EXIT(); |
| 4892 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4893 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | } |
| 4895 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4896 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 4897 | struct hdd_adapter *adapter) |
| 4898 | { |
| 4899 | switch (adapter->device_mode) { |
| 4900 | case QDF_STA_MODE: |
| 4901 | case QDF_P2P_CLIENT_MODE: |
| 4902 | case QDF_IBSS_MODE: |
| 4903 | case QDF_P2P_DEVICE_MODE: |
| 4904 | case QDF_NDI_MODE: |
| 4905 | wlan_hdd_scan_abort(adapter); |
| 4906 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4907 | if (adapter->device_mode == QDF_STA_MODE) |
| 4908 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4909 | adapter->dev); |
| 4910 | break; |
| 4911 | case QDF_P2P_GO_MODE: |
| 4912 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4913 | break; |
| 4914 | case QDF_SAP_MODE: |
| 4915 | wlan_hdd_undo_acs(adapter); |
| 4916 | break; |
| 4917 | default: |
| 4918 | break; |
| 4919 | } |
| 4920 | } |
| 4921 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4922 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4924 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4925 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4926 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame^] | 4927 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | |
| 4929 | ENTER(); |
| 4930 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4931 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4932 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4933 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame^] | 4934 | hdd_notice("[SSR] reset adapter with device mode %s(%d)", |
| 4935 | hdd_device_mode_to_string(adapter->device_mode), |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4936 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4937 | |
| 4938 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4939 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4940 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4941 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4942 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4943 | if (hdd_ctx->config->sap_internal_restart && |
| 4944 | adapter->device_mode == QDF_SAP_MODE) { |
| 4945 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4946 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4947 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4948 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4949 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4950 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4951 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4952 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4953 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4954 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4955 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4956 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4957 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4958 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4959 | adapter->session.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4960 | |
| 4961 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4962 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4963 | adapter->device_mode, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4964 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4965 | hdd_wmm_adapter_close(adapter); |
| 4966 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4967 | } |
| 4968 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4969 | if (adapter->device_mode == QDF_STA_MODE) |
| 4970 | hdd_clear_fils_connection_info(adapter); |
| 4971 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4972 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4973 | /* |
| 4974 | * If adapter is SAP, set session ID to invalid |
| 4975 | * since SAP session will be cleanup during SSR. |
| 4976 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4977 | wlansap_set_invalid_session( |
| 4978 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4979 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4980 | wlansap_cleanup_cac_timer( |
| 4981 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4982 | } |
| 4983 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame^] | 4984 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4985 | if (adapter->device_mode == QDF_STA_MODE || |
| 4986 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4987 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4988 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4989 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4990 | |
| 4991 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4992 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame^] | 4993 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 4994 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 4995 | if (adapter->sta_info[sta_id].in_use) { |
| 4996 | hdd_debug("[SSR] deregister STA with ID %d", |
| 4997 | sta_id); |
| 4998 | hdd_softap_deregister_sta(adapter, |
| 4999 | sta_id); |
| 5000 | adapter->sta_info[sta_id].in_use = 0; |
| 5001 | } |
| 5002 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5003 | } |
| 5004 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5005 | /* Destroy vdev which will be recreated during reinit. */ |
| 5006 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5007 | } |
| 5008 | |
| 5009 | EXIT(); |
| 5010 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5011 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5012 | } |
| 5013 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5014 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5015 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5016 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5017 | bool close_modules = true; |
| 5018 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5019 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5020 | hdd_info("FTM mode, don't close the module"); |
| 5021 | return false; |
| 5022 | } |
| 5023 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5024 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5025 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5026 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5027 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5028 | close_modules = false; |
| 5029 | break; |
| 5030 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5031 | } |
| 5032 | |
| 5033 | return close_modules; |
| 5034 | } |
| 5035 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5036 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5037 | { |
| 5038 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5039 | return true; |
| 5040 | else |
| 5041 | return false; |
| 5042 | } |
| 5043 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5044 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5045 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5046 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5047 | struct ieee80211_channel *channel, |
| 5048 | const u8 *bssid, const u8 *ssid, |
| 5049 | size_t ssid_len) |
| 5050 | { |
| 5051 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5052 | ssid, ssid_len, |
| 5053 | WLAN_CAPABILITY_ESS, |
| 5054 | WLAN_CAPABILITY_ESS); |
| 5055 | } |
| 5056 | #else |
| 5057 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5058 | struct ieee80211_channel *channel, |
| 5059 | const u8 *bssid, const u8 *ssid, |
| 5060 | size_t ssid_len) |
| 5061 | { |
| 5062 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5063 | ssid, ssid_len, |
| 5064 | IEEE80211_BSS_TYPE_ESS, |
| 5065 | IEEE80211_PRIVACY_ANY); |
| 5066 | } |
| 5067 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5068 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5069 | #if defined CFG80211_CONNECT_BSS || \ |
| 5070 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5071 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5072 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5073 | /** |
| 5074 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5075 | * @timeout_reason: reason for connect timeout |
| 5076 | * |
| 5077 | * This function is used to convert host timeout |
| 5078 | * reason enum to kernel specific enum. |
| 5079 | * |
| 5080 | * Return: nl timeout enum |
| 5081 | */ |
| 5082 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5083 | tSirResultCodes timeout_reason) |
| 5084 | { |
| 5085 | switch (timeout_reason) { |
| 5086 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5087 | return NL80211_TIMEOUT_SCAN; |
| 5088 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5089 | return NL80211_TIMEOUT_AUTH; |
| 5090 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5091 | return NL80211_TIMEOUT_ASSOC; |
| 5092 | default: |
| 5093 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5094 | } |
| 5095 | } |
| 5096 | |
| 5097 | /** |
| 5098 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5099 | * @dev: network device |
| 5100 | * @bssid: bssid to which we want to associate |
| 5101 | * @timeout_reason: reason for connect timeout |
| 5102 | * |
| 5103 | * This API is used to send connection timeout reason to supplicant |
| 5104 | * |
| 5105 | * Return: void |
| 5106 | */ |
| 5107 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5108 | const u8 *bssid, |
| 5109 | tSirResultCodes timeout_reason) |
| 5110 | { |
| 5111 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5112 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5113 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5114 | |
| 5115 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5116 | nl_timeout_reason); |
| 5117 | } |
| 5118 | |
| 5119 | /** |
| 5120 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5121 | * @dev: network device |
| 5122 | * @bssid: bssid to which we want to associate |
| 5123 | * @req_ie: Request Information Element |
| 5124 | * @req_ie_len: len of the req IE |
| 5125 | * @resp_ie: Response IE |
| 5126 | * @resp_ie_len: len of ht response IE |
| 5127 | * @status: status |
| 5128 | * @gfp: Kernel Flag |
| 5129 | * @timeout_reason: reason for connect timeout |
| 5130 | * |
| 5131 | * Return: void |
| 5132 | */ |
| 5133 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5134 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5135 | size_t req_ie_len, const u8 *resp_ie, |
| 5136 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5137 | tSirResultCodes timeout_reason) |
| 5138 | { |
| 5139 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5140 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5141 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5142 | |
| 5143 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5144 | resp_ie, resp_ie_len, status, gfp, |
| 5145 | nl_timeout_reason); |
| 5146 | } |
| 5147 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5148 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5149 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5150 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5151 | const u8 *bssid, |
| 5152 | tSirResultCodes timeout_reason) |
| 5153 | { |
| 5154 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5155 | } |
| 5156 | #endif |
| 5157 | |
| 5158 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5159 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5160 | size_t req_ie_len, const u8 *resp_ie, |
| 5161 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5162 | tSirResultCodes timeout_reason) |
| 5163 | { |
| 5164 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5165 | resp_ie, resp_ie_len, status, gfp); |
| 5166 | } |
| 5167 | #endif |
| 5168 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5169 | /** |
| 5170 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5171 | * @dev: network device |
| 5172 | * @bssid: bssid to which we want to associate |
| 5173 | * @req_ie: Request Information Element |
| 5174 | * @req_ie_len: len of the req IE |
| 5175 | * @resp_ie: Response IE |
| 5176 | * @resp_ie_len: len of ht response IE |
| 5177 | * @status: status |
| 5178 | * @gfp: Kernel Flag |
| 5179 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5180 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5181 | * |
| 5182 | * The API is a wrapper to send connection status to supplicant |
| 5183 | * |
| 5184 | * Return: Void |
| 5185 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5186 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5187 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5188 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5189 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5190 | size_t req_ie_len, const u8 *resp_ie, |
| 5191 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5192 | bool connect_timeout, |
| 5193 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5194 | { |
| 5195 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5196 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5197 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5198 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5199 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5200 | } |
| 5201 | #else |
| 5202 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5203 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5204 | size_t req_ie_len, const u8 *resp_ie, |
| 5205 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5206 | bool connect_timeout, |
| 5207 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5208 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5209 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5210 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5211 | } |
| 5212 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5213 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5214 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5215 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5216 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5217 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5218 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5219 | /** |
| 5220 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5221 | * @fils_params: connect response to supplicant |
| 5222 | * @fils_kek: FILS kek |
| 5223 | * @fils_kek_len: FILS kek length |
| 5224 | * @pmk: FILS PMK |
| 5225 | * @pmk_len: FILS PMK length |
| 5226 | * @pmkid: PMKID |
| 5227 | * @fils_seq_num: FILS Seq number |
| 5228 | * |
| 5229 | * Return: None |
| 5230 | */ |
| 5231 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5232 | *fils_params, const uint8_t *fils_kek, |
| 5233 | size_t fils_kek_len, const uint8_t *pmk, |
| 5234 | size_t pmk_len, const uint8_t *pmkid, |
| 5235 | uint16_t fils_seq_num) |
| 5236 | { |
| 5237 | /* Increament seq number to be used for next FILS */ |
| 5238 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5239 | fils_params->update_erp_next_seq_num = true; |
| 5240 | fils_params->fils_kek = fils_kek; |
| 5241 | fils_params->fils_kek_len = fils_kek_len; |
| 5242 | fils_params->pmk = pmk; |
| 5243 | fils_params->pmk_len = pmk_len; |
| 5244 | fils_params->pmkid = pmkid; |
| 5245 | } |
| 5246 | #else |
| 5247 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5248 | *fils_params, const uint8_t |
| 5249 | *fils_kek, size_t fils_kek_len, |
| 5250 | const uint8_t *pmk, size_t pmk_len, |
| 5251 | const uint8_t *pmkid, |
| 5252 | uint16_t fils_seq_num) |
| 5253 | { } |
| 5254 | #endif |
| 5255 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5256 | void hdd_update_hlp_info(struct net_device *dev, |
| 5257 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5258 | { |
| 5259 | struct sk_buff *skb; |
| 5260 | uint16_t skb_len; |
| 5261 | struct llc_snap_hdr_t *llc_hdr; |
| 5262 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5263 | uint8_t *hlp_data; |
| 5264 | uint16_t hlp_data_len; |
| 5265 | struct fils_join_rsp_params *roam_fils_params |
| 5266 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5267 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5268 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5269 | if (!roam_fils_params) { |
| 5270 | hdd_err("FILS Roam Param NULL"); |
| 5271 | return; |
| 5272 | } |
| 5273 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5274 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5275 | hdd_err("FILS HLP Data NULL, len %d", |
| 5276 | roam_fils_params->hlp_data_len); |
| 5277 | return; |
| 5278 | } |
| 5279 | |
| 5280 | hlp_data = roam_fils_params->hlp_data; |
| 5281 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5282 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5283 | /* Calculate skb length */ |
| 5284 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5285 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5286 | if (skb == NULL) { |
| 5287 | hdd_err("HLP packet nbuf alloc fails"); |
| 5288 | return; |
| 5289 | } |
| 5290 | |
| 5291 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5292 | QDF_MAC_ADDR_SIZE); |
| 5293 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5294 | QDF_MAC_ADDR_SIZE); |
| 5295 | |
| 5296 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5297 | if (IS_SNAP(llc_hdr)) { |
| 5298 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5299 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5300 | } |
| 5301 | |
| 5302 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5303 | |
| 5304 | /* |
| 5305 | * This HLP packet is formed from HLP info encapsulated |
| 5306 | * in assoc response frame which is AEAD encrypted. |
| 5307 | * Hence, this checksum validation can be set unnecessary. |
| 5308 | * i.e. network layer need not worry about checksum. |
| 5309 | */ |
| 5310 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5311 | |
| 5312 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5313 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5314 | hdd_err("Sending HLP packet fails"); |
| 5315 | return; |
| 5316 | } |
| 5317 | hdd_debug("send HLP packet to netif successfully"); |
| 5318 | } |
| 5319 | |
| 5320 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5321 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5322 | * @dev: network device |
| 5323 | * @bssid: bssid to which we want to associate |
| 5324 | * @bss: cfg80211 bss info |
| 5325 | * @roam_info: information about connected bss |
| 5326 | * @req_ie: Request Information Element |
| 5327 | * @req_ie_len: len of the req IE |
| 5328 | * @resp_ie: Response IE |
| 5329 | * @resp_ie_len: len of ht response IE |
| 5330 | * @status: status |
| 5331 | * @gfp: allocation flags |
| 5332 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5333 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5334 | * |
| 5335 | * This API is used as wrapper to send FILS key/sequence number |
| 5336 | * params etc. to supplicant in case of FILS connection |
| 5337 | * |
| 5338 | * Return: None |
| 5339 | */ |
| 5340 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5341 | struct cfg80211_bss *bss, |
| 5342 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5343 | const u8 *req_ie, size_t req_ie_len, |
| 5344 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5345 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5346 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5347 | { |
| 5348 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5349 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5350 | struct fils_join_rsp_params *roam_fils_params = |
| 5351 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5352 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5353 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5354 | |
| 5355 | if (!roam_fils_params) { |
| 5356 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5357 | } else { |
| 5358 | fils_params.status = status; |
| 5359 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5360 | fils_params.timeout_reason = |
| 5361 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5362 | fils_params.req_ie = req_ie; |
| 5363 | fils_params.req_ie_len = req_ie_len; |
| 5364 | fils_params.resp_ie = resp_ie; |
| 5365 | fils_params.resp_ie_len = resp_ie_len; |
| 5366 | fils_params.bss = bss; |
| 5367 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5368 | roam_fils_params->kek_len, |
| 5369 | roam_fils_params->fils_pmk, |
| 5370 | roam_fils_params->fils_pmk_len, |
| 5371 | roam_fils_params->fils_pmkid, |
| 5372 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5373 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5374 | } |
| 5375 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5376 | fils_params.status, |
| 5377 | fils_params.fils_erp_next_seq_num); |
| 5378 | |
| 5379 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5380 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5381 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5382 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5383 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5384 | /* Clear all the FILS key info */ |
| 5385 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5386 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5387 | if (roam_fils_params) |
| 5388 | qdf_mem_free(roam_fils_params); |
| 5389 | roam_info->fils_join_rsp = NULL; |
| 5390 | } |
| 5391 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5392 | static inline void |
| 5393 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5394 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5395 | const u8 *req_ie, size_t req_ie_len, |
| 5396 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5397 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5398 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5399 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5400 | #endif |
| 5401 | #endif |
| 5402 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5403 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5404 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5405 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5406 | /** |
| 5407 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5408 | * supplicant. |
| 5409 | * @dev: network device |
| 5410 | * @bssid: bssid to which we want to associate |
| 5411 | * @bss: cfg80211 bss info |
| 5412 | * @roam_info: information about connected bss |
| 5413 | * @req_ie: Request Information Element |
| 5414 | * @req_ie_len: len of the req IE |
| 5415 | * @resp_ie: Response IE |
| 5416 | * @resp_ie_len: len of ht response IE |
| 5417 | * @status: status |
| 5418 | * @gfp: allocation flags |
| 5419 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5420 | * @timeout_reason: reason for connect timeout |
| 5421 | * |
| 5422 | * The API is a wrapper to send connection status to supplicant |
| 5423 | * |
| 5424 | * Return: 0 if success else failure |
| 5425 | */ |
| 5426 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5427 | const u8 *bssid, |
| 5428 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5429 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5430 | size_t req_ie_len, const u8 *resp_ie, |
| 5431 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5432 | bool connect_timeout, |
| 5433 | tSirResultCodes timeout_reason) |
| 5434 | { |
| 5435 | ENTER(); |
| 5436 | if (!roam_info || !roam_info->is_fils_connection) |
| 5437 | return -EINVAL; |
| 5438 | |
| 5439 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5440 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5441 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5442 | return 0; |
| 5443 | } |
| 5444 | #else |
| 5445 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5446 | const u8 *bssid, |
| 5447 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5448 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5449 | size_t req_ie_len, const u8 *resp_ie, |
| 5450 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5451 | bool connect_timeout, |
| 5452 | tSirResultCodes timeout_reason) |
| 5453 | { |
| 5454 | return -EINVAL; |
| 5455 | } |
| 5456 | #endif |
| 5457 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5458 | /** |
| 5459 | * hdd_connect_result() - API to send connection status to supplicant |
| 5460 | * @dev: network device |
| 5461 | * @bssid: bssid to which we want to associate |
| 5462 | * @roam_info: information about connected bss |
| 5463 | * @req_ie: Request Information Element |
| 5464 | * @req_ie_len: len of the req IE |
| 5465 | * @resp_ie: Response IE |
| 5466 | * @resp_ie_len: len of ht response IE |
| 5467 | * @status: status |
| 5468 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5469 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5470 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5471 | * |
| 5472 | * The API is a wrapper to send connection status to supplicant |
| 5473 | * and allow runtime suspend |
| 5474 | * |
| 5475 | * Return: Void |
| 5476 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5477 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5478 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5479 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5480 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5481 | bool connect_timeout, |
| 5482 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5483 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5484 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5485 | struct cfg80211_bss *bss = NULL; |
| 5486 | |
| 5487 | if (WLAN_STATUS_SUCCESS == status) { |
| 5488 | struct ieee80211_channel *chan; |
| 5489 | int freq; |
| 5490 | int chan_no = roam_info->pBssDesc->channelId; |
| 5491 | |
| 5492 | if (chan_no <= 14) |
| 5493 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5494 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5495 | else |
| 5496 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5497 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5498 | |
| 5499 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5500 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5501 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5502 | roam_info->u.pConnectedProfile->SSID.length); |
| 5503 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5504 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5505 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5506 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5507 | resp_ie_len, status, gfp, connect_timeout, |
| 5508 | timeout_reason) != 0) { |
| 5509 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5510 | req_ie_len, resp_ie, resp_ie_len, |
| 5511 | status, gfp, connect_timeout, timeout_reason); |
| 5512 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5513 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5514 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5515 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5516 | } |
| 5517 | #else |
| 5518 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5519 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5520 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5521 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5522 | bool connect_timeout, |
| 5523 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5524 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5525 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5526 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5527 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5528 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5529 | |
| 5530 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5531 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5532 | } |
| 5533 | #endif |
| 5534 | |
| 5535 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5536 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5537 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5538 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5539 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5540 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5541 | #endif |
| 5542 | eConnectionState connState; |
| 5543 | |
| 5544 | ENTER(); |
| 5545 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5546 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5547 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5548 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5549 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame^] | 5550 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5551 | hdd_device_mode_to_string(adapter->device_mode), |
| 5552 | adapter->device_mode); |
| 5553 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | hdd_wmm_init(adapter); |
| 5555 | |
| 5556 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5557 | case QDF_STA_MODE: |
| 5558 | case QDF_P2P_CLIENT_MODE: |
| 5559 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5560 | |
| 5561 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5562 | ->conn_info.connState; |
| 5563 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5564 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5565 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5566 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5567 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5568 | /* Indicate disconnect event to supplicant |
| 5569 | * if associated previously |
| 5570 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5571 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5572 | eConnectionState_IbssConnected == connState || |
| 5573 | eConnectionState_NotConnected == connState || |
| 5574 | eConnectionState_IbssDisconnected == connState || |
| 5575 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5576 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5577 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5578 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5579 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5580 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5581 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5582 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5583 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5584 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5585 | |
| 5586 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5587 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5588 | adapter->dev, false, |
| 5589 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5590 | } else if (eConnectionState_Connecting == connState) { |
| 5591 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5592 | * Indicate connect failure to supplicant if we |
| 5593 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5594 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5595 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5596 | NULL, 0, NULL, 0, |
| 5597 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5598 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5599 | } |
| 5600 | |
| 5601 | hdd_register_tx_flow_control(adapter, |
| 5602 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5603 | hdd_tx_resume_cb, |
| 5604 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5605 | |
| 5606 | break; |
| 5607 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5608 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5609 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5610 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | break; |
| 5613 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5614 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5615 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5616 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5617 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5618 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5619 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5620 | /* event supplicant to restart */ |
| 5621 | cfg80211_del_sta(adapter->dev, |
| 5622 | (const u8 *)&bcastMac.bytes[0], |
| 5623 | GFP_KERNEL); |
| 5624 | #endif |
| 5625 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5626 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5627 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5628 | hdd_set_mon_rx_cb(adapter->dev); |
| 5629 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5630 | adapter->mon_bandwidth); |
| 5631 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | default: |
| 5633 | break; |
| 5634 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5635 | /* |
| 5636 | * Action frame registered in one adapter which will |
| 5637 | * applicable to all interfaces |
| 5638 | */ |
| 5639 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5640 | } |
| 5641 | |
| 5642 | EXIT(); |
| 5643 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5644 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5645 | } |
| 5646 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5647 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5648 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5649 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5650 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5651 | qdf_list_node_t *node; |
| 5652 | |
| 5653 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5654 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5655 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5656 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5657 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5658 | |
| 5659 | if (QDF_IS_STATUS_ERROR(status)) |
| 5660 | return status; |
| 5661 | |
| 5662 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5663 | |
| 5664 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5665 | } |
| 5666 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5667 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5668 | struct hdd_adapter *current_adapter, |
| 5669 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5670 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5671 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5672 | qdf_list_node_t *node; |
| 5673 | |
| 5674 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5675 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5676 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5677 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5678 | ¤t_adapter->node, |
| 5679 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5680 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5681 | |
| 5682 | if (QDF_IS_STATUS_ERROR(status)) |
| 5683 | return status; |
| 5684 | |
| 5685 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5687 | return status; |
| 5688 | } |
| 5689 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5690 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5691 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5692 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5693 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5694 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5695 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5696 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5697 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5698 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5699 | return status; |
| 5700 | } |
| 5701 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5702 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5703 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5704 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5705 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5706 | qdf_list_node_t *node; |
| 5707 | |
| 5708 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5709 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5710 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5711 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5712 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5713 | |
| 5714 | if (QDF_IS_STATUS_ERROR(status)) |
| 5715 | return status; |
| 5716 | |
| 5717 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5718 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5719 | return status; |
| 5720 | } |
| 5721 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5722 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5723 | struct hdd_adapter *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; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5726 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5727 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5728 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5729 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5731 | return status; |
| 5732 | } |
| 5733 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5734 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5735 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5736 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5737 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5738 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5739 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5740 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5741 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5743 | return status; |
| 5744 | } |
| 5745 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5746 | 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] | 5747 | tSirMacAddr macAddr) |
| 5748 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5749 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5750 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5751 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5752 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5753 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5754 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5755 | } |
| 5756 | |
| 5757 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5758 | } |
| 5759 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5760 | 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] | 5761 | uint32_t vdev_id) |
| 5762 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5763 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5764 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5765 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5766 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5767 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5768 | } |
| 5769 | |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 5770 | hdd_err_ratelimited(RATE_LIMIT_ERROR_LOG, |
| 5771 | "vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5772 | |
| 5773 | return NULL; |
| 5774 | } |
| 5775 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5776 | /** |
| 5777 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5778 | * the sessionid |
| 5779 | * @hdd_ctx: hdd context. |
| 5780 | * @sme_session_id: sme session is for the adapter to get. |
| 5781 | * |
| 5782 | * This function is used to get the adapter with provided session id |
| 5783 | * |
| 5784 | * Return: adapter pointer if found |
| 5785 | * |
| 5786 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5787 | struct hdd_adapter * |
| 5788 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5789 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5790 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5791 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5792 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5793 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5794 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5795 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5796 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5797 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5798 | return NULL; |
| 5799 | } |
| 5800 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5801 | 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] | 5802 | const char *iface_name) |
| 5803 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5804 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5805 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5806 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5807 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5808 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5809 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5810 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5811 | return NULL; |
| 5812 | } |
| 5813 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5814 | /** |
| 5815 | * hdd_get_adapter() - to get adapter matching the mode |
| 5816 | * @hdd_ctx: hdd context |
| 5817 | * @mode: adapter mode |
| 5818 | * |
| 5819 | * This routine will return the pointer to adapter matching |
| 5820 | * with the passed mode. |
| 5821 | * |
| 5822 | * Return: pointer to adapter or null |
| 5823 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5824 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5825 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5826 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5827 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5828 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5829 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5830 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5831 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5832 | } |
| 5833 | |
| 5834 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5835 | } |
| 5836 | |
| 5837 | /** |
| 5838 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5839 | * @hdd_ctx: Pointer to the HDD context. |
| 5840 | * @mode: Device mode for which operating channel is required. |
| 5841 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5842 | * QDF_STA_MODE, |
| 5843 | * QDF_P2P_CLIENT_MODE, |
| 5844 | * QDF_SAP_MODE, |
| 5845 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5846 | * |
| 5847 | * This API returns the operating channel of the requested device mode |
| 5848 | * |
| 5849 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5850 | * not connected. |
| 5851 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5852 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5853 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5854 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5855 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5856 | uint8_t operatingChannel = 0; |
| 5857 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5858 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5859 | if (mode == adapter->device_mode) { |
| 5860 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5861 | case QDF_STA_MODE: |
| 5862 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5863 | if (hdd_conn_is_connected |
| 5864 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5865 | (adapter))) { |
| 5866 | operatingChannel = |
| 5867 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5868 | (adapter))->conn_info. |
| 5869 | operationChannel; |
| 5870 | } |
| 5871 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5872 | case QDF_SAP_MODE: |
| 5873 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5874 | /* softap connection info */ |
| 5875 | if (test_bit |
| 5876 | (SOFTAP_BSS_STARTED, |
| 5877 | &adapter->event_flags)) |
| 5878 | operatingChannel = |
| 5879 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 5880 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5881 | break; |
| 5882 | default: |
| 5883 | break; |
| 5884 | } |
| 5885 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5886 | /* Found the device of interest. break the loop */ |
| 5887 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5888 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5889 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5890 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5891 | return operatingChannel; |
| 5892 | } |
| 5893 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5894 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5895 | hdd_ctx) |
| 5896 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5897 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | |
| 5899 | ENTER(); |
| 5900 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5901 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5902 | if (adapter->device_mode == QDF_STA_MODE || |
| 5903 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5904 | adapter->device_mode == QDF_IBSS_MODE || |
| 5905 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5906 | adapter->device_mode == QDF_SAP_MODE || |
| 5907 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5909 | hdd_unregister_wext(adapter->dev); |
| 5910 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5911 | } |
| 5912 | |
| 5913 | EXIT(); |
| 5914 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5915 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5916 | } |
| 5917 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5918 | 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] | 5919 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5920 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5921 | |
| 5922 | ENTER(); |
| 5923 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5924 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5925 | if (adapter->device_mode == QDF_STA_MODE || |
| 5926 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5927 | adapter->device_mode == QDF_IBSS_MODE || |
| 5928 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5929 | adapter->device_mode == QDF_SAP_MODE || |
| 5930 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5931 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5932 | adapter->session_id, INVALID_SCAN_ID, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5933 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5934 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5935 | } |
| 5936 | |
| 5937 | EXIT(); |
| 5938 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5939 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | } |
| 5941 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5942 | /** |
| 5943 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5944 | * adapters |
| 5945 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5946 | * |
| 5947 | * return: QDF_STATUS_SUCCESS |
| 5948 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5949 | 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] | 5950 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5951 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5952 | int err; |
| 5953 | |
| 5954 | ENTER(); |
| 5955 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5956 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5957 | if (adapter->device_mode == QDF_STA_MODE || |
| 5958 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5959 | adapter->device_mode == QDF_IBSS_MODE || |
| 5960 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5961 | adapter->device_mode == QDF_SAP_MODE || |
| 5962 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5963 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5964 | if (err) |
| 5965 | hdd_err("Unable to stop scheduled scan"); |
| 5966 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5967 | } |
| 5968 | |
| 5969 | EXIT(); |
| 5970 | |
| 5971 | return QDF_STATUS_SUCCESS; |
| 5972 | } |
| 5973 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5974 | #ifdef WLAN_NS_OFFLOAD |
| 5975 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5976 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5977 | * @hdd_ctx: Pointer to hdd context |
| 5978 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5979 | * Unregister for IPv6 address change notifications. |
| 5980 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5981 | * Return: None |
| 5982 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5983 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5984 | { |
| 5985 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5986 | } |
| 5987 | |
| 5988 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5989 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5990 | * @hdd_ctx: Pointer to hdd context |
| 5991 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5992 | * Register for IPv6 address change notifications. |
| 5993 | * |
| 5994 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5995 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5996 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5997 | { |
| 5998 | int ret; |
| 5999 | |
| 6000 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6001 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6002 | if (ret) { |
| 6003 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6004 | goto out; |
| 6005 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6006 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6007 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6008 | out: |
| 6009 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6010 | } |
| 6011 | #else |
| 6012 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6013 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6014 | * @hdd_ctx: Pointer to hdd context |
| 6015 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6016 | * Unregister for IPv6 address change notifications. |
| 6017 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6018 | * Return: None |
| 6019 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6020 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6021 | { |
| 6022 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6024 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6025 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6026 | * @hdd_ctx: Pointer to hdd context |
| 6027 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6028 | * Register for IPv6 address change notifications. |
| 6029 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6030 | * Return: None |
| 6031 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6032 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6033 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6034 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6035 | } |
| 6036 | #endif |
| 6037 | |
| 6038 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6039 | * hdd_register_notifiers - Register netdev notifiers. |
| 6040 | * @hdd_ctx: HDD context |
| 6041 | * |
| 6042 | * Register netdev notifiers like IPv4 and IPv6. |
| 6043 | * |
| 6044 | * Return: 0 on success and errno on failure |
| 6045 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6046 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6047 | { |
| 6048 | int ret; |
| 6049 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6050 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6051 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6052 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6053 | |
| 6054 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6055 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6056 | if (ret) { |
| 6057 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6058 | goto unregister_ip6_notifier; |
| 6059 | } |
| 6060 | |
| 6061 | return 0; |
| 6062 | |
| 6063 | unregister_ip6_notifier: |
| 6064 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6065 | out: |
| 6066 | return ret; |
| 6067 | |
| 6068 | } |
| 6069 | |
| 6070 | /** |
| 6071 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6072 | * @hdd_ctx: HDD context |
| 6073 | * |
| 6074 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6075 | * |
| 6076 | * Return: None. |
| 6077 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6078 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6079 | { |
| 6080 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6081 | |
| 6082 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6083 | } |
| 6084 | |
| 6085 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6086 | * hdd_exit_netlink_services - Exit netlink services |
| 6087 | * @hdd_ctx: HDD context |
| 6088 | * |
| 6089 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6090 | * nl service. |
| 6091 | * |
| 6092 | * Return: None. |
| 6093 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6094 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6095 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6096 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6097 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6098 | ptt_sock_deactivate_svc(); |
| 6099 | |
| 6100 | nl_srv_exit(); |
| 6101 | } |
| 6102 | |
| 6103 | /** |
| 6104 | * hdd_init_netlink_services- Init netlink services |
| 6105 | * @hdd_ctx: HDD context |
| 6106 | * |
| 6107 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6108 | * nl service. |
| 6109 | * |
| 6110 | * Return: 0 on success and errno on failure. |
| 6111 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6112 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6113 | { |
| 6114 | int ret; |
| 6115 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6116 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6117 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6118 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6119 | goto out; |
| 6120 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6121 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6122 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6123 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6124 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6125 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6126 | goto err_nl_srv; |
| 6127 | } |
| 6128 | |
| 6129 | ret = ptt_sock_activate_svc(); |
| 6130 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6131 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6132 | goto err_nl_srv; |
| 6133 | } |
| 6134 | |
| 6135 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6136 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6137 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6138 | |
| 6139 | ret = cnss_diag_activate_service(); |
| 6140 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6141 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6142 | goto err_close_cesium; |
| 6143 | } |
| 6144 | |
| 6145 | return 0; |
| 6146 | |
| 6147 | err_close_cesium: |
| 6148 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6149 | ptt_sock_deactivate_svc(); |
| 6150 | err_nl_srv: |
| 6151 | nl_srv_exit(); |
| 6152 | out: |
| 6153 | return ret; |
| 6154 | } |
| 6155 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6156 | /** |
| 6157 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6158 | * @hdd_ctx: HDD context. |
| 6159 | * |
| 6160 | * Destroy RX wakelock. |
| 6161 | * |
| 6162 | * Return: None. |
| 6163 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6164 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6165 | { |
| 6166 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6167 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6168 | |
| 6169 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6170 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6171 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6172 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6173 | * Create RX wakelock. |
| 6174 | * |
| 6175 | * Return: None. |
| 6176 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6177 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6178 | { |
| 6179 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6180 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6181 | |
| 6182 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6183 | * hdd_context_deinit() - Deinitialize HDD context |
| 6184 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6185 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6186 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6187 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6188 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6189 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6190 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6191 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6192 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6193 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6194 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6195 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6196 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6197 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6198 | hdd_sap_context_destroy(hdd_ctx); |
| 6199 | |
| 6200 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6201 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6202 | hdd_scan_context_destroy(hdd_ctx); |
| 6203 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6204 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6205 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6206 | return 0; |
| 6207 | } |
| 6208 | |
| 6209 | /** |
| 6210 | * hdd_context_destroy() - Destroy HDD context |
| 6211 | * @hdd_ctx: HDD context to be destroyed. |
| 6212 | * |
| 6213 | * Free config and HDD context as well as destroy all the resources. |
| 6214 | * |
| 6215 | * Return: None |
| 6216 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6217 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6218 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6219 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6220 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6221 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6222 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6223 | hdd_context_deinit(hdd_ctx); |
| 6224 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6225 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6226 | hdd_ctx->config = NULL; |
| 6227 | |
| 6228 | wiphy_free(hdd_ctx->wiphy); |
| 6229 | } |
| 6230 | |
| 6231 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6232 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6233 | * |
| 6234 | * This function is used to destroy bug report lock |
| 6235 | * |
| 6236 | * Return: None |
| 6237 | */ |
| 6238 | static void wlan_destroy_bug_report_lock(void) |
| 6239 | { |
| 6240 | p_cds_contextType p_cds_context; |
| 6241 | |
| 6242 | p_cds_context = cds_get_global_context(); |
| 6243 | if (!p_cds_context) { |
| 6244 | hdd_err("cds context is NULL"); |
| 6245 | return; |
| 6246 | } |
| 6247 | |
| 6248 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6249 | } |
| 6250 | |
| 6251 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6253 | * @hdd_ctx: Pointer to the HDD Context |
| 6254 | * |
| 6255 | * This is the driver exit point (invoked during rmmod) |
| 6256 | * |
| 6257 | * Return: None |
| 6258 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6259 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6260 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6261 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6262 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6263 | |
| 6264 | ENTER(); |
| 6265 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6266 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6267 | |
| 6268 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6269 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6270 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6271 | |
| 6272 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6273 | if (QDF_TIMER_STATE_RUNNING == |
| 6274 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6275 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6276 | } |
| 6277 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6278 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6279 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6280 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6281 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6282 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6283 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6284 | hdd_ctx->last_acs_channel_list = NULL; |
| 6285 | hdd_ctx->num_of_channels = 0; |
| 6286 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6287 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6289 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6290 | driver_status = hdd_ctx->driver_status; |
| 6291 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6292 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6293 | /* |
| 6294 | * Powersave Offload Case |
| 6295 | * Disable Idle Power Save Mode |
| 6296 | */ |
| 6297 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6298 | /* clear the scan queue in all the scenarios */ |
| 6299 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6300 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6301 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6302 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6303 | /* |
| 6304 | * Cancel any outstanding scan requests. We are about to close |
| 6305 | * all of our adapters, but an adapter structure is what SME |
| 6306 | * passes back to our callback function. Hence if there |
| 6307 | * are any outstanding scan requests then there is a |
| 6308 | * race condition between when the adapter is closed and |
| 6309 | * when the callback is invoked. We try to resolve that |
| 6310 | * race condition here by canceling any outstanding scans |
| 6311 | * before we close the adapters. |
| 6312 | * Note that the scans may be cancelled in an asynchronous |
| 6313 | * manner, so ideally there needs to be some kind of |
| 6314 | * synchronization. Rather than introduce a new |
| 6315 | * synchronization here, we will utilize the fact that we are |
| 6316 | * about to Request Full Power, and since that is synchronized, |
| 6317 | * the expectation is that by the time Request Full Power has |
| 6318 | * completed, all scans will be cancelled |
| 6319 | */ |
| 6320 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6321 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6322 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6323 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6324 | } |
| 6325 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6326 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6327 | |
Dustin Brown | 36e24e2 | 2017-12-21 12:34:13 -0800 | [diff] [blame] | 6328 | hdd_close_all_adapters(hdd_ctx, false); |
| 6329 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6330 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6331 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6332 | hdd_driver_memdump_deinit(); |
| 6333 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6334 | qdf_nbuf_deinit_replenish_timer(); |
| 6335 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6336 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6337 | hdd_info("Release wakelock for monitor mode!"); |
| 6338 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6339 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6340 | } |
| 6341 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6342 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6343 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6344 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6345 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | /* |
| 6347 | * Close CDS |
| 6348 | * This frees pMac(HAL) context. There should not be any call |
| 6349 | * that requires pMac access after this. |
| 6350 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6351 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6352 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6353 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | hdd_ipa_cleanup(hdd_ctx); |
| 6355 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6356 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6357 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6358 | /* |
| 6359 | * If there is re_init failure wiphy would have already de-registered |
| 6360 | * check the wiphy status before un-registering again |
| 6361 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6362 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6363 | wiphy_unregister(wiphy); |
| 6364 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6365 | hdd_lpass_notify_stop(hdd_ctx); |
| 6366 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6367 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6368 | hdd_exit_netlink_services(hdd_ctx); |
| 6369 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6370 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6371 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6372 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6373 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6374 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6375 | if (driver_status) |
| 6376 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6377 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6378 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6379 | } |
| 6380 | |
| 6381 | void __hdd_wlan_exit(void) |
| 6382 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6383 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6384 | |
| 6385 | ENTER(); |
| 6386 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6387 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6388 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6389 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6390 | EXIT(); |
| 6391 | return; |
| 6392 | } |
| 6393 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6394 | /* Do all the cleanup before deregistering the driver */ |
| 6395 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6396 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | EXIT(); |
| 6398 | } |
| 6399 | |
| 6400 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6401 | /** |
| 6402 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6403 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6404 | * |
| 6405 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6406 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6407 | * scan information. |
| 6408 | * |
| 6409 | * Return: void |
| 6410 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6411 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6412 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6413 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6414 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6415 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6416 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6417 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6418 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6419 | hdd_ctx->last_acs_channel_list = NULL; |
| 6420 | hdd_ctx->num_of_channels = 0; |
| 6421 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6422 | |
| 6423 | if (!hdd_ctx->hHal) |
| 6424 | return; |
| 6425 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6426 | } |
| 6427 | #endif |
| 6428 | |
| 6429 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6430 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6431 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6432 | { |
| 6433 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6434 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6435 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6436 | |
| 6437 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6438 | |
| 6439 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6440 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6441 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6442 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6443 | if (!hdd_ctx->hHal) |
| 6444 | return -EINVAL; |
| 6445 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6446 | 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] | 6447 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6448 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6449 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | return -EINVAL; |
| 6451 | } |
| 6452 | |
| 6453 | return 0; |
| 6454 | } |
| 6455 | #endif |
| 6456 | |
| 6457 | /** |
| 6458 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6459 | * @state: state |
| 6460 | * |
| 6461 | * This function notifies FW with modem power status |
| 6462 | * |
| 6463 | * Return: 0 if successful, error number otherwise |
| 6464 | */ |
| 6465 | int hdd_wlan_notify_modem_power_state(int state) |
| 6466 | { |
| 6467 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6468 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6469 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6470 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6471 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6472 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6473 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6474 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6475 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6476 | if (!hdd_ctx->hHal) |
| 6477 | return -EINVAL; |
| 6478 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6479 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6480 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6481 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | state); |
| 6483 | return -EINVAL; |
| 6484 | } |
| 6485 | return 0; |
| 6486 | } |
| 6487 | |
| 6488 | /** |
| 6489 | * |
| 6490 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6491 | * @adapter - Pointer to the HDD |
| 6492 | * |
| 6493 | * Return: None |
| 6494 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6495 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6497 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | |
| 6499 | /* |
| 6500 | * Send ready indication to the HDD. This will kick off the MAC |
| 6501 | * into a 'running' state and should kick off an initial scan. |
| 6502 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6503 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6504 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6505 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6506 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6507 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | } |
| 6509 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6510 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6511 | } |
| 6512 | |
| 6513 | /* wake lock APIs for HDD */ |
| 6514 | void hdd_prevent_suspend(uint32_t reason) |
| 6515 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6516 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6517 | } |
| 6518 | |
| 6519 | void hdd_allow_suspend(uint32_t reason) |
| 6520 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6521 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6522 | } |
| 6523 | |
| 6524 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6525 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6526 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6527 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6528 | } |
| 6529 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6531 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6532 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6533 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6534 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6535 | hdd_ctx->reg.alpha2, |
| 6536 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6537 | } |
| 6538 | |
| 6539 | /** |
| 6540 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6541 | * @hdd_ctx: Pointer to the hdd context |
| 6542 | * |
| 6543 | * HDD function to know if hardware supports 5GHz |
| 6544 | * |
| 6545 | * Return: true if hardware supports 5GHz |
| 6546 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6547 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6548 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6549 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6550 | return true; |
| 6551 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6552 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6553 | return true; |
| 6554 | else |
| 6555 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6556 | } |
| 6557 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6558 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6559 | { |
| 6560 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6561 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | |
| 6563 | wiphy = hdd_ctx->wiphy; |
| 6564 | |
| 6565 | /* |
| 6566 | * The channel information in |
| 6567 | * wiphy needs to be initialized before wiphy registration |
| 6568 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6569 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6570 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6571 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6572 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6573 | } |
| 6574 | |
| 6575 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6576 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6577 | #else |
| 6578 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6579 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6580 | WIPHY_WOWLAN_DISCONNECT | |
| 6581 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6582 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6583 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6584 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6585 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6586 | |
| 6587 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6588 | WOW_MAX_FILTERS_PER_LIST); |
| 6589 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6590 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6591 | #endif |
| 6592 | |
| 6593 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6594 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6595 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6596 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6597 | return ret_val; |
| 6598 | } |
| 6599 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6600 | if (!hdd_ctx->reg_offload) |
| 6601 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6603 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6604 | } |
| 6605 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6606 | #ifdef MSM_PLATFORM |
| 6607 | /** |
| 6608 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6609 | * @hdd_ctx - handle to hdd context |
| 6610 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6611 | * |
| 6612 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6613 | * Stats show up in wlan driver logs. |
| 6614 | * |
| 6615 | * Returns: None |
| 6616 | */ |
| 6617 | static inline |
| 6618 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6619 | bool data_in_interval) |
| 6620 | { |
| 6621 | static u32 counter; |
| 6622 | static bool data_in_time_period; |
| 6623 | ol_txrx_pdev_handle pdev; |
| 6624 | |
| 6625 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6626 | return; |
| 6627 | |
| 6628 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6629 | if (!pdev) { |
| 6630 | hdd_err("pdev is NULL"); |
| 6631 | return; |
| 6632 | } |
| 6633 | |
| 6634 | counter++; |
| 6635 | if (data_in_interval) |
| 6636 | data_in_time_period = data_in_interval; |
| 6637 | |
| 6638 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6639 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6640 | if (data_in_time_period) { |
| 6641 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6642 | CDP_TXRX_PATH_STATS, |
| 6643 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6644 | wlan_hdd_display_netif_queue_history |
| 6645 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6646 | qdf_dp_trace_dump_stats(); |
| 6647 | } |
| 6648 | counter = 0; |
| 6649 | data_in_time_period = false; |
| 6650 | } |
| 6651 | } |
| 6652 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6653 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6654 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6655 | * @hdd_ctx - handle to hdd context |
| 6656 | * @tx_packets - transmit packet count |
| 6657 | * @rx_packets - receive packet count |
| 6658 | * |
| 6659 | * The function controls the bus bandwidth and dynamic control of |
| 6660 | * tcp delayed ack configuration |
| 6661 | * |
| 6662 | * Returns: None |
| 6663 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6664 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6665 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6666 | const uint64_t tx_packets, |
| 6667 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6669 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6670 | uint64_t temp_rx = 0; |
| 6671 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6672 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6673 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6674 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6675 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6676 | uint16_t index = 0; |
| 6677 | bool vote_level_change = false; |
| 6678 | bool rx_level_change = false; |
| 6679 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6680 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6681 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6682 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6683 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6684 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6685 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6686 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6687 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6688 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6689 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6690 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6691 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6692 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6693 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6694 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6695 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6696 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6697 | if (hdd_ctx->hbw_requested) { |
| 6698 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6699 | hdd_ctx->hbw_requested = false; |
| 6700 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6701 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6702 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6703 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6704 | if (!hdd_ctx->hbw_requested) { |
| 6705 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6706 | hdd_ctx->hbw_requested = true; |
| 6707 | } |
| 6708 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6709 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6710 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6711 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6712 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6713 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6714 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6715 | qdf_dp_trace_throttle_live_mode( |
| 6716 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6717 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6718 | /* fine-tuning parameters for RX Flows */ |
| 6719 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6720 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6721 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6722 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6723 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6724 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6725 | else |
| 6726 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6727 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6728 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6729 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6730 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6731 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6732 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6733 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6734 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6735 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6736 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6737 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6738 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6739 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 6740 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6741 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6742 | next_rx_level, temp_rx); |
| 6743 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6744 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6745 | /* Send throughput indication only if it is enabled. |
| 6746 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6747 | * to default delayed ack. Note that this will disable the |
| 6748 | * dynamic delayed ack mechanism across the system |
| 6749 | */ |
| 6750 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6751 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 6752 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 6753 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 6754 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 6755 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6756 | rx_tp_data.level = next_rx_level; |
| 6757 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6758 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 6759 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6760 | } |
| 6761 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6762 | /* fine-tuning parameters for TX Flows */ |
| 6763 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6764 | hdd_ctx->prev_tx = tx_packets; |
| 6765 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6766 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6767 | else |
| 6768 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6769 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6770 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6771 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6772 | next_tx_level, temp_tx); |
| 6773 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6774 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6775 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6776 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6777 | &next_tx_level, |
| 6778 | sizeof(next_tx_level)); |
| 6779 | } |
| 6780 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6781 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6782 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6783 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6784 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6785 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6786 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6787 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6788 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6789 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6790 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6791 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6792 | |
| 6793 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6794 | } |
| 6795 | |
| 6796 | #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] | 6797 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6798 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6799 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6800 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6801 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6802 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6803 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6804 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6805 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6806 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6807 | bool connected = false; |
| 6808 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6809 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6810 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6811 | return; |
| 6812 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 6813 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6814 | goto restart_timer; |
| 6815 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6816 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6817 | /* |
| 6818 | * Validate magic so we don't end up accessing |
| 6819 | * an invalid adapter. |
| 6820 | */ |
| 6821 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6822 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6823 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6824 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6825 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6826 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6827 | != eConnectionState_Associated) { |
| 6828 | |
| 6829 | continue; |
| 6830 | } |
| 6831 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6832 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6833 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 6834 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6835 | |
| 6836 | continue; |
| 6837 | } |
| 6838 | |
| 6839 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6840 | adapter->prev_tx_packets); |
| 6841 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6842 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6843 | |
| 6844 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6845 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6846 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6847 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6848 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6849 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6850 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6851 | &fwd_tx_packets, &fwd_rx_packets); |
| 6852 | if (ret == A_OK) { |
| 6853 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6854 | fwd_tx_packets, |
| 6855 | adapter->prev_fwd_tx_packets); |
| 6856 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6857 | fwd_tx_packets, |
| 6858 | adapter->prev_fwd_rx_packets); |
| 6859 | } |
| 6860 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6861 | |
| 6862 | total_rx += adapter->stats.rx_packets; |
| 6863 | total_tx += adapter->stats.tx_packets; |
| 6864 | |
| 6865 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6866 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6867 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6868 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6869 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6870 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6871 | connected = true; |
| 6872 | } |
| 6873 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6874 | /* add intra bss forwarded tx and rx packets */ |
| 6875 | tx_packets += fwd_tx_packets_diff; |
| 6876 | rx_packets += fwd_rx_packets_diff; |
| 6877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6878 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6879 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6880 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6881 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6882 | if (adapter) { |
| 6883 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6884 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6885 | } |
| 6886 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6887 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6888 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6889 | return; |
| 6890 | } |
| 6891 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6892 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6893 | |
| 6894 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6895 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6896 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6897 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6898 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6899 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6900 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6901 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6902 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6903 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6904 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6905 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6906 | /** |
| 6907 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6908 | * @arg: Argument of timer function |
| 6909 | * |
| 6910 | * Schedule a workqueue in this function where all the processing is done. |
| 6911 | * |
| 6912 | * Return: None. |
| 6913 | */ |
| 6914 | static void __hdd_bus_bw_cbk(void *arg) |
| 6915 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6916 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6917 | |
| 6918 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6919 | return; |
| 6920 | |
| 6921 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6922 | } |
| 6923 | |
| 6924 | /** |
| 6925 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6926 | * @arg: Argument of timer function |
| 6927 | * |
| 6928 | * Return: None. |
| 6929 | */ |
| 6930 | static void hdd_bus_bw_cbk(void *arg) |
| 6931 | { |
| 6932 | cds_ssr_protect(__func__); |
| 6933 | __hdd_bus_bw_cbk(arg); |
| 6934 | cds_ssr_unprotect(__func__); |
| 6935 | } |
| 6936 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6937 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6938 | { |
| 6939 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6940 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6941 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6942 | hdd_ctx->bus_bw_timer_running = false; |
| 6943 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6944 | qdf_timer_init(NULL, |
| 6945 | &hdd_ctx->bus_bw_timer, |
| 6946 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6947 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6948 | |
| 6949 | return 0; |
| 6950 | } |
| 6951 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6952 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6953 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6954 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6955 | hdd_reset_tcp_delack(hdd_ctx); |
| 6956 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6957 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6958 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6959 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6960 | hdd_ctx->bus_bw_timer_running = false; |
| 6961 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6962 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6963 | |
| 6964 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6965 | { |
| 6966 | if (hdd_ctx) |
| 6967 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6968 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 6969 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6970 | #endif |
| 6971 | |
| 6972 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6973 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6974 | * @hdd_ctx: hdd context |
| 6975 | * |
| 6976 | * Return: 0 for success or error code |
| 6977 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6978 | 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] | 6979 | { |
| 6980 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6981 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6982 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6983 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6984 | return -ENOMEM; |
| 6985 | } |
| 6986 | return 0; |
| 6987 | } |
| 6988 | |
| 6989 | /** |
| 6990 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6991 | * @hdd_ctx: hdd context |
| 6992 | * |
| 6993 | * Return: none |
| 6994 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6995 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6996 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6997 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6998 | return; |
| 6999 | |
| 7000 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7001 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7002 | } |
| 7003 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7004 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7005 | { |
| 7006 | switch (level) { |
| 7007 | /* initialize the wlan sub system */ |
| 7008 | case WLAN_SVC_TP_NONE: |
| 7009 | return "NONE"; |
| 7010 | case WLAN_SVC_TP_LOW: |
| 7011 | return "LOW"; |
| 7012 | case WLAN_SVC_TP_MEDIUM: |
| 7013 | return "MED"; |
| 7014 | case WLAN_SVC_TP_HIGH: |
| 7015 | return "HIGH"; |
| 7016 | default: |
| 7017 | return "INVAL"; |
| 7018 | } |
| 7019 | } |
| 7020 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7021 | |
| 7022 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7023 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7024 | * @hdd_ctx: hdd context |
| 7025 | * |
| 7026 | * Return: none |
| 7027 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7028 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7029 | { |
| 7030 | int i; |
| 7031 | |
| 7032 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7033 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7034 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7035 | 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] | 7036 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7037 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7038 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7039 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7040 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7041 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7042 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7043 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7044 | 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] | 7045 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7046 | #endif |
| 7047 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7048 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7049 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7050 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7051 | 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] | 7052 | |
| 7053 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7054 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7055 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7056 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7057 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7058 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7059 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7060 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7061 | convert_level_to_string( |
| 7062 | hdd_ctx->hdd_txrx_hist[i]. |
| 7063 | next_vote_level), |
| 7064 | convert_level_to_string( |
| 7065 | hdd_ctx->hdd_txrx_hist[i]. |
| 7066 | next_rx_level), |
| 7067 | convert_level_to_string( |
| 7068 | hdd_ctx->hdd_txrx_hist[i]. |
| 7069 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7070 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7071 | } |
| 7072 | |
| 7073 | /** |
| 7074 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7075 | * @hdd_ctx: hdd context |
| 7076 | * |
| 7077 | * Return: none |
| 7078 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7079 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7080 | { |
| 7081 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7082 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7083 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7084 | } |
| 7085 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7086 | /* length of the netif queue log needed per adapter */ |
| 7087 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7088 | |
| 7089 | /** |
| 7090 | * |
| 7091 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7092 | * @hdd_ctx: hdd context |
| 7093 | * |
| 7094 | * Return: none |
| 7095 | */ |
| 7096 | static void |
| 7097 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7098 | { |
| 7099 | int adapter_num = 0; |
| 7100 | int i; |
| 7101 | int bytes_written; |
| 7102 | u32 tbytes; |
| 7103 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7104 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
| 7105 | char comb_log_str[(ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1]; |
| 7106 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7107 | |
| 7108 | bytes_written = 0; |
| 7109 | qdf_mem_set(comb_log_str, 0, sizeof(comb_log_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7110 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7111 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7112 | curr_time = qdf_system_ticks(); |
| 7113 | total = curr_time - adapter->start_time; |
| 7114 | delta = curr_time - adapter->last_time; |
| 7115 | |
| 7116 | if (adapter->pause_map) { |
| 7117 | pause = adapter->total_pause_time + delta; |
| 7118 | unpause = adapter->total_unpause_time; |
| 7119 | } else { |
| 7120 | unpause = adapter->total_unpause_time + delta; |
| 7121 | pause = adapter->total_pause_time; |
| 7122 | } |
| 7123 | |
| 7124 | tbytes = 0; |
| 7125 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7126 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7127 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7128 | continue; |
| 7129 | tbytes += |
| 7130 | snprintf( |
| 7131 | &temp_str[tbytes], |
| 7132 | (tbytes >= sizeof(temp_str) ? |
| 7133 | 0 : sizeof(temp_str) - tbytes), |
| 7134 | "%d(%d,%d) ", |
| 7135 | i, |
| 7136 | adapter->queue_oper_stats[i]. |
| 7137 | pause_count, |
| 7138 | adapter->queue_oper_stats[i]. |
| 7139 | unpause_count); |
| 7140 | } |
| 7141 | if (tbytes >= sizeof(temp_str)) |
| 7142 | hdd_warn("log truncated"); |
| 7143 | |
| 7144 | bytes_written += snprintf(&comb_log_str[bytes_written], |
| 7145 | bytes_written >= sizeof(comb_log_str) ? 0 : |
| 7146 | sizeof(comb_log_str) - bytes_written, |
| 7147 | "[%d %d] (%d) %u/%ums %s|", |
| 7148 | adapter->session_id, adapter->device_mode, |
| 7149 | adapter->pause_map, |
| 7150 | qdf_system_ticks_to_msecs(pause), |
| 7151 | qdf_system_ticks_to_msecs(total), |
| 7152 | temp_str); |
| 7153 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7154 | adapter_num++; |
| 7155 | } |
| 7156 | |
| 7157 | /* using QDF_TRACE to avoid printing function name */ |
| 7158 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7159 | "STATS |%s", comb_log_str); |
| 7160 | |
| 7161 | if (bytes_written >= sizeof(comb_log_str)) |
| 7162 | hdd_warn("log string truncated"); |
| 7163 | } |
| 7164 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7165 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7166 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7167 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7168 | * |
| 7169 | * Return: none |
| 7170 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7171 | void |
| 7172 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7173 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7174 | { |
| 7175 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7176 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7177 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7178 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7179 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7180 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7181 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7182 | return; |
| 7183 | } |
| 7184 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7185 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7186 | hdd_debug("Netif queue operation statistics:"); |
| 7187 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7188 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7189 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7190 | curr_time = qdf_system_ticks(); |
| 7191 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7192 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7193 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7194 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7195 | unpause = adapter->total_unpause_time; |
| 7196 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7197 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7198 | pause = adapter->total_pause_time; |
| 7199 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7200 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7201 | qdf_system_ticks_to_msecs(total), |
| 7202 | qdf_system_ticks_to_msecs(pause), |
| 7203 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7204 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7205 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7206 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7207 | qdf_time_t pause_delta = 0; |
| 7208 | |
| 7209 | if (adapter->pause_map & (1 << i)) |
| 7210 | pause_delta = delta; |
| 7211 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7212 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7213 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7214 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7215 | hdd_reason_type_to_string(i), |
| 7216 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7217 | adapter->queue_oper_stats[i].unpause_count, |
| 7218 | qdf_system_ticks_to_msecs( |
| 7219 | adapter->queue_oper_stats[i].total_pause_time + |
| 7220 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7221 | } |
| 7222 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7223 | hdd_debug("Netif queue operation history:"); |
| 7224 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7225 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7226 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7227 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7228 | |
| 7229 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7230 | /* using hdd_log to avoid printing function name */ |
| 7231 | if (adapter->queue_oper_history[i].time == 0) |
| 7232 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7233 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7234 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 7235 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7236 | adapter->queue_oper_history[i].time), |
| 7237 | hdd_action_type_to_string( |
| 7238 | adapter->queue_oper_history[i].netif_action), |
| 7239 | hdd_reason_type_to_string( |
| 7240 | adapter->queue_oper_history[i].netif_reason), |
| 7241 | adapter->queue_oper_history[i].pause_map); |
| 7242 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7243 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7244 | } |
| 7245 | |
| 7246 | /** |
| 7247 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7248 | * @hdd_ctx: hdd context |
| 7249 | * |
| 7250 | * Return: none |
| 7251 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7252 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7253 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7254 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7255 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7256 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7257 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7258 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7259 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7260 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7261 | adapter->history_index = 0; |
| 7262 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7263 | adapter->total_pause_time = 0; |
| 7264 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7265 | } |
| 7266 | } |
| 7267 | |
| 7268 | /** |
| 7269 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7270 | * @halHandle: Hal handle |
| 7271 | * @pContext: Pointer to the context |
| 7272 | * @sessionId: Session ID |
| 7273 | * @scanId: Scan ID |
| 7274 | * @status: Status |
| 7275 | * |
| 7276 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7277 | * the scan results |
| 7278 | * |
| 7279 | * 11d scan is done during driver load and is a passive scan on all |
| 7280 | * channels supported by the device, 11d scans may find some APs on |
| 7281 | * frequencies which are forbidden to be used in the regulatory domain |
| 7282 | * the device is operating in. If these APs are notified to the supplicant |
| 7283 | * it may try to connect to these APs, thus flush out all the scan results |
| 7284 | * which are present in SME after 11d scan is done. |
| 7285 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7286 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7287 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7288 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7289 | uint8_t sessionId, uint32_t scanId, |
| 7290 | eCsrScanStatus status) |
| 7291 | { |
| 7292 | ENTER(); |
| 7293 | |
| 7294 | sme_scan_flush_result(halHandle); |
| 7295 | |
| 7296 | EXIT(); |
| 7297 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7298 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7299 | } |
| 7300 | |
| 7301 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7302 | /** |
| 7303 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7304 | * @hdd_ctx: hdd global context |
| 7305 | * |
| 7306 | * Return: none |
| 7307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7308 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7309 | { |
| 7310 | uint8_t i; |
| 7311 | |
| 7312 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7313 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7314 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7315 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7316 | } |
| 7317 | } |
| 7318 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7319 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7320 | { |
| 7321 | } |
| 7322 | #endif |
| 7323 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7324 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7325 | /** |
| 7326 | * 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] | 7327 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7328 | * @enable: enable or disable this behaviour |
| 7329 | * |
| 7330 | * Return: int |
| 7331 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7332 | 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] | 7333 | { |
| 7334 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7335 | struct wow_pulse_mode wow_pulse_set_info; |
| 7336 | QDF_STATUS status; |
| 7337 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7338 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7339 | |
| 7340 | if (false == phddctx->config->wow_pulse_support) |
| 7341 | return 0; |
| 7342 | |
| 7343 | /* prepare the request to send to SME */ |
| 7344 | if (enable == true) { |
| 7345 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7346 | wow_pulse_set_info.wow_pulse_pin = |
| 7347 | pcfg_ini->wow_pulse_pin; |
| 7348 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7349 | pcfg_ini->wow_pulse_interval_low; |
| 7350 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7351 | pcfg_ini->wow_pulse_interval_high; |
| 7352 | } else { |
| 7353 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7354 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7355 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7356 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7357 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7358 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7359 | wow_pulse_set_info.wow_pulse_enable, |
| 7360 | wow_pulse_set_info.wow_pulse_pin, |
| 7361 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7362 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7363 | |
| 7364 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7365 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7366 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7367 | return -EIO; |
| 7368 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7369 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7370 | return 0; |
| 7371 | } |
| 7372 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7373 | 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] | 7374 | { |
| 7375 | return 0; |
| 7376 | } |
| 7377 | #endif |
| 7378 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7379 | #ifdef WLAN_FEATURE_FASTPATH |
| 7380 | /** |
| 7381 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7382 | * @hdd_cfg: hdd config |
| 7383 | * @context: lower layer context |
| 7384 | * |
| 7385 | * Return: none |
| 7386 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7387 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7388 | void *context) |
| 7389 | { |
| 7390 | if (hdd_cfg->fastpath_enable) |
| 7391 | hif_enable_fastpath(context); |
| 7392 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7393 | #endif |
| 7394 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7395 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7396 | /** |
| 7397 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7398 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7399 | * @level: thermal level |
| 7400 | * |
| 7401 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7402 | * than 0, and restore the original data path when throttle level is 0 |
| 7403 | * |
| 7404 | * Return: none |
| 7405 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7406 | 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] | 7407 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7408 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7409 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7410 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7411 | if (level > THROTTLE_LEVEL_0) |
| 7412 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7413 | else |
| 7414 | /* restore original concurrency mode */ |
| 7415 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7416 | } |
| 7417 | |
| 7418 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7419 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7420 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7421 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7422 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7423 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7424 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7425 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7427 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7428 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7429 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7430 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7431 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7432 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7433 | struct sir_pcl_list pcl; |
| 7434 | QDF_STATUS status; |
| 7435 | uint32_t i, j; |
| 7436 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7437 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7438 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7439 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7440 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7441 | if (!hdd_ctx) { |
| 7442 | hdd_err("invalid HDD context"); |
| 7443 | return INVALID_CHANNEL_ID; |
| 7444 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7445 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7446 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7447 | if (!hal_handle) { |
| 7448 | hdd_err("invalid HAL handle"); |
| 7449 | return INVALID_CHANNEL_ID; |
| 7450 | } |
| 7451 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7452 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7453 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7454 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7455 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7456 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7457 | hdd_err("Get PCL failed"); |
| 7458 | return INVALID_CHANNEL_ID; |
| 7459 | } |
| 7460 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7461 | /* |
| 7462 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7463 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7464 | * try to choose a safe channel from acs range. |
| 7465 | */ |
| 7466 | if (!pcl.pcl_len) |
| 7467 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7468 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7469 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7470 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7471 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7472 | |
| 7473 | /* PCL already takes unsafe channel into account */ |
| 7474 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7475 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7476 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7477 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7478 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7479 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7480 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7481 | return pcl.pcl_list[i]; |
| 7482 | } |
| 7483 | } |
| 7484 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7485 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7486 | |
| 7487 | /* Try for safe channel from all valid channel */ |
| 7488 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7489 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7490 | &pcl.pcl_len); |
| 7491 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7492 | hdd_err("error in getting valid channel list"); |
| 7493 | return INVALID_CHANNEL_ID; |
| 7494 | } |
| 7495 | |
| 7496 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7497 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7498 | found = false; |
| 7499 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7500 | if (pcl.pcl_list[i] == |
| 7501 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7502 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7503 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7504 | break; |
| 7505 | } |
| 7506 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7507 | |
| 7508 | if (found) |
| 7509 | continue; |
| 7510 | |
| 7511 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7512 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7513 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7514 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7515 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7516 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7517 | } |
| 7518 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7519 | |
| 7520 | return INVALID_CHANNEL_ID; |
| 7521 | } |
| 7522 | |
| 7523 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7524 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7525 | * @adapter: AP adapter |
| 7526 | * @channel: Channel |
| 7527 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7528 | * Moves the SAP interface by invoking the function which |
| 7529 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7530 | * |
| 7531 | * Return: None |
| 7532 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7533 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7534 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7535 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7536 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7537 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7538 | |
| 7539 | if (!adapter) { |
| 7540 | hdd_err("invalid adapter"); |
| 7541 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7542 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7543 | |
| 7544 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7545 | |
| 7546 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7547 | if (!hal_handle) { |
| 7548 | hdd_err("invalid HAL handle"); |
| 7549 | return; |
| 7550 | } |
| 7551 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7552 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7553 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7554 | hdd_ap_ctx->sap_config.channel = channel; |
| 7555 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7556 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7557 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7558 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7559 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7560 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7561 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7562 | hdd_ap_ctx->sap_config.channel, |
| 7563 | hdd_ap_ctx->sap_config.sec_ch, |
| 7564 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7565 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7566 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7567 | adapter->session_id, channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7568 | hdd_ap_ctx->sap_config.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7569 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7570 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7571 | 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] | 7572 | { |
| 7573 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7574 | int status; |
| 7575 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7576 | |
| 7577 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7578 | |
| 7579 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7580 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7581 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7582 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7583 | } |
| 7584 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7585 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7586 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7587 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7588 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7589 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7590 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7591 | hdd_err("failed to start external acs timer"); |
| 7592 | return -ENOSPC; |
| 7593 | } |
| 7594 | /* Update config to application */ |
| 7595 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7596 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7597 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7598 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7599 | } |
| 7600 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7601 | /** |
| 7602 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7603 | * @hdd_ctx: hdd context pointer |
| 7604 | * |
| 7605 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7606 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7607 | * sap. User space on LTE coex indication restart driver. |
| 7608 | * |
| 7609 | * Return - none |
| 7610 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7611 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7612 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7613 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7614 | uint32_t i; |
| 7615 | bool found = false; |
| 7616 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7617 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7618 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7619 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7620 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7621 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7622 | adapter->device_mode, |
| 7623 | adapter->session.ap.sap_config. |
| 7624 | acs_cfg.acs_mode); |
| 7625 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7626 | } |
| 7627 | |
| 7628 | found = false; |
| 7629 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7630 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7631 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7632 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7633 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7634 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7635 | break; |
| 7636 | } |
| 7637 | } |
| 7638 | |
| 7639 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7640 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7641 | adapter->session.ap.operating_channel); |
| 7642 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7643 | } |
| 7644 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7645 | if (hdd_ctxt->config->vendor_acs_support && |
| 7646 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7647 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7648 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7649 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7650 | } else |
| 7651 | restart_chan = |
| 7652 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7653 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7654 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7655 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7656 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7657 | /* |
| 7658 | * SAP restart due to unsafe channel. While |
| 7659 | * restarting the SAP, make sure to clear |
| 7660 | * acs_channel, channel to reset to |
| 7661 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7662 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7663 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7664 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7665 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7666 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7667 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7668 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7669 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7670 | hdd_debug("driver to start sap: %d", |
| 7671 | hdd_ctxt->config->sap_internal_restart); |
| 7672 | if (hdd_ctxt->config->sap_internal_restart) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7673 | hdd_switch_sap_channel(adapter, restart_chan); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7674 | else |
| 7675 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7676 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7677 | } |
| 7678 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7679 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7680 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7681 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7682 | * @hdd_ctx: HDD global context |
| 7683 | * |
| 7684 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7685 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7686 | * down to the lower layers. Then subscribe to subsequent channel |
| 7687 | * avoidance events. |
| 7688 | * |
| 7689 | * Return: None |
| 7690 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7691 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7692 | { |
| 7693 | uint16_t unsafe_channel_count; |
| 7694 | int index; |
| 7695 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7696 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7697 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7698 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7699 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7700 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7701 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7702 | hdd_ctx->unsafe_channel_count); |
| 7703 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7704 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7705 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7706 | |
| 7707 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7708 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7709 | hdd_ctx->unsafe_channel_list[index]); |
| 7710 | |
| 7711 | } |
| 7712 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7713 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7714 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7715 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7716 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7717 | { |
| 7718 | uint8_t restart_chan; |
| 7719 | |
| 7720 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7721 | if (!restart_chan) { |
| 7722 | hdd_alert("fail to restart SAP"); |
| 7723 | return; |
| 7724 | } |
| 7725 | |
| 7726 | /* SAP restart due to unsafe channel. While restarting |
| 7727 | * the SAP, make sure to clear acs_channel, channel to |
| 7728 | * reset to 0. Otherwise these settings will override |
| 7729 | * the ACS while restart. |
| 7730 | */ |
| 7731 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7732 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7733 | |
| 7734 | hdd_debug("sending coex indication"); |
| 7735 | |
| 7736 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7737 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7738 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7739 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7740 | |
| 7741 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7742 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7743 | { |
| 7744 | uint32_t size; |
| 7745 | uint16_t *unsafe_list; |
| 7746 | uint16_t chan_count; |
| 7747 | |
| 7748 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7749 | return -EINVAL; |
| 7750 | |
| 7751 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7752 | NUM_CHANNELS); |
| 7753 | if (chan_count) { |
| 7754 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7755 | unsafe_list = qdf_mem_malloc(size); |
| 7756 | if (!unsafe_list) { |
| 7757 | hdd_err("No memory for unsafe chan list size%d", |
| 7758 | size); |
| 7759 | return -ENOMEM; |
| 7760 | } |
| 7761 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7762 | } else { |
| 7763 | unsafe_list = NULL; |
| 7764 | } |
| 7765 | |
| 7766 | *local_unsafe_list = unsafe_list; |
| 7767 | *local_unsafe_list_count = chan_count; |
| 7768 | |
| 7769 | return 0; |
| 7770 | } |
| 7771 | |
| 7772 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7773 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7774 | { |
| 7775 | int i, j; |
| 7776 | |
| 7777 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7778 | return true; |
| 7779 | if (local_unsafe_list_count == 0) |
| 7780 | return false; |
| 7781 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7782 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7783 | if (local_unsafe_list[i] == |
| 7784 | hdd_ctx->unsafe_channel_list[j]) |
| 7785 | break; |
| 7786 | if (j >= local_unsafe_list_count) |
| 7787 | break; |
| 7788 | } |
| 7789 | if (i >= local_unsafe_list_count) { |
| 7790 | hdd_info("unsafe chan list same"); |
| 7791 | return false; |
| 7792 | } |
| 7793 | |
| 7794 | return true; |
| 7795 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7796 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7797 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7798 | { |
| 7799 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7800 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7801 | 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] | 7802 | { |
| 7803 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7804 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7805 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7806 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7807 | { |
| 7808 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7809 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7810 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7811 | |
| 7812 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7813 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7814 | * user space |
| 7815 | * @frame_ind: Management frame data to be informed. |
| 7816 | * |
| 7817 | * This function is used to indicate management frame to |
| 7818 | * user space |
| 7819 | * |
| 7820 | * Return: None |
| 7821 | * |
| 7822 | */ |
| 7823 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7824 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7825 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7826 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7827 | int i; |
| 7828 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7829 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7830 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7831 | |
| 7832 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7833 | return; |
| 7834 | |
| 7835 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7836 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7837 | adapter = |
| 7838 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7839 | if (adapter) |
| 7840 | break; |
| 7841 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 7842 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 7843 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7844 | if ((NULL != adapter) && |
| 7845 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 7846 | __hdd_indicate_mgmt_frame(adapter, |
| 7847 | frame_ind->frame_len, |
| 7848 | frame_ind->frameBuf, |
| 7849 | frame_ind->frameType, |
| 7850 | frame_ind->rxChan, |
| 7851 | frame_ind->rxRssi); |
| 7852 | } |
| 7853 | } |
| 7854 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7855 | } else { |
| 7856 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7857 | frame_ind->sessionId); |
| 7858 | } |
| 7859 | |
| 7860 | if ((NULL != adapter) && |
| 7861 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7862 | __hdd_indicate_mgmt_frame(adapter, |
| 7863 | frame_ind->frame_len, |
| 7864 | frame_ind->frameBuf, |
| 7865 | frame_ind->frameType, |
| 7866 | frame_ind->rxChan, |
| 7867 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7868 | } |
| 7869 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7870 | void hdd_acs_response_timeout_handler(void *context) |
| 7871 | { |
| 7872 | struct hdd_external_acs_timer_context *timer_context = |
| 7873 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7874 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7875 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7876 | uint8_t reason; |
| 7877 | |
| 7878 | ENTER(); |
| 7879 | if (!timer_context) { |
| 7880 | hdd_err("invlaid timer context"); |
| 7881 | return; |
| 7882 | } |
| 7883 | adapter = timer_context->adapter; |
| 7884 | reason = timer_context->reason; |
| 7885 | |
| 7886 | |
| 7887 | if ((!adapter) || |
| 7888 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7889 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7890 | return; |
| 7891 | } |
| 7892 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7893 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7894 | return; |
| 7895 | |
| 7896 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7897 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7898 | else |
| 7899 | return; |
| 7900 | |
| 7901 | hdd_err("ACS timeout happened for %s reason %d", |
| 7902 | adapter->dev->name, reason); |
| 7903 | switch (reason) { |
| 7904 | /* SAP init case */ |
| 7905 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7906 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7907 | false); |
| 7908 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7909 | break; |
| 7910 | /* DFS detected on current channel */ |
| 7911 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7912 | wlan_sap_update_next_channel( |
| 7913 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7914 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7915 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7916 | break; |
| 7917 | /* LTE coex event on current channel */ |
| 7918 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7919 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7920 | break; |
| 7921 | default: |
| 7922 | hdd_info("invalid reason for timer invoke"); |
| 7923 | |
| 7924 | } |
| 7925 | } |
| 7926 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7927 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7928 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7929 | * @hdd_ctx: HDD context |
| 7930 | * |
| 7931 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7932 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7933 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7934 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7935 | 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] | 7936 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7937 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7938 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7939 | |
| 7940 | if (!hdd_ctx) { |
| 7941 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7942 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7943 | } |
| 7944 | |
| 7945 | cfg.scan_config = 0; |
| 7946 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7947 | 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] | 7948 | |
| 7949 | hdd_debug("Disabling all dual mac features..."); |
| 7950 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7951 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7952 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7953 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7954 | return status; |
| 7955 | } |
| 7956 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7957 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7958 | } |
| 7959 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7960 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7961 | 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] | 7962 | { |
| 7963 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7964 | QDF_STATUS status; |
| 7965 | |
| 7966 | if (!hdd_ctx) { |
| 7967 | hdd_err("HDD context is NULL"); |
| 7968 | return QDF_STATUS_E_FAILURE; |
| 7969 | } |
| 7970 | |
| 7971 | cfg.scan_config = 0; |
| 7972 | cfg.fw_mode_config = 0; |
| 7973 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7974 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7975 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7976 | &cfg.fw_mode_config, |
| 7977 | hdd_ctx->config->dual_mac_feature_disable); |
| 7978 | |
| 7979 | if (status != QDF_STATUS_SUCCESS) { |
| 7980 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7981 | status); |
| 7982 | return status; |
| 7983 | } |
| 7984 | |
| 7985 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7986 | cfg.scan_config, cfg.fw_mode_config); |
| 7987 | |
| 7988 | status = sme_soc_set_dual_mac_config(cfg); |
| 7989 | if (status != QDF_STATUS_SUCCESS) { |
| 7990 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7991 | return status; |
| 7992 | } |
| 7993 | |
| 7994 | return QDF_STATUS_SUCCESS; |
| 7995 | } |
| 7996 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7997 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7998 | * hdd_override_ini_config - Override INI config |
| 7999 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8000 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8001 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8002 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8003 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8004 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8005 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8006 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8007 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8008 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8009 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8010 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8011 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8012 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8013 | if (0 == enable_11d || 1 == enable_11d) { |
| 8014 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8015 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8016 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8017 | |
| 8018 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 8019 | hdd_ctx->config->IpaConfig = 0; |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8020 | |
| 8021 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8022 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8023 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8024 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8025 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8026 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8027 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8028 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8029 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8030 | /** |
| 8031 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8032 | * @hdd_ctx - HDD context |
| 8033 | * |
| 8034 | * Set trace level for each module based on INI config. |
| 8035 | * |
| 8036 | * Return: None |
| 8037 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8038 | 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] | 8039 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8040 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8041 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8042 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8043 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8044 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8045 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8046 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8047 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8048 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8049 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8050 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8051 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8052 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8053 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8054 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8055 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8056 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8057 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8058 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8059 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8060 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8061 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8062 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8063 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8064 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8065 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8066 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8067 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8068 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8069 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8070 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8071 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8072 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8073 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8074 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8075 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8076 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8077 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8078 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8079 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8080 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8081 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8082 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8083 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 8084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8085 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8086 | } |
| 8087 | |
| 8088 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8089 | * hdd_context_init() - Initialize HDD context |
| 8090 | * @hdd_ctx: HDD context. |
| 8091 | * |
| 8092 | * Initialize HDD context along with all the feature specific contexts. |
| 8093 | * |
| 8094 | * return: 0 on success and errno on failure. |
| 8095 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8096 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8097 | { |
| 8098 | int ret; |
| 8099 | |
| 8100 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8101 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8102 | |
| 8103 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8104 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8105 | |
| 8106 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8107 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8108 | |
| 8109 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8110 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8111 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8112 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8113 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8114 | |
| 8115 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8116 | |
| 8117 | ret = hdd_scan_context_init(hdd_ctx); |
| 8118 | if (ret) |
| 8119 | goto list_destroy; |
| 8120 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8121 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8122 | |
| 8123 | ret = hdd_sap_context_init(hdd_ctx); |
| 8124 | if (ret) |
| 8125 | goto scan_destroy; |
| 8126 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8127 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8128 | |
| 8129 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8130 | |
| 8131 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8132 | hdd_ctx->config); |
| 8133 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8134 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8135 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8136 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8137 | "monitor_mode_wakelock"); |
| 8138 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8139 | return 0; |
| 8140 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8141 | sap_destroy: |
| 8142 | hdd_sap_context_destroy(hdd_ctx); |
| 8143 | |
| 8144 | scan_destroy: |
| 8145 | hdd_scan_context_destroy(hdd_ctx); |
| 8146 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8147 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8148 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8149 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8150 | return ret; |
| 8151 | } |
| 8152 | |
| 8153 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8154 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8155 | * @hdd_ctx: pointer to hdd context |
| 8156 | * |
| 8157 | * Return: status of initialization |
| 8158 | * 0 - success |
| 8159 | * negative value - failure |
| 8160 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8161 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8162 | { |
| 8163 | int ret; |
| 8164 | |
| 8165 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8166 | return 0; |
| 8167 | |
| 8168 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8169 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8170 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8171 | return -EINVAL; |
| 8172 | } |
| 8173 | |
| 8174 | /* parse ini string probe req oui */ |
| 8175 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8176 | if (ret) { |
| 8177 | hdd_err("parsing error: disable ie whitelisting"); |
| 8178 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8179 | } |
| 8180 | |
| 8181 | return ret; |
| 8182 | } |
| 8183 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8184 | |
| 8185 | /** |
| 8186 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8187 | * @priv: pointer to hdd context |
| 8188 | * |
| 8189 | * This function is invoked when the timer waiting for the interface change |
| 8190 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8191 | * |
| 8192 | * Return: void |
| 8193 | */ |
| 8194 | static void hdd_iface_change_callback(void *priv) |
| 8195 | { |
| 8196 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8197 | int ret; |
| 8198 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8199 | |
| 8200 | if (status) |
| 8201 | return; |
| 8202 | |
| 8203 | ENTER(); |
| 8204 | hdd_debug("Interface change timer expired close the modules!"); |
| 8205 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8206 | if (ret) |
| 8207 | hdd_err("Failed to stop modules"); |
| 8208 | EXIT(); |
| 8209 | } |
| 8210 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8211 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8212 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8213 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8214 | * |
| 8215 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8216 | * wiphy allocation and then context is initialized. |
| 8217 | * |
| 8218 | * Return: HDD context on success and ERR_PTR on failure |
| 8219 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8220 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8221 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8222 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8223 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8224 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8225 | |
| 8226 | ENTER(); |
| 8227 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8228 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8229 | if (hdd_ctx == NULL) { |
| 8230 | ret = -ENOMEM; |
| 8231 | goto err_out; |
| 8232 | } |
| 8233 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8234 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8235 | hdd_iface_change_callback, |
| 8236 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8237 | |
| 8238 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8239 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8240 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8241 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8242 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8243 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8244 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8245 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8246 | ret = -ENOMEM; |
| 8247 | goto err_free_hdd_context; |
| 8248 | } |
| 8249 | |
| 8250 | /* Read and parse the qcom_cfg.ini file */ |
| 8251 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8252 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8253 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8254 | WLAN_INI_FILE); |
| 8255 | ret = -EINVAL; |
| 8256 | goto err_free_config; |
| 8257 | } |
| 8258 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8259 | ie_whitelist_attrs_init(hdd_ctx); |
| 8260 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8261 | hdd_debug("setting timer multiplier: %u", |
| 8262 | hdd_ctx->config->timer_multiplier); |
| 8263 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8264 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8265 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8266 | if (hdd_ctx->config->fhostNSOffload) |
| 8267 | hdd_ctx->ns_offload_enable = true; |
| 8268 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8269 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8270 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8271 | hdd_override_ini_config(hdd_ctx); |
| 8272 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8273 | ret = hdd_context_init(hdd_ctx); |
| 8274 | |
| 8275 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8276 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8277 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8278 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8279 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8280 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8281 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8282 | goto skip_multicast_logging; |
| 8283 | |
| 8284 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8285 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8286 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8287 | if (ret) |
| 8288 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8289 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8290 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8291 | if (ret) |
| 8292 | goto err_deinit_txrx_histogram; |
| 8293 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 8294 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 8295 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8296 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8297 | skip_multicast_logging: |
| 8298 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8299 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8300 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8301 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8302 | EXIT(); |
| 8303 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8304 | return hdd_ctx; |
| 8305 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8306 | err_deinit_txrx_histogram: |
| 8307 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8308 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8309 | err_deinit_hdd_context: |
| 8310 | hdd_context_deinit(hdd_ctx); |
| 8311 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8312 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8313 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8314 | |
| 8315 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8316 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8317 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8318 | |
| 8319 | err_out: |
| 8320 | return ERR_PTR(ret); |
| 8321 | } |
| 8322 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8323 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8324 | /** |
| 8325 | * hdd_open_p2p_interface - Open P2P interface |
| 8326 | * @hdd_ctx: HDD context |
| 8327 | * @rtnl_held: True if RTNL lock held |
| 8328 | * |
| 8329 | * Open P2P interface during probe. This function called to open the P2P |
| 8330 | * interface at probe along with STA interface. |
| 8331 | * |
| 8332 | * Return: 0 on success and errno on failure |
| 8333 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8334 | 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] | 8335 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8336 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8337 | uint8_t *p2p_dev_addr; |
| 8338 | |
| 8339 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8340 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8341 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8342 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8343 | sizeof(tSirMacAddr)); |
| 8344 | |
| 8345 | /* |
| 8346 | * Generate the P2P Device Address. This consists of |
| 8347 | * the device's primary MAC address with the locally |
| 8348 | * administered bit set. |
| 8349 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8350 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8351 | } else { |
| 8352 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8353 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8354 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8355 | return -ENOSPC; |
| 8356 | } |
| 8357 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8358 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8359 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8360 | } |
| 8361 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8362 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8363 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8364 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8365 | |
| 8366 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8367 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8368 | return -ENOSPC; |
| 8369 | } |
| 8370 | |
| 8371 | return 0; |
| 8372 | } |
| 8373 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8374 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8375 | bool rtnl_held) |
| 8376 | { |
| 8377 | return 0; |
| 8378 | } |
| 8379 | #endif |
| 8380 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8381 | 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] | 8382 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8383 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8384 | int ret = 0; |
| 8385 | |
| 8386 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8387 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8388 | NET_NAME_UNKNOWN, rtnl_held); |
| 8389 | if (adapter == NULL) { |
| 8390 | hdd_err("Failed to open 802.11p interface"); |
| 8391 | ret = -ENOSPC; |
| 8392 | } |
| 8393 | |
| 8394 | return ret; |
| 8395 | } |
| 8396 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8397 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8398 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8399 | * @adapter: HDD adapter |
| 8400 | * |
| 8401 | * This function initializes the adapter for the station mode. |
| 8402 | * |
| 8403 | * Return: 0 on success or errno on failure. |
| 8404 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8405 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8406 | { |
| 8407 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8408 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8409 | |
| 8410 | ENTER_DEV(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8411 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8412 | hdd_err("session is already opened, %d", |
| 8413 | adapter->session_id); |
| 8414 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8415 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8416 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8417 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8418 | if (ret) { |
| 8419 | hdd_err("failed to create vdev: %d", ret); |
| 8420 | return ret; |
| 8421 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8422 | status = hdd_init_station_mode(adapter); |
| 8423 | |
| 8424 | if (QDF_STATUS_SUCCESS != status) { |
| 8425 | hdd_err("Error Initializing station mode: %d", status); |
| 8426 | return qdf_status_to_os_return(status); |
| 8427 | } |
| 8428 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8429 | hdd_register_tx_flow_control(adapter, |
| 8430 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8431 | hdd_tx_resume_cb, |
| 8432 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8433 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8434 | EXIT(); |
| 8435 | return 0; |
| 8436 | } |
| 8437 | |
| 8438 | /** |
| 8439 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8440 | * @adapter: HDD adapter |
| 8441 | * |
| 8442 | * This function initializes the adapter for the AP mode. |
| 8443 | * |
| 8444 | * Return: 0 on success errno on failure. |
| 8445 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8446 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8447 | { |
| 8448 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8449 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8450 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8451 | |
| 8452 | ENTER(); |
| 8453 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8454 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8455 | hdd_err("session is already opened, %d", |
| 8456 | adapter->session_id); |
| 8457 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8458 | } |
| 8459 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8460 | * In SSR case no need to create new sap context. |
| 8461 | * Otherwise create sap context first and then create |
| 8462 | * vdev as while creating the vdev, driver needs to |
| 8463 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8464 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8465 | if (adapter->session.ap.sap_context) { |
| 8466 | is_ssr = true; |
| 8467 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8468 | hdd_err("sap creation failed"); |
| 8469 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8470 | } |
| 8471 | |
| 8472 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8473 | adapter->session.ap.sap_context); |
| 8474 | if (ret) { |
| 8475 | hdd_err("failed to create vdev, status:%d", ret); |
| 8476 | hdd_sap_destroy_ctx(adapter); |
| 8477 | return ret; |
| 8478 | } |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8479 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8480 | |
| 8481 | if (QDF_STATUS_SUCCESS != status) { |
| 8482 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8483 | return qdf_status_to_os_return(status); |
| 8484 | } |
| 8485 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8486 | hdd_register_tx_flow_control(adapter, |
| 8487 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8488 | hdd_softap_tx_resume_cb, |
| 8489 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8490 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8491 | EXIT(); |
| 8492 | return 0; |
| 8493 | } |
| 8494 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8495 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8496 | bool rtnl_held) |
| 8497 | { |
| 8498 | struct hdd_adapter *adapter; |
| 8499 | |
| 8500 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8501 | hdd_ctx->config->enableConcurrentSTA, |
| 8502 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8503 | NET_NAME_UNKNOWN, rtnl_held); |
| 8504 | |
| 8505 | if (!adapter) |
| 8506 | return -ENOSPC; |
| 8507 | |
| 8508 | return 0; |
| 8509 | } |
| 8510 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8511 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8512 | * hdd_open_interfaces - Open all required interfaces |
| 8513 | * hdd_ctx: HDD context |
| 8514 | * rtnl_held: True if RTNL lock is held |
| 8515 | * |
| 8516 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8517 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8518 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8519 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8520 | 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] | 8521 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8522 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8523 | int ret; |
| 8524 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8525 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8526 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8527 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8528 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8529 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8530 | |
| 8531 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8532 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8533 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8534 | if (!adapter) { |
| 8535 | hdd_err("open adapter failed"); |
| 8536 | return -ENOSPC; |
| 8537 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8538 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8539 | return 0; |
| 8540 | } |
| 8541 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8542 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8543 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8544 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8545 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8546 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8547 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8548 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8549 | |
| 8550 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8551 | return -ENOSPC; |
| 8552 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8553 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8554 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8555 | if (ret) |
| 8556 | hdd_err("Cannot create concurrent STA interface"); |
| 8557 | } |
| 8558 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8559 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8560 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8561 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8562 | |
| 8563 | /* Open 802.11p Interface */ |
| 8564 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8565 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8566 | if (ret) |
| 8567 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8568 | } |
| 8569 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8570 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8571 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8572 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8573 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8574 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8575 | } |
| 8576 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8577 | /** |
| 8578 | * hdd_update_country_code - Update country code |
| 8579 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8580 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8581 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8582 | * |
| 8583 | * Return: 0 on success and errno on failure |
| 8584 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8585 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8586 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8587 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8588 | return 0; |
| 8589 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8590 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8591 | } |
| 8592 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8593 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8594 | /** |
| 8595 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8596 | * @cds_cfg: CDS Configuration |
| 8597 | * @hdd_ctx: Pointer to hdd context |
| 8598 | * |
| 8599 | * Return: none |
| 8600 | */ |
| 8601 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8602 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8603 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8604 | { |
| 8605 | cds_cfg->tx_flow_stop_queue_th = |
| 8606 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8607 | cds_cfg->tx_flow_start_queue_offset = |
| 8608 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8609 | } |
| 8610 | #else |
| 8611 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8612 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8613 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8614 | { |
| 8615 | } |
| 8616 | #endif |
| 8617 | |
| 8618 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8619 | /** |
| 8620 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8621 | * @cds_cfg: CDS Configuration |
| 8622 | * @hdd_ctx: Pointer to hdd context |
| 8623 | * |
| 8624 | * Return: none |
| 8625 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8626 | 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] | 8627 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8628 | { |
| 8629 | cds_cfg->ra_ratelimit_interval = |
| 8630 | hdd_ctx->config->RArateLimitInterval; |
| 8631 | cds_cfg->is_ra_ratelimit_enabled = |
| 8632 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8633 | } |
| 8634 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8635 | 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] | 8636 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8637 | { |
| 8638 | } |
| 8639 | #endif |
| 8640 | |
| 8641 | /** |
| 8642 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8643 | * @hdd_ctx: HDD Context |
| 8644 | * |
| 8645 | * Return: 0 for Success, errno on failure |
| 8646 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8647 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8648 | { |
| 8649 | struct cds_config_info *cds_cfg; |
| 8650 | |
| 8651 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8652 | if (!cds_cfg) { |
| 8653 | hdd_err("failed to allocate cds config"); |
| 8654 | return -ENOMEM; |
| 8655 | } |
| 8656 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8657 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8658 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8659 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8660 | cds_cfg->powersave_offload_enabled = |
| 8661 | hdd_ctx->config->enablePowersaveOffload; |
| 8662 | } else { |
| 8663 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8664 | PS_QPOWER_NODEEPSLEEP) || |
| 8665 | (hdd_ctx->config->enablePowersaveOffload == |
| 8666 | PS_LEGACY_NODEEPSLEEP)) |
| 8667 | cds_cfg->powersave_offload_enabled = |
| 8668 | PS_LEGACY_NODEEPSLEEP; |
| 8669 | else |
| 8670 | cds_cfg->powersave_offload_enabled = |
| 8671 | PS_LEGACY_DEEPSLEEP; |
| 8672 | hdd_info("Qpower disabled in cds config, %d", |
| 8673 | cds_cfg->powersave_offload_enabled); |
| 8674 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8675 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8676 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8677 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8678 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8679 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8680 | |
| 8681 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8682 | * ns offload and others. Currently 1st bit is used for arp |
| 8683 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8684 | */ |
| 8685 | if (hdd_ctx->config->fhostArpOffload) |
| 8686 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8687 | if (hdd_ctx->config->fhostNSOffload) |
| 8688 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8689 | |
| 8690 | /* |
| 8691 | * Copy the DFS Phyerr Filtering Offload status. |
| 8692 | * This parameter reflects the value of the |
| 8693 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8694 | */ |
| 8695 | cds_cfg->dfs_phyerr_filter_offload = |
| 8696 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8697 | if (hdd_ctx->config->ssdp) |
| 8698 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8699 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8700 | cds_cfg->force_target_assert_enabled = |
| 8701 | hdd_ctx->config->crash_inject_enabled; |
| 8702 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8703 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8704 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8705 | |
| 8706 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8707 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8708 | |
| 8709 | cds_cfg->ap_disable_intrabss_fwd = |
| 8710 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8711 | |
| 8712 | cds_cfg->dfs_pri_multiplier = |
| 8713 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8714 | cds_cfg->reorder_offload = |
| 8715 | hdd_ctx->config->reorderOffloadSupport; |
| 8716 | |
| 8717 | /* IPA micro controller data path offload resource config item */ |
| 8718 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8719 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8720 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8721 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8722 | hdd_ctx->config->IpaUcTxBufCount); |
| 8723 | hdd_ctx->config->IpaUcTxBufCount = |
| 8724 | rounddown_pow_of_two( |
| 8725 | hdd_ctx->config->IpaUcTxBufCount); |
| 8726 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8727 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8728 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8729 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8730 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8731 | hdd_ctx->config->IpaUcTxBufCount); |
| 8732 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8733 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8734 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8735 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8736 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8737 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8738 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8739 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8740 | rounddown_pow_of_two( |
| 8741 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8742 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8743 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8744 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8745 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8746 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8747 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8748 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8749 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8750 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8751 | cds_cfg->uc_tx_partition_base = |
| 8752 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8753 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8754 | |
| 8755 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8756 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8757 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8758 | cds_cfg->ce_classify_enabled = |
| 8759 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8760 | cds_cfg->bpf_packet_filter_enable = |
| 8761 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8762 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8763 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8764 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8765 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8766 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8767 | cds_cfg->max_msdus_per_rxinorderind = |
| 8768 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8769 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8770 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8771 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8772 | 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] | 8773 | cds_cfg->auto_power_save_fail_mode = |
| 8774 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8775 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8776 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8777 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8778 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8779 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8780 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8781 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8782 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8783 | cds_init_ini_config(cds_cfg); |
| 8784 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8785 | |
| 8786 | exit: |
| 8787 | qdf_mem_free(cds_cfg); |
| 8788 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8789 | } |
| 8790 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8791 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8792 | * hdd_update_user_config() - API to update user configuration |
| 8793 | * parameters to obj mgr which are used by multiple components |
| 8794 | * @hdd_ctx: HDD Context |
| 8795 | * |
| 8796 | * Return: 0 for Success, errno on failure |
| 8797 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8798 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8799 | { |
| 8800 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8801 | |
| 8802 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8803 | if (user_config == NULL) { |
| 8804 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8805 | return -ENOMEM; |
| 8806 | } |
| 8807 | |
| 8808 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8809 | user_config->dual_mac_feature_disable = |
| 8810 | hdd_ctx->config->dual_mac_feature_disable; |
| 8811 | user_config->indoor_channel_support = |
| 8812 | hdd_ctx->config->indoor_channel_support; |
| 8813 | user_config->is_11d_support_enabled = |
| 8814 | hdd_ctx->config->Is11dSupportEnabled; |
| 8815 | user_config->is_11h_support_enabled = |
| 8816 | hdd_ctx->config->Is11hSupportEnabled; |
| 8817 | user_config->optimize_chan_avoid_event = |
| 8818 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8819 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8820 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8821 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8822 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8823 | |
| 8824 | qdf_mem_free(user_config); |
| 8825 | return 0; |
| 8826 | } |
| 8827 | |
| 8828 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8829 | * hdd_init_thermal_info - Initialize thermal level |
| 8830 | * @hdd_ctx: HDD context |
| 8831 | * |
| 8832 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8833 | * which would be called when a configured thermal threshold is hit. |
| 8834 | * |
| 8835 | * Return: 0 on success and errno on failure |
| 8836 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8837 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8838 | { |
| 8839 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8840 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8841 | |
| 8842 | thermal_param.smeThermalMgmtEnabled = |
| 8843 | hdd_ctx->config->thermalMitigationEnable; |
| 8844 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8845 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8846 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8847 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8848 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8849 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8850 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8851 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8852 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8853 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8854 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8855 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8856 | hdd_ctx->config->thermalTempMinLevel0; |
| 8857 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8858 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8859 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8860 | hdd_ctx->config->thermalTempMinLevel1; |
| 8861 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8862 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8863 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8864 | hdd_ctx->config->thermalTempMinLevel2; |
| 8865 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8866 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8867 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8868 | hdd_ctx->config->thermalTempMinLevel3; |
| 8869 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8870 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8871 | |
| 8872 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8873 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8874 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8875 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8876 | |
| 8877 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8878 | hdd_set_thermal_level_cb); |
| 8879 | |
| 8880 | return 0; |
| 8881 | |
| 8882 | } |
| 8883 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8884 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8885 | /** |
| 8886 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8887 | * |
| 8888 | * Hold RTNL lock |
| 8889 | * |
| 8890 | * Return: True if held and false otherwise |
| 8891 | */ |
| 8892 | static inline bool hdd_hold_rtnl_lock(void) |
| 8893 | { |
| 8894 | rtnl_lock(); |
| 8895 | return true; |
| 8896 | } |
| 8897 | |
| 8898 | /** |
| 8899 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8900 | * |
| 8901 | * Release RTNL lock |
| 8902 | * |
| 8903 | * Return: None |
| 8904 | */ |
| 8905 | static inline void hdd_release_rtnl_lock(void) |
| 8906 | { |
| 8907 | rtnl_unlock(); |
| 8908 | } |
| 8909 | #else |
| 8910 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8911 | static inline void hdd_release_rtnl_lock(void) { } |
| 8912 | #endif |
| 8913 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8914 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8915 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8916 | /* MAX iwpriv command support */ |
| 8917 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8918 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8919 | #define MAX_PKTLOG_SIZE 16 |
| 8920 | |
| 8921 | /** |
| 8922 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8923 | * @hdd_ctx: hdd context |
| 8924 | * @set_value2: pktlog buffer size value |
| 8925 | * |
| 8926 | * |
| 8927 | * Return: 0 for success or error. |
| 8928 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8929 | 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] | 8930 | { |
| 8931 | struct sir_wifi_start_log start_log = { 0 }; |
| 8932 | QDF_STATUS status; |
| 8933 | |
| 8934 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8935 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8936 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8937 | start_log.user_triggered = 1; |
| 8938 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8939 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8940 | |
| 8941 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8942 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8943 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8944 | EXIT(); |
| 8945 | return -EINVAL; |
| 8946 | } |
| 8947 | |
| 8948 | return 0; |
| 8949 | } |
| 8950 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8951 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8952 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8953 | * @hdd_ctx: hdd context |
| 8954 | * |
| 8955 | * Return: 0 for success or error. |
| 8956 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8957 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8958 | { |
| 8959 | struct sir_wifi_start_log start_log; |
| 8960 | QDF_STATUS status; |
| 8961 | |
| 8962 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8963 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8964 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8965 | start_log.user_triggered = 1; |
| 8966 | start_log.size = 0; |
| 8967 | start_log.is_pktlog_buff_clear = true; |
| 8968 | |
| 8969 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8970 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8971 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8972 | EXIT(); |
| 8973 | return -EINVAL; |
| 8974 | } |
| 8975 | |
| 8976 | return 0; |
| 8977 | } |
| 8978 | |
| 8979 | |
| 8980 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8981 | * hdd_process_pktlog_command() - process pktlog command |
| 8982 | * @hdd_ctx: hdd context |
| 8983 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8984 | * @set_value2: pktlog buffer size value |
| 8985 | * |
| 8986 | * This function process pktlog command. |
| 8987 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8988 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8989 | * |
| 8990 | * Return: 0 for success or error. |
| 8991 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8992 | 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] | 8993 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8994 | { |
| 8995 | int ret; |
| 8996 | bool enable; |
| 8997 | uint8_t user_triggered = 0; |
| 8998 | |
| 8999 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9000 | if (0 != ret) |
| 9001 | return ret; |
| 9002 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9003 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9004 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9005 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9006 | hdd_err("invalid pktlog value %d", set_value); |
| 9007 | return -EINVAL; |
| 9008 | } |
| 9009 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9010 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9011 | if (set_value2 <= 0) { |
| 9012 | hdd_err("invalid pktlog size %d", set_value2); |
| 9013 | return -EINVAL; |
| 9014 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9015 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9016 | return -EINVAL; |
| 9017 | } |
| 9018 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9019 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9020 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9021 | } |
| 9022 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9023 | /* |
| 9024 | * set_value = 0 then disable packetlog |
| 9025 | * set_value = 1 enable packetlog forcefully |
| 9026 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9027 | * enable packetlog with AUTO type. |
| 9028 | */ |
| 9029 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9030 | true : false; |
| 9031 | |
| 9032 | if (1 == set_value) { |
| 9033 | enable = true; |
| 9034 | user_triggered = 1; |
| 9035 | } |
| 9036 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9037 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9038 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9039 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9040 | /** |
| 9041 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9042 | * @hdd_ctx: HDD context |
| 9043 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9044 | * @user_triggered: triggered through iwpriv |
| 9045 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9046 | * |
| 9047 | * Return: 0 on success; error number otherwise |
| 9048 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9049 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9050 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9051 | { |
| 9052 | struct sir_wifi_start_log start_log; |
| 9053 | QDF_STATUS status; |
| 9054 | |
| 9055 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9056 | start_log.verbose_level = |
| 9057 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9058 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9059 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9060 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9061 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9062 | /* |
| 9063 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9064 | * commands. Host uses this flag to decide whether to send pktlog |
| 9065 | * disable command to fw without sending pktlog enable command |
| 9066 | * previously. For eg, If vendor sends pktlog disable command without |
| 9067 | * sending pktlog enable command, then host discards the packet |
| 9068 | * but for iwpriv command, host will send it to fw. |
| 9069 | */ |
| 9070 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9071 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9072 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9073 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 9074 | EXIT(); |
| 9075 | return -EINVAL; |
| 9076 | } |
| 9077 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9078 | if (enable == true) |
| 9079 | hdd_ctx->is_pktlog_enabled = 1; |
| 9080 | else |
| 9081 | hdd_ctx->is_pktlog_enabled = 0; |
| 9082 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9083 | return 0; |
| 9084 | } |
| 9085 | #endif /* REMOVE_PKT_LOG */ |
| 9086 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9087 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9088 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9089 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9090 | * @dev: Device Pointer |
| 9091 | * @num: Number of Valid Mac address |
| 9092 | * |
| 9093 | * Return: Pointer to MAC address buffer |
| 9094 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9095 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9096 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9097 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9098 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9099 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9100 | |
| 9101 | /** |
| 9102 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9103 | * @hdd_ctx: HDD Context |
| 9104 | * @num: Number of random mac addresses needed |
| 9105 | * |
| 9106 | * Generate random addresses using bit manipulation on the base mac address |
| 9107 | * |
| 9108 | * Return: None |
| 9109 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9110 | 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] | 9111 | { |
| 9112 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9113 | uint32_t iter; |
| 9114 | struct hdd_config *ini = hdd_ctx->config; |
| 9115 | uint8_t *buf = NULL; |
| 9116 | uint8_t macaddr_b3, tmp_br3; |
| 9117 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9118 | |
| 9119 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9120 | buf = ini->intfMacAddr[iter].bytes; |
| 9121 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9122 | macaddr_b3 = buf[3]; |
| 9123 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9124 | INTF_MACADDR_MASK; |
| 9125 | macaddr_b3 += tmp_br3; |
| 9126 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9127 | buf[0] |= 0x02; |
| 9128 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9129 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9130 | } |
| 9131 | } |
| 9132 | |
| 9133 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9134 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9135 | * @hdd_ctx: HDD Context |
| 9136 | * |
| 9137 | * API to get mac addresses from platform driver and update the driver |
| 9138 | * structures and configure FW with the base mac address. |
| 9139 | * Return: int |
| 9140 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9141 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9142 | { |
| 9143 | uint32_t no_of_mac_addr, iter; |
| 9144 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9145 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9146 | uint8_t *addr, *buf; |
| 9147 | struct device *dev = hdd_ctx->parent_dev; |
| 9148 | struct hdd_config *ini = hdd_ctx->config; |
| 9149 | tSirMacAddr mac_addr; |
| 9150 | QDF_STATUS status; |
| 9151 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9152 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9153 | |
| 9154 | if (no_of_mac_addr == 0 || !addr) { |
| 9155 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9156 | return -EINVAL; |
| 9157 | } |
| 9158 | |
| 9159 | if (no_of_mac_addr > max_mac_addr) |
| 9160 | no_of_mac_addr = max_mac_addr; |
| 9161 | |
| 9162 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9163 | |
| 9164 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9165 | buf = ini->intfMacAddr[iter].bytes; |
| 9166 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9167 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9168 | } |
| 9169 | |
| 9170 | status = sme_set_custom_mac_addr(mac_addr); |
| 9171 | |
| 9172 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9173 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9174 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9175 | if (no_of_mac_addr < max_mac_addr) |
| 9176 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9177 | no_of_mac_addr); |
| 9178 | return 0; |
| 9179 | } |
| 9180 | |
| 9181 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9182 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9183 | * @hdd_ctx: HDD Context |
| 9184 | * |
| 9185 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9186 | * will generate its own MAC and update it to FW. |
| 9187 | * |
| 9188 | * Return: 0 for success |
| 9189 | * Non-zero error code for failure |
| 9190 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9191 | 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] | 9192 | { |
| 9193 | tSirMacAddr customMacAddr; |
| 9194 | QDF_STATUS status; |
| 9195 | |
| 9196 | qdf_mem_copy(&customMacAddr, |
| 9197 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9198 | sizeof(tSirMacAddr)); |
| 9199 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9200 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9201 | return -EAGAIN; |
| 9202 | return 0; |
| 9203 | } |
| 9204 | |
| 9205 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9206 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9207 | * @hdd_ctx: HDD Context |
| 9208 | * |
| 9209 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9210 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9211 | * wlan_mac.bin to update HW MAC addresses. |
| 9212 | * |
| 9213 | * Return: None |
| 9214 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9215 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9216 | { |
| 9217 | QDF_STATUS status; |
| 9218 | int ret; |
| 9219 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9220 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9221 | if (ret == 0) |
| 9222 | return; |
| 9223 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9224 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9225 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9226 | |
| 9227 | status = hdd_update_mac_config(hdd_ctx); |
| 9228 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9229 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9230 | return; |
| 9231 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9232 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9233 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9234 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9235 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9236 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9237 | if (ret != 0) { |
| 9238 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9239 | QDF_ASSERT(ret); |
| 9240 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9241 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9242 | } |
| 9243 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9244 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9245 | { |
| 9246 | int vdev_id = 0; |
| 9247 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9248 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9249 | int vpdev = PDEV_CMD; |
| 9250 | int ret; |
| 9251 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9252 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9253 | if (ret) |
| 9254 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9255 | |
| 9256 | return ret; |
| 9257 | } |
| 9258 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9259 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9260 | { |
| 9261 | int vdev_id = 0; |
| 9262 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9263 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9264 | int vpdev = PDEV_CMD; |
| 9265 | int ret; |
| 9266 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9267 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9268 | if (ret) |
| 9269 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9270 | ret); |
| 9271 | |
| 9272 | return ret; |
| 9273 | } |
| 9274 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9275 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9276 | { |
| 9277 | int vdev_id = 0; |
| 9278 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9279 | int value = hdd_ctx->config->ani_enabled; |
| 9280 | int vpdev = PDEV_CMD; |
| 9281 | int ret; |
| 9282 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9283 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9284 | if (ret) |
| 9285 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9286 | |
| 9287 | return ret; |
| 9288 | } |
| 9289 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9290 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9291 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9292 | * @hdd_ctx: HDD context |
| 9293 | * |
| 9294 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9295 | * |
| 9296 | * Return: 0 on success and errno on failure. |
| 9297 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9298 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9299 | { |
| 9300 | int ret; |
| 9301 | QDF_STATUS status; |
| 9302 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9303 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9304 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9305 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9306 | /* |
| 9307 | * Set 802.11p config |
| 9308 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9309 | * parameter is set in CSR when we init the channel list. This should |
| 9310 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9311 | * domain. |
| 9312 | */ |
| 9313 | hdd_set_dot11p_config(hdd_ctx); |
| 9314 | |
| 9315 | /* |
| 9316 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9317 | * The cfg download must occur before we update the SME config |
| 9318 | * since the SME config operation must access the cfg database |
| 9319 | */ |
| 9320 | status = hdd_set_sme_config(hdd_ctx); |
| 9321 | |
| 9322 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9323 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9324 | ret = qdf_status_to_os_return(status); |
| 9325 | goto out; |
| 9326 | } |
| 9327 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9328 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9329 | if (QDF_STATUS_SUCCESS != status) { |
| 9330 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9331 | ret = qdf_status_to_os_return(status); |
| 9332 | goto out; |
| 9333 | } |
| 9334 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9335 | 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] | 9336 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9337 | PDEV_CMD); |
| 9338 | if (0 != ret) { |
| 9339 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9340 | goto out; |
| 9341 | } |
| 9342 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9343 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9344 | if (ret) |
| 9345 | goto out; |
| 9346 | |
| 9347 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9348 | if (ret) |
| 9349 | goto out; |
| 9350 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9351 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9352 | if (ret) |
| 9353 | goto out; |
| 9354 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9355 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9356 | hdd_ctx->config->arp_ac_category, |
| 9357 | PDEV_CMD); |
| 9358 | if (0 != ret) { |
| 9359 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9360 | hdd_ctx->config->arp_ac_category, ret); |
| 9361 | goto out; |
| 9362 | } |
| 9363 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9364 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9365 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9366 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9367 | ret = qdf_status_to_os_return(status); |
| 9368 | goto out; |
| 9369 | } |
| 9370 | |
| 9371 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9372 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9373 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9374 | ret = -EINVAL; |
| 9375 | goto out; |
| 9376 | } |
| 9377 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9378 | /* |
| 9379 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9380 | * Remove this once self sta is added as part of session open. |
| 9381 | */ |
| 9382 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9383 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9384 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9385 | |
| 9386 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9387 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9388 | hal_status, hal_status); |
| 9389 | ret = -EINVAL; |
| 9390 | goto out; |
| 9391 | } |
| 9392 | |
| 9393 | hdd_init_channel_avoidance(hdd_ctx); |
| 9394 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9395 | /* update enable sap mandatory chan list */ |
| 9396 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9397 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9398 | out: |
| 9399 | return ret; |
| 9400 | } |
| 9401 | |
| 9402 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9403 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9404 | * @context_ptr - hdd context pointer |
| 9405 | * @event_ptr - event structure pointer |
| 9406 | * |
| 9407 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9408 | * event back to supplicant to notify the stop reason. |
| 9409 | * |
| 9410 | * Return: None |
| 9411 | */ |
| 9412 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9413 | void *event_ptr) |
| 9414 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9415 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9416 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9417 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9418 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9419 | |
| 9420 | ENTER(); |
| 9421 | |
| 9422 | if (hdd_ctx == NULL) { |
| 9423 | hdd_err("Invalid HDD context pointer"); |
| 9424 | return; |
| 9425 | } |
| 9426 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9427 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9428 | if (!adapter) { |
| 9429 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9430 | evt->vdev_id); |
| 9431 | return; |
| 9432 | } |
| 9433 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9434 | vendor_event = |
| 9435 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9436 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9437 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9438 | GFP_KERNEL); |
| 9439 | |
| 9440 | if (!vendor_event) { |
| 9441 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9442 | return; |
| 9443 | } |
| 9444 | |
| 9445 | if (nla_put_u32(vendor_event, |
| 9446 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9447 | evt->reason_code)) { |
| 9448 | hdd_err("nla put failed"); |
| 9449 | kfree_skb(vendor_event); |
| 9450 | return; |
| 9451 | } |
| 9452 | |
| 9453 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9454 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9455 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9456 | } |
| 9457 | |
| 9458 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9459 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9460 | * @hdd_ctx: HDD context |
| 9461 | * |
| 9462 | * This function sends the adaptive dwell time config configuration to the |
| 9463 | * firmware via WMA |
| 9464 | * |
| 9465 | * Return: 0 - success, < 0 - failure |
| 9466 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9467 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9468 | { |
| 9469 | QDF_STATUS status; |
| 9470 | struct adaptive_dwelltime_params dwelltime_params; |
| 9471 | |
| 9472 | dwelltime_params.is_enabled = |
| 9473 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9474 | dwelltime_params.dwelltime_mode = |
| 9475 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9476 | dwelltime_params.lpf_weight = |
| 9477 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9478 | dwelltime_params.passive_mon_intval = |
| 9479 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9480 | dwelltime_params.wifi_act_threshold = |
| 9481 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9482 | |
| 9483 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9484 | &dwelltime_params); |
| 9485 | |
| 9486 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9487 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9488 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9489 | return -EAGAIN; |
| 9490 | } |
| 9491 | return 0; |
| 9492 | } |
| 9493 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9494 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9495 | { |
| 9496 | QDF_STATUS status; |
| 9497 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9498 | uint32_t i = 0; |
| 9499 | uint8_t count = 0, numentries = 0; |
| 9500 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9501 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9502 | |
| 9503 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9504 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9505 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9506 | return -EINVAL; |
| 9507 | |
| 9508 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9509 | dbs_scan_config, &numentries, |
| 9510 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9511 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9512 | |
| 9513 | hdd_info("numentries %hu", numentries); |
| 9514 | if (!numentries) { |
| 9515 | hdd_info("Donot send scan_selection_config"); |
| 9516 | return 0; |
| 9517 | } |
| 9518 | |
| 9519 | /* hdd_set_fw_log_params */ |
| 9520 | dbs_scan_params.num_clients = 0; |
| 9521 | while (count < (numentries - 2)) { |
| 9522 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9523 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9524 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9525 | dbs_scan_config[count + 2]; |
| 9526 | dbs_scan_params.num_clients++; |
| 9527 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9528 | dbs_scan_params.module_id[i], |
| 9529 | dbs_scan_params.num_dbs_scans[i], |
| 9530 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9531 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9532 | i++; |
| 9533 | } |
| 9534 | |
| 9535 | dbs_scan_params.pdev_id = 0; |
| 9536 | |
| 9537 | hdd_debug("clients:%d pdev:%d", |
| 9538 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9539 | |
| 9540 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9541 | &dbs_scan_params); |
| 9542 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9543 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9544 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9545 | return -EAGAIN; |
| 9546 | } |
| 9547 | return 0; |
| 9548 | } |
| 9549 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9550 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9551 | /** |
| 9552 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9553 | * @hdd_ctx: HDD context |
| 9554 | * |
| 9555 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9556 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9557 | * |
| 9558 | * Return: 0 on success and errno on failure. |
| 9559 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9560 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9561 | { |
| 9562 | QDF_STATUS status; |
| 9563 | |
| 9564 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9565 | return 0; |
| 9566 | |
| 9567 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9568 | wlan_hdd_auto_shutdown_cb); |
| 9569 | if (status != QDF_STATUS_SUCCESS) |
| 9570 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9571 | status); |
| 9572 | |
| 9573 | return qdf_status_to_os_return(status); |
| 9574 | } |
| 9575 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9576 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9577 | { |
| 9578 | return 0; |
| 9579 | } |
| 9580 | #endif |
| 9581 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9582 | 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] | 9583 | { |
| 9584 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9585 | |
| 9586 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9587 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9588 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9589 | if (status != QDF_STATUS_SUCCESS) |
| 9590 | hdd_err("Failed to disable dual mac features"); |
| 9591 | break; |
| 9592 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9593 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9594 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9595 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9596 | if (status != QDF_STATUS_SUCCESS) |
| 9597 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9598 | break; |
| 9599 | default: |
| 9600 | break; |
| 9601 | } |
| 9602 | |
| 9603 | return status; |
| 9604 | } |
| 9605 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9606 | /** |
| 9607 | * hdd_features_init() - Init features |
| 9608 | * @hdd_ctx: HDD context |
| 9609 | * @adapter: Primary adapter context |
| 9610 | * |
| 9611 | * Initialize features and their feature context after WLAN firmware is up. |
| 9612 | * |
| 9613 | * Return: 0 on success and errno on failure. |
| 9614 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9615 | 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] | 9616 | { |
| 9617 | tSirTxPowerLimit hddtxlimit; |
| 9618 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9619 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9620 | int ret; |
| 9621 | |
| 9622 | ENTER(); |
| 9623 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9624 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9625 | if (ret) { |
| 9626 | hdd_err("Failed to update country code: %d", ret); |
| 9627 | goto out; |
| 9628 | } |
| 9629 | |
| 9630 | /* FW capabilities received, Set the Dot11 mode */ |
| 9631 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9632 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9633 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9634 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9635 | |
| 9636 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9637 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9638 | else |
| 9639 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9640 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9641 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9642 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9643 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9644 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9645 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9646 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9647 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9648 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9649 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9650 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9651 | if (hdd_lro_init(hdd_ctx)) |
| 9652 | hdd_err("Unable to initialize LRO in fw"); |
| 9653 | |
| 9654 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9655 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9656 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9657 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9658 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9659 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9660 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9661 | if (ret) { |
| 9662 | hdd_err("Error while initializing thermal information"); |
| 9663 | goto deregister_frames; |
| 9664 | } |
| 9665 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9666 | /** |
| 9667 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9668 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9669 | * device up. |
| 9670 | */ |
| 9671 | if (cds_is_driver_recovering()) { |
| 9672 | if (hdd_ctx->is_pktlog_enabled) |
| 9673 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9674 | } else if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9675 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9676 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9677 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9678 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9679 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9680 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9681 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9682 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9683 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9684 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9685 | ret = hdd_register_cb(hdd_ctx); |
| 9686 | if (ret) { |
| 9687 | hdd_err("Failed to register HDD callbacks!"); |
| 9688 | goto deregister_frames; |
| 9689 | } |
| 9690 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9691 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9692 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9693 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9694 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9695 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9696 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9697 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9698 | status = sme_enable_disable_chanavoidind_event( |
| 9699 | hdd_ctx->hHal, 0); |
| 9700 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9701 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9702 | goto deregister_cb; |
| 9703 | } |
| 9704 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9705 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9706 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9707 | band_pref_params.rssi_boost_threshold_5g = |
| 9708 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9709 | band_pref_params.rssi_boost_factor_5g = |
| 9710 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9711 | band_pref_params.max_rssi_boost_5g = |
| 9712 | hdd_ctx->config->max_rssi_boost_5g; |
| 9713 | band_pref_params.rssi_penalize_threshold_5g = |
| 9714 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9715 | band_pref_params.rssi_penalize_factor_5g = |
| 9716 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9717 | band_pref_params.max_rssi_penalize_5g = |
| 9718 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9719 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9720 | } |
| 9721 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9722 | /* register P2P Listen Offload event callback */ |
| 9723 | if (wma_is_p2p_lo_capable()) |
| 9724 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9725 | wlan_hdd_p2p_lo_event_callback); |
| 9726 | |
| 9727 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9728 | |
| 9729 | if (ret) |
| 9730 | goto deregister_cb; |
| 9731 | |
| 9732 | EXIT(); |
| 9733 | return 0; |
| 9734 | |
| 9735 | deregister_cb: |
| 9736 | hdd_deregister_cb(hdd_ctx); |
| 9737 | deregister_frames: |
| 9738 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9739 | out: |
| 9740 | return -EINVAL; |
| 9741 | |
| 9742 | } |
| 9743 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9744 | /** |
| 9745 | * hdd_features_deinit() - Deinit features |
| 9746 | * @hdd_ctx: HDD context |
| 9747 | * |
| 9748 | * De-Initialize features and their feature context. |
| 9749 | * |
| 9750 | * Return: none. |
| 9751 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9752 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9753 | { |
| 9754 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9755 | } |
| 9756 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9757 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9758 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9759 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9760 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9761 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9762 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9763 | 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] | 9764 | { |
| 9765 | QDF_STATUS status; |
| 9766 | |
| 9767 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9768 | wlan_cfg80211_inform_bss_frame, |
| 9769 | SCAN_CB_TYPE_INFORM_BCN); |
| 9770 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9771 | hdd_err("failed with status code %08d [x%08x]", |
| 9772 | status, status); |
| 9773 | return status; |
| 9774 | } |
| 9775 | |
| 9776 | return QDF_STATUS_SUCCESS; |
| 9777 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9778 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9779 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9780 | * hdd_configure_cds() - Configure cds modules |
| 9781 | * @hdd_ctx: HDD context |
| 9782 | * @adapter: Primary adapter context |
| 9783 | * |
| 9784 | * Enable Cds modules after WLAN firmware is up. |
| 9785 | * |
| 9786 | * Return: 0 on success and errno on failure. |
| 9787 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9788 | 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] | 9789 | { |
| 9790 | int ret; |
| 9791 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9792 | int set_value; |
| 9793 | uint32_t num_abg_tx_chains = 0; |
| 9794 | uint32_t num_11b_tx_chains = 0; |
| 9795 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9796 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9797 | |
| 9798 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9799 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9800 | hdd_ctx->config->sifs_burst_duration; |
| 9801 | |
| 9802 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9803 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9804 | set_value, PDEV_CMD); |
| 9805 | } |
| 9806 | |
| 9807 | if (hdd_ctx->config->is_force_1x1) |
| 9808 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9809 | 1, PDEV_CMD); |
| 9810 | /* set chip power save failure detected callback */ |
| 9811 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9812 | hdd_chip_pwr_save_fail_detected_cb); |
| 9813 | |
| 9814 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9815 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9816 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9817 | set_value, PDEV_CMD); |
| 9818 | } |
| 9819 | |
| 9820 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9821 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9822 | sme_cli_set_command(0, |
| 9823 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9824 | set_value, PDEV_CMD); |
| 9825 | } |
| 9826 | |
| 9827 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9828 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9829 | sme_cli_set_command(0, |
| 9830 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9831 | set_value, PDEV_CMD); |
| 9832 | } |
| 9833 | |
| 9834 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9835 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9836 | if (!hdd_ctx->config->enable2x2) { |
| 9837 | if (num_11b_tx_chains > 1) |
| 9838 | num_11b_tx_chains = 1; |
| 9839 | if (num_11ag_tx_chains > 1) |
| 9840 | num_11ag_tx_chains = 1; |
| 9841 | } |
| 9842 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9843 | num_11b_tx_chains); |
| 9844 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9845 | num_11ag_tx_chains); |
| 9846 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9847 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9848 | |
| 9849 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9850 | if (ret) { |
| 9851 | hdd_err("Failed to pre-configure cds"); |
| 9852 | goto out; |
| 9853 | } |
| 9854 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9855 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9856 | * IPA module before configuring them to FW. Sequence required as crash |
| 9857 | * observed otherwise. |
| 9858 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9859 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9860 | hdd_err("Failed to setup pipes"); |
| 9861 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9862 | } |
| 9863 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9864 | /* |
| 9865 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9866 | * else |
| 9867 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9868 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9869 | |
| 9870 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9871 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9872 | goto out; |
| 9873 | } |
| 9874 | |
| 9875 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9876 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9877 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9878 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9879 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9880 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9881 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9882 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9883 | goto cds_disable; |
| 9884 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9885 | |
| 9886 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9887 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9888 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9889 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9890 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9891 | 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] | 9892 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9893 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9894 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9895 | goto cds_disable; |
| 9896 | } |
| 9897 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 9898 | if (ucfg_green_ap_enable_egap(hdd_ctx->hdd_pdev)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9899 | hdd_debug("enhance green ap is not enabled"); |
| 9900 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9901 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9902 | hdd_debug("Failed to set wow pulse"); |
| 9903 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9904 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9905 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9906 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9907 | |
| 9908 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9909 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9910 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9911 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9912 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9913 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9914 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9915 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9916 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9917 | out: |
| 9918 | return -EINVAL; |
| 9919 | } |
| 9920 | |
| 9921 | /** |
| 9922 | * hdd_deconfigure_cds() -De-Configure cds |
| 9923 | * @hdd_ctx: HDD context |
| 9924 | * |
| 9925 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9926 | * |
| 9927 | * Return: 0 on success and errno on failure. |
| 9928 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9929 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9930 | { |
| 9931 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9932 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9933 | |
| 9934 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9935 | |
| 9936 | /* De-init features */ |
| 9937 | hdd_features_deinit(hdd_ctx); |
| 9938 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9939 | /* De-register the SME callbacks */ |
| 9940 | hdd_deregister_cb(hdd_ctx); |
| 9941 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9942 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9943 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9944 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9945 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9946 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9947 | } |
| 9948 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9949 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9950 | hdd_err("Failed to disconnect pipes"); |
| 9951 | ret = -EINVAL; |
| 9952 | } |
| 9953 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9954 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9955 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9956 | } |
| 9957 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9958 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9959 | static void hdd_deregister_policy_manager_callback( |
| 9960 | struct wlan_objmgr_psoc *psoc) |
| 9961 | { |
| 9962 | if (QDF_STATUS_SUCCESS != |
| 9963 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9964 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9965 | } |
| 9966 | } |
| 9967 | #else |
| 9968 | static void hdd_deregister_policy_manager_callback( |
| 9969 | struct wlan_objmgr_psoc *psoc) |
| 9970 | { |
| 9971 | } |
| 9972 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9973 | |
| 9974 | /** |
| 9975 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9976 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9977 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9978 | * |
| 9979 | * This function maintains the driver state machine it will be invoked from |
| 9980 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9981 | * shall perform the stopping/closing of the modules. |
| 9982 | * |
| 9983 | * Return: 0 for success; non-zero for failure |
| 9984 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9985 | 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] | 9986 | { |
| 9987 | void *hif_ctx; |
| 9988 | qdf_device_t qdf_ctx; |
| 9989 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9990 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 9991 | bool is_recovery_stop = cds_is_driver_recovering(); |
| 9992 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9993 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9994 | |
| 9995 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9996 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 9997 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9998 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9999 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10000 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10001 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10002 | if (!qdf_ctx) { |
| 10003 | hdd_err("QDF device context NULL"); |
| 10004 | return -EINVAL; |
| 10005 | } |
| 10006 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10007 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10008 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10009 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10010 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10011 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10012 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10013 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10014 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10015 | |
| 10016 | cds_print_external_threads(); |
| 10017 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10018 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10019 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10020 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10021 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10022 | hdd_prevent_suspend_timeout( |
| 10023 | hdd_ctx->config->iface_change_wait_time, |
| 10024 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10025 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10026 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10027 | return 0; |
| 10028 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10029 | } |
| 10030 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10031 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10032 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10033 | /* free user wowl patterns */ |
| 10034 | hdd_free_user_wowl_ptrns(); |
| 10035 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10036 | switch (hdd_ctx->driver_status) { |
| 10037 | case DRIVER_MODULES_UNINITIALIZED: |
| 10038 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10039 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10040 | case DRIVER_MODULES_CLOSED: |
| 10041 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10042 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10043 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10044 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10045 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10046 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10047 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10048 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10049 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10050 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10051 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10052 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10053 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10054 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10055 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10056 | |
| 10057 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10058 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10059 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10060 | break; |
| 10061 | default: |
| 10062 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10063 | hdd_ctx->driver_status); |
| 10064 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10065 | ret = -EINVAL; |
| 10066 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10067 | } |
| 10068 | |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10069 | hdd_debug("Closing CDS modules!"); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10070 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10071 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10072 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10073 | qdf_status); |
| 10074 | ret = -EINVAL; |
| 10075 | QDF_ASSERT(0); |
| 10076 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10077 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10078 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10079 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 10080 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10081 | if (ret) { |
| 10082 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10083 | QDF_ASSERT(0); |
| 10084 | } |
| 10085 | |
| 10086 | /* |
| 10087 | * Reset total mac phy during module stop such that during |
| 10088 | * next module start same psoc is used to populate new service |
| 10089 | * ready data |
| 10090 | */ |
| 10091 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
| 10092 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10093 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10094 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10095 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10096 | ret = -EINVAL; |
| 10097 | QDF_ASSERT(0); |
| 10098 | } |
| 10099 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10100 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10101 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10102 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10103 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10104 | QDF_ASSERT(0); |
| 10105 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10106 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10107 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10108 | if (!hif_ctx) { |
| 10109 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10110 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10111 | } |
| 10112 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10113 | if (hdd_ctx->target_hw_name) { |
| 10114 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10115 | hdd_ctx->target_hw_name = NULL; |
| 10116 | } |
| 10117 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10118 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10119 | |
| 10120 | ol_cds_free(); |
| 10121 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10122 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10123 | ret = pld_power_off(qdf_ctx->dev); |
| 10124 | if (ret) |
| 10125 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10126 | ret); |
| 10127 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10128 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10129 | /* many adapter resources are not freed by design in SSR case */ |
| 10130 | if (!is_recovery_stop) |
| 10131 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10132 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10133 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10134 | /* Once the firmware sequence is completed reset this flag */ |
| 10135 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10136 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10137 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10138 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10139 | done: |
| 10140 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10141 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10142 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10143 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10144 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10145 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10146 | EXIT(); |
| 10147 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10148 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10149 | } |
| 10150 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10151 | |
| 10152 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10153 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10154 | * @buf: buffer pointer |
| 10155 | * @size: size of buffer to be filled |
| 10156 | * |
| 10157 | * This function is used to dump state information of hdd layer |
| 10158 | * |
| 10159 | * Return: None |
| 10160 | */ |
| 10161 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10162 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10163 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10164 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10165 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10166 | uint16_t len = 0; |
| 10167 | char *buf = *buf_ptr; |
| 10168 | |
| 10169 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10170 | if (!hdd_ctx) { |
| 10171 | hdd_err("Failed to get hdd context "); |
| 10172 | return; |
| 10173 | } |
| 10174 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10175 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10176 | |
| 10177 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10178 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10179 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10180 | "\n is_scheduler_suspended %d", |
| 10181 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10182 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10183 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10184 | if (adapter->dev) |
| 10185 | len += scnprintf(buf + len, *size - len, |
| 10186 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10187 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10188 | "\n device_mode: %d", adapter->device_mode); |
| 10189 | switch (adapter->device_mode) { |
| 10190 | case QDF_STA_MODE: |
| 10191 | case QDF_P2P_CLIENT_MODE: |
| 10192 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10193 | len += scnprintf(buf + len, *size - len, |
| 10194 | "\n connState: %d", |
| 10195 | hdd_sta_ctx->conn_info.connState); |
| 10196 | break; |
| 10197 | |
| 10198 | default: |
| 10199 | break; |
| 10200 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10201 | } |
| 10202 | |
| 10203 | *size -= len; |
| 10204 | *buf_ptr += len; |
| 10205 | } |
| 10206 | |
| 10207 | /** |
| 10208 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10209 | * to print hdd state information |
| 10210 | * |
| 10211 | * Return: None |
| 10212 | */ |
| 10213 | static void hdd_register_debug_callback(void) |
| 10214 | { |
| 10215 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10216 | } |
| 10217 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10218 | /* |
| 10219 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10220 | * |
| 10221 | * This function is used to create bug report lock |
| 10222 | * |
| 10223 | * Return: None |
| 10224 | */ |
| 10225 | static void wlan_init_bug_report_lock(void) |
| 10226 | { |
| 10227 | p_cds_contextType p_cds_context; |
| 10228 | |
| 10229 | p_cds_context = cds_get_global_context(); |
| 10230 | if (!p_cds_context) { |
| 10231 | hdd_err("cds context is NULL"); |
| 10232 | return; |
| 10233 | } |
| 10234 | |
| 10235 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10236 | } |
| 10237 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10238 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10239 | { |
| 10240 | |
| 10241 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10242 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10243 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10244 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10245 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10246 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10247 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10248 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10249 | |
| 10250 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10251 | &num_entries, sizeof(config_params)); |
| 10252 | |
| 10253 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10254 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10255 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10256 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10257 | else if (bw_compute_interval > 1000) { |
| 10258 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10259 | thresh_time_limit = 1; |
| 10260 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10261 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10262 | |
| 10263 | switch (num_entries) { |
| 10264 | case 4: |
| 10265 | proto_bitmap = config_params[3]; |
| 10266 | case 3: |
| 10267 | verbosity = config_params[2]; |
| 10268 | case 2: |
| 10269 | thresh = config_params[1]; |
| 10270 | case 1: |
| 10271 | live_mode = config_params[0]; |
| 10272 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10273 | 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] | 10274 | live_mode, thresh, thresh_time_limit, |
| 10275 | verbosity, proto_bitmap); |
| 10276 | }; |
| 10277 | |
| 10278 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10279 | verbosity, proto_bitmap); |
| 10280 | |
| 10281 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10282 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10283 | * hdd_wlan_startup() - HDD init function |
| 10284 | * @dev: Pointer to the underlying device |
| 10285 | * |
| 10286 | * This is the driver startup code executed once a WLAN device has been detected |
| 10287 | * |
| 10288 | * Return: 0 for success, < 0 for failure |
| 10289 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10290 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10291 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10292 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10293 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10294 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10295 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10296 | |
| 10297 | ENTER(); |
| 10298 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10299 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10300 | |
| 10301 | if (IS_ERR(hdd_ctx)) |
| 10302 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10303 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10304 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10305 | DEFAULT_PSOC_ID); |
| 10306 | if (ret) { |
| 10307 | hdd_err("Psoc creation fails!"); |
| 10308 | QDF_BUG(0); |
| 10309 | goto err_hdd_free_context; |
| 10310 | } |
| 10311 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10312 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10313 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10314 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10315 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10316 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10317 | hdd_request_manager_init(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10318 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10319 | hdd_driver_memdump_init(); |
| 10320 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10321 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10322 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10323 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10324 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10325 | } |
| 10326 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10327 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10328 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10329 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10330 | |
| 10331 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10332 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10333 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10334 | } |
| 10335 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10336 | ret = hdd_wiphy_init(hdd_ctx); |
| 10337 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10338 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10339 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10340 | } |
| 10341 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10342 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10343 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10344 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10345 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10346 | goto err_wiphy_unregister; |
| 10347 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 10348 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10349 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10350 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10351 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10352 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10353 | if (ret) { |
| 10354 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10355 | goto err_ipa_cleanup; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10356 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10357 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10358 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10359 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10360 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10361 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10362 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10363 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10364 | } |
| 10365 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10366 | hdd_release_rtnl_lock(); |
| 10367 | rtnl_held = false; |
| 10368 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10369 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10370 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10371 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10372 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10373 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10374 | hdd_skip_acs_scan_timer_handler, |
| 10375 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10376 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10377 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10378 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10379 | #endif |
| 10380 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10381 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10382 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10383 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10384 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10385 | if (hdd_ctx->rps) |
| 10386 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10387 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10388 | ret = hdd_register_notifiers(hdd_ctx); |
| 10389 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10390 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10391 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10392 | status = wlansap_global_init(); |
| 10393 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10394 | hdd_unregister_notifiers(hdd_ctx); |
| 10395 | goto err_close_adapters; |
| 10396 | } |
| 10397 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10398 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10399 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10400 | else |
| 10401 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10402 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10403 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10404 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10405 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10406 | hdd_prevent_suspend_timeout( |
| 10407 | hdd_ctx->config->iface_change_wait_time, |
| 10408 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10409 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10410 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10411 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10412 | goto success; |
| 10413 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10414 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10415 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10416 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10417 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10418 | if (rtnl_held) |
| 10419 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10420 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10421 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10422 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10423 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10424 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10425 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10426 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10427 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10428 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10429 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10430 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10431 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10432 | err_memdump_deinit: |
| 10433 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10434 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10435 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10436 | hdd_exit_netlink_services(hdd_ctx); |
| 10437 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10438 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10439 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10440 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10441 | if (cds_is_fw_down()) |
| 10442 | hdd_err("Not setting the complete event as fw is down"); |
| 10443 | else |
| 10444 | hdd_start_complete(ret); |
| 10445 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10446 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10447 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10448 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10449 | |
| 10450 | success: |
| 10451 | EXIT(); |
| 10452 | return 0; |
| 10453 | } |
| 10454 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10455 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10456 | * hdd_wlan_update_target_info() - update target type info |
| 10457 | * @hdd_ctx: HDD context |
| 10458 | * @context: hif context |
| 10459 | * |
| 10460 | * Update target info received from firmware in hdd context |
| 10461 | * Return:None |
| 10462 | */ |
| 10463 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10464 | 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] | 10465 | { |
| 10466 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10467 | |
| 10468 | if (!tgt_info) { |
| 10469 | hdd_err("Target info is Null"); |
| 10470 | return; |
| 10471 | } |
| 10472 | |
| 10473 | hdd_ctx->target_type = tgt_info->target_type; |
| 10474 | } |
| 10475 | |
| 10476 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10477 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10478 | * received from the firmware |
| 10479 | * @data: pointer to adapter. |
| 10480 | * @rsp: pointer to data received from FW. |
| 10481 | * |
| 10482 | * This is called when wlan driver received response event for |
| 10483 | * get arp stats to firmware. |
| 10484 | * |
| 10485 | * Return: None |
| 10486 | */ |
| 10487 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10488 | { |
| 10489 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10490 | struct hdd_nud_stats_context *context; |
| 10491 | int status; |
| 10492 | struct hdd_adapter *adapter = NULL; |
| 10493 | |
| 10494 | ENTER(); |
| 10495 | |
| 10496 | if (!rsp) { |
| 10497 | hdd_err("data is null"); |
| 10498 | return; |
| 10499 | } |
| 10500 | |
| 10501 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10502 | if (0 != status) |
| 10503 | return; |
| 10504 | |
| 10505 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10506 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10507 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10508 | return; |
| 10509 | } |
| 10510 | |
| 10511 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10512 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10513 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10514 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10515 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10516 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10517 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10518 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10519 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10520 | rsp->ba_session_establishment_status); |
| 10521 | |
| 10522 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10523 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10524 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10525 | adapter->dad |= rsp->dad_detected; |
| 10526 | adapter->con_status = rsp->connect_status; |
| 10527 | |
| 10528 | spin_lock(&hdd_context_lock); |
| 10529 | context = &hdd_ctx->nud_stats_context; |
| 10530 | complete(&context->response_event); |
| 10531 | spin_unlock(&hdd_context_lock); |
| 10532 | |
| 10533 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10534 | } |
| 10535 | |
| 10536 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10537 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10538 | * @hdd_ctx: HDD context |
| 10539 | * |
| 10540 | * Register the HDD callbacks to CDS/SME. |
| 10541 | * |
| 10542 | * Return: 0 for success or Error code for failure |
| 10543 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10544 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10545 | { |
| 10546 | QDF_STATUS status; |
| 10547 | int ret = 0; |
| 10548 | |
| 10549 | ENTER(); |
| 10550 | |
| 10551 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10552 | |
| 10553 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10554 | hdd_send_oem_data_rsp_msg); |
| 10555 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10556 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10557 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10558 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10559 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10560 | wlan_hdd_cfg80211_nan_callback); |
| 10561 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10562 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10563 | |
| 10564 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10565 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10566 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10567 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10568 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10569 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10570 | hdd_rssi_threshold_breached); |
| 10571 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10572 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10573 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10574 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10575 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10576 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10577 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10578 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10579 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10580 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10581 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10582 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10583 | hdd_lost_link_info_cb); |
| 10584 | /* print error and not block the startup process */ |
| 10585 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10586 | hdd_err("set lost link info callback failed"); |
| 10587 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10588 | ret = hdd_register_data_stall_detect_cb(); |
| 10589 | if (ret) { |
| 10590 | hdd_err("Register data stall detect detect callback failed."); |
| 10591 | return ret; |
| 10592 | } |
| 10593 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10594 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10595 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10596 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10597 | hdd_set_connection_in_progress, |
| 10598 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10599 | |
| 10600 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10601 | hdd_update_cca_info_cb); |
| 10602 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10603 | hdd_err("set congestion callback failed"); |
| 10604 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10605 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10606 | hdd_bt_activity_cb); |
| 10607 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10608 | hdd_err("set bt activity info callback failed"); |
| 10609 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10610 | EXIT(); |
| 10611 | |
| 10612 | return ret; |
| 10613 | } |
| 10614 | |
| 10615 | /** |
| 10616 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10617 | * @hdd_ctx: HDD context |
| 10618 | * |
| 10619 | * De-Register the HDD callbacks to CDS/SME. |
| 10620 | * |
| 10621 | * Return: void |
| 10622 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10623 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10624 | { |
| 10625 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10626 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10627 | |
| 10628 | ENTER(); |
| 10629 | |
| 10630 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10631 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10632 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10633 | status); |
| 10634 | |
| 10635 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10636 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10637 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10638 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10639 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10640 | |
| 10641 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10642 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10643 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10644 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10645 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10646 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10647 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10648 | if (ret) |
| 10649 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10650 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10651 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10652 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10653 | |
| 10654 | EXIT(); |
| 10655 | } |
| 10656 | |
| 10657 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10658 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10659 | * @adapter: Pointer to the HDD |
| 10660 | * @enable: bool value |
| 10661 | * |
| 10662 | * This to take counter measure to handle deauth req from HDD |
| 10663 | * |
| 10664 | * Return: None |
| 10665 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10666 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10667 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10668 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10669 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10670 | |
| 10671 | ENTER(); |
| 10672 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10673 | /* Ignore request to deauth bcmc station */ |
| 10674 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10675 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10676 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10677 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10678 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10679 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10680 | |
| 10681 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10682 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10683 | } |
| 10684 | |
| 10685 | /** |
| 10686 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10687 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10688 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10689 | * |
| 10690 | * This to take counter measure to handle deauth req from HDD |
| 10691 | * |
| 10692 | * Return: None |
| 10693 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10694 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10695 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10696 | { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10697 | struct sir_peer_sta_info peer_sta_info; |
| 10698 | struct hdd_station_info *stainfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10699 | ENTER(); |
| 10700 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10701 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10702 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10703 | return; |
| 10704 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10705 | wlan_hdd_get_peer_rssi(adapter, &pDelStaParams->peerMacAddr, |
| 10706 | &peer_sta_info); |
| 10707 | stainfo = hdd_get_stainfo(adapter->cache_sta_info, |
| 10708 | pDelStaParams->peerMacAddr); |
| 10709 | if (stainfo) { |
| 10710 | stainfo->rssi = peer_sta_info.info[0].rssi; |
| 10711 | stainfo->tx_rate = peer_sta_info.info[0].tx_rate; |
| 10712 | stainfo->rx_rate = peer_sta_info.info[0].rx_rate; |
| 10713 | } |
| 10714 | |
| 10715 | stainfo->reason_code = pDelStaParams->reason_code; |
| 10716 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10717 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10718 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10719 | } |
| 10720 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10721 | /** |
| 10722 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10723 | * @hdd_ctx: HDD Context |
| 10724 | * |
| 10725 | * API to find if there is any STA or P2P-Client is connected |
| 10726 | * |
| 10727 | * Return: true if connected; false otherwise |
| 10728 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10729 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10730 | { |
| 10731 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10732 | } |
| 10733 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10734 | /** |
| 10735 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10736 | * @adapter: HDD adapter pointer |
| 10737 | * |
| 10738 | * This function loop through each adapter and disable roaming on each STA |
| 10739 | * device mode except the input adapter. |
| 10740 | * |
| 10741 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10742 | * disable. |
| 10743 | * |
| 10744 | * Return: None |
| 10745 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10746 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10747 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10748 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10749 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10750 | |
| 10751 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10752 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10753 | QDF_STA_MODE == adapter->device_mode && |
| 10754 | policy_mgr_is_sta_active_connection_exists( |
| 10755 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10756 | hdd_debug("Connect received on STA session Id(%d)", |
| 10757 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10758 | /* |
| 10759 | * Loop through adapter and disable roaming for each STA device |
| 10760 | * mode except the input adapter. |
| 10761 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10762 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10763 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10764 | adapter->session_id != adapterIdx->session_id) { |
| 10765 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10766 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10767 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10768 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10769 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10770 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10771 | } |
| 10772 | } |
| 10773 | } |
| 10774 | |
| 10775 | /** |
| 10776 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10777 | * @adapter: HDD adapter pointer |
| 10778 | * |
| 10779 | * This function loop through each adapter and enable roaming on each STA |
| 10780 | * device mode except the input adapter. |
| 10781 | * Note: On the input adapter no need to enable roaming because link got |
| 10782 | * disconnected on this. |
| 10783 | * |
| 10784 | * Return: None |
| 10785 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10786 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10787 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10788 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10789 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10790 | |
| 10791 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10792 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10793 | QDF_STA_MODE == adapter->device_mode && |
| 10794 | policy_mgr_is_sta_active_connection_exists( |
| 10795 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10796 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10797 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10798 | /* |
| 10799 | * Loop through adapter and enable roaming for each STA device |
| 10800 | * mode except the input adapter. |
| 10801 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10802 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10803 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10804 | adapter->session_id != adapterIdx->session_id) { |
| 10805 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10806 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10807 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10808 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10809 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10810 | REASON_CONNECT); |
| 10811 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10812 | } |
| 10813 | } |
| 10814 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10815 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10816 | /** |
| 10817 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10818 | * @skb: sk buffer pointer |
| 10819 | * |
| 10820 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10821 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10822 | * |
| 10823 | * Return: None |
| 10824 | */ |
| 10825 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10826 | { |
| 10827 | #ifdef CNSS_GENL |
| 10828 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10829 | #else |
| 10830 | nl_srv_bcast(skb); |
| 10831 | #endif |
| 10832 | } |
| 10833 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10834 | 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] | 10835 | { |
| 10836 | struct sk_buff *skb; |
| 10837 | struct nlmsghdr *nlh; |
| 10838 | tAniMsgHdr *ani_hdr; |
| 10839 | void *nl_data = NULL; |
| 10840 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10841 | struct radio_index_tlv *radio_info; |
| 10842 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10843 | |
| 10844 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10845 | flags = GFP_ATOMIC; |
| 10846 | |
| 10847 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10848 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10849 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10850 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10851 | |
| 10852 | nlh = (struct nlmsghdr *)skb->data; |
| 10853 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10854 | nlh->nlmsg_flags = 0; |
| 10855 | nlh->nlmsg_seq = 0; |
| 10856 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10857 | |
| 10858 | ani_hdr = NLMSG_DATA(nlh); |
| 10859 | ani_hdr->type = type; |
| 10860 | |
| 10861 | switch (type) { |
| 10862 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10863 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10864 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10865 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10866 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10867 | ani_hdr->length = 0; |
| 10868 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10869 | break; |
| 10870 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10871 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10872 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10873 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10874 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10875 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10876 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10877 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10878 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 10879 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10880 | ani_hdr->length = len; |
| 10881 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10882 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10883 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10884 | break; |
| 10885 | |
| 10886 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10887 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10888 | type); |
| 10889 | kfree_skb(skb); |
| 10890 | return; |
| 10891 | } |
| 10892 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10893 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10894 | * Add radio index at the end of the svc event in TLV format |
| 10895 | * to maintain the backward compatibility with userspace |
| 10896 | * applications. |
| 10897 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10898 | |
| 10899 | tlv_len = 0; |
| 10900 | |
| 10901 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10902 | < WLAN_NL_MAX_PAYLOAD) { |
| 10903 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10904 | sizeof(*ani_hdr) + len); |
| 10905 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10906 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10907 | radio_info->radio = radio; |
| 10908 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10909 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10910 | "Added radio index tlv - radio index %d", |
| 10911 | radio_info->radio); |
| 10912 | } |
| 10913 | |
| 10914 | nlh->nlmsg_len += tlv_len; |
| 10915 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10916 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10917 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10918 | } |
| 10919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10920 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10921 | void wlan_hdd_auto_shutdown_cb(void) |
| 10922 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10923 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10924 | |
| 10925 | if (!hdd_ctx) |
| 10926 | return; |
| 10927 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10928 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10929 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10930 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10931 | } |
| 10932 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10933 | 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] | 10934 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10935 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10936 | bool ap_connected = false, sta_connected = false; |
| 10937 | tHalHandle hal_handle; |
| 10938 | |
| 10939 | hal_handle = hdd_ctx->hHal; |
| 10940 | if (hal_handle == NULL) |
| 10941 | return; |
| 10942 | |
| 10943 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10944 | return; |
| 10945 | |
| 10946 | if (enable == false) { |
| 10947 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10948 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10949 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10950 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10951 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10952 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10953 | return; |
| 10954 | } |
| 10955 | |
| 10956 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10957 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 10958 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10959 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10960 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10961 | conn_info.connState == |
| 10962 | eConnectionState_Associated) { |
| 10963 | sta_connected = true; |
| 10964 | break; |
| 10965 | } |
| 10966 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10967 | |
| 10968 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10969 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10970 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10971 | ap_connected = true; |
| 10972 | break; |
| 10973 | } |
| 10974 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10975 | } |
| 10976 | } |
| 10977 | |
| 10978 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10979 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10980 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10981 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10982 | |
| 10983 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10984 | hdd_ctx->config->WlanAutoShutdown) |
| 10985 | != QDF_STATUS_SUCCESS) |
| 10986 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10987 | else |
| 10988 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10989 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10990 | } |
| 10991 | #endif |
| 10992 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10993 | struct hdd_adapter * |
| 10994 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 10995 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10996 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10997 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10998 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10999 | |
| 11000 | con_sap_adapter = NULL; |
| 11001 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11002 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11003 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11004 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11005 | adapter != this_sap_adapter) { |
| 11006 | if (check_start_bss) { |
| 11007 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11008 | &adapter->event_flags)) { |
| 11009 | con_sap_adapter = adapter; |
| 11010 | break; |
| 11011 | } |
| 11012 | } else { |
| 11013 | con_sap_adapter = adapter; |
| 11014 | break; |
| 11015 | } |
| 11016 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11017 | } |
| 11018 | |
| 11019 | return con_sap_adapter; |
| 11020 | } |
| 11021 | |
| 11022 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11023 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11024 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11025 | return adapter->device_mode == QDF_STA_MODE || |
| 11026 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11027 | } |
| 11028 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11029 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11030 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11031 | return adapter->device_mode == QDF_SAP_MODE || |
| 11032 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11033 | } |
| 11034 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11035 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11036 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11037 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11038 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11039 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11040 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11041 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11042 | conn_info.connState == eConnectionState_Associated) { |
| 11043 | return true; |
| 11044 | } |
| 11045 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11046 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11047 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11048 | return true; |
| 11049 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11050 | } |
| 11051 | |
| 11052 | return false; |
| 11053 | } |
| 11054 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11055 | 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] | 11056 | { |
| 11057 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11058 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11059 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11060 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11061 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11062 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11063 | return is_running; |
| 11064 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11065 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11066 | 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] | 11067 | { |
| 11068 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11069 | hdd_ctx->bus_bw_timer_running = true; |
| 11070 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11071 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11072 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11073 | } |
| 11074 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11075 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11076 | { |
| 11077 | ENTER(); |
| 11078 | |
| 11079 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11080 | hdd_debug("Bandwidth compute timer already started"); |
| 11081 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11082 | } |
| 11083 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11084 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11085 | |
| 11086 | EXIT(); |
| 11087 | } |
| 11088 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11089 | 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] | 11090 | { |
| 11091 | ENTER(); |
| 11092 | |
| 11093 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11094 | hdd_debug("Bandwidth compute timer already started"); |
| 11095 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11096 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11097 | |
| 11098 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11099 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11100 | |
| 11101 | EXIT(); |
| 11102 | } |
| 11103 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11104 | 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] | 11105 | { |
| 11106 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 11107 | |
| 11108 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11109 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11110 | hdd_ctx->bus_bw_timer_running = false; |
| 11111 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11112 | |
| 11113 | hdd_reset_tcp_delack(hdd_ctx); |
| 11114 | } |
| 11115 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11116 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11117 | { |
| 11118 | ENTER(); |
| 11119 | |
| 11120 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11121 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11122 | return; |
| 11123 | } |
| 11124 | |
| 11125 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11126 | |
| 11127 | EXIT(); |
| 11128 | } |
| 11129 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11130 | 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] | 11131 | { |
| 11132 | ENTER(); |
| 11133 | |
| 11134 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11135 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11136 | return; |
| 11137 | } |
| 11138 | |
| 11139 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11140 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11141 | |
| 11142 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11143 | } |
| 11144 | #endif |
| 11145 | |
| 11146 | /** |
| 11147 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11148 | * and sta's operating channel. |
| 11149 | * @sta_adapter: Describe the first argument to foobar. |
| 11150 | * @ap_adapter: Describe the second argument to foobar. |
| 11151 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11152 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11153 | * set this flag to true else false. |
| 11154 | * |
| 11155 | * This function checks the sap's operating channel and sta's operating channel. |
| 11156 | * if both are same then it will return false else it will restart the sap in |
| 11157 | * sta's channel and return true. |
| 11158 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11159 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11160 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11161 | QDF_STATUS |
| 11162 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11163 | struct hdd_adapter *ap_adapter, |
| 11164 | tCsrRoamProfile *roam_profile, |
| 11165 | tScanResultHandle *scan_cache, |
| 11166 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11167 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11168 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11169 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11170 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11171 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11172 | *concurrent_chnl_same = true; |
| 11173 | |
| 11174 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11175 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11176 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11177 | scan_cache, |
| 11178 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11179 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11180 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11181 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11182 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11183 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11184 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11185 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11186 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11187 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11188 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11189 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11190 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11191 | } |
| 11192 | } |
| 11193 | } else { |
| 11194 | /* |
| 11195 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11196 | * failed so we have to stop the SAP to avoid any channel |
| 11197 | * discrepancy between SAP's channel and STA's channel. |
| 11198 | * Return the status as failure so caller function could know |
| 11199 | * that scan look up is failed. |
| 11200 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11201 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11202 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11203 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11204 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | } |
| 11206 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11207 | /** |
| 11208 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11209 | * @ap_adapter: SAP adapter |
| 11210 | * |
| 11211 | * This function will process the stopping of sap adapter. |
| 11212 | * |
| 11213 | * Return: None |
| 11214 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11215 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11216 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11217 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11218 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11219 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11220 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | |
| 11222 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11223 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11224 | return; |
| 11225 | } |
| 11226 | |
| 11227 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11228 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11229 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11230 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11232 | mutex_lock(&hdd_ctx->sap_lock); |
| 11233 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11234 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11235 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11236 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11237 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11238 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11239 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11240 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11241 | qdf_stop_bss_event, |
| 11242 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11243 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11244 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11245 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11246 | return; |
| 11247 | } |
| 11248 | } |
| 11249 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11250 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11251 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11252 | ap_adapter->session_id); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11253 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11254 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11255 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11256 | } |
| 11257 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11258 | } |
| 11259 | |
| 11260 | /** |
| 11261 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11262 | * @ap_adapter: SAP adapter |
| 11263 | * |
| 11264 | * This function will process the starting of sap adapter. |
| 11265 | * |
| 11266 | * Return: None |
| 11267 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11268 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11269 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11270 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11271 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11272 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11273 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11274 | tsap_Config_t *sap_config; |
| 11275 | |
| 11276 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11277 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11278 | return; |
| 11279 | } |
| 11280 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11281 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11282 | hdd_err("SoftAp role has not been enabled"); |
| 11283 | return; |
| 11284 | } |
| 11285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11286 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11287 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11288 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11289 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11290 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11291 | mutex_lock(&hdd_ctx->sap_lock); |
| 11292 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11293 | goto end; |
| 11294 | |
| 11295 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11296 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11297 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 11298 | goto end; |
| 11299 | } |
| 11300 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11301 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11302 | 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] | 11303 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11304 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11305 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11306 | goto end; |
| 11307 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11308 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11309 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11310 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11311 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11312 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11313 | goto end; |
| 11314 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11315 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11316 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 11317 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11318 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11319 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11320 | ap_adapter->session_id); |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11321 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11322 | |
| 11323 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11324 | end: |
| 11325 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11326 | /* SAP context and beacon cleanup will happen during driver unload |
| 11327 | * in hdd_stop_adapter |
| 11328 | */ |
| 11329 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11330 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11331 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11332 | |
| 11333 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11334 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11335 | * mac scan config |
| 11336 | * @status: Status of set antenna mode |
| 11337 | * |
| 11338 | * Callback on setting the dual mac configuration |
| 11339 | * |
| 11340 | * Return: None |
| 11341 | */ |
| 11342 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11343 | enum set_antenna_mode_status status) |
| 11344 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11345 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11346 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11347 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11348 | |
| 11349 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11350 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11351 | return; |
| 11352 | |
| 11353 | /* Signal the completion of set dual mac config */ |
| 11354 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11355 | } |
| 11356 | |
| 11357 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11358 | * hdd_get_fw_version() - Get FW version |
| 11359 | * @hdd_ctx: pointer to HDD context. |
| 11360 | * @major_spid: FW version - major spid. |
| 11361 | * @minor_spid: FW version - minor spid |
| 11362 | * @ssid: FW version - ssid |
| 11363 | * @crmid: FW version - crmid |
| 11364 | * |
| 11365 | * This function is called to get the firmware build version stored |
| 11366 | * as part of the HDD context |
| 11367 | * |
| 11368 | * Return: None |
| 11369 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11370 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11371 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11372 | uint32_t *siid, uint32_t *crmid) |
| 11373 | { |
| 11374 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11375 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11376 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11377 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11378 | } |
| 11379 | |
| 11380 | #ifdef QCA_CONFIG_SMP |
| 11381 | /** |
| 11382 | * wlan_hdd_get_cpu() - get cpu_index |
| 11383 | * |
| 11384 | * Return: cpu_index |
| 11385 | */ |
| 11386 | int wlan_hdd_get_cpu(void) |
| 11387 | { |
| 11388 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11390 | put_cpu(); |
| 11391 | return cpu_index; |
| 11392 | } |
| 11393 | #endif |
| 11394 | |
| 11395 | /** |
| 11396 | * hdd_get_fwpath() - get framework path |
| 11397 | * |
| 11398 | * This function is used to get the string written by |
| 11399 | * userspace to start the wlan driver |
| 11400 | * |
| 11401 | * Return: string |
| 11402 | */ |
| 11403 | const char *hdd_get_fwpath(void) |
| 11404 | { |
| 11405 | return fwpath.string; |
| 11406 | } |
| 11407 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11408 | static int hdd_qdf_print_init(void) |
| 11409 | { |
| 11410 | int qdf_print_idx; |
| 11411 | QDF_STATUS status; |
| 11412 | |
| 11413 | status = qdf_print_setup(); |
| 11414 | if (status != QDF_STATUS_SUCCESS) { |
| 11415 | pr_err("qdf_print_setup failed\n"); |
| 11416 | return -EINVAL; |
| 11417 | } |
| 11418 | |
| 11419 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11420 | |
| 11421 | if (qdf_print_idx < 0) { |
| 11422 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11423 | qdf_print_idx); |
| 11424 | return -EINVAL; |
| 11425 | } |
| 11426 | |
| 11427 | qdf_set_pidx(qdf_print_idx); |
| 11428 | |
| 11429 | return 0; |
| 11430 | } |
| 11431 | |
| 11432 | static void hdd_qdf_print_deinit(void) |
| 11433 | { |
| 11434 | int qdf_print_idx; |
| 11435 | |
| 11436 | qdf_print_idx = qdf_get_pidx(); |
| 11437 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11438 | } |
| 11439 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11440 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11441 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11442 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11443 | * This function initilizes CDS global context with the help of cds_init. This |
| 11444 | * has to be the first function called after probe to get a valid global |
| 11445 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11446 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11447 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11448 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11449 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11450 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11451 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11452 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11453 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11454 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11455 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11456 | hdd_err("Failed to allocate CDS context"); |
| 11457 | ret = -ENOMEM; |
| 11458 | goto err_out; |
| 11459 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11460 | |
| 11461 | wlan_init_bug_report_lock(); |
| 11462 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11463 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11464 | wlan_logging_sock_init_svc(); |
| 11465 | #endif |
| 11466 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11467 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11468 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11469 | QDF_TIMER_TYPE_SW); |
| 11470 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11471 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11472 | hdd_qdf_print_init(); |
| 11473 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11474 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11475 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11476 | err_out: |
| 11477 | return ret; |
| 11478 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11479 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11480 | /** |
| 11481 | * hdd_deinit() - Deinitialize Driver |
| 11482 | * |
| 11483 | * This function frees CDS global context with the help of cds_deinit. This |
| 11484 | * has to be the last function call in remove callback to free the global |
| 11485 | * context. |
| 11486 | */ |
| 11487 | void hdd_deinit(void) |
| 11488 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11489 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11490 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11491 | wlan_destroy_bug_report_lock(); |
| 11492 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11493 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11494 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11495 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11496 | wlan_logging_sock_deinit_svc(); |
| 11497 | #endif |
| 11498 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11499 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11500 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11501 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11502 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11503 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11504 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11505 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11506 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11507 | struct file *file) |
| 11508 | { |
| 11509 | return 0; |
| 11510 | } |
| 11511 | |
| 11512 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11513 | const char __user *user_buf, |
| 11514 | size_t count, |
| 11515 | loff_t *f_pos) |
| 11516 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11517 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11518 | static const char wlan_off_str[] = "OFF"; |
| 11519 | static const char wlan_on_str[] = "ON"; |
| 11520 | int ret; |
| 11521 | unsigned long rc; |
| 11522 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11523 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11524 | pr_err("Failed to read buffer\n"); |
| 11525 | return -EINVAL; |
| 11526 | } |
| 11527 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11528 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11529 | pr_debug("Wifi turning off from UI\n"); |
| 11530 | goto exit; |
| 11531 | } |
| 11532 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11533 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11534 | pr_err("Invalid value received from framework"); |
| 11535 | goto exit; |
| 11536 | } |
| 11537 | |
| 11538 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11539 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11540 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11541 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11542 | if (!rc) { |
| 11543 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11544 | ret = -EINVAL; |
| 11545 | hdd_start_complete(ret); |
| 11546 | return ret; |
| 11547 | } |
| 11548 | |
| 11549 | hdd_start_complete(0); |
| 11550 | } |
| 11551 | |
| 11552 | exit: |
| 11553 | return count; |
| 11554 | } |
| 11555 | |
| 11556 | |
| 11557 | const struct file_operations wlan_hdd_state_fops = { |
| 11558 | .owner = THIS_MODULE, |
| 11559 | .open = wlan_hdd_state_ctrl_param_open, |
| 11560 | .write = wlan_hdd_state_ctrl_param_write, |
| 11561 | }; |
| 11562 | |
| 11563 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11564 | { |
| 11565 | unsigned int wlan_hdd_state_major = 0; |
| 11566 | int ret; |
| 11567 | struct device *dev; |
| 11568 | |
| 11569 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11570 | |
| 11571 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11572 | if (ret) { |
| 11573 | pr_err("Failed to register qcwlanstate"); |
| 11574 | goto dev_alloc_err; |
| 11575 | } |
| 11576 | wlan_hdd_state_major = MAJOR(device); |
| 11577 | |
| 11578 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11579 | if (IS_ERR(class)) { |
| 11580 | pr_err("wlan_hdd_state class_create error"); |
| 11581 | goto class_err; |
| 11582 | } |
| 11583 | |
| 11584 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11585 | if (IS_ERR(dev)) { |
| 11586 | pr_err("wlan_hdd_statedevice_create error"); |
| 11587 | goto err_class_destroy; |
| 11588 | } |
| 11589 | |
| 11590 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11591 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11592 | if (ret) { |
| 11593 | pr_err("Failed to add cdev error"); |
| 11594 | goto cdev_add_err; |
| 11595 | } |
| 11596 | |
| 11597 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11598 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11599 | |
| 11600 | return 0; |
| 11601 | |
| 11602 | cdev_add_err: |
| 11603 | device_destroy(class, device); |
| 11604 | err_class_destroy: |
| 11605 | class_destroy(class); |
| 11606 | class_err: |
| 11607 | unregister_chrdev_region(device, dev_num); |
| 11608 | dev_alloc_err: |
| 11609 | return -ENODEV; |
| 11610 | } |
| 11611 | |
| 11612 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11613 | { |
| 11614 | cdev_del(&wlan_hdd_state_cdev); |
| 11615 | device_destroy(class, device); |
| 11616 | class_destroy(class); |
| 11617 | unregister_chrdev_region(device, dev_num); |
| 11618 | |
| 11619 | pr_info("Device node unregistered"); |
| 11620 | } |
| 11621 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11622 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11623 | * component_init - API to init cld component's |
| 11624 | * |
| 11625 | * Return: None |
| 11626 | */ |
| 11627 | static void component_init(void) |
| 11628 | { |
| 11629 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11630 | disa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11631 | } |
| 11632 | |
| 11633 | /** |
| 11634 | * component_deinit - API to deinit cld component's |
| 11635 | * |
| 11636 | * Return: None |
| 11637 | */ |
| 11638 | static void component_deinit(void) |
| 11639 | { |
| 11640 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11641 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11642 | } |
| 11643 | |
| 11644 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11645 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11646 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11647 | } |
| 11648 | |
| 11649 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11650 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11651 | disa_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11652 | } |
| 11653 | |
| 11654 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11655 | * __hdd_module_init - Module init helper |
| 11656 | * |
| 11657 | * Module init helper function used by both module and static driver. |
| 11658 | * |
| 11659 | * Return: 0 for success, errno on failure |
| 11660 | */ |
| 11661 | static int __hdd_module_init(void) |
| 11662 | { |
| 11663 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11664 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11665 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11666 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11667 | g_wlan_driver_version, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11668 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11669 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11670 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11671 | if (ret) { |
| 11672 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11673 | goto err_dev_state; |
| 11674 | } |
| 11675 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11676 | pld_init(); |
| 11677 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11678 | ret = hdd_init(); |
| 11679 | if (ret) { |
| 11680 | pr_err("hdd_init failed %x\n", ret); |
| 11681 | goto err_hdd_init; |
| 11682 | } |
| 11683 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11684 | dispatcher_init(); |
| 11685 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11686 | /* Ensure to call post objmgr init */ |
| 11687 | component_init(); |
| 11688 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11689 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11690 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11691 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11692 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11693 | ret = wlan_hdd_register_driver(); |
| 11694 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11695 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11696 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11697 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11698 | } |
| 11699 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11700 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11701 | |
| 11702 | return 0; |
| 11703 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11704 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11705 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11706 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11707 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11708 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11709 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11710 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11711 | wlan_hdd_state_ctrl_param_destroy(); |
| 11712 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11713 | return ret; |
| 11714 | } |
| 11715 | |
| 11716 | /** |
| 11717 | * __hdd_module_exit - Module exit helper |
| 11718 | * |
| 11719 | * Module exit helper function used by both module and static driver. |
| 11720 | */ |
| 11721 | static void __hdd_module_exit(void) |
| 11722 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11723 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11724 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11725 | QWLAN_VERSIONSTR); |
| 11726 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11727 | hdd_wait_for_recovery_completion(); |
| 11728 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11729 | wlan_hdd_unregister_driver(); |
| 11730 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11731 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11732 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11733 | /* Ensure to call prior to objmgr deinit */ |
| 11734 | component_deinit(); |
| 11735 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11736 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11737 | |
| 11738 | hdd_sysfs_destroy_version_interface(); |
| 11739 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11740 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11741 | pld_deinit(); |
| 11742 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11743 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11744 | } |
| 11745 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11746 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11747 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11748 | * wlan_boot_cb() - Wlan boot callback |
| 11749 | * @kobj: object whose directory we're creating the link in. |
| 11750 | * @attr: attribute the user is interacting with |
| 11751 | * @buff: the buffer containing the user data |
| 11752 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11753 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11754 | * This callback is invoked when the fs is ready to start the |
| 11755 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11756 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11757 | * 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] | 11758 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11759 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11760 | struct kobj_attribute *attr, |
| 11761 | const char *buf, |
| 11762 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11763 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11764 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11765 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11766 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11767 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11768 | } |
| 11769 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11770 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11771 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11772 | return -EIO; |
| 11773 | } |
| 11774 | |
| 11775 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11776 | |
| 11777 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11778 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11779 | |
| 11780 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11781 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11782 | * |
| 11783 | * Return: None |
| 11784 | * |
| 11785 | */ |
| 11786 | static void hdd_sysfs_cleanup(void) |
| 11787 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11788 | /* remove from group */ |
| 11789 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11790 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11791 | wlan_loader->attr_group); |
| 11792 | |
| 11793 | /* unlink the object from parent */ |
| 11794 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11795 | |
| 11796 | /* free the object */ |
| 11797 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11798 | |
| 11799 | kfree(wlan_loader->attr_group); |
| 11800 | kfree(wlan_loader); |
| 11801 | |
| 11802 | wlan_loader = NULL; |
| 11803 | } |
| 11804 | |
| 11805 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11806 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11807 | * ready |
| 11808 | * |
| 11809 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11810 | * when the filesystem is ready. |
| 11811 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11812 | * QDF API cannot be used here since this function is called even before |
| 11813 | * initializing WLAN driver. |
| 11814 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11815 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11816 | */ |
| 11817 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11818 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11819 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11820 | |
| 11821 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11822 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11823 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11824 | |
| 11825 | wlan_loader->boot_wlan_obj = NULL; |
| 11826 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11827 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11828 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11829 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11830 | |
| 11831 | wlan_loader->loaded_state = 0; |
| 11832 | wlan_loader->attr_group->attrs = attrs; |
| 11833 | |
| 11834 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11835 | kernel_kobj); |
| 11836 | if (!wlan_loader->boot_wlan_obj) { |
| 11837 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11838 | goto error_return; |
| 11839 | } |
| 11840 | |
| 11841 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11842 | wlan_loader->attr_group); |
| 11843 | if (ret) { |
| 11844 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11845 | goto error_return; |
| 11846 | } |
| 11847 | |
| 11848 | return 0; |
| 11849 | |
| 11850 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11851 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11852 | |
| 11853 | return ret; |
| 11854 | } |
| 11855 | |
| 11856 | /** |
| 11857 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11858 | * |
| 11859 | * Return: 0 on success or errno on failure |
| 11860 | */ |
| 11861 | static int wlan_deinit_sysfs(void) |
| 11862 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11863 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11864 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11865 | return -EINVAL; |
| 11866 | } |
| 11867 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11868 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11869 | return 0; |
| 11870 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11871 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11872 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11873 | |
| 11874 | #ifdef MODULE |
| 11875 | /** |
| 11876 | * __hdd_module_init - Module init helper |
| 11877 | * |
| 11878 | * Module init helper function used by both module and static driver. |
| 11879 | * |
| 11880 | * Return: 0 for success, errno on failure |
| 11881 | */ |
| 11882 | static int hdd_module_init(void) |
| 11883 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11884 | if (__hdd_module_init()) { |
| 11885 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11886 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11887 | } |
| 11888 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11889 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11890 | } |
| 11891 | #else |
| 11892 | static int __init hdd_module_init(void) |
| 11893 | { |
| 11894 | int ret = -EINVAL; |
| 11895 | |
| 11896 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11897 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11898 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11899 | |
| 11900 | return ret; |
| 11901 | } |
| 11902 | #endif |
| 11903 | |
| 11904 | |
| 11905 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11906 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11907 | * hdd_module_exit() - Exit function |
| 11908 | * |
| 11909 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11910 | * |
| 11911 | * Return: None |
| 11912 | */ |
| 11913 | static void __exit hdd_module_exit(void) |
| 11914 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11915 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11916 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11917 | #else |
| 11918 | static void __exit hdd_module_exit(void) |
| 11919 | { |
| 11920 | __hdd_module_exit(); |
| 11921 | wlan_deinit_sysfs(); |
| 11922 | } |
| 11923 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11924 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11925 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11926 | { |
| 11927 | return param_set_copystring(kmessage, kp); |
| 11928 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11929 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11930 | /** |
| 11931 | * is_con_mode_valid() check con mode is valid or not |
| 11932 | * @mode: global con mode |
| 11933 | * |
| 11934 | * Return: TRUE on success FALSE on failure |
| 11935 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11936 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11937 | { |
| 11938 | switch (mode) { |
| 11939 | case QDF_GLOBAL_MONITOR_MODE: |
| 11940 | case QDF_GLOBAL_FTM_MODE: |
| 11941 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11942 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11943 | return true; |
| 11944 | default: |
| 11945 | return false; |
| 11946 | } |
| 11947 | } |
| 11948 | |
| 11949 | /** |
| 11950 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11951 | * @mode: global con mode |
| 11952 | * |
| 11953 | * Return: adapter mode |
| 11954 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11955 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11956 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11957 | { |
| 11958 | |
| 11959 | switch (mode) { |
| 11960 | case QDF_GLOBAL_MISSION_MODE: |
| 11961 | return QDF_STA_MODE; |
| 11962 | case QDF_GLOBAL_MONITOR_MODE: |
| 11963 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11964 | case QDF_GLOBAL_EPPING_MODE: |
| 11965 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11966 | case QDF_GLOBAL_FTM_MODE: |
| 11967 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11968 | case QDF_GLOBAL_QVIT_MODE: |
| 11969 | return QDF_QVIT_MODE; |
| 11970 | default: |
| 11971 | return QDF_MAX_NO_OF_MODE; |
| 11972 | } |
| 11973 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11974 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11975 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11976 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11977 | { |
| 11978 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11979 | return; |
| 11980 | |
| 11981 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11982 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 11983 | hdd_info("Release wakelock for monitor mode!"); |
| 11984 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 11985 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 11986 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11987 | case QDF_GLOBAL_FTM_MODE: |
| 11988 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11989 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 11990 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11991 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11992 | break; |
| 11993 | default: |
| 11994 | break; |
| 11995 | } |
| 11996 | } |
| 11997 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11998 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11999 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12000 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12001 | int driver_status; |
| 12002 | |
| 12003 | driver_status = hdd_ctx->driver_status; |
| 12004 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12005 | switch (curr_mode) { |
| 12006 | case QDF_GLOBAL_MISSION_MODE: |
| 12007 | case QDF_GLOBAL_MONITOR_MODE: |
| 12008 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12009 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12010 | hdd_close_all_adapters(hdd_ctx, false); |
| 12011 | break; |
| 12012 | case QDF_GLOBAL_EPPING_MODE: |
| 12013 | epping_disable(); |
| 12014 | epping_close(); |
| 12015 | break; |
| 12016 | default: |
| 12017 | return; |
| 12018 | } |
| 12019 | } |
| 12020 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12021 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12022 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12023 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12024 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12025 | int ret = 0; |
| 12026 | bool rtnl_held; |
| 12027 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12028 | QDF_STATUS status; |
| 12029 | |
| 12030 | if (!qdf_dev) { |
| 12031 | hdd_err("qdf device context is Null return!"); |
| 12032 | return -EINVAL; |
| 12033 | } |
| 12034 | |
| 12035 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12036 | switch (mode) { |
| 12037 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12038 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12039 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12040 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12041 | break; |
| 12042 | case QDF_GLOBAL_FTM_MODE: |
| 12043 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12044 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12045 | NET_NAME_UNKNOWN, rtnl_held); |
| 12046 | if (adapter == NULL) |
| 12047 | ret = -EINVAL; |
| 12048 | break; |
| 12049 | case QDF_GLOBAL_MONITOR_MODE: |
| 12050 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12051 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12052 | NET_NAME_UNKNOWN, rtnl_held); |
| 12053 | if (adapter == NULL) |
| 12054 | ret = -EINVAL; |
| 12055 | break; |
| 12056 | case QDF_GLOBAL_EPPING_MODE: |
| 12057 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12058 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12059 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12060 | ret = -EINVAL; |
| 12061 | break; |
| 12062 | } |
| 12063 | ret = epping_enable(qdf_dev->dev); |
| 12064 | if (ret) { |
| 12065 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12066 | epping_close(); |
| 12067 | } |
| 12068 | break; |
| 12069 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12070 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12071 | ret = -ENOTSUPP; |
| 12072 | break; |
| 12073 | } |
| 12074 | hdd_release_rtnl_lock(); |
| 12075 | rtnl_held = false; |
| 12076 | return ret; |
| 12077 | } |
| 12078 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12079 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12080 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12081 | * @kmessage: con mode name on which driver to be bring up |
| 12082 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12083 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12084 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12085 | * This function is invoked when user updates con mode using sys entry, |
| 12086 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12087 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12088 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12089 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12090 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12091 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12092 | { |
| 12093 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12094 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12095 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12096 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12097 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12098 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12099 | hdd_info("con_mode handler: %s", kmessage); |
| 12100 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12101 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12102 | if (ret) |
| 12103 | return ret; |
| 12104 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12105 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12106 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12107 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12108 | if (ret) { |
| 12109 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12110 | goto reset_flags; |
| 12111 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12112 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12113 | if (!is_con_mode_valid(new_con_mode)) { |
| 12114 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12115 | ret = -EINVAL; |
| 12116 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12117 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12118 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12119 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12120 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12121 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12122 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12123 | ret = 0; |
| 12124 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12125 | } |
| 12126 | |
Sourav Mohapatra | 3bc5e98 | 2017-11-24 15:53:49 +0530 | [diff] [blame] | 12127 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12128 | hdd_warn("Waiting for monitor mode: External threads are active"); |
| 12129 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12130 | /* ensure adapters are stopped */ |
| 12131 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12132 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12133 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12134 | if (ret) { |
| 12135 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12136 | goto reset_flags; |
| 12137 | } |
| 12138 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12139 | /* Cleanup present mode before switching to new mode */ |
| 12140 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12141 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12142 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12143 | |
| 12144 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12145 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12146 | if (ret) { |
| 12147 | hdd_err("Failed to register for new mode"); |
| 12148 | goto reset_flags; |
| 12149 | } |
| 12150 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12151 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12152 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12153 | hdd_err("invalid adapter"); |
| 12154 | ret = -EINVAL; |
| 12155 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12156 | } |
| 12157 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12158 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12159 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12160 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12161 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12162 | } |
| 12163 | |
| 12164 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12165 | if (ret) { |
| 12166 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12167 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12168 | } |
| 12169 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12170 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12171 | if (hdd_start_adapter(adapter)) { |
| 12172 | hdd_err("Failed to start %s adapter", kmessage); |
| 12173 | ret = -EINVAL; |
| 12174 | goto reset_flags; |
| 12175 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12176 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12177 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12178 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12179 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12180 | } |
| 12181 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12182 | /* con_mode is a global module parameter */ |
| 12183 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12184 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12185 | ret = 0; |
| 12186 | |
| 12187 | reset_flags: |
| 12188 | cds_set_load_in_progress(false); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12189 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12190 | return ret; |
| 12191 | } |
| 12192 | |
| 12193 | |
| 12194 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12195 | { |
| 12196 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12197 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12198 | |
| 12199 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12200 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12201 | if (ret) |
| 12202 | return ret; |
| 12203 | |
| 12204 | cds_ssr_protect(__func__); |
| 12205 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12206 | cds_ssr_unprotect(__func__); |
| 12207 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12208 | return ret; |
| 12209 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12210 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12211 | static int con_mode_handler_ftm(const char *kmessage, |
| 12212 | struct kernel_param *kp) |
| 12213 | { |
| 12214 | int ret; |
| 12215 | |
| 12216 | ret = param_set_int(kmessage, kp); |
| 12217 | |
| 12218 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12219 | pr_err("Only FTM mode supported!"); |
| 12220 | return -ENOTSUPP; |
| 12221 | } |
| 12222 | |
| 12223 | hdd_set_conparam(con_mode_ftm); |
| 12224 | con_mode = con_mode_ftm; |
| 12225 | |
| 12226 | return ret; |
| 12227 | } |
| 12228 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12229 | static int con_mode_handler_monitor(const char *kmessage, |
| 12230 | struct kernel_param *kp) |
| 12231 | { |
| 12232 | int ret; |
| 12233 | |
| 12234 | ret = param_set_int(kmessage, kp); |
| 12235 | |
| 12236 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12237 | pr_err("Only Monitor mode supported!"); |
| 12238 | return -ENOTSUPP; |
| 12239 | } |
| 12240 | |
| 12241 | hdd_set_conparam(con_mode_monitor); |
| 12242 | con_mode = con_mode_monitor; |
| 12243 | |
| 12244 | return ret; |
| 12245 | } |
| 12246 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12247 | /** |
| 12248 | * hdd_get_conparam() - driver exit point |
| 12249 | * |
| 12250 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12251 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12252 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12253 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12254 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12255 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12256 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12257 | } |
| 12258 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12259 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12260 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12261 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12262 | } |
| 12263 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12264 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12265 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12266 | * @hdd_ctx: HDD context |
| 12267 | * |
| 12268 | * Cleans up the pre cac interface, if it exists |
| 12269 | * |
| 12270 | * Return: None |
| 12271 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12272 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12273 | { |
| 12274 | uint8_t session_id; |
| 12275 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12276 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12277 | |
| 12278 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12279 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12280 | hdd_err("failed to get pre cac vdev id"); |
| 12281 | return; |
| 12282 | } |
| 12283 | |
| 12284 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12285 | if (!precac_adapter) { |
| 12286 | hdd_err("invalid pre cac adapater"); |
| 12287 | return; |
| 12288 | } |
| 12289 | |
| 12290 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12291 | wlan_hdd_sap_pre_cac_failure, |
| 12292 | (void *)precac_adapter); |
| 12293 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12294 | |
| 12295 | } |
| 12296 | |
| 12297 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12298 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12299 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12300 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12301 | * Return: void |
| 12302 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12303 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12304 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12305 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12306 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12307 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12308 | if (!ol_ctx) |
| 12309 | return; |
| 12310 | |
| 12311 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12312 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12313 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12314 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12315 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12316 | |
| 12317 | ol_init_ini_config(ol_ctx, &cfg); |
| 12318 | } |
| 12319 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12320 | #ifdef FEATURE_RUNTIME_PM |
| 12321 | /** |
| 12322 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12323 | * @hdd_ctx: hdd context |
| 12324 | * @cfg: pointer to the configuration memory being populated |
| 12325 | * |
| 12326 | * Return: void |
| 12327 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12328 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12329 | struct hif_config_info *cfg) |
| 12330 | { |
| 12331 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12332 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12333 | } |
| 12334 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12335 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12336 | struct hif_config_info *cfg) |
| 12337 | { |
| 12338 | } |
| 12339 | #endif |
| 12340 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12341 | /** |
| 12342 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12343 | * @hdd_ctx: HDD Context |
| 12344 | * |
| 12345 | * Return: void |
| 12346 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12347 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12348 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12349 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12350 | struct hif_config_info cfg; |
| 12351 | |
| 12352 | if (!scn) |
| 12353 | return; |
| 12354 | |
| 12355 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12356 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12357 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12358 | |
| 12359 | if (hdd_ctx->config->prevent_link_down) |
| 12360 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12361 | } |
| 12362 | |
| 12363 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12364 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12365 | * datapath |
| 12366 | * @hdd_ctx: HDD Context |
| 12367 | * |
| 12368 | * Return: 0 for success/errno for failure |
| 12369 | */ |
| 12370 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12371 | { |
| 12372 | struct cdp_config_params params; |
| 12373 | QDF_STATUS status; |
| 12374 | |
| 12375 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12376 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12377 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12378 | params.tx_flow_stop_queue_threshold = |
| 12379 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12380 | params.tx_flow_start_queue_offset = |
| 12381 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12382 | #endif |
| 12383 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12384 | params.napi_enable = hdd_ctx->napi_enable; |
| 12385 | params.tcp_udp_checksumoffload = |
| 12386 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12387 | |
| 12388 | status = cdp_update_config_parameters( |
| 12389 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12390 | ¶ms); |
| 12391 | if (status) { |
| 12392 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 12393 | "%s: Failed to attach config parameters", __func__); |
| 12394 | return status; |
| 12395 | } |
| 12396 | |
| 12397 | return 0; |
| 12398 | } |
| 12399 | |
| 12400 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12401 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12402 | * @hdd_ctx: HDD Context |
| 12403 | * |
| 12404 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12405 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12406 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12407 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12408 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12409 | int ret; |
| 12410 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12411 | hdd_update_ol_config(hdd_ctx); |
| 12412 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12413 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12414 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12415 | else |
| 12416 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12417 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12418 | |
| 12419 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12420 | } |
| 12421 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12422 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12423 | /** |
| 12424 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12425 | * @psoc_cfg: pmo psoc Configuration |
| 12426 | * @hdd_ctx: Pointer to hdd context |
| 12427 | * |
| 12428 | * Return: none |
| 12429 | */ |
| 12430 | static inline void hdd_ra_populate_pmo_config( |
| 12431 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12432 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12433 | { |
| 12434 | psoc_cfg->ra_ratelimit_interval = |
| 12435 | hdd_ctx->config->RArateLimitInterval; |
| 12436 | psoc_cfg->ra_ratelimit_enable = |
| 12437 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12438 | } |
| 12439 | #else |
| 12440 | static inline void hdd_ra_populate_pmo_config( |
| 12441 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12442 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12443 | { |
| 12444 | } |
| 12445 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12446 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12447 | /** |
| 12448 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12449 | * @hdd_ctx: HDD context |
| 12450 | * |
| 12451 | * Return: void |
| 12452 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12453 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12454 | { |
| 12455 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12456 | struct pmo_psoc_cfg psoc_cfg; |
| 12457 | QDF_STATUS status; |
| 12458 | |
| 12459 | /* |
| 12460 | * Value of hdd_ctx->wowEnable can be, |
| 12461 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12462 | * 1 - Enable magic pattern match on all interfaces. |
| 12463 | * 2 - Enable pattern byte match on all interfaces. |
| 12464 | * 3 - Enable both magic patter and pattern byte match on |
| 12465 | * all interfaces. |
| 12466 | */ |
| 12467 | psoc_cfg.magic_ptrn_enable = |
| 12468 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12469 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12470 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12471 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12472 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12473 | psoc_cfg.bpf_enable = |
| 12474 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12475 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12476 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12477 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12478 | if (hdd_ctx->config->fhostNSOffload) |
| 12479 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12480 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12481 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12482 | psoc_cfg.active_mode_offload = |
| 12483 | hdd_ctx->config->active_mode_offload; |
| 12484 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12485 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12486 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12487 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12488 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12489 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12490 | psoc_cfg.power_save_mode = |
| 12491 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12492 | psoc_cfg.auto_power_save_fail_mode = |
| 12493 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12494 | |
| 12495 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12496 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12497 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Rajeev Kumar | d1a7ac4 | 2017-11-08 14:54:22 -0800 | [diff] [blame] | 12498 | status = ucfg_pmo_update_psoc_config(psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12499 | if (status != QDF_STATUS_SUCCESS) { |
| 12500 | hdd_err("failed pmo psoc configuration"); |
| 12501 | return -EINVAL; |
| 12502 | } |
| 12503 | |
| 12504 | return 0; |
| 12505 | } |
| 12506 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12507 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12508 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12509 | struct hdd_config *cfg) |
| 12510 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12511 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12512 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12513 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12514 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12515 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12516 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12517 | pno_cfg->channel_prediction_full_scan = |
| 12518 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12519 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12520 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12521 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12522 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12523 | } |
| 12524 | #else |
| 12525 | static inline void |
| 12526 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12527 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12528 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12529 | } |
| 12530 | #endif |
| 12531 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12532 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12533 | struct hdd_config *cfg) |
| 12534 | { |
| 12535 | uint8_t i = 0; |
| 12536 | |
| 12537 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12538 | if (!ie_whitelist->white_list) |
| 12539 | return; |
| 12540 | |
| 12541 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12542 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12543 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12544 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12545 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12546 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12547 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12548 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12549 | |
| 12550 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12551 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12552 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12553 | } |
| 12554 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12555 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12556 | { |
| 12557 | uint8_t i, score; |
| 12558 | |
| 12559 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12560 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12561 | if (score > MAX_INDEX_SCORE) |
| 12562 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12563 | MAX_INDEX_SCORE, i); |
| 12564 | } |
| 12565 | |
| 12566 | return per_index_score; |
| 12567 | } |
| 12568 | |
| 12569 | /** |
| 12570 | * hdd_update_score_config - API to update candidate scoring related params |
| 12571 | * configuration parameters |
| 12572 | * @score_config: score config to update |
| 12573 | * @cfg: config params |
| 12574 | * |
| 12575 | * Return: 0 if success else err |
| 12576 | */ |
| 12577 | static void hdd_update_score_config( |
| 12578 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12579 | { |
| 12580 | int total_weight; |
| 12581 | |
| 12582 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12583 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12584 | score_config->weight_cfg.vht_caps_weightage = |
| 12585 | cfg->vht_caps_weightage; |
| 12586 | score_config->weight_cfg.he_caps_weightage = |
| 12587 | cfg->he_caps_weightage; |
| 12588 | score_config->weight_cfg.chan_width_weightage = |
| 12589 | cfg->chan_width_weightage; |
| 12590 | score_config->weight_cfg.chan_band_weightage = |
| 12591 | cfg->chan_band_weightage; |
| 12592 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12593 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12594 | cfg->beamforming_cap_weightage; |
| 12595 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12596 | score_config->weight_cfg.channel_congestion_weightage = |
| 12597 | cfg->channel_congestion_weightage; |
| 12598 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12599 | |
| 12600 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12601 | score_config->weight_cfg.ht_caps_weightage + |
| 12602 | score_config->weight_cfg.vht_caps_weightage + |
| 12603 | score_config->weight_cfg.he_caps_weightage + |
| 12604 | score_config->weight_cfg.chan_width_weightage + |
| 12605 | score_config->weight_cfg.chan_band_weightage + |
| 12606 | score_config->weight_cfg.nss_weightage + |
| 12607 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12608 | score_config->weight_cfg.pcl_weightage + |
| 12609 | score_config->weight_cfg.channel_congestion_weightage + |
| 12610 | score_config->weight_cfg.oce_wan_weightage; |
| 12611 | |
| 12612 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12613 | hdd_err("total weight is greater than %d fallback to default values", |
| 12614 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12615 | |
| 12616 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12617 | score_config->weight_cfg.ht_caps_weightage = |
| 12618 | HT_CAPABILITY_WEIGHTAGE; |
| 12619 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12620 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12621 | score_config->weight_cfg.chan_width_weightage = |
| 12622 | CHAN_WIDTH_WEIGHTAGE; |
| 12623 | score_config->weight_cfg.chan_band_weightage = |
| 12624 | CHAN_BAND_WEIGHTAGE; |
| 12625 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12626 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12627 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12628 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12629 | score_config->weight_cfg.channel_congestion_weightage = |
| 12630 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12631 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12632 | } |
| 12633 | |
| 12634 | score_config->bandwidth_weight_per_index = |
| 12635 | hdd_limit_max_per_index_score( |
| 12636 | cfg->bandwidth_weight_per_index); |
| 12637 | score_config->nss_weight_per_index = |
| 12638 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12639 | score_config->band_weight_per_index = |
| 12640 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12641 | |
| 12642 | score_config->rssi_score.best_rssi_threshold = |
| 12643 | cfg->best_rssi_threshold; |
| 12644 | score_config->rssi_score.good_rssi_threshold = |
| 12645 | cfg->good_rssi_threshold; |
| 12646 | score_config->rssi_score.bad_rssi_threshold = |
| 12647 | cfg->bad_rssi_threshold; |
| 12648 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12649 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12650 | score_config->rssi_score.good_rssi_bucket_size = |
| 12651 | cfg->good_rssi_bucket_size; |
| 12652 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12653 | cfg->bad_rssi_bucket_size; |
| 12654 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12655 | cfg->rssi_pref_5g_rssi_thresh; |
| 12656 | |
| 12657 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12658 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12659 | hdd_limit_max_per_index_score( |
| 12660 | cfg->esp_qbss_score_slots3_to_0); |
| 12661 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12662 | hdd_limit_max_per_index_score( |
| 12663 | cfg->esp_qbss_score_slots7_to_4); |
| 12664 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12665 | hdd_limit_max_per_index_score( |
| 12666 | cfg->esp_qbss_score_slots11_to_8); |
| 12667 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12668 | hdd_limit_max_per_index_score( |
| 12669 | cfg->esp_qbss_score_slots15_to_12); |
| 12670 | |
| 12671 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12672 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12673 | hdd_limit_max_per_index_score( |
| 12674 | cfg->oce_wan_score_slots3_to_0); |
| 12675 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12676 | hdd_limit_max_per_index_score( |
| 12677 | cfg->oce_wan_score_slots7_to_4); |
| 12678 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12679 | hdd_limit_max_per_index_score( |
| 12680 | cfg->oce_wan_score_slots11_to_8); |
| 12681 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12682 | hdd_limit_max_per_index_score( |
| 12683 | cfg->oce_wan_score_slots15_to_12); |
| 12684 | |
| 12685 | |
| 12686 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12687 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12688 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12689 | |
| 12690 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12691 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12692 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12693 | score_config->he_cap = 1; |
| 12694 | |
| 12695 | if (score_config->he_cap || |
| 12696 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12697 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12698 | score_config->vht_cap = 1; |
| 12699 | |
| 12700 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12701 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12702 | score_config->ht_cap = 1; |
| 12703 | |
| 12704 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12705 | score_config->vht_24G_cap = 1; |
| 12706 | |
| 12707 | if (cfg->enableTxBF) |
| 12708 | score_config->beamformee_cap = 1; |
| 12709 | |
| 12710 | } |
| 12711 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12712 | /** |
| 12713 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12714 | * @hdd_ctx: HDD context |
| 12715 | * |
| 12716 | * Return: 0 if success else err |
| 12717 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12718 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12719 | { |
| 12720 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12721 | struct scan_user_cfg scan_cfg; |
| 12722 | struct hdd_config *cfg = hdd_ctx->config; |
| 12723 | QDF_STATUS status; |
| 12724 | |
| 12725 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12726 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12727 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12728 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12729 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12730 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12731 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12732 | /* convert to ms */ |
| 12733 | scan_cfg.scan_cache_aging_time = |
| 12734 | cfg->scanAgingTimeout * 1000; |
| 12735 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12736 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12737 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12738 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12739 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12740 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12741 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12742 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12743 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12744 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12745 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12746 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12747 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12748 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12749 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12750 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12751 | if (status != QDF_STATUS_SUCCESS) { |
| 12752 | hdd_err("failed pmo psoc configuration"); |
| 12753 | return -EINVAL; |
| 12754 | } |
| 12755 | |
| 12756 | return 0; |
| 12757 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12758 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12759 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12760 | { |
| 12761 | int ret; |
| 12762 | |
| 12763 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12764 | if (ret) |
| 12765 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12766 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12767 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12768 | if (ret) |
| 12769 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12770 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12771 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12772 | if (ret) |
| 12773 | return ret; |
| 12774 | |
| 12775 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12776 | |
| 12777 | return ret; |
| 12778 | } |
| 12779 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12780 | /** |
| 12781 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12782 | * @mode : cfg80211 DFS mode |
| 12783 | * |
| 12784 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12785 | */ |
| 12786 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12787 | { |
| 12788 | switch (mode) { |
| 12789 | case DFS_MODE_ENABLE: |
| 12790 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12791 | case DFS_MODE_DISABLE: |
| 12792 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12793 | case DFS_MODE_DEPRIORITIZE: |
| 12794 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12795 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12796 | hdd_debug("ACS dfs mode is NONE"); |
| 12797 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12798 | } |
| 12799 | } |
| 12800 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12801 | /** |
| 12802 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12803 | * @hddctx: pointer to hdd context |
| 12804 | * @set_value: enable/disable |
| 12805 | * |
| 12806 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12807 | * Host(even though it is duplicate). When Host send vendor command |
| 12808 | * disable,FW doesn't perform any action. Whenever any change in |
| 12809 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12810 | * |
| 12811 | * return - 0 on success, appropriate error values on failure. |
| 12812 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12813 | 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] | 12814 | { |
| 12815 | QDF_STATUS status; |
| 12816 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12817 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12818 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12819 | |
| 12820 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12821 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12822 | return -EINVAL; |
| 12823 | } |
| 12824 | |
| 12825 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12826 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12827 | hdd_err("Failed to send chan avoid command to SME"); |
| 12828 | return -EINVAL; |
| 12829 | } |
| 12830 | return 0; |
| 12831 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12832 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12833 | /** |
| 12834 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12835 | * @value: value to set |
| 12836 | * |
| 12837 | * This function will set the passed value to roaming in progress flag. |
| 12838 | * |
| 12839 | * Return: None |
| 12840 | */ |
| 12841 | void hdd_set_roaming_in_progress(bool value) |
| 12842 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12843 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12844 | |
| 12845 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12846 | if (!hdd_ctx) { |
| 12847 | hdd_err("HDD context is NULL"); |
| 12848 | return; |
| 12849 | } |
| 12850 | |
| 12851 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12852 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12853 | } |
| 12854 | |
| 12855 | /** |
| 12856 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12857 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12858 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12859 | * 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] | 12860 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12861 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12862 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12863 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12864 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12865 | |
| 12866 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12867 | if (!hdd_ctx) { |
| 12868 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12869 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12870 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12871 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12872 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12873 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12874 | hdd_ctx->roaming_in_progress); |
| 12875 | |
| 12876 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12877 | } |
| 12878 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12879 | /** |
| 12880 | * hdd_is_connection_in_progress() - check if connection is in |
| 12881 | * progress |
| 12882 | * @session_id: session id |
| 12883 | * @reason: scan reject reason |
| 12884 | * |
| 12885 | * Go through each adapter and check if Connection is in progress |
| 12886 | * |
| 12887 | * Return: true if connection is in progress else false |
| 12888 | */ |
| 12889 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12890 | enum scan_reject_states *reason) |
| 12891 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12892 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12893 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12894 | uint8_t sta_id = 0; |
| 12895 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12896 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12897 | |
| 12898 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12899 | if (!hdd_ctx) { |
| 12900 | hdd_err("HDD context is NULL"); |
| 12901 | return false; |
| 12902 | } |
| 12903 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12904 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12905 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12906 | hdd_device_mode_to_string(adapter->device_mode), |
| 12907 | adapter->device_mode); |
| 12908 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12909 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12910 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12911 | && (eConnectionState_Connecting == |
| 12912 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12913 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12914 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12915 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12916 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12917 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12918 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12919 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12920 | } |
| 12921 | return true; |
| 12922 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12923 | /* |
| 12924 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12925 | * hdd_is_roaming_in_progress is for LFR3 |
| 12926 | */ |
| 12927 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12928 | sme_neighbor_middle_of_roaming( |
| 12929 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12930 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12931 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12932 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12933 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12934 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12935 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12936 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12937 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12938 | } |
| 12939 | return true; |
| 12940 | } |
| 12941 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12942 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12943 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12944 | hdd_sta_ctx = |
| 12945 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12946 | if ((eConnectionState_Associated == |
| 12947 | hdd_sta_ctx->conn_info.connState) |
| 12948 | && (false == |
| 12949 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12950 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 12951 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12952 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12953 | " is in middle of WPS/EAPOL exchange.", |
| 12954 | MAC_ADDR_ARRAY(sta_mac)); |
| 12955 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12956 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12957 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12958 | } |
| 12959 | return true; |
| 12960 | } |
| 12961 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12962 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12963 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12964 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12965 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12966 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12967 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12968 | continue; |
| 12969 | |
| 12970 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12971 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 12972 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12973 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12974 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12975 | MAC_ADDR_ARRAY(sta_mac)); |
| 12976 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12977 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12978 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12979 | } |
| 12980 | return true; |
| 12981 | } |
| 12982 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12983 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12984 | return true; |
| 12985 | } |
| 12986 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12987 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12988 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12989 | return false; |
| 12990 | } |
| 12991 | |
| 12992 | /** |
| 12993 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12994 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12995 | * |
| 12996 | * Return: None |
| 12997 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12998 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12999 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13000 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13001 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13002 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13003 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13004 | tsap_Config_t *sap_config; |
| 13005 | void *sap_ctx; |
| 13006 | |
| 13007 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13008 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13009 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13010 | |
| 13011 | mutex_lock(&hdd_ctx->sap_lock); |
| 13012 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13013 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13014 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13015 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13016 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13017 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13018 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13019 | qdf_stop_bss_event, |
| 13020 | SME_CMD_TIMEOUT_VALUE); |
| 13021 | |
| 13022 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13023 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13024 | goto end; |
| 13025 | } |
| 13026 | } |
| 13027 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13028 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13029 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13030 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13031 | |
| 13032 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13033 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13034 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13035 | eUPDATE_IE_ALL); |
| 13036 | goto end; |
| 13037 | } |
| 13038 | |
| 13039 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13040 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13041 | sap_config, |
| 13042 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13043 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13044 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13045 | eUPDATE_IE_ALL); |
| 13046 | goto end; |
| 13047 | } |
| 13048 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13049 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13050 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13051 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13052 | SME_CMD_TIMEOUT_VALUE); |
| 13053 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13054 | eUPDATE_IE_ALL); |
| 13055 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13056 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13057 | goto end; |
| 13058 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13059 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13060 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 13061 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13062 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13063 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13064 | ap_adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13065 | } |
| 13066 | end: |
| 13067 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13068 | } |
| 13069 | |
| 13070 | /** |
| 13071 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13072 | * with non dfs acs |
| 13073 | * |
| 13074 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13075 | * |
| 13076 | * Return: None |
| 13077 | */ |
| 13078 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13079 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13080 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13081 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13082 | cds_context_type *cds_ctx; |
| 13083 | |
| 13084 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13085 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13086 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13087 | return; |
| 13088 | } |
| 13089 | |
| 13090 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13091 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13092 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13093 | return; |
| 13094 | } |
| 13095 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13096 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13097 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13098 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13099 | return; |
| 13100 | } |
| 13101 | |
| 13102 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13103 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13104 | &ap_adapter->event_flags) && |
| 13105 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13106 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13107 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13108 | 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] | 13109 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13110 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13111 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13112 | acs_cfg.acs_mode = true; |
| 13113 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13114 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13115 | } |
| 13116 | } |
| 13117 | |
| 13118 | /** |
| 13119 | * hdd_set_connection_in_progress() - to set the connection in |
| 13120 | * progress flag |
| 13121 | * @value: value to set |
| 13122 | * |
| 13123 | * This function will set the passed value to connection in progress flag. |
| 13124 | * If value is previously being set to true then no need to set it again. |
| 13125 | * |
| 13126 | * Return: true if value is being set correctly and false otherwise. |
| 13127 | */ |
| 13128 | bool hdd_set_connection_in_progress(bool value) |
| 13129 | { |
| 13130 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13131 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13132 | |
| 13133 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13134 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13135 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13136 | return false; |
| 13137 | } |
| 13138 | |
| 13139 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13140 | /* |
| 13141 | * if the value is set to true previously and if someone is |
| 13142 | * trying to make it true again then it could be some race |
| 13143 | * condition being triggered. Avoid this situation by returning |
| 13144 | * false |
| 13145 | */ |
| 13146 | if (hdd_ctx->connection_in_progress && value) |
| 13147 | status = false; |
| 13148 | else |
| 13149 | hdd_ctx->connection_in_progress = value; |
| 13150 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13151 | return status; |
| 13152 | } |
| 13153 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13154 | 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] | 13155 | { |
| 13156 | if (!adapter) { |
| 13157 | hdd_err("Invalid adapter"); |
| 13158 | return -EINVAL; |
| 13159 | } |
| 13160 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13161 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13162 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13163 | set_value, VDEV_CMD); |
| 13164 | return 0; |
| 13165 | |
| 13166 | } |
| 13167 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13168 | 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] | 13169 | { |
| 13170 | if (!adapter) { |
| 13171 | hdd_err("Invalid adapter"); |
| 13172 | return -EINVAL; |
| 13173 | } |
| 13174 | |
| 13175 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13176 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13177 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13178 | set_value, VDEV_CMD); |
| 13179 | return 0; |
| 13180 | } |
| 13181 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13182 | 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] | 13183 | *psoc, uint8_t vdev_id) |
| 13184 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13185 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13186 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13187 | |
| 13188 | /* |
| 13189 | * Currently PSOC is not being used. But this logic will |
| 13190 | * change once we have the converged implementation of |
| 13191 | * HDD context per PSOC in place. This would break if |
| 13192 | * multiple vdev objects reuse the vdev id. |
| 13193 | */ |
| 13194 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13195 | if (!adapter) |
| 13196 | hdd_err("Get adapter by vdev id failed"); |
| 13197 | |
| 13198 | return adapter; |
| 13199 | } |
| 13200 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13201 | 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] | 13202 | int8_t *rssi, int8_t *snr) |
| 13203 | { |
| 13204 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 13205 | struct hdd_wext_state *wext_state = |
| 13206 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13207 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 13208 | |
| 13209 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 13210 | profile, bssid, rssi, snr); |
| 13211 | if (QDF_STATUS_SUCCESS != status) { |
| 13212 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13213 | return -EINVAL; |
| 13214 | } |
| 13215 | |
| 13216 | return 0; |
| 13217 | } |
| 13218 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13219 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13220 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13221 | * @adapter - HDD adapter |
| 13222 | * @tos - type of service |
| 13223 | * @status - status of the traffic |
| 13224 | * |
| 13225 | * Return: 0 on success and non zero value on failure |
| 13226 | */ |
| 13227 | |
| 13228 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13229 | bool is_tos_active) |
| 13230 | { |
| 13231 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13232 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13233 | uint32_t max_off_chan_time = 0; |
| 13234 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13235 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13236 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13237 | |
| 13238 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13239 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13240 | |
| 13241 | if (ret < 0) { |
| 13242 | hdd_err("failed to set limit off chan params"); |
| 13243 | return ret; |
| 13244 | } |
| 13245 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13246 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13247 | |
| 13248 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13249 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13250 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13251 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13252 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13253 | if (adapter->active_ac) { |
| 13254 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13255 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13256 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13257 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13258 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13259 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13260 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13261 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13262 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13263 | PM_LATENCY); |
| 13264 | } else { |
| 13265 | /*ignore this command if only BE/BK is active */ |
| 13266 | is_tos_active = false; |
| 13267 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13268 | hdd_ctx->config->conc_system_pref); |
| 13269 | } |
| 13270 | } else { |
| 13271 | /* No active tos */ |
| 13272 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13273 | hdd_ctx->config->conc_system_pref); |
| 13274 | } |
| 13275 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13276 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13277 | is_tos_active, max_off_chan_time, |
| 13278 | hdd_ctx->config->nRestTimeConc, true); |
| 13279 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13280 | hdd_err("failed to set limit off chan params"); |
| 13281 | ret = -EINVAL; |
| 13282 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13283 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13284 | return ret; |
| 13285 | } |
| 13286 | |
| 13287 | /** |
| 13288 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13289 | * @adapter - HDD adapter |
| 13290 | * |
| 13291 | * Return: 0 on success and non zero value on failure |
| 13292 | */ |
| 13293 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13294 | { |
| 13295 | struct hdd_context *hdd_ctx; |
| 13296 | int ret; |
| 13297 | QDF_STATUS status; |
| 13298 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13299 | |
| 13300 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13301 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13302 | if (ret < 0) |
| 13303 | return ret; |
| 13304 | |
| 13305 | /* set the system preferece to default */ |
| 13306 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13307 | hdd_ctx->config->conc_system_pref); |
| 13308 | |
| 13309 | /* clear the bitmap */ |
| 13310 | adapter->active_ac = 0; |
| 13311 | |
| 13312 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13313 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13314 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13315 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13316 | false, 0, 0, false); |
| 13317 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13318 | hdd_err("failed to reset limit off chan params"); |
| 13319 | ret = -EINVAL; |
| 13320 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13321 | |
| 13322 | return ret; |
| 13323 | } |
| 13324 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13325 | /** |
| 13326 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13327 | * @drv_op: Enum indicating driver op |
| 13328 | * |
| 13329 | * Return: none |
| 13330 | */ |
| 13331 | void hdd_start_driver_ops_timer(int drv_op) |
| 13332 | { |
| 13333 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13334 | switch (drv_op) { |
| 13335 | case eHDD_DRV_OP_PROBE: |
| 13336 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13337 | break; |
| 13338 | case eHDD_DRV_OP_REMOVE: |
| 13339 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13340 | break; |
| 13341 | case eHDD_DRV_OP_SHUTDOWN: |
| 13342 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13343 | break; |
| 13344 | case eHDD_DRV_OP_REINIT: |
| 13345 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13346 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13347 | case eHDD_DRV_OP_IFF_UP: |
| 13348 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13349 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13350 | } |
| 13351 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13352 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13353 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13354 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13355 | } |
| 13356 | |
| 13357 | /** |
| 13358 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13359 | * |
| 13360 | * Return: none |
| 13361 | */ |
| 13362 | void hdd_stop_driver_ops_timer(void) |
| 13363 | { |
| 13364 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13365 | } |
| 13366 | |
| 13367 | /** |
| 13368 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13369 | * inactivity timer |
| 13370 | * |
| 13371 | * Return: None |
| 13372 | */ |
| 13373 | void hdd_drv_ops_inactivity_handler(void) |
| 13374 | { |
| 13375 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13376 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13377 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13378 | if (hdd_drv_ops_task) { |
| 13379 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13380 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13381 | } else { |
| 13382 | hdd_err("hdd_drv_ops_task is null"); |
| 13383 | } |
| 13384 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13385 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13386 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13387 | sizeof("shutdown"))) |
| 13388 | QDF_BUG(0); |
| 13389 | |
| 13390 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13391 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13392 | else |
| 13393 | QDF_BUG(0); |
| 13394 | } |
| 13395 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13396 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13397 | { |
| 13398 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13399 | |
| 13400 | if (!hdd_ctx) |
| 13401 | return; |
| 13402 | |
| 13403 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13404 | } |
| 13405 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13406 | /** |
| 13407 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13408 | * @struct hdd_context *hdd_ctx |
| 13409 | * @struct hdd_adapter *padapter |
| 13410 | * @bool enble |
| 13411 | * |
| 13412 | * Return: none |
| 13413 | */ |
| 13414 | void hdd_set_rx_mode_rps(bool enable) |
| 13415 | { |
| 13416 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13417 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13418 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13419 | |
| 13420 | if (adapter && hdd_ctx && |
| 13421 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13422 | if (enable && !cds_cfg->rps_enabled) |
| 13423 | hdd_send_rps_ind(adapter); |
| 13424 | else if (!enable && cds_cfg->rps_enabled) |
| 13425 | hdd_send_rps_disable_ind(adapter); |
| 13426 | } |
| 13427 | } |
| 13428 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13429 | /* Register the module init/exit functions */ |
| 13430 | module_init(hdd_module_init); |
| 13431 | module_exit(hdd_module_exit); |
| 13432 | |
| 13433 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13434 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13435 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13436 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13437 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13438 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13439 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13440 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13441 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13442 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13443 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13444 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13446 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13447 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13448 | |
| 13449 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13450 | |
| 13451 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13452 | |
| 13453 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |