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" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 106 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 107 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 108 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 110 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 112 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 113 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 114 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 115 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 116 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 117 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 118 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 119 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 120 | #include "os_if_wifi_pos.h" |
| 121 | #include "wifi_pos_api.h" |
| 122 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 123 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 124 | #include "os_if_nan.h" |
| 125 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 126 | #include "wlan_reg_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 127 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 128 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 129 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 130 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 131 | #include "wlan_hdd_sysfs.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 132 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame^] | 133 | #ifdef WLAN_FEATURE_DISA |
| 134 | #include "wlan_disa_ucfg_api.h" |
| 135 | #endif |
| 136 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 137 | #ifdef CNSS_GENL |
| 138 | #include <net/cnss_nl.h> |
| 139 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 140 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 141 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 142 | #ifdef MODULE |
| 143 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 144 | #else |
| 145 | #define WLAN_MODULE_NAME "wlan" |
| 146 | #endif |
| 147 | |
| 148 | #ifdef TIMER_MANAGER |
| 149 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 150 | #else |
| 151 | #define TIMER_MANAGER_STR "" |
| 152 | #endif |
| 153 | |
| 154 | #ifdef MEMORY_DEBUG |
| 155 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 156 | #else |
| 157 | #define MEMORY_DEBUG_STR "" |
| 158 | #endif |
| 159 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 160 | int wlan_start_ret_val; |
| 161 | static DECLARE_COMPLETION(wlan_start_comp); |
| 162 | static unsigned int dev_num = 1; |
| 163 | static struct cdev wlan_hdd_state_cdev; |
| 164 | static struct class *class; |
| 165 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 166 | #ifndef MODULE |
| 167 | static struct gwlan_loader *wlan_loader; |
| 168 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 169 | struct kobj_attribute *attr, |
| 170 | const char *buf, size_t count); |
| 171 | struct gwlan_loader { |
| 172 | bool loaded_state; |
| 173 | struct kobject *boot_wlan_obj; |
| 174 | struct attribute_group *attr_group; |
| 175 | }; |
| 176 | |
| 177 | static struct kobj_attribute wlan_boot_attribute = |
| 178 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 179 | |
| 180 | static struct attribute *attrs[] = { |
| 181 | &wlan_boot_attribute.attr, |
| 182 | NULL, |
| 183 | }; |
| 184 | |
| 185 | #define MODULE_INITIALIZED 1 |
| 186 | #endif |
| 187 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 188 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 189 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 190 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 191 | |
| 192 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 193 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 194 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 195 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 196 | /* the Android framework expects this param even though we don't use it */ |
| 197 | #define BUF_LEN 20 |
| 198 | static char fwpath_buffer[BUF_LEN]; |
| 199 | static struct kparam_string fwpath = { |
| 200 | .string = fwpath_buffer, |
| 201 | .maxlen = BUF_LEN, |
| 202 | }; |
| 203 | |
| 204 | static char *country_code; |
| 205 | static int enable_11d = -1; |
| 206 | static int enable_dfs_chan_scan = -1; |
| 207 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 208 | /* |
| 209 | * spinlock for synchronizing asynchronous request/response |
| 210 | * (full description of use in wlan_hdd_main.h) |
| 211 | */ |
| 212 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 213 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 214 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 215 | #define WLAN_NLINK_CESIUM 30 |
| 216 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 217 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 218 | |
| 219 | #define WOW_MAX_FILTER_LISTS 1 |
| 220 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 221 | #define WOW_MIN_PATTERN_SIZE 6 |
| 222 | #define WOW_MAX_PATTERN_SIZE 64 |
| 223 | |
| 224 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 225 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 226 | .flags = WIPHY_WOWLAN_ANY | |
| 227 | WIPHY_WOWLAN_MAGIC_PKT | |
| 228 | WIPHY_WOWLAN_DISCONNECT | |
| 229 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 230 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 231 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 232 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 233 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 234 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 235 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 236 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 237 | }; |
| 238 | #endif |
| 239 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 240 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 241 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 242 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 243 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 244 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 245 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 246 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 247 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 253 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 254 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 255 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 256 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 257 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 275 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 276 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 277 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 278 | }; |
| 279 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 280 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 281 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 282 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 283 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 284 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 285 | }; |
| 286 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 287 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 288 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 289 | |
| 290 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 291 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 292 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 293 | #endif |
| 294 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 295 | void hdd_start_complete(int ret) |
| 296 | { |
| 297 | wlan_start_ret_val = ret; |
| 298 | |
| 299 | complete(&wlan_start_comp); |
| 300 | } |
| 301 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 302 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 303 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 304 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 305 | * |
| 306 | * Return: none |
| 307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 308 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 309 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 310 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 311 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 312 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 313 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 317 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 318 | * @vdev_id: vdev_id |
| 319 | * @action: action type |
| 320 | * @reason: reason type |
| 321 | * |
| 322 | * Return: none |
| 323 | */ |
| 324 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 325 | enum netif_action_type action, enum netif_reason_type reason) |
| 326 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 327 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 328 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 329 | |
| 330 | if (!hdd_ctx) { |
| 331 | hdd_err("hdd ctx is NULL"); |
| 332 | return; |
| 333 | } |
| 334 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 335 | |
| 336 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 340 | * Store WLAN driver version and timestamp info in global variables such that |
| 341 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 342 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 344 | #ifdef BUILD_TAG |
| 345 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 346 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 347 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 348 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 349 | |
| 350 | /** |
| 351 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 352 | * @device_mode: device mode |
| 353 | * |
| 354 | * This utility function helps log string conversion of device mode. |
| 355 | * |
| 356 | * Return: string conversion of device mode, if match found; |
| 357 | * "Unknown" otherwise. |
| 358 | */ |
| 359 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 360 | { |
| 361 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 362 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 363 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 364 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 365 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 366 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 367 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 368 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 369 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 370 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 371 | default: |
| 372 | return "Unknown"; |
| 373 | } |
| 374 | } |
| 375 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 376 | /** |
| 377 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 378 | * @adapter: HDD adapter |
| 379 | * @chan_number: Channel number |
| 380 | * @chan_bw: Bandwidth |
| 381 | * |
| 382 | * Checks if the given bandwidth is valid for the given channel number. |
| 383 | * |
| 384 | * Return: 0 for success, non-zero for failure |
| 385 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 386 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 387 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 388 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 389 | { |
| 390 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 391 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 392 | bool found = false; |
| 393 | tHalHandle hal; |
| 394 | |
| 395 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 396 | if (!hal) { |
| 397 | hdd_err("Invalid HAL context"); |
| 398 | return -EINVAL; |
| 399 | } |
| 400 | |
| 401 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 402 | hdd_err("No valid channel list"); |
| 403 | return -EOPNOTSUPP; |
| 404 | } |
| 405 | |
| 406 | for (i = 0; i < len; i++) { |
| 407 | if (chan[i] == chan_number) { |
| 408 | found = true; |
| 409 | break; |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | if (found == false) { |
| 414 | hdd_err("Channel not in driver's valid channel list"); |
| 415 | return -EOPNOTSUPP; |
| 416 | } |
| 417 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 418 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 419 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 420 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 421 | return -EINVAL; |
| 422 | } |
| 423 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 424 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 425 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 426 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 427 | return -EINVAL; |
| 428 | } |
| 429 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 430 | (chan_bw != CH_WIDTH_MAX)) { |
| 431 | hdd_err("Only BW20 possible on channel 14"); |
| 432 | return -EINVAL; |
| 433 | } |
| 434 | } |
| 435 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 436 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 437 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 438 | (chan_bw != CH_WIDTH_MAX)) { |
| 439 | hdd_err("Only BW20 possible on channel 165"); |
| 440 | return -EINVAL; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 447 | /** |
| 448 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 449 | * |
| 450 | * Block the unloading of the driver (or) interface up until the |
| 451 | * cds recovery is completed |
| 452 | * |
| 453 | * Return: true for recovery completion else false |
| 454 | */ |
| 455 | static bool hdd_wait_for_recovery_completion(void) |
| 456 | { |
| 457 | int retry = 0; |
| 458 | |
| 459 | /* Wait for recovery to complete */ |
| 460 | while (cds_is_driver_recovering()) { |
| 461 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 462 | hdd_err("Recovery in progress; wait here!!!"); |
| 463 | msleep(1000); |
| 464 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 465 | hdd_err("SSR never completed, error"); |
| 466 | /* |
| 467 | * Trigger the bug_on in the internal builds, in the |
| 468 | * customer builds self-recovery will be enabled |
| 469 | * in those cases just return error. |
| 470 | */ |
| 471 | if (cds_is_self_recovery_enabled()) |
| 472 | return false; |
| 473 | QDF_BUG(0); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | hdd_info("Recovery completed successfully!"); |
| 478 | return true; |
| 479 | } |
| 480 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 481 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 482 | unsigned long state, void *data) |
| 483 | { |
| 484 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 485 | struct netdev_notifier_info *dev_notif_info = data; |
| 486 | struct net_device *dev = dev_notif_info->dev; |
| 487 | #else |
| 488 | struct net_device *dev = data; |
| 489 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 490 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 491 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 492 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 493 | ENTER_DEV(dev); |
| 494 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 495 | /* Make sure that this callback corresponds to our device. */ |
| 496 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 497 | return NOTIFY_DONE; |
| 498 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 499 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 500 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 501 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 502 | return NOTIFY_DONE; |
| 503 | } |
| 504 | |
| 505 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 506 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 507 | return NOTIFY_DONE; |
| 508 | } |
| 509 | |
| 510 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 511 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 512 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 513 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 514 | return NOTIFY_DONE; |
| 515 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 516 | |
| 517 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 518 | hdd_err("%s: Driver module is closed", __func__); |
| 519 | return NOTIFY_DONE; |
| 520 | } |
| 521 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 522 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 523 | return NOTIFY_DONE; |
| 524 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 525 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 526 | dev->name, state); |
| 527 | |
| 528 | switch (state) { |
| 529 | case NETDEV_REGISTER: |
| 530 | break; |
| 531 | |
| 532 | case NETDEV_UNREGISTER: |
| 533 | break; |
| 534 | |
| 535 | case NETDEV_UP: |
| 536 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 537 | break; |
| 538 | |
| 539 | case NETDEV_DOWN: |
| 540 | break; |
| 541 | |
| 542 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 543 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | complete(&adapter->linkup_event_var); |
| 545 | break; |
| 546 | |
| 547 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 548 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 549 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 550 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 551 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 552 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 553 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 554 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 555 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 556 | /* |
| 557 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 558 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 559 | * flag after which driver does not send the cfg80211_scan_done. |
| 560 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 561 | */ |
| 562 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | break; |
| 564 | |
| 565 | default: |
| 566 | break; |
| 567 | } |
| 568 | |
| 569 | return NOTIFY_DONE; |
| 570 | } |
| 571 | |
| 572 | /** |
| 573 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 574 | * @nb: pointer to notifier block |
| 575 | * @state: state |
| 576 | * @ndev: ndev pointer |
| 577 | * |
| 578 | * Return: 0 on success, error number otherwise. |
| 579 | */ |
| 580 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 581 | unsigned long state, |
| 582 | void *ndev) |
| 583 | { |
| 584 | int ret; |
| 585 | |
| 586 | cds_ssr_protect(__func__); |
| 587 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 588 | cds_ssr_unprotect(__func__); |
| 589 | |
| 590 | return ret; |
| 591 | } |
| 592 | |
| 593 | struct notifier_block hdd_netdev_notifier = { |
| 594 | .notifier_call = hdd_netdev_notifier_call, |
| 595 | }; |
| 596 | |
| 597 | /* variable to hold the insmod parameters */ |
| 598 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 599 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 600 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 601 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 602 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 603 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 606 | /** |
| 607 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 608 | * @ch_width: NL channel width |
| 609 | * |
| 610 | * Converts the NL channel width to the driver's internal representation |
| 611 | * |
| 612 | * Return: Converted channel width. In case of non matching NL channel width, |
| 613 | * CH_WIDTH_MAX will be returned. |
| 614 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 615 | 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] | 616 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 617 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 618 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 619 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 620 | switch (ch_width) { |
| 621 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 622 | case NL80211_CHAN_WIDTH_20: |
| 623 | return CH_WIDTH_20MHZ; |
| 624 | case NL80211_CHAN_WIDTH_40: |
| 625 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 626 | case NL80211_CHAN_WIDTH_80: |
| 627 | return CH_WIDTH_80MHZ; |
| 628 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 629 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 630 | return CH_WIDTH_80P80MHZ; |
| 631 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 632 | return CH_WIDTH_160MHZ; |
| 633 | else |
| 634 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 635 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 636 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 637 | return CH_WIDTH_160MHZ; |
| 638 | else |
| 639 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 640 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 641 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 642 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 643 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 644 | default: |
| 645 | hdd_err("Invalid channel width %d, setting to default", |
| 646 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 647 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 648 | } |
| 649 | } |
| 650 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 651 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 652 | * @hal: handler to HAL |
| 653 | * @channel: channel id |
| 654 | * @bw_offset: bandwidth offset |
| 655 | * |
| 656 | * Function invokes sme api to find the operating class |
| 657 | * |
| 658 | * Return: operating class |
| 659 | */ |
| 660 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 661 | uint8_t bw_offset) |
| 662 | { |
| 663 | uint8_t opclass = 0; |
| 664 | |
| 665 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 666 | return opclass; |
| 667 | } |
| 668 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 669 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 670 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 671 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 672 | * @bitmask: Bitmask of log levels to be enabled |
| 673 | * |
| 674 | * Called immediately after the cfg.ini is read in order to configure |
| 675 | * the desired trace levels. |
| 676 | * |
| 677 | * Return: None |
| 678 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 679 | 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] | 680 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 681 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 682 | int qdf_print_idx = -1; |
| 683 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 684 | /* |
| 685 | * if the bitmask is the default value, then a bitmask was not |
| 686 | * specified in cfg.ini, so leave the logging level alone (it |
| 687 | * will remain at the "compiled in" default value) |
| 688 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 689 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 690 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 691 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 692 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 693 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 694 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 695 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 696 | QDF_TRACE_LEVEL_NONE, 0); |
| 697 | |
| 698 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 699 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 700 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 701 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 702 | while (0 != bitmask) { |
| 703 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 704 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 705 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 706 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 707 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 709 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 710 | level++; |
| 711 | bitmask >>= 1; |
| 712 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 713 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 714 | } |
| 715 | |
| 716 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 717 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 718 | * @hdd_ctx: HDD context pointer |
| 719 | * |
| 720 | * Return: 0 if the context is valid. Error code otherwise |
| 721 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 722 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 723 | { |
| 724 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 725 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 726 | return -ENODEV; |
| 727 | } |
| 728 | |
| 729 | if (cds_is_driver_recovering()) { |
| 730 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 731 | (void *)_RET_IP_, cds_get_driver_state()); |
| 732 | return -EAGAIN; |
| 733 | } |
| 734 | |
| 735 | if (hdd_ctx->start_modules_in_progress || |
| 736 | hdd_ctx->stop_modules_in_progress) { |
| 737 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 738 | (void *)_RET_IP_); |
| 739 | return -EAGAIN; |
| 740 | } |
| 741 | |
| 742 | return 0; |
| 743 | } |
| 744 | |
| 745 | |
| 746 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | * wlan_hdd_validate_context() - check the HDD context |
| 748 | * @hdd_ctx: HDD context pointer |
| 749 | * |
| 750 | * Return: 0 if the context is valid. Error code otherwise |
| 751 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 752 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 753 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 754 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 755 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | return -ENODEV; |
| 757 | } |
| 758 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 759 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 760 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 761 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | return -EAGAIN; |
| 763 | } |
| 764 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 765 | if (cds_is_load_or_unload_in_progress()) { |
| 766 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 767 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 768 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 769 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 770 | |
| 771 | if (hdd_ctx->start_modules_in_progress || |
| 772 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 773 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 774 | (void *)_RET_IP_); |
| 775 | return -EAGAIN; |
| 776 | } |
| 777 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 778 | if (cds_is_driver_in_bad_state()) { |
| 779 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 780 | (void *)_RET_IP_, cds_get_driver_state()); |
| 781 | return -ENODEV; |
| 782 | } |
| 783 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | return 0; |
| 785 | } |
| 786 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 787 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 788 | { |
| 789 | if (!adapter) { |
| 790 | hdd_err("adapter is null"); |
| 791 | return -EINVAL; |
| 792 | } |
| 793 | |
| 794 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 795 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 796 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 797 | return -EINVAL; |
| 798 | } |
| 799 | |
| 800 | if (!adapter->dev) { |
| 801 | hdd_err("adapter net_device is null"); |
| 802 | return -EINVAL; |
| 803 | } |
| 804 | |
| 805 | if (!(adapter->dev->flags & IFF_UP)) { |
| 806 | hdd_info("adapter net_device is not up"); |
| 807 | return -EAGAIN; |
| 808 | } |
| 809 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 810 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 811 | hdd_info("adapter session is not open"); |
| 812 | return -EAGAIN; |
| 813 | } |
| 814 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 815 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 816 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 817 | return -EINVAL; |
| 818 | } |
| 819 | |
| 820 | return 0; |
| 821 | } |
| 822 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 823 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 824 | * wlan_hdd_validate_modules_state() - Check modules status |
| 825 | * @hdd_ctx: HDD context pointer |
| 826 | * |
| 827 | * Check's the driver module's state and returns true if the |
| 828 | * modules are enabled returns false if modules are closed. |
| 829 | * |
| 830 | * Return: True if modules are enabled or false. |
| 831 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 832 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 833 | { |
| 834 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 835 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 836 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 837 | hdd_notice("Modules not enabled, Present status: %d", |
| 838 | hdd_ctx->driver_status); |
| 839 | return false; |
| 840 | } |
| 841 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 842 | return true; |
| 843 | } |
| 844 | |
| 845 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | * 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] | 847 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 848 | * |
| 849 | * This function sets the IBSS power save config parameters to WMA |
| 850 | * which will send it to firmware if FW supports IBSS power save |
| 851 | * before vdev start. |
| 852 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 853 | * 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] | 854 | * on failure. |
| 855 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 856 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | { |
| 858 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 859 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | |
| 861 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 862 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 863 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 864 | } |
| 865 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 866 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 867 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 868 | hdd_ctx->config->ibssATIMWinSize, |
| 869 | VDEV_CMD); |
| 870 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 871 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 872 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 873 | } |
| 874 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 875 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 877 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 878 | VDEV_CMD); |
| 879 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 880 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 881 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 882 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 883 | } |
| 884 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 885 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 886 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 887 | hdd_ctx->config-> |
| 888 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 889 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 890 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 891 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 892 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 893 | } |
| 894 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 895 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 897 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 898 | VDEV_CMD); |
| 899 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 900 | 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] | 901 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 902 | } |
| 903 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 904 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 905 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 906 | hdd_ctx->config->ibssInactivityCount, |
| 907 | VDEV_CMD); |
| 908 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 909 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 910 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | } |
| 912 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 913 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 914 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 915 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 916 | VDEV_CMD); |
| 917 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 918 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 919 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 920 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 921 | } |
| 922 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 923 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 925 | hdd_ctx->config->ibssPsWarmupTime, |
| 926 | VDEV_CMD); |
| 927 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 928 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 929 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 930 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 931 | } |
| 932 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 933 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 934 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 935 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 936 | VDEV_CMD); |
| 937 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 938 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 939 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 940 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | } |
| 942 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 943 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | } |
| 945 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 946 | #ifdef FEATURE_RUNTIME_PM |
| 947 | /** |
| 948 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 949 | * @hdd_ctx: HDD context |
| 950 | * |
| 951 | * Return: None |
| 952 | */ |
| 953 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 954 | { |
| 955 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 956 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 957 | qdf_runtime_lock_init(&ctx->dfs); |
| 958 | |
| 959 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 960 | } |
| 961 | |
| 962 | /** |
| 963 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 964 | * @hdd_ctx: HDD Context |
| 965 | * |
| 966 | * Return: None |
| 967 | */ |
| 968 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 969 | { |
| 970 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 971 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 972 | qdf_runtime_lock_deinit(&ctx->dfs); |
| 973 | |
| 974 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 975 | } |
| 976 | |
| 977 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
| 978 | { |
| 979 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 980 | |
| 981 | qdf_runtime_lock_init(&ctx->connect); |
| 982 | } |
| 983 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 984 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 985 | { |
| 986 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 987 | |
| 988 | qdf_runtime_lock_deinit(&ctx->connect); |
| 989 | } |
| 990 | #else /* FEATURE_RUNTIME_PM */ |
| 991 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 992 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
| 993 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 994 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 995 | #endif /* FEATURE_RUNTIME_PM */ |
| 996 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | #define INTF_MACADDR_MASK 0x7 |
| 998 | |
| 999 | /** |
| 1000 | * hdd_update_macaddr() - update mac address |
| 1001 | * @config: hdd configuration |
| 1002 | * @hw_macaddr: mac address |
| 1003 | * |
| 1004 | * Mac address for multiple virtual interface is found as following |
| 1005 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1006 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1007 | * define the mac address for the remaining interfaces and locally |
| 1008 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1009 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1010 | * interface). |
| 1011 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1012 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1013 | * |
| 1014 | * Return: None |
| 1015 | */ |
| 1016 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1017 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | { |
| 1019 | int8_t i; |
| 1020 | uint8_t macaddr_b3, tmp_br3; |
| 1021 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1022 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1023 | QDF_MAC_ADDR_SIZE); |
| 1024 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1025 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1026 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1028 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1029 | INTF_MACADDR_MASK; |
| 1030 | macaddr_b3 += tmp_br3; |
| 1031 | |
| 1032 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1033 | * mac address range before collision |
| 1034 | */ |
| 1035 | macaddr_b3 ^= (1 << 7); |
| 1036 | |
| 1037 | /* Set locally administered bit */ |
| 1038 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1039 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1040 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | MAC_ADDRESS_STR, i, |
| 1042 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1043 | } |
| 1044 | } |
| 1045 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1046 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1047 | { |
| 1048 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1049 | struct tdls_start_params tdls_cfg; |
| 1050 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1051 | struct hdd_config *cfg = hdd_ctx->config; |
| 1052 | QDF_STATUS status; |
| 1053 | |
| 1054 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1055 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1056 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1057 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1058 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1059 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1060 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1061 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1062 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1063 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1064 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1065 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1066 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1067 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1068 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1069 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1070 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1071 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1072 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1073 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1074 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1075 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1076 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1077 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1078 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1079 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1080 | (cfg->fTDLSExternalControl ? |
| 1081 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1082 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1083 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1084 | |
| 1085 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1086 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1087 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1088 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1089 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1090 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1091 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1092 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 1093 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 1094 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 1095 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
| 1096 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1097 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1098 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1099 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1100 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1101 | |
| 1102 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1103 | if (status != QDF_STATUS_SUCCESS) { |
| 1104 | hdd_err("failed pmo psoc configuration"); |
| 1105 | return -EINVAL; |
| 1106 | } |
| 1107 | |
| 1108 | hdd_ctx->tdls_umac_comp_active = true; |
| 1109 | /* enable napier specific tdls data path */ |
| 1110 | hdd_ctx->tdls_nap_active = true; |
| 1111 | |
| 1112 | return 0; |
| 1113 | } |
| 1114 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1115 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1116 | struct wma_tgt_services *cfg) |
| 1117 | { |
| 1118 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1119 | |
| 1120 | /* Set up UAPSD */ |
| 1121 | config->apUapsdEnabled &= cfg->uapsd; |
| 1122 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1123 | /* 11AX mode support */ |
| 1124 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1125 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1126 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1128 | /* 11AC mode support */ |
| 1129 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1130 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1131 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | |
| 1133 | /* ARP offload: override user setting if invalid */ |
| 1134 | config->fhostArpOffload &= cfg->arp_offload; |
| 1135 | |
| 1136 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1137 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1138 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1139 | if (cfg->pno_offload) |
| 1140 | config->PnoOffload = true; |
| 1141 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1142 | #ifdef FEATURE_WLAN_TDLS |
| 1143 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1144 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1145 | cfg->en_tdls_offchan; |
| 1146 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1147 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1148 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1149 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1150 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1151 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1152 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1153 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1154 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1155 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1156 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1157 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1158 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1159 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1160 | |
| 1161 | } |
| 1162 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1163 | /** |
| 1164 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1165 | * @hdd_ctx: HDD context |
| 1166 | * |
| 1167 | * Sets the Nss per vdev type based on INI |
| 1168 | * |
| 1169 | * Return: None |
| 1170 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1171 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1172 | { |
| 1173 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1174 | uint8_t max_supp_nss = 1; |
| 1175 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1176 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1177 | max_supp_nss = 2; |
| 1178 | |
| 1179 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1180 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1181 | |
| 1182 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1183 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1184 | } |
| 1185 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1186 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1187 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1188 | * @hdd_ctx: HDD context |
| 1189 | * |
| 1190 | * Updates wiphy vhtcap fields |
| 1191 | * |
| 1192 | * Return: None |
| 1193 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1194 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1195 | { |
| 1196 | struct ieee80211_supported_band *band_5g = |
| 1197 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1198 | uint32_t val; |
| 1199 | |
| 1200 | if (!band_5g) { |
| 1201 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1202 | return; |
| 1203 | } |
| 1204 | |
| 1205 | val = hdd_ctx->config->txBFCsnValue; |
| 1206 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1207 | |
| 1208 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1209 | band_5g->vht_cap.cap |= |
| 1210 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1211 | |
| 1212 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1213 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1214 | } |
| 1215 | |
| 1216 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1217 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1218 | * @hdd_ctx: HDD context |
| 1219 | * |
| 1220 | * Sets the DBS capability as per INI and firmware capability |
| 1221 | * |
| 1222 | * Return: None |
| 1223 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1224 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1225 | { |
| 1226 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1227 | uint8_t hw_dbs_capable = 0; |
| 1228 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1229 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1230 | ((cfg_ini->dual_mac_feature_disable == |
| 1231 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1232 | (cfg_ini->dual_mac_feature_disable == |
| 1233 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1234 | hw_dbs_capable = 1; |
| 1235 | |
| 1236 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1237 | } |
| 1238 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1239 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | struct wma_tgt_ht_cap *cfg) |
| 1241 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1242 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | uint32_t value, val32; |
| 1244 | uint16_t val16; |
| 1245 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1246 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1247 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1248 | uint8_t enable_tx_stbc; |
| 1249 | |
| 1250 | /* check and update RX STBC */ |
| 1251 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1252 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1253 | |
| 1254 | /* get the MPDU density */ |
| 1255 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1256 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1257 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1258 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1259 | value = 0; |
| 1260 | } |
| 1261 | |
| 1262 | /* |
| 1263 | * MPDU density: |
| 1264 | * override user's setting if value is larger |
| 1265 | * than the one supported by target |
| 1266 | */ |
| 1267 | if (value > cfg->mpdu_density) { |
| 1268 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1269 | cfg->mpdu_density); |
| 1270 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1271 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1272 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1273 | } |
| 1274 | |
| 1275 | /* get the HT capability info */ |
| 1276 | 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] | 1277 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1278 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1279 | return; |
| 1280 | } |
| 1281 | val16 = (uint16_t) val32; |
| 1282 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1283 | |
| 1284 | /* Set the LDPC capability */ |
| 1285 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1286 | |
| 1287 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1288 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1289 | |
| 1290 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1291 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1292 | |
| 1293 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1294 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1295 | |
| 1296 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1297 | |
| 1298 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1299 | pconfig->enable2x2 = 1; |
| 1300 | } else { |
| 1301 | pconfig->enable2x2 = 0; |
| 1302 | enable_tx_stbc = 0; |
| 1303 | |
| 1304 | /* 1x1 */ |
| 1305 | /* Update Rx Highest Long GI data Rate */ |
| 1306 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1307 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1308 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1309 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1310 | 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] | 1311 | } |
| 1312 | |
| 1313 | /* Update Tx Highest Long GI data Rate */ |
| 1314 | if (sme_cfg_set_int |
| 1315 | (hdd_ctx->hHal, |
| 1316 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1317 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1318 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1319 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1320 | } |
| 1321 | } |
| 1322 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1323 | enable_tx_stbc = 0; |
| 1324 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1325 | |
| 1326 | val32 = val16; |
| 1327 | 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] | 1328 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1329 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1331 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1332 | 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] | 1333 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1334 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1335 | |
| 1336 | if (pconfig->enable2x2) { |
| 1337 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1338 | mcs_set[value] = |
| 1339 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1340 | |
| 1341 | status = |
| 1342 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1343 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1344 | mcs_set, |
| 1345 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1346 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1347 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | } |
| 1349 | } |
| 1350 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1351 | } |
| 1352 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1353 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1354 | struct wma_tgt_vht_cap *cfg) |
| 1355 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1356 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1357 | uint32_t value = 0; |
| 1358 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1359 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1360 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1361 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1362 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1363 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1364 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1365 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1366 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1367 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1368 | return; |
| 1369 | } |
| 1370 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1371 | /* Get the current MPDU length */ |
| 1372 | status = |
| 1373 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1374 | &value); |
| 1375 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1376 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1377 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1378 | value = 0; |
| 1379 | } |
| 1380 | |
| 1381 | /* |
| 1382 | * VHT max MPDU length: |
| 1383 | * override if user configured value is too high |
| 1384 | * that the target cannot support |
| 1385 | */ |
| 1386 | if (value > cfg->vht_max_mpdu) { |
| 1387 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1388 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1389 | cfg->vht_max_mpdu); |
| 1390 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1391 | if (status == QDF_STATUS_E_FAILURE) |
| 1392 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1393 | } |
| 1394 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1395 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1396 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1397 | |
| 1398 | if (pconfig->enable2x2) |
| 1399 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1400 | |
| 1401 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1402 | QDF_STATUS_E_FAILURE) { |
| 1403 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1404 | } |
| 1405 | |
| 1406 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1407 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1408 | if (pconfig->enable2x2) |
| 1409 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1410 | |
| 1411 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1412 | QDF_STATUS_E_FAILURE) { |
| 1413 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1414 | } |
| 1415 | |
| 1416 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1417 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1418 | if (pconfig->enable2x2) |
| 1419 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1420 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1421 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1422 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1423 | |
| 1424 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1425 | QDF_STATUS_E_FAILURE) { |
| 1426 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1427 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1429 | 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] | 1430 | &value); |
| 1431 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1432 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1433 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1434 | value = 0; |
| 1435 | } |
| 1436 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1437 | /* Set HW RX LDPC capability */ |
| 1438 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1439 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1441 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1442 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1443 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1444 | if (status == QDF_STATUS_E_FAILURE) |
| 1445 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | /* Get current GI 80 value */ |
| 1449 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1450 | &value); |
| 1451 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1452 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1453 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | value = 0; |
| 1455 | } |
| 1456 | |
| 1457 | /* set the Guard interval 80MHz */ |
| 1458 | if (value && !cfg->vht_short_gi_80) { |
| 1459 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1460 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1461 | cfg->vht_short_gi_80); |
| 1462 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1463 | if (status == QDF_STATUS_E_FAILURE) |
| 1464 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | } |
| 1466 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1467 | /* Get VHT TX STBC cap */ |
| 1468 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1469 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1470 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1471 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | value = 0; |
| 1473 | } |
| 1474 | |
| 1475 | /* VHT TX STBC cap */ |
| 1476 | if (value && !cfg->vht_tx_stbc) { |
| 1477 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1478 | cfg->vht_tx_stbc); |
| 1479 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1480 | if (status == QDF_STATUS_E_FAILURE) |
| 1481 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | /* Get VHT RX STBC cap */ |
| 1485 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1486 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1487 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1488 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1489 | value = 0; |
| 1490 | } |
| 1491 | |
| 1492 | /* VHT RX STBC cap */ |
| 1493 | if (value && !cfg->vht_rx_stbc) { |
| 1494 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1495 | cfg->vht_rx_stbc); |
| 1496 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1497 | if (status == QDF_STATUS_E_FAILURE) |
| 1498 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1499 | } |
| 1500 | |
| 1501 | /* Get VHT SU Beamformer cap */ |
| 1502 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1503 | &value); |
| 1504 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1505 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1506 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1507 | value = 0; |
| 1508 | } |
| 1509 | |
| 1510 | /* set VHT SU Beamformer cap */ |
| 1511 | if (value && !cfg->vht_su_bformer) { |
| 1512 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1513 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1514 | cfg->vht_su_bformer); |
| 1515 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1516 | if (status == QDF_STATUS_E_FAILURE) |
| 1517 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | } |
| 1519 | |
| 1520 | /* check and update SU BEAMFORMEE capabality */ |
| 1521 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1522 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1523 | |
| 1524 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1525 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1526 | pconfig->enableTxBF); |
| 1527 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1528 | if (status == QDF_STATUS_E_FAILURE) |
| 1529 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1530 | |
| 1531 | /* Get VHT MU Beamformer cap */ |
| 1532 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1533 | &value); |
| 1534 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1535 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1536 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1537 | value = 0; |
| 1538 | } |
| 1539 | |
| 1540 | /* set VHT MU Beamformer cap */ |
| 1541 | if (value && !cfg->vht_mu_bformer) { |
| 1542 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1543 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1544 | cfg->vht_mu_bformer); |
| 1545 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1546 | if (status == QDF_STATUS_E_FAILURE) |
| 1547 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | } |
| 1549 | |
| 1550 | /* Get VHT MU Beamformee cap */ |
| 1551 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1552 | &value); |
| 1553 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1554 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1555 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1556 | value = 0; |
| 1557 | } |
| 1558 | |
| 1559 | /* set VHT MU Beamformee cap */ |
| 1560 | if (value && !cfg->vht_mu_bformee) { |
| 1561 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1562 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1563 | cfg->vht_mu_bformee); |
| 1564 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1565 | if (status == QDF_STATUS_E_FAILURE) |
| 1566 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | /* Get VHT MAX AMPDU Len exp */ |
| 1570 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1571 | &value); |
| 1572 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1573 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1574 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | value = 0; |
| 1576 | } |
| 1577 | |
| 1578 | /* |
| 1579 | * VHT max AMPDU len exp: |
| 1580 | * override if user configured value is too high |
| 1581 | * that the target cannot support. |
| 1582 | * Even though Rome publish ampdu_len=7, it can |
| 1583 | * only support 4 because of some h/w bug. |
| 1584 | */ |
| 1585 | |
| 1586 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1587 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1588 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1589 | cfg->vht_max_ampdu_len_exp); |
| 1590 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1591 | if (status == QDF_STATUS_E_FAILURE) |
| 1592 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | } |
| 1594 | |
| 1595 | /* Get VHT TXOP PS CAP */ |
| 1596 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1597 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1598 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1599 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | value = 0; |
| 1601 | } |
| 1602 | |
| 1603 | /* set VHT TXOP PS cap */ |
| 1604 | if (value && !cfg->vht_txop_ps) { |
| 1605 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1606 | cfg->vht_txop_ps); |
| 1607 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1608 | if (status == QDF_STATUS_E_FAILURE) |
| 1609 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1610 | } |
| 1611 | |
| 1612 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1613 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1614 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1615 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1616 | else |
| 1617 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1618 | |
| 1619 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1620 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1621 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1622 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1623 | VHT_CAP_160_AND_80P80_SUPP); |
| 1624 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1625 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1626 | band_5g->vht_cap.cap |= |
| 1627 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1628 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1629 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1630 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1631 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1632 | VHT_CAP_160_SUPP); |
| 1633 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1634 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | band_5g->vht_cap.cap |= |
| 1636 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1637 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1638 | } |
| 1639 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1640 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1641 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1642 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1643 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1644 | &value); |
| 1645 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1646 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1647 | value = 0; |
| 1648 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1649 | /* set the Guard interval 160MHz */ |
| 1650 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1651 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1652 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1653 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1654 | |
| 1655 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1656 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1657 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1658 | |
| 1659 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1660 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1661 | |
| 1662 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1663 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1664 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1665 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1666 | |
| 1667 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1668 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1669 | |
| 1670 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1671 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1672 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1673 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1674 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1675 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1676 | |
| 1677 | band_5g->vht_cap.cap |= |
| 1678 | (cfg->vht_max_ampdu_len_exp << |
| 1679 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1680 | |
| 1681 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1682 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1683 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1684 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1685 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1686 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1687 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1688 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1689 | |
| 1690 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1691 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1692 | |
| 1693 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1694 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1695 | /** |
| 1696 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1697 | * @hdd_ctx: Pointer to the HDD context |
| 1698 | * |
| 1699 | * Auto-generate mac address using device serial number. |
| 1700 | * Keep the first 3 bytes of OUI as before and replace |
| 1701 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1702 | * |
| 1703 | * Return: 0 for success |
| 1704 | * Non zero failure code for errors |
| 1705 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1706 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1707 | { |
| 1708 | unsigned int serialno = 0; |
| 1709 | struct qdf_mac_addr mac_addr = { |
| 1710 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1711 | }; |
| 1712 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1713 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1714 | if (serialno == 0) |
| 1715 | return -EINVAL; |
| 1716 | |
| 1717 | serialno &= 0x00ffffff; |
| 1718 | |
| 1719 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1720 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1721 | mac_addr.bytes[5] = serialno & 0xff; |
| 1722 | |
| 1723 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1724 | return 0; |
| 1725 | } |
| 1726 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1727 | /** |
| 1728 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1729 | * configuration to cfg_ini in HDD |
| 1730 | * @hdd_ctx: Pointer to hdd_ctx |
| 1731 | * @cfg: target configuration |
| 1732 | * |
| 1733 | * Return: None |
| 1734 | */ |
| 1735 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1736 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1737 | struct wma_tgt_cfg *cfg) |
| 1738 | { |
| 1739 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1740 | } |
| 1741 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1742 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1743 | struct wma_tgt_cfg *cfg) |
| 1744 | { |
| 1745 | } |
| 1746 | #endif |
| 1747 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1748 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1749 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1750 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1751 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1752 | struct wma_tgt_cfg *cfg = param; |
| 1753 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1754 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1755 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1756 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1757 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1758 | if (ret) { |
| 1759 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1760 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1761 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1762 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1763 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1764 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1765 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1766 | if (cds_cfg) { |
| 1767 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1768 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1769 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1770 | cds_cfg->sub_20_channel_width = |
| 1771 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1772 | } else { |
| 1773 | cds_cfg->sub_20_channel_width = |
| 1774 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1775 | } |
| 1776 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1777 | |
| 1778 | /* first store the INI band capability */ |
| 1779 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1780 | |
| 1781 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1782 | hdd_ctx->is_fils_roaming_supported = |
| 1783 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1785 | /* |
| 1786 | * now overwrite the target band capability with INI |
| 1787 | * setting if INI setting is a subset |
| 1788 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1790 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1791 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1792 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1793 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1794 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1795 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1796 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1797 | } |
| 1798 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1799 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1800 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1801 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1802 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1803 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1804 | } |
| 1805 | |
| 1806 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1807 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1808 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1809 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1810 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1811 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1812 | static struct qdf_mac_addr default_mac_addr = { |
| 1813 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1814 | }; |
| 1815 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1816 | &default_mac_addr)) { |
| 1817 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1818 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1819 | MAC_ADDRESS_STR, |
| 1820 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1821 | intfMacAddr[0].bytes)); |
| 1822 | } else { |
| 1823 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1824 | MAC_ADDRESS_STR, |
| 1825 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1826 | intfMacAddr[0].bytes)); |
| 1827 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1828 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1829 | } |
| 1830 | |
| 1831 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1832 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1833 | |
| 1834 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1835 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1836 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1837 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1838 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1839 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1840 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1841 | |
| 1842 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1843 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1844 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1845 | if (cfg->services.en_11ax) { |
| 1846 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1847 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1848 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1849 | |
| 1850 | hdd_update_vdev_nss(hdd_ctx); |
| 1851 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1852 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1853 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1854 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1855 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1856 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1857 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1858 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1859 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1860 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1861 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1862 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1863 | hdd_ctx->current_antenna_mode); |
| 1864 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1865 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1866 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1867 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1868 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1869 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1870 | if ((hdd_ctx->config->txBFCsnValue > |
| 1871 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1872 | !cfg->tx_bfee_8ss_enabled) |
| 1873 | hdd_ctx->config->txBFCsnValue = |
| 1874 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1875 | |
| 1876 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1877 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1878 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1879 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1880 | |
| 1881 | |
| 1882 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1883 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1884 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1885 | |
| 1886 | /* |
| 1887 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1888 | */ |
| 1889 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1890 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1891 | /* |
| 1892 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1893 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1894 | * configure the STA mode wow pattern. |
| 1895 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1896 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1897 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1898 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1899 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1900 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1901 | /* |
| 1902 | * This needs to be done after HDD pdev is created and stored since |
| 1903 | * it will access the HDD pdev object lock. |
| 1904 | */ |
| 1905 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1906 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1907 | /* Configure NAN datapath features */ |
| 1908 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1909 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 1910 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | } |
| 1912 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1913 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1915 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1916 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1917 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1918 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1919 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1920 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1921 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1922 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1924 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1925 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1926 | |
| 1927 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1928 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1929 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 1930 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1931 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 1932 | true; |
| 1933 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1934 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1935 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1937 | |
| 1938 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1939 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1940 | |
| 1941 | /** |
| 1942 | * hdd_is_valid_mac_address() - validate MAC address |
| 1943 | * @pMacAddr: Pointer to the input MAC address |
| 1944 | * |
| 1945 | * This function validates whether the given MAC address is valid or not |
| 1946 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1947 | * where X is the hexa decimal digit character and separated by ':' |
| 1948 | * This algorithm works even if MAC address is not separated by ':' |
| 1949 | * |
| 1950 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1951 | * digits and a separator colon : appears in the input string only after |
| 1952 | * an even number of hex digits. |
| 1953 | * |
| 1954 | * Return: 1 for valid and 0 for invalid |
| 1955 | */ |
| 1956 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1957 | { |
| 1958 | int xdigit = 0; |
| 1959 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1960 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1961 | while (*pMacAddr) { |
| 1962 | if (isxdigit(*pMacAddr)) { |
| 1963 | xdigit++; |
| 1964 | } else if (':' == *pMacAddr) { |
| 1965 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1966 | break; |
| 1967 | |
| 1968 | ++separator; |
| 1969 | } else { |
| 1970 | /* Invalid MAC found */ |
| 1971 | return 0; |
| 1972 | } |
| 1973 | ++pMacAddr; |
| 1974 | } |
| 1975 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1976 | } |
| 1977 | |
| 1978 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1979 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1980 | * @dev: Handle to struct net_device to be updated. |
| 1981 | * |
| 1982 | * Return: None |
| 1983 | */ |
| 1984 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1985 | { |
| 1986 | dev->header_ops = NULL; |
| 1987 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1988 | dev->hard_header_len = ETH_HLEN; |
| 1989 | dev->mtu = ETH_DATA_LEN; |
| 1990 | dev->addr_len = ETH_ALEN; |
| 1991 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1992 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1993 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1994 | |
| 1995 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1996 | } |
| 1997 | |
| 1998 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1999 | * __hdd__mon_open() - HDD Open function |
| 2000 | * @dev: Pointer to net_device structure |
| 2001 | * |
| 2002 | * This is called in response to ifconfig up |
| 2003 | * |
| 2004 | * Return: 0 for success; non-zero for failure |
| 2005 | */ |
| 2006 | static int __hdd_mon_open(struct net_device *dev) |
| 2007 | { |
| 2008 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2009 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2010 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2011 | |
| 2012 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2013 | |
| 2014 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2015 | if (ret) |
| 2016 | return ret; |
| 2017 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2018 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2019 | |
| 2020 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2021 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2022 | if (ret) { |
| 2023 | hdd_err("Failed to start WLAN modules return"); |
| 2024 | return ret; |
| 2025 | } |
| 2026 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2027 | |
| 2028 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2029 | ret = hdd_start_adapter(adapter); |
| 2030 | if (ret) { |
| 2031 | hdd_err("Failed to start adapter :%d", |
| 2032 | adapter->device_mode); |
| 2033 | return ret; |
| 2034 | } |
| 2035 | hdd_err("hdd_start_adapters() successful !"); |
| 2036 | } |
| 2037 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2038 | } |
| 2039 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2040 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2041 | |
| 2042 | if (!ret) |
| 2043 | ret = hdd_enable_monitor_mode(dev); |
| 2044 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2045 | return ret; |
| 2046 | } |
| 2047 | |
| 2048 | /** |
| 2049 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2050 | * @dev: Pointer to net_device structure |
| 2051 | * |
| 2052 | * This is called in response to ifconfig up |
| 2053 | * |
| 2054 | * Return: 0 for success; non-zero for failure |
| 2055 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2056 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2057 | { |
| 2058 | int ret; |
| 2059 | |
| 2060 | cds_ssr_protect(__func__); |
| 2061 | ret = __hdd_mon_open(dev); |
| 2062 | cds_ssr_unprotect(__func__); |
| 2063 | |
| 2064 | return ret; |
| 2065 | } |
| 2066 | |
| 2067 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2068 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2069 | * @adapter: pointer to HDD adapter |
| 2070 | * |
| 2071 | * This function is called to start the device specific adapter for |
| 2072 | * the mode passed in the adapter's device_mode. |
| 2073 | * |
| 2074 | * Return: 0 for success; non-zero for failure |
| 2075 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2076 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2077 | { |
| 2078 | |
| 2079 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2080 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2081 | |
| 2082 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2083 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2084 | |
| 2085 | switch (device_mode) { |
| 2086 | case QDF_P2P_CLIENT_MODE: |
| 2087 | case QDF_P2P_DEVICE_MODE: |
| 2088 | case QDF_OCB_MODE: |
| 2089 | case QDF_STA_MODE: |
| 2090 | case QDF_MONITOR_MODE: |
| 2091 | ret = hdd_start_station_adapter(adapter); |
| 2092 | if (ret) |
| 2093 | goto err_start_adapter; |
| 2094 | break; |
| 2095 | case QDF_P2P_GO_MODE: |
| 2096 | case QDF_SAP_MODE: |
| 2097 | ret = hdd_start_ap_adapter(adapter); |
| 2098 | if (ret) |
| 2099 | goto err_start_adapter; |
| 2100 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2101 | case QDF_IBSS_MODE: |
| 2102 | /* |
| 2103 | * For IBSS interface is initialized as part of |
| 2104 | * hdd_init_station_mode() |
| 2105 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2106 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2107 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2108 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2109 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2110 | default: |
| 2111 | hdd_err("Invalid session type %d", device_mode); |
| 2112 | QDF_ASSERT(0); |
| 2113 | goto err_start_adapter; |
| 2114 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2115 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2116 | if (hdd_set_fw_params(adapter)) |
| 2117 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2118 | |
| 2119 | /* |
| 2120 | * Action frame registered in one adapter which will |
| 2121 | * applicable to all interfaces |
| 2122 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2123 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2124 | if (ret < 0) { |
| 2125 | hdd_err("Failed to register frames - ret %d", ret); |
| 2126 | goto err_start_adapter; |
| 2127 | } |
| 2128 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2129 | exit_with_success: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2130 | EXIT(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2131 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2132 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2133 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2134 | err_start_adapter: |
| 2135 | return -EINVAL; |
| 2136 | } |
| 2137 | |
| 2138 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2139 | * hdd_enable_power_management() - API to Enable Power Management |
| 2140 | * |
| 2141 | * API invokes Bus Interface Layer power management functionality |
| 2142 | * |
| 2143 | * Return: None |
| 2144 | */ |
| 2145 | static void hdd_enable_power_management(void) |
| 2146 | { |
| 2147 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2148 | |
| 2149 | if (!hif_ctx) { |
| 2150 | hdd_err("Bus Interface Context is Invalid"); |
| 2151 | return; |
| 2152 | } |
| 2153 | |
| 2154 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2155 | } |
| 2156 | |
| 2157 | /** |
| 2158 | * hdd_disable_power_management() - API to disable Power Management |
| 2159 | * |
| 2160 | * API disable Bus Interface Layer Power management functionality |
| 2161 | * |
| 2162 | * Return: None |
| 2163 | */ |
| 2164 | static void hdd_disable_power_management(void) |
| 2165 | { |
| 2166 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2167 | |
| 2168 | if (!hif_ctx) { |
| 2169 | hdd_err("Bus Interface Context is Invalid"); |
| 2170 | return; |
| 2171 | } |
| 2172 | |
| 2173 | hif_disable_power_management(hif_ctx); |
| 2174 | } |
| 2175 | |
| 2176 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2177 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2178 | * |
| 2179 | * API to update the HW and SW information in the driver |
| 2180 | * |
| 2181 | * Return: None |
| 2182 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2183 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2184 | { |
| 2185 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2186 | size_t target_hw_name_len; |
| 2187 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2188 | |
| 2189 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2190 | if (!hif_sc) { |
| 2191 | hdd_err("HIF context is NULL"); |
| 2192 | return; |
| 2193 | } |
| 2194 | |
| 2195 | /* |
| 2196 | * target hw version/revision would only be retrieved after firmware |
| 2197 | * download |
| 2198 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2199 | hif_get_hw_info(hif_sc, |
| 2200 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2201 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2202 | &target_hw_name); |
| 2203 | |
| 2204 | if (hdd_ctx->target_hw_name) |
| 2205 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2206 | |
| 2207 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2208 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2209 | if (hdd_ctx->target_hw_name) |
| 2210 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2211 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2212 | |
| 2213 | /* Get the wlan hw/fw version */ |
| 2214 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2215 | } |
| 2216 | |
| 2217 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2218 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2219 | * @hdd_ctx: Pointer to hdd context |
| 2220 | * |
| 2221 | * Return: none |
| 2222 | */ |
| 2223 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2224 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2225 | { |
| 2226 | uint8_t num_entries = 0; |
| 2227 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2228 | uint8_t *tx_sched_wrr_ac; |
| 2229 | int i; |
| 2230 | cds_context_type *cds_ctx; |
| 2231 | |
| 2232 | if (NULL == hdd_ctx) |
| 2233 | return; |
| 2234 | |
| 2235 | if (NULL == hdd_ctx->config) { |
| 2236 | /* Do nothing if hdd_ctx is invalid */ |
| 2237 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2238 | return; |
| 2239 | } |
| 2240 | |
| 2241 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2242 | |
| 2243 | if (!cds_ctx) { |
| 2244 | hdd_err("Invalid CDS Context"); |
| 2245 | return; |
| 2246 | } |
| 2247 | |
| 2248 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2249 | switch (i) { |
| 2250 | case OL_TX_WMM_AC_BE: |
| 2251 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2252 | break; |
| 2253 | case OL_TX_WMM_AC_BK: |
| 2254 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2255 | break; |
| 2256 | case OL_TX_WMM_AC_VI: |
| 2257 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2258 | break; |
| 2259 | case OL_TX_WMM_AC_VO: |
| 2260 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2261 | break; |
| 2262 | default: |
| 2263 | tx_sched_wrr_ac = NULL; |
| 2264 | break; |
| 2265 | } |
| 2266 | |
| 2267 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2268 | tx_sched_wrr_param, |
| 2269 | &num_entries, |
| 2270 | sizeof(tx_sched_wrr_param)); |
| 2271 | |
| 2272 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2273 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2274 | tx_sched_wrr_param[0]; |
| 2275 | cds_ctx->ac_specs[i].credit_threshold = |
| 2276 | tx_sched_wrr_param[1]; |
| 2277 | cds_ctx->ac_specs[i].send_limit = |
| 2278 | tx_sched_wrr_param[2]; |
| 2279 | cds_ctx->ac_specs[i].credit_reserve = |
| 2280 | tx_sched_wrr_param[3]; |
| 2281 | cds_ctx->ac_specs[i].discard_weight = |
| 2282 | tx_sched_wrr_param[4]; |
| 2283 | } |
| 2284 | |
| 2285 | num_entries = 0; |
| 2286 | } |
| 2287 | } |
| 2288 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2289 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2290 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2291 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2292 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2293 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2294 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2295 | |
| 2296 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2297 | if (!adapter) { |
| 2298 | hdd_err("Adapter is NULL"); |
| 2299 | return PM_MAX_NUM_OF_MODE; |
| 2300 | } |
| 2301 | |
| 2302 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2303 | adapter->device_mode); |
| 2304 | } |
| 2305 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2306 | static void hdd_register_policy_manager_callback( |
| 2307 | struct wlan_objmgr_psoc *psoc) |
| 2308 | { |
| 2309 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2310 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2311 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2312 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2313 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2314 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2315 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2316 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2317 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2318 | if (QDF_STATUS_SUCCESS != |
| 2319 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2320 | hdd_err("HDD callback registration with policy manager failed"); |
| 2321 | } |
| 2322 | } |
| 2323 | #else |
| 2324 | static void hdd_register_policy_manager_callback( |
| 2325 | struct wlan_objmgr_psoc *psoc) |
| 2326 | { |
| 2327 | } |
| 2328 | #endif |
| 2329 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2330 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2331 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2332 | { |
| 2333 | struct nan_callbacks cb_obj = {0}; |
| 2334 | |
| 2335 | cb_obj.ndi_open = hdd_ndi_open; |
| 2336 | cb_obj.ndi_close = hdd_ndi_close; |
| 2337 | cb_obj.ndi_start = hdd_ndi_start; |
| 2338 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2339 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2340 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2341 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2342 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2343 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2344 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2345 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2346 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2347 | } |
| 2348 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2349 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2350 | { |
| 2351 | } |
| 2352 | #endif |
| 2353 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2354 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2355 | /** |
| 2356 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2357 | * |
| 2358 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2359 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2360 | * |
| 2361 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2362 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2363 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2364 | * fixed. |
| 2365 | * |
| 2366 | * Return: None |
| 2367 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2368 | static void hdd_check_for_leaks(void) |
| 2369 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2370 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2371 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2372 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2373 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2374 | } |
| 2375 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2376 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2377 | #else |
| 2378 | static inline void hdd_check_for_leaks(void) {} |
| 2379 | |
| 2380 | #define hdd_debug_domain_set(domain) |
| 2381 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2382 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2383 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2384 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2385 | * @hdd_ctx: HDD context |
| 2386 | * @adapter: HDD adapter |
| 2387 | * @reinit: flag to indicate from SSR or normal path |
| 2388 | * |
| 2389 | * This function maintains the driver state machine it will be invoked from |
| 2390 | * startup, reinit and change interface. Depending on the driver state shall |
| 2391 | * perform the opening of the modules. |
| 2392 | * |
| 2393 | * Return: 0 for success; non-zero for failure |
| 2394 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2395 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2396 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2397 | bool reinit) |
| 2398 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2399 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2400 | qdf_device_t qdf_dev; |
| 2401 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2402 | bool unint = false; |
| 2403 | void *hif_ctx; |
| 2404 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2405 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2406 | |
| 2407 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2408 | if (!qdf_dev) { |
| 2409 | hdd_err("QDF Device Context is Invalid return"); |
| 2410 | return -EINVAL; |
| 2411 | } |
| 2412 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2413 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2414 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2415 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2416 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2417 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2418 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2419 | hdd_info("Driver modules already Enabled"); |
| 2420 | EXIT(); |
| 2421 | return 0; |
| 2422 | } |
| 2423 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2424 | hdd_ctx->start_modules_in_progress = true; |
| 2425 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2426 | switch (hdd_ctx->driver_status) { |
| 2427 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2428 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2429 | unint = true; |
| 2430 | /* Fall through dont add break here */ |
| 2431 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2432 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2433 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2434 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2435 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2436 | if (!reinit && !unint) { |
| 2437 | ret = pld_power_on(qdf_dev->dev); |
| 2438 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2439 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2440 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2441 | goto release_lock; |
| 2442 | } |
| 2443 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2444 | |
| 2445 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2446 | hdd_ctx->config->enable_fw_log); |
| 2447 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2448 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2449 | qdf_dev->bus_type, |
| 2450 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2451 | HIF_ENABLE_TYPE_PROBE); |
| 2452 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2453 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2454 | goto power_down; |
| 2455 | } |
| 2456 | |
| 2457 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2458 | if (!hif_ctx) { |
| 2459 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2460 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2461 | goto power_down; |
| 2462 | } |
| 2463 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2464 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2465 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2466 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2467 | status); |
| 2468 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2469 | goto hif_close; |
| 2470 | } |
| 2471 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2472 | ret = hdd_update_config(hdd_ctx); |
| 2473 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2474 | hdd_err("Failed to update configuration; errno: %d", |
| 2475 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2476 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2477 | } |
| 2478 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2479 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2480 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2481 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2482 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2483 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2484 | ret = qdf_status_to_os_return(status); |
| 2485 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2486 | } |
| 2487 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2488 | /* initalize components configurations after psoc open */ |
| 2489 | ret = hdd_update_components_config(hdd_ctx); |
| 2490 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2491 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2492 | ret); |
| 2493 | goto close; |
| 2494 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2495 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2496 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2497 | hdd_err("Failed to Open cds post open; status: %d", |
| 2498 | status); |
| 2499 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2500 | goto close; |
| 2501 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2502 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2503 | /* |
| 2504 | * NAN compoenet requires certian operations like, open adapter, |
| 2505 | * close adapter, etc. to be initiated by HDD, for those |
| 2506 | * register HDD callbacks with UMAC's NAN componenet. |
| 2507 | */ |
| 2508 | hdd_nan_register_callbacks(hdd_ctx); |
| 2509 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2510 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2511 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2512 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2513 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2514 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2515 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2516 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2517 | } |
| 2518 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2519 | hdd_register_policy_manager_callback( |
| 2520 | hdd_ctx->hdd_psoc); |
| 2521 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2522 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2523 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2524 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2525 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2526 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2527 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2528 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2529 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2530 | hdd_ftm_mc_process_msg); |
| 2531 | break; |
| 2532 | } |
| 2533 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2534 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2535 | break; |
| 2536 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2537 | |
| 2538 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2539 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2540 | if (ret) { |
| 2541 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2542 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2543 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2544 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2545 | } |
| 2546 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2547 | /* Fall through dont add break here */ |
| 2548 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2549 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2550 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2551 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2552 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2553 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2554 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2555 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2556 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2557 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2558 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2559 | break; |
| 2560 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2561 | |
| 2562 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2563 | if (ret) { |
| 2564 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2565 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2566 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2567 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2568 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2569 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2570 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2571 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2572 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2573 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2574 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2575 | default: |
| 2576 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2577 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2578 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2579 | goto release_lock; |
| 2580 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2581 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2582 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2583 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2584 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2585 | EXIT(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2586 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2587 | return 0; |
| 2588 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2589 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2590 | cds_post_disable(); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2591 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2592 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2593 | cds_txrx_free: |
| 2594 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2595 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2596 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2597 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2598 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2599 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2600 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2601 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2602 | deinit_config: |
| 2603 | cds_deinit_ini_config(); |
| 2604 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2605 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2606 | ol_cds_free(); |
| 2607 | |
| 2608 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2609 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2610 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2611 | power_down: |
| 2612 | if (!reinit && !unint) |
| 2613 | pld_power_off(qdf_dev->dev); |
| 2614 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2615 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2616 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2617 | |
| 2618 | /* many adapter resources are not freed by design in SSR case */ |
| 2619 | if (!reinit) |
| 2620 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2621 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2622 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2623 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2624 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2625 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2626 | } |
| 2627 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2628 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2629 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2630 | { |
| 2631 | int ret = os_if_wifi_pos_register_nl(); |
| 2632 | |
| 2633 | if (ret) |
| 2634 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2635 | |
| 2636 | return ret; |
| 2637 | } |
| 2638 | |
| 2639 | static int hdd_deactivate_wifi_pos(void) |
| 2640 | { |
| 2641 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2642 | |
| 2643 | if (ret) |
| 2644 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2645 | |
| 2646 | return ret; |
| 2647 | } |
| 2648 | |
| 2649 | /** |
| 2650 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2651 | * @hdd_ctx: hdd context |
| 2652 | * |
| 2653 | * Return: status of operation |
| 2654 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2655 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2656 | { |
| 2657 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2658 | struct hdd_config *cfg = hdd_ctx->config; |
| 2659 | |
| 2660 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2661 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2662 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2663 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2664 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2665 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2666 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2667 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2668 | } |
| 2669 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2670 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2671 | { |
| 2672 | return oem_activate_service(hdd_ctx); |
| 2673 | } |
| 2674 | |
| 2675 | static int hdd_deactivate_wifi_pos(void) |
| 2676 | { |
| 2677 | return 0; |
| 2678 | } |
| 2679 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2680 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2681 | { |
| 2682 | } |
| 2683 | #endif |
| 2684 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2685 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2686 | * __hdd_open() - HDD Open function |
| 2687 | * @dev: Pointer to net_device structure |
| 2688 | * |
| 2689 | * This is called in response to ifconfig up |
| 2690 | * |
| 2691 | * Return: 0 for success; non-zero for failure |
| 2692 | */ |
| 2693 | static int __hdd_open(struct net_device *dev) |
| 2694 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2695 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2696 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2697 | int ret; |
| 2698 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2699 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2700 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2701 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2702 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2703 | /* Nothing to be done if device is unloading */ |
| 2704 | if (cds_is_driver_unloading()) { |
| 2705 | hdd_err("Driver is unloading can not open the hdd"); |
| 2706 | return -EBUSY; |
| 2707 | } |
| 2708 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2709 | if (cds_is_driver_recovering()) { |
| 2710 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2711 | return -EBUSY; |
| 2712 | } |
| 2713 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2714 | mutex_lock(&hdd_init_deinit_lock); |
| 2715 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2716 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2717 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2718 | /* |
| 2719 | * This scenario can be hit in cases where in the wlan driver after |
| 2720 | * registering the netdevices and there is a failure in driver |
| 2721 | * initialization. So return error gracefully because the netdevices |
| 2722 | * will be de-registered as part of the load failure. |
| 2723 | */ |
| 2724 | |
| 2725 | if (!cds_is_driver_loaded()) { |
| 2726 | hdd_err("Failed to start the wlan driver!!"); |
| 2727 | ret = -EIO; |
| 2728 | goto err_hdd_hdd_init_deinit_lock; |
| 2729 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2731 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2732 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2733 | if (ret) { |
| 2734 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2735 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2736 | } |
| 2737 | |
| 2738 | |
| 2739 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2740 | ret = hdd_start_adapter(adapter); |
| 2741 | if (ret) { |
| 2742 | hdd_err("Failed to start adapter :%d", |
| 2743 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2744 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2745 | } |
| 2746 | } |
| 2747 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2748 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2749 | 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] | 2750 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2751 | /* Enable TX queues only when we are connected */ |
| 2752 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2753 | WLAN_START_ALL_NETIF_QUEUE, |
| 2754 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2755 | } |
| 2756 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2757 | /* Enable carrier and transmit queues for NDI */ |
| 2758 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2759 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2760 | wlan_hdd_netif_queue_control(adapter, |
| 2761 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2762 | WLAN_CONTROL_PATH); |
| 2763 | } |
| 2764 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2765 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2766 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2767 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2768 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2769 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2770 | return ret; |
| 2771 | } |
| 2772 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2773 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2774 | /** |
| 2775 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2776 | * @dev: Pointer to net_device structure |
| 2777 | * |
| 2778 | * This is called in response to ifconfig up |
| 2779 | * |
| 2780 | * Return: 0 for success; non-zero for failure |
| 2781 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2782 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2783 | { |
| 2784 | int ret; |
| 2785 | |
| 2786 | cds_ssr_protect(__func__); |
| 2787 | ret = __hdd_open(dev); |
| 2788 | cds_ssr_unprotect(__func__); |
| 2789 | |
| 2790 | return ret; |
| 2791 | } |
| 2792 | |
| 2793 | /** |
| 2794 | * __hdd_stop() - HDD stop function |
| 2795 | * @dev: Pointer to net_device structure |
| 2796 | * |
| 2797 | * This is called in response to ifconfig down |
| 2798 | * |
| 2799 | * Return: 0 for success; non-zero for failure |
| 2800 | */ |
| 2801 | static int __hdd_stop(struct net_device *dev) |
| 2802 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2803 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2804 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2805 | int ret; |
| 2806 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2807 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2808 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2809 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2810 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2811 | |
| 2812 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2813 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2814 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2815 | |
| 2816 | /* Nothing to be done if the interface is not opened */ |
| 2817 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2818 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2819 | return -ENODEV; |
| 2820 | } |
| 2821 | |
| 2822 | /* Make sure the interface is marked as closed */ |
| 2823 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2824 | |
| 2825 | hdd_debug("Disabling Auto Power save timer"); |
| 2826 | sme_ps_disable_auto_ps_timer( |
| 2827 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2828 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2829 | |
| 2830 | /* |
| 2831 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2832 | * be called on that interface |
| 2833 | */ |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 2834 | hdd_notice("Disabling queues, adapter device mode: %s(%d)", |
| 2835 | hdd_device_mode_to_string(adapter->device_mode), |
| 2836 | adapter->device_mode); |
| 2837 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2838 | wlan_hdd_netif_queue_control(adapter, |
| 2839 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2840 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2841 | |
| 2842 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2843 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2844 | * bursty in nature and depends on the need to transfer. The service |
| 2845 | * layer may down the interface after the usage and up again when |
| 2846 | * required. In some sense, the NDI is expected to be available |
| 2847 | * (like SAP) iface until NDI delete request is issued by the service |
| 2848 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2849 | * interface (NDI). |
| 2850 | */ |
| 2851 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2852 | return 0; |
| 2853 | |
| 2854 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2855 | * The interface is marked as down for outside world (aka kernel) |
| 2856 | * But the driver is pretty much alive inside. The driver needs to |
| 2857 | * tear down the existing connection on the netdev (session) |
| 2858 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2859 | * for this interface. The call also needs to wait until the above |
| 2860 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2861 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2862 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2863 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2864 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2865 | |
| 2866 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2867 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2868 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2869 | |
| 2870 | /* |
| 2871 | * Find if any iface is up. If any iface is up then can't put device to |
| 2872 | * sleep/power save mode |
| 2873 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2874 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2875 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2876 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 2877 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2878 | hdd_prevent_suspend_timeout( |
| 2879 | hdd_ctx->config->iface_change_wait_time, |
| 2880 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2881 | } |
| 2882 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2883 | EXIT(); |
| 2884 | return 0; |
| 2885 | } |
| 2886 | |
| 2887 | /** |
| 2888 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2889 | * @dev: pointer to net_device structure |
| 2890 | * |
| 2891 | * This is called in response to ifconfig down |
| 2892 | * |
| 2893 | * Return: 0 for success and error number for failure |
| 2894 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2895 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2896 | { |
| 2897 | int ret; |
| 2898 | |
| 2899 | cds_ssr_protect(__func__); |
| 2900 | ret = __hdd_stop(dev); |
| 2901 | cds_ssr_unprotect(__func__); |
| 2902 | |
| 2903 | return ret; |
| 2904 | } |
| 2905 | |
| 2906 | /** |
| 2907 | * __hdd_uninit() - HDD uninit function |
| 2908 | * @dev: Pointer to net_device structure |
| 2909 | * |
| 2910 | * This is called during the netdev unregister to uninitialize all data |
| 2911 | * associated with the device |
| 2912 | * |
| 2913 | * Return: None |
| 2914 | */ |
| 2915 | static void __hdd_uninit(struct net_device *dev) |
| 2916 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2917 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2918 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2919 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2920 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2921 | |
| 2922 | do { |
| 2923 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2924 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2925 | break; |
| 2926 | } |
| 2927 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2928 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2929 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2930 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2931 | break; |
| 2932 | } |
| 2933 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2934 | if (dev != adapter->dev) |
| 2935 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2936 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2937 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2938 | |
| 2939 | /* after uninit our adapter structure will no longer be valid */ |
| 2940 | adapter->dev = NULL; |
| 2941 | adapter->magic = 0; |
| 2942 | } while (0); |
| 2943 | |
| 2944 | EXIT(); |
| 2945 | } |
| 2946 | |
| 2947 | /** |
| 2948 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2949 | * @dev: pointer to net_device structure |
| 2950 | * |
| 2951 | * This is called during the netdev unregister to uninitialize all data |
| 2952 | * associated with the device |
| 2953 | * |
| 2954 | * Return: none |
| 2955 | */ |
| 2956 | static void hdd_uninit(struct net_device *dev) |
| 2957 | { |
| 2958 | cds_ssr_protect(__func__); |
| 2959 | __hdd_uninit(dev); |
| 2960 | cds_ssr_unprotect(__func__); |
| 2961 | } |
| 2962 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2963 | static int hdd_open_cesium_nl_sock(void) |
| 2964 | { |
| 2965 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2966 | struct netlink_kernel_cfg cfg = { |
| 2967 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2968 | .input = NULL |
| 2969 | }; |
| 2970 | #endif |
| 2971 | int ret = 0; |
| 2972 | |
| 2973 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2974 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2975 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2976 | THIS_MODULE, |
| 2977 | #endif |
| 2978 | &cfg); |
| 2979 | #else |
| 2980 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2981 | WLAN_NLINK_MCAST_GRP_ID, |
| 2982 | NULL, NULL, THIS_MODULE); |
| 2983 | #endif |
| 2984 | |
| 2985 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2986 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2987 | ret = -ECONNREFUSED; |
| 2988 | } |
| 2989 | |
| 2990 | return ret; |
| 2991 | } |
| 2992 | |
| 2993 | static void hdd_close_cesium_nl_sock(void) |
| 2994 | { |
| 2995 | if (NULL != cesium_nl_srv_sock) { |
| 2996 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2997 | cesium_nl_srv_sock = NULL; |
| 2998 | } |
| 2999 | } |
| 3000 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3001 | /** |
| 3002 | * __hdd_set_mac_address() - set the user specified mac address |
| 3003 | * @dev: Pointer to the net device. |
| 3004 | * @addr: Pointer to the sockaddr. |
| 3005 | * |
| 3006 | * This function sets the user specified mac address using |
| 3007 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3008 | * |
| 3009 | * Return: 0 for success, non zero for failure |
| 3010 | */ |
| 3011 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3012 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3013 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3014 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3015 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3016 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | int ret; |
| 3018 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3019 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3020 | |
| 3021 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3022 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3023 | if (0 != ret) |
| 3024 | return ret; |
| 3025 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3026 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3027 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3028 | |
| 3029 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3030 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3031 | } |
| 3032 | |
| 3033 | /** |
| 3034 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3035 | * function from SSR |
| 3036 | * @dev: pointer to net_device structure |
| 3037 | * @addr: Pointer to the sockaddr |
| 3038 | * |
| 3039 | * This function sets the user specified mac address using |
| 3040 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3041 | * |
| 3042 | * Return: 0 for success. |
| 3043 | */ |
| 3044 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3045 | { |
| 3046 | int ret; |
| 3047 | |
| 3048 | cds_ssr_protect(__func__); |
| 3049 | ret = __hdd_set_mac_address(dev, addr); |
| 3050 | cds_ssr_unprotect(__func__); |
| 3051 | |
| 3052 | return ret; |
| 3053 | } |
| 3054 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3055 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3056 | { |
| 3057 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3058 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3059 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3060 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3061 | break; |
| 3062 | } |
| 3063 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3064 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3065 | return NULL; |
| 3066 | |
| 3067 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3068 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3069 | } |
| 3070 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3071 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3072 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | { |
| 3074 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3075 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3076 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3077 | if (!memcmp(releaseAddr, |
| 3078 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3079 | 6)) { |
| 3080 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3081 | break; |
| 3082 | } |
| 3083 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3084 | } |
| 3085 | |
| 3086 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3087 | /** |
| 3088 | * __hdd_set_multicast_list() - set the multicast address list |
| 3089 | * @dev: Pointer to the WLAN device. |
| 3090 | * @skb: Pointer to OS packet (sk_buff). |
| 3091 | * |
| 3092 | * This funciton sets the multicast address list. |
| 3093 | * |
| 3094 | * Return: None |
| 3095 | */ |
| 3096 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3097 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3098 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3099 | int i = 0, status; |
| 3100 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3101 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3102 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3103 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3104 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3105 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3106 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3107 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3108 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3110 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3111 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3112 | goto out; |
| 3113 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3114 | status = hdd_validate_adapter(adapter); |
| 3115 | if (status) |
| 3116 | goto out; |
| 3117 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3118 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3119 | hdd_err("%s: Driver module is closed", __func__); |
| 3120 | return; |
| 3121 | } |
| 3122 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3123 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3124 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3125 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3126 | goto out; |
| 3127 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3128 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3129 | /* Delete already configured multicast address list */ |
| 3130 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3131 | hdd_info("clear previously configured MC address list"); |
| 3132 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3133 | pmo_mc_list_change_notify); |
| 3134 | } |
| 3135 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3136 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3137 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3138 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3139 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | } else { |
| 3141 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3142 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3143 | 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] | 3144 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3145 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3146 | pmo_mc_list_change_notify); |
| 3147 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3149 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3150 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3151 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3152 | if (i == mc_count) |
| 3153 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3154 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3155 | 0, ETH_ALEN); |
| 3156 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3157 | ha->addr, ETH_ALEN); |
| 3158 | hdd_info("mlist[%d] = %pM", i, |
| 3159 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3160 | i++; |
| 3161 | } |
| 3162 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3163 | |
| 3164 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3165 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3166 | mc_list_request->count = mc_count; |
| 3167 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3168 | if (status == 0) { |
| 3169 | hdd_enable_mc_addr_filtering(adapter, |
| 3170 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3171 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3172 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3174 | out: |
| 3175 | if (mc_list_request) |
| 3176 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3177 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | } |
| 3179 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3180 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3181 | /** |
| 3182 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3183 | * @dev: pointer to net_device |
| 3184 | * |
| 3185 | * Return: none |
| 3186 | */ |
| 3187 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3188 | { |
| 3189 | cds_ssr_protect(__func__); |
| 3190 | __hdd_set_multicast_list(dev); |
| 3191 | cds_ssr_unprotect(__func__); |
| 3192 | } |
| 3193 | #endif |
| 3194 | |
| 3195 | /** |
| 3196 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3197 | * @dev: Pointer to the WLAN device. |
| 3198 | * @skb: Pointer to OS packet (sk_buff). |
| 3199 | * |
| 3200 | * This function is registered with the Linux OS for network |
| 3201 | * core to decide which queue to use first. |
| 3202 | * |
| 3203 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3204 | */ |
| 3205 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3206 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3207 | , void *accel_priv |
| 3208 | #endif |
| 3209 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3210 | , select_queue_fallback_t fallback |
| 3211 | #endif |
| 3212 | ) |
| 3213 | { |
| 3214 | return hdd_wmm_select_queue(dev, skb); |
| 3215 | } |
| 3216 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3217 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | .ndo_open = hdd_open, |
| 3219 | .ndo_stop = hdd_stop, |
| 3220 | .ndo_uninit = hdd_uninit, |
| 3221 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3222 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3223 | .ndo_get_stats = hdd_get_stats, |
| 3224 | .ndo_do_ioctl = hdd_ioctl, |
| 3225 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3226 | .ndo_select_queue = hdd_select_queue, |
| 3227 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3228 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3229 | #endif |
| 3230 | }; |
| 3231 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3232 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3233 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3234 | .ndo_open = hdd_mon_open, |
| 3235 | .ndo_stop = hdd_stop, |
| 3236 | .ndo_get_stats = hdd_get_stats, |
| 3237 | }; |
| 3238 | |
| 3239 | /** |
| 3240 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3241 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3242 | * Return: None |
| 3243 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3244 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3245 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3246 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3247 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3248 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3249 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3250 | } |
| 3251 | |
| 3252 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3253 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3254 | * @hdd_ctx: global hdd context |
| 3255 | * @macAddr: mac address to assign to the interface |
| 3256 | * @name: User-visible name of the interface |
| 3257 | * |
| 3258 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3259 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3260 | * |
| 3261 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3262 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3263 | 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] | 3264 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3265 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3266 | const char *name) |
| 3267 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3268 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3269 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3270 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3271 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | /* |
| 3273 | * cfg80211 initialization and registration.... |
| 3274 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3275 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3276 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3277 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3279 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3280 | hdd_mon_mode_ether_setup : ether_setup), |
| 3281 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3282 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3283 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | |
| 3285 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3286 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3288 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3289 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3290 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3291 | sizeof(sta_ctx->conn_info.staId), |
| 3292 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3293 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3294 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3295 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3296 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3297 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3298 | qdf_status = qdf_event_create( |
| 3299 | &adapter->qdf_session_open_event); |
| 3300 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3301 | hdd_err("Session open QDF event init failed!"); |
| 3302 | free_netdev(adapter->dev); |
| 3303 | return NULL; |
| 3304 | } |
| 3305 | |
| 3306 | qdf_status = qdf_event_create( |
| 3307 | &adapter->qdf_session_close_event); |
| 3308 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3309 | hdd_err("Session close QDF event init failed!"); |
| 3310 | free_netdev(adapter->dev); |
| 3311 | return NULL; |
| 3312 | } |
| 3313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3314 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3315 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | init_completion(&adapter->linkup_event_var); |
| 3317 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3318 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3319 | init_completion(&adapter->sta_authorized_event); |
| 3320 | init_completion(&adapter->offchannel_tx_event); |
| 3321 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3322 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3324 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3325 | |
| 3326 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3327 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3329 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3330 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3331 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3332 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3333 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3335 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3336 | |
| 3337 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3338 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3340 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3342 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3343 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3344 | hdd_set_station_ops(adapter->dev); |
| 3345 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3346 | hdd_dev_setup_destructor(dev); |
| 3347 | dev->ieee80211_ptr = &adapter->wdev; |
| 3348 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3349 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3350 | adapter->wdev.netdev = dev; |
| 3351 | /* set dev's parent to underlying device */ |
| 3352 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3353 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3354 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3356 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | } |
| 3358 | |
| 3359 | return adapter; |
| 3360 | } |
| 3361 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3362 | 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] | 3363 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3364 | struct net_device *dev = adapter->dev; |
| 3365 | int ret; |
| 3366 | |
| 3367 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3368 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3369 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3370 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3371 | |
| 3372 | ret = dev_alloc_name(dev, dev->name); |
| 3373 | if (ret < 0) { |
| 3374 | hdd_err( |
| 3375 | "unable to get dev name: %s, err = 0x%x", |
| 3376 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3377 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3378 | } |
| 3379 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3380 | |
| 3381 | ret = register_netdevice(dev); |
| 3382 | if (ret) { |
| 3383 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3384 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3385 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3386 | } |
| 3387 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3388 | ret = register_netdev(dev); |
| 3389 | if (ret) { |
| 3390 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3391 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3392 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | } |
| 3394 | } |
| 3395 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3396 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3397 | EXIT(); |
| 3398 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3399 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | } |
| 3401 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3402 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3403 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3404 | struct hdd_adapter *adapter; |
| 3405 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3406 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3407 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3408 | if (!hdd_ctx) { |
| 3409 | hdd_err("Invalid HDD_CTX"); |
| 3410 | return QDF_STATUS_E_FAILURE; |
| 3411 | } |
| 3412 | |
| 3413 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3414 | if (NULL == adapter) { |
| 3415 | hdd_err("NULL adapter"); |
| 3416 | return QDF_STATUS_E_INVAL; |
| 3417 | } |
| 3418 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3419 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3420 | hdd_debug("session %d opened", adapter->session_id); |
| 3421 | |
| 3422 | return QDF_STATUS_SUCCESS; |
| 3423 | } |
| 3424 | |
| 3425 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3426 | { |
| 3427 | struct hdd_adapter *adapter; |
| 3428 | struct hdd_context *hdd_ctx; |
| 3429 | |
| 3430 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3431 | if (!hdd_ctx) { |
| 3432 | hdd_err("Invalid HDD_CTX"); |
| 3433 | return QDF_STATUS_E_FAILURE; |
| 3434 | } |
| 3435 | |
| 3436 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3438 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3439 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | } |
| 3441 | |
| 3442 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3443 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3444 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3445 | } |
| 3446 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3447 | /* |
| 3448 | * For NAN Data interface, the close session results in the final |
| 3449 | * indication to the userspace |
| 3450 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3451 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3452 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3453 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3454 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3455 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3456 | /* |
| 3457 | * We can be blocked while waiting for scheduled work to be |
| 3458 | * flushed, and the adapter structure can potentially be freed, in |
| 3459 | * which case the magic will have been reset. So make sure the |
| 3460 | * magic is still good, and hence the adapter structure is still |
| 3461 | * valid, before signaling completion |
| 3462 | */ |
| 3463 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3464 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3465 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3466 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | } |
| 3468 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3469 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3470 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3471 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3472 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3473 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3474 | if (QDF_IS_STATUS_ERROR(status)) |
| 3475 | return qdf_status_to_os_return(status); |
| 3476 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3477 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3478 | if (QDF_IS_STATUS_ERROR(status)) |
| 3479 | return qdf_status_to_os_return(status); |
| 3480 | |
| 3481 | if (wma_capability_enhanced_mcast_filter()) |
| 3482 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3483 | else |
| 3484 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3485 | |
| 3486 | return qdf_status_to_os_return(status); |
| 3487 | } |
| 3488 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3489 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3490 | { |
| 3491 | QDF_STATUS status; |
| 3492 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3493 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3494 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3495 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3496 | vdev_id = adapter->session_id; |
| 3497 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3498 | |
| 3499 | /* vdev created sanity check */ |
| 3500 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3501 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3502 | return -EINVAL; |
| 3503 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3504 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3505 | /* |
| 3506 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3507 | * it has already asserted. vdev can be released directly. |
| 3508 | */ |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3509 | if (cds_is_driver_recovering()) { |
| 3510 | hdd_debug("SSR: silently release the vdev for session-id: %d", |
| 3511 | adapter->session_id); |
| 3512 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3513 | goto release_vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3514 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3515 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3516 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3517 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3518 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3519 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3520 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3521 | hdd_err("failed to close sme session: %d", status); |
| 3522 | return qdf_status_to_os_return(status); |
| 3523 | } |
| 3524 | |
| 3525 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3526 | status = qdf_wait_for_event_completion( |
| 3527 | &adapter->qdf_session_close_event, |
| 3528 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3529 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3530 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3531 | hdd_ndp_session_end_handler(adapter); |
| 3532 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3533 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3534 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3535 | hdd_err("timed out waiting for close sme session: %u", status); |
| 3536 | return -ETIMEDOUT; |
| 3537 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3538 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
| 3539 | return -EINVAL; |
| 3540 | } else { |
| 3541 | hdd_err("Failed to close sme session (%u)", status); |
| 3542 | return -EINVAL; |
| 3543 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3544 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3545 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3546 | /* do vdev logical destroy via objmgr */ |
| 3547 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3548 | if (errno) { |
| 3549 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3550 | return errno; |
| 3551 | } |
| 3552 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3553 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3554 | errno = hdd_objmgr_release_vdev(adapter); |
| 3555 | if (errno) { |
| 3556 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3557 | return errno; |
| 3558 | } |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3559 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3560 | |
| 3561 | return 0; |
| 3562 | } |
| 3563 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3564 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3565 | struct sme_session_params *session_param, |
| 3566 | csr_roam_completeCallback callback, |
| 3567 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3568 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3569 | uint32_t type; |
| 3570 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3571 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3572 | |
| 3573 | /* determine vdev (sub)type */ |
| 3574 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3575 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3576 | hdd_err("failed to get vdev type: %d", status); |
| 3577 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3579 | session_param->sme_session_id = adapter->session_id; |
| 3580 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3581 | session_param->type_of_persona = type; |
| 3582 | session_param->subtype_of_persona = sub_type; |
| 3583 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3584 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3585 | session_param->callback = callback; |
| 3586 | session_param->callback_ctx = callback_ctx; |
| 3587 | |
| 3588 | return 0; |
| 3589 | } |
| 3590 | |
| 3591 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3592 | csr_roam_completeCallback callback, void *ctx) |
| 3593 | { |
| 3594 | QDF_STATUS status; |
| 3595 | int errno; |
| 3596 | struct hdd_context *hdd_ctx; |
| 3597 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3598 | |
| 3599 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3600 | |
| 3601 | /* do vdev create via objmgr */ |
| 3602 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3603 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3604 | if (errno) { |
| 3605 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3606 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3607 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3608 | |
| 3609 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3610 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3611 | if (QDF_STATUS_SUCCESS != status) { |
| 3612 | hdd_err("failed to reinit session open event"); |
| 3613 | return -EINVAL; |
| 3614 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3615 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3616 | callback, ctx); |
| 3617 | if (errno) { |
| 3618 | hdd_err("failed to populating SME params"); |
| 3619 | goto objmgr_vdev_destroy_procedure; |
| 3620 | } |
| 3621 | |
| 3622 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3623 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3624 | hdd_err("failed to open sme session: %d", status); |
| 3625 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3626 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3627 | } |
| 3628 | |
| 3629 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3630 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3631 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3632 | if (QDF_STATUS_SUCCESS != status) { |
| 3633 | if (adapter->qdf_session_open_event.force_set) { |
| 3634 | /* |
| 3635 | * SSR/PDR has caused shutdown, which has forcefully |
| 3636 | * set the event. Return without the closing session. |
| 3637 | */ |
| 3638 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3639 | hdd_err("Session open event forcefully set"); |
| 3640 | return -EINVAL; |
| 3641 | } else { |
| 3642 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3643 | hdd_err("Session failed to open within timeout period"); |
| 3644 | else |
| 3645 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3646 | status); |
| 3647 | errno = -ETIMEDOUT; |
| 3648 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3649 | goto hdd_vdev_destroy_procedure; |
| 3650 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3651 | } |
| 3652 | |
| 3653 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3654 | errno = hdd_vdev_ready(adapter); |
| 3655 | if (errno) { |
| 3656 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3657 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3658 | } |
| 3659 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3660 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3661 | |
| 3662 | return 0; |
| 3663 | |
| 3664 | /* |
| 3665 | * Due to legacy constraints, we need to destroy in the same order as |
| 3666 | * create. So, split error handling into 2 cases to accommodate. |
| 3667 | */ |
| 3668 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3669 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3670 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3671 | |
| 3672 | return errno; |
| 3673 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3674 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3675 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3676 | |
| 3677 | return errno; |
| 3678 | } |
| 3679 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3680 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3681 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3682 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3683 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3684 | QDF_STATUS status; |
| 3685 | int ret_val; |
| 3686 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3687 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3688 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3689 | 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] | 3690 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3691 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3693 | status = hdd_register_wext(adapter->dev); |
| 3694 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3695 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | goto error_register_wext; |
| 3697 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3698 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3699 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3700 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3701 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3702 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3703 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3704 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3705 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3706 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3707 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3708 | hdd_ctx->config->OperatingChannel; |
| 3709 | |
| 3710 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3711 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3712 | |
| 3713 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3714 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3715 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3716 | status, status); |
| 3717 | goto error_init_txrx; |
| 3718 | } |
| 3719 | |
| 3720 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3721 | |
| 3722 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3723 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3724 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | status, status); |
| 3726 | goto error_wmm_init; |
| 3727 | } |
| 3728 | |
| 3729 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3730 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3731 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3732 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3733 | hdd_ctx->config->enableSifsBurst, |
| 3734 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3735 | if (ret_val) |
| 3736 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3738 | /* |
| 3739 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3740 | * during that time, then as part of SSR init, do not enable |
| 3741 | * the LRO again. Keep the LRO state same as before SSR. |
| 3742 | */ |
| 3743 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3744 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3745 | |
| 3746 | /* rcpi info initialization */ |
| 3747 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3748 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3749 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | error_wmm_init: |
| 3752 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3753 | hdd_deinit_tx_rx(adapter); |
| 3754 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3755 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3757 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | return status; |
| 3760 | } |
| 3761 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3762 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3763 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3764 | * @hdd_ctx: global hdd context |
| 3765 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3766 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3767 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3768 | * |
| 3769 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3770 | * |
| 3771 | * Return: None. |
| 3772 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3773 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3774 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3775 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3776 | { |
| 3777 | ENTER_DEV(adapter->dev); |
| 3778 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3779 | if (adapter->dev) { |
| 3780 | if (rtnl_held) |
| 3781 | adapter->dev->wireless_handlers = NULL; |
| 3782 | else { |
| 3783 | rtnl_lock(); |
| 3784 | adapter->dev->wireless_handlers = NULL; |
| 3785 | rtnl_unlock(); |
| 3786 | } |
| 3787 | } |
| 3788 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3789 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3790 | hdd_deinit_tx_rx(adapter); |
| 3791 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3792 | } |
| 3793 | |
| 3794 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3795 | hdd_wmm_adapter_close(adapter); |
| 3796 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3797 | } |
| 3798 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3799 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3800 | EXIT(); |
| 3801 | } |
| 3802 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3803 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 3804 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3805 | bool rtnl_held) |
| 3806 | { |
| 3807 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3809 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3810 | case QDF_STA_MODE: |
| 3811 | case QDF_P2P_CLIENT_MODE: |
| 3812 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3813 | case QDF_IBSS_MODE: |
| 3814 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3815 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3816 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | break; |
| 3818 | } |
| 3819 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3820 | case QDF_SAP_MODE: |
| 3821 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3822 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3823 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3824 | break; |
| 3825 | } |
| 3826 | |
| 3827 | default: |
| 3828 | break; |
| 3829 | } |
| 3830 | |
| 3831 | EXIT(); |
| 3832 | } |
| 3833 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3834 | 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] | 3835 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3836 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3837 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3838 | |
| 3839 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3840 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3841 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3842 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | return; |
| 3844 | } |
| 3845 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3846 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3847 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 3848 | hdd_adapter_runtime_suspend_deinit(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3849 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | /* |
| 3851 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3852 | * the driver is almost closed and cannot handle either control |
| 3853 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3854 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3855 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3856 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3857 | * the interface is closed and restricts any operations on that |
| 3858 | */ |
| 3859 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3860 | |
| 3861 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3862 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3863 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3864 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3865 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3866 | /* |
| 3867 | * Note that the adapter is no longer valid at this point |
| 3868 | * since the memory has been reclaimed |
| 3869 | */ |
| 3870 | } |
| 3871 | } |
| 3872 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3873 | 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] | 3874 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3875 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3876 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3877 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3878 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3879 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 3880 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3881 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3882 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3884 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3885 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3887 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3888 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3889 | /** |
| 3890 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3891 | * @hdd_ctx: HDD Context |
| 3892 | * @adapter: HDD Adapter |
| 3893 | * |
| 3894 | * This function set the FW Debug log level based on the INI. |
| 3895 | * |
| 3896 | * Return: None |
| 3897 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3898 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3899 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3900 | { |
| 3901 | uint8_t count = 0, numentries = 0, |
| 3902 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3903 | uint32_t value = 0; |
| 3904 | int ret; |
| 3905 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3906 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3907 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3908 | 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] | 3909 | return; |
| 3910 | } |
| 3911 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3912 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3913 | hdd_ctx->fw_log_settings.dl_type = |
| 3914 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3915 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3916 | WMI_DBGLOG_TYPE, |
| 3917 | hdd_ctx->config->enableFwLogType, |
| 3918 | DBG_CMD); |
| 3919 | if (ret != 0) |
| 3920 | hdd_err("Failed to enable FW log type ret %d", |
| 3921 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3922 | |
| 3923 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3924 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3925 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3926 | WMI_DBGLOG_LOG_LEVEL, |
| 3927 | hdd_ctx->config->enableFwLogLevel, |
| 3928 | DBG_CMD); |
| 3929 | if (ret != 0) |
| 3930 | hdd_err("Failed to enable FW log level ret %d", |
| 3931 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3932 | |
| 3933 | hdd_string_to_u8_array( |
| 3934 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3935 | moduleloglevel, |
| 3936 | &numentries, |
| 3937 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3938 | |
| 3939 | while (count < numentries) { |
| 3940 | /* |
| 3941 | * FW module log level input string looks like |
| 3942 | * below: |
| 3943 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3944 | * <Log Level>,... |
| 3945 | * For example: |
| 3946 | * gFwDebugModuleLoglevel= |
| 3947 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3948 | * Above input string means : |
| 3949 | * For FW module ID 1 enable log level 0 |
| 3950 | * For FW module ID 2 enable log level 1 |
| 3951 | * For FW module ID 3 enable log level 2 |
| 3952 | * For FW module ID 4 enable log level 3 |
| 3953 | * For FW module ID 5 enable log level 4 |
| 3954 | * For FW module ID 6 enable log level 5 |
| 3955 | * For FW module ID 7 enable log level 6 |
| 3956 | */ |
| 3957 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3958 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3959 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3960 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3961 | moduleloglevel[count], |
| 3962 | moduleloglevel[count + 1]); |
| 3963 | return; |
| 3964 | } |
| 3965 | |
| 3966 | value = moduleloglevel[count] << 16; |
| 3967 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3968 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3969 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3970 | value, DBG_CMD); |
| 3971 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3972 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3973 | value, ret); |
| 3974 | |
| 3975 | count += 2; |
| 3976 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3977 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3978 | } |
| 3979 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3980 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3981 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3982 | { |
| 3983 | } |
| 3984 | |
| 3985 | #endif |
| 3986 | |
| 3987 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 3988 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 3989 | * @adapter: HDD adapter |
| 3990 | * |
| 3991 | * Return: 0 on success or errno on failure |
| 3992 | */ |
| 3993 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 3994 | { |
| 3995 | int ret_val; |
| 3996 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3997 | |
| 3998 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 3999 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4000 | hdd_ctx->config->txchainmask1x1, |
| 4001 | hdd_ctx->config->rxchainmask1x1); |
| 4002 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4003 | hdd_ctx->config->dual_mac_feature_disable, |
| 4004 | hdd_ctx->config->tx_chain_mask_2g, |
| 4005 | hdd_ctx->config->rx_chain_mask_2g); |
| 4006 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4007 | hdd_ctx->config->tx_chain_mask_5g, |
| 4008 | hdd_ctx->config->rx_chain_mask_5g); |
| 4009 | |
| 4010 | if (hdd_ctx->config->enable2x2) { |
| 4011 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4012 | return 0; |
| 4013 | } |
| 4014 | |
| 4015 | if (hdd_ctx->config->txchainmask1x1) { |
| 4016 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4017 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4018 | hdd_ctx->config->txchainmask1x1, |
| 4019 | PDEV_CMD); |
| 4020 | if (ret_val) |
| 4021 | goto error; |
| 4022 | } |
| 4023 | |
| 4024 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4025 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4026 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4027 | hdd_ctx->config->rxchainmask1x1, |
| 4028 | PDEV_CMD); |
| 4029 | if (ret_val) |
| 4030 | goto error; |
| 4031 | } |
| 4032 | |
| 4033 | if (hdd_ctx->lte_coex_ant_share) { |
| 4034 | hdd_info("lte ant sharing enabled. skip per band chain mask"); |
| 4035 | return 0; |
| 4036 | } |
| 4037 | |
| 4038 | if (hdd_ctx->config->txchainmask1x1 || |
| 4039 | hdd_ctx->config->rxchainmask1x1) { |
| 4040 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4041 | return 0; |
| 4042 | } |
| 4043 | |
| 4044 | if (!hdd_ctx->config->dual_mac_feature_disable) { |
| 4045 | hdd_info("DBS enabled. skip per band chain mask"); |
| 4046 | return 0; |
| 4047 | } |
| 4048 | |
| 4049 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4050 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4051 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4052 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4053 | if (0 != ret_val) |
| 4054 | goto error; |
| 4055 | } |
| 4056 | |
| 4057 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4058 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4059 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4060 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4061 | if (0 != ret_val) |
| 4062 | goto error; |
| 4063 | } |
| 4064 | |
| 4065 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4066 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4067 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4068 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4069 | if (0 != ret_val) |
| 4070 | goto error; |
| 4071 | } |
| 4072 | |
| 4073 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4074 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4075 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4076 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4077 | if (0 != ret_val) |
| 4078 | goto error; |
| 4079 | } |
| 4080 | |
| 4081 | return 0; |
| 4082 | |
| 4083 | error: |
| 4084 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4085 | return -EINVAL; |
| 4086 | } |
| 4087 | |
| 4088 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4089 | * hdd_set_fw_params() - Set parameters to firmware |
| 4090 | * @adapter: HDD adapter |
| 4091 | * |
| 4092 | * This function Sets various parameters to fw once the |
| 4093 | * adapter is started. |
| 4094 | * |
| 4095 | * Return: 0 on success or errno on failure |
| 4096 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4097 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4098 | { |
| 4099 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4100 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4101 | |
| 4102 | ENTER_DEV(adapter->dev); |
| 4103 | |
| 4104 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4105 | if (!hdd_ctx) |
| 4106 | return -EINVAL; |
| 4107 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4108 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4109 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4110 | return 0; |
| 4111 | } |
| 4112 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4113 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4114 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4115 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4116 | if (ret) { |
| 4117 | hdd_err("Failed to set LPRx"); |
| 4118 | goto error; |
| 4119 | } |
| 4120 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4121 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4122 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4123 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4124 | hdd_ctx->config->upper_brssi_thresh); |
| 4125 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4126 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4127 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4128 | hdd_ctx->config->lower_brssi_thresh); |
| 4129 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4130 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4131 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4132 | hdd_ctx->config->enable_dtim_1chrx); |
| 4133 | } |
| 4134 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4135 | if (hdd_ctx->config->enable2x2) { |
| 4136 | hdd_debug("configuring 2x2 mode fw params"); |
| 4137 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4138 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4139 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4140 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4141 | PDEV_CMD); |
| 4142 | if (ret) { |
| 4143 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4144 | ret); |
| 4145 | goto error; |
| 4146 | } |
| 4147 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4148 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4149 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4150 | hdd_debug("configuring 1x1 mode fw params"); |
| 4151 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4152 | /* |
| 4153 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4154 | * we are passing two value |
| 4155 | * as param_id << 29 | param_value. |
| 4156 | * Below param_value = 0(disable) |
| 4157 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4158 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4159 | WMI_STA_SMPS_PARAM_CMDID, |
| 4160 | HDD_DTIM_1CHAIN_RX_ID << |
| 4161 | HDD_SMPS_PARAM_VALUE_S, |
| 4162 | VDEV_CMD); |
| 4163 | if (ret) { |
| 4164 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4165 | goto error; |
| 4166 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4167 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4168 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4169 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4170 | |
| 4171 | if (hdd_configure_chain_mask(adapter)) |
| 4172 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4173 | } |
| 4174 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4175 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4176 | WMI_PDEV_PARAM_HYST_EN, |
| 4177 | hdd_ctx->config->enableMemDeepSleep, |
| 4178 | PDEV_CMD); |
| 4179 | if (ret) { |
| 4180 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4181 | goto error; |
| 4182 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4183 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4184 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4185 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4186 | hdd_ctx->config->rts_profile, |
| 4187 | VDEV_CMD); |
| 4188 | if (ret) { |
| 4189 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4190 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4191 | } |
| 4192 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4193 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4194 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4195 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4196 | GEN_VDEV_PARAM_AMSDU, |
| 4197 | hdd_ctx->config->max_amsdu_num, |
| 4198 | GEN_CMD); |
| 4199 | if (ret != 0) { |
| 4200 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4201 | goto error; |
| 4202 | } |
| 4203 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4204 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4205 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4206 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4207 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4208 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4209 | error: |
| 4210 | return -EINVAL; |
| 4211 | } |
| 4212 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4213 | /** |
| 4214 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4215 | * @hdd_ctx: global hdd context |
| 4216 | * @session_type: type of the interface to be created |
| 4217 | * @iface_name: User-visible name of the interface |
| 4218 | * @macAddr: MAC address to assign to the interface |
| 4219 | * @name_assign_type: the name of assign type of the netdev |
| 4220 | * @rtnl_held: the rtnl lock hold flag |
| 4221 | * |
| 4222 | * This function open and setup the hdd adpater according to the device |
| 4223 | * type request, assign the name, the mac address assigned, and then prepared |
| 4224 | * the hdd related parameters, queue, lock and ready to start. |
| 4225 | * |
| 4226 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4227 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4228 | 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] | 4229 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4230 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4231 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4232 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4233 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4234 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4235 | |
| 4236 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4237 | /* |
| 4238 | * Max limit reached on the number of vdevs configured by the |
| 4239 | * host. Return error |
| 4240 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4241 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4242 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4243 | return NULL; |
| 4244 | } |
| 4245 | |
| 4246 | if (macAddr == NULL) { |
| 4247 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4248 | 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] | 4249 | return NULL; |
| 4250 | } |
| 4251 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4252 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4253 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4254 | " already exists", |
| 4255 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4256 | return NULL; |
| 4257 | } |
| 4258 | |
| 4259 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4260 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4261 | /* Reset locally administered bit if the device mode is STA */ |
| 4262 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4263 | hdd_info("locally administered bit reset in sta mode: " |
| 4264 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4265 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4266 | case QDF_P2P_CLIENT_MODE: |
| 4267 | case QDF_P2P_DEVICE_MODE: |
| 4268 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4269 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4270 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4271 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4272 | name_assign_type, |
| 4273 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | |
| 4275 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4276 | hdd_err("failed to allocate adapter for session %d", |
| 4277 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4278 | return NULL; |
| 4279 | } |
| 4280 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4281 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4282 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4283 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4284 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4285 | else if (QDF_MONITOR_MODE == session_type) |
| 4286 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4287 | else |
| 4288 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4289 | |
| 4290 | adapter->device_mode = session_type; |
| 4291 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4292 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4293 | /* |
| 4294 | * Workqueue which gets scheduled in IPv4 notification |
| 4295 | * callback |
| 4296 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4297 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4298 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4299 | |
| 4300 | #ifdef WLAN_NS_OFFLOAD |
| 4301 | /* |
| 4302 | * Workqueue which gets scheduled in IPv6 |
| 4303 | * notification callback. |
| 4304 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4305 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4306 | hdd_ipv6_notifier_work_queue); |
| 4307 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4308 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4309 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4310 | goto err_deinit_adapter_runtime_pm; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4311 | |
| 4312 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4313 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4314 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4315 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4316 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4317 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4318 | /* Initialize NAN Data Interface */ |
| 4319 | if (QDF_NDI_MODE == session_type) { |
| 4320 | status = hdd_init_nan_data_mode(adapter); |
| 4321 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4322 | goto err_deinit_adapter_runtime_pm; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4323 | } |
| 4324 | |
| 4325 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4326 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4327 | case QDF_P2P_GO_MODE: |
| 4328 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4329 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4330 | name_assign_type, |
| 4331 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4332 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4333 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4334 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4335 | return NULL; |
| 4336 | } |
| 4337 | |
| 4338 | adapter->wdev.iftype = |
| 4339 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4340 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | NL80211_IFTYPE_P2P_GO; |
| 4342 | adapter->device_mode = session_type; |
| 4343 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4344 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4345 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4346 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4347 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4348 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4349 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4350 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4351 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4352 | |
| 4353 | /* |
| 4354 | * Workqueue which gets scheduled in IPv4 notification |
| 4355 | * callback |
| 4356 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4357 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4358 | hdd_ipv4_notifier_work_queue); |
| 4359 | |
| 4360 | #ifdef WLAN_NS_OFFLOAD |
| 4361 | /* |
| 4362 | * Workqueue which gets scheduled in IPv6 |
| 4363 | * notification callback. |
| 4364 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4365 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4366 | hdd_ipv6_notifier_work_queue); |
| 4367 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4368 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4369 | case QDF_FTM_MODE: |
| 4370 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4371 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4372 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4373 | if (NULL == adapter) { |
| 4374 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4375 | return NULL; |
| 4376 | } |
| 4377 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4378 | adapter->device_mode = session_type; |
| 4379 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4380 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4381 | goto err_deinit_adapter_runtime_pm; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4382 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4383 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4384 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4385 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4386 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4387 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4388 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4389 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4390 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4391 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4392 | return NULL; |
| 4393 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4395 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4396 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4397 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4399 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4400 | } |
| 4401 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4402 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4403 | if (NULL != adapter) { |
| 4404 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4405 | adapter = NULL; |
| 4406 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4407 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4408 | return NULL; |
| 4409 | } |
| 4410 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4411 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4412 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4413 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4414 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4415 | /* Adapter successfully added. Increment the vdev count */ |
| 4416 | hdd_ctx->current_intf_count++; |
| 4417 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4418 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4419 | hdd_ctx->current_intf_count); |
| 4420 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4421 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4422 | } |
| 4423 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4424 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4425 | hdd_err("Interface %s wow debug_fs init failed", |
| 4426 | netdev_name(adapter->dev)); |
| 4427 | |
| 4428 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4429 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4430 | |
| 4431 | return adapter; |
| 4432 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4433 | err_deinit_adapter_runtime_pm: |
| 4434 | /* |
| 4435 | * For certain error cases that hdd_alloc_station_adapter() |
| 4436 | * is used to allocate the adapter. |
| 4437 | */ |
| 4438 | hdd_adapter_runtime_suspend_deinit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4439 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4440 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4441 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4442 | |
| 4443 | return NULL; |
| 4444 | } |
| 4445 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4446 | 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] | 4447 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4448 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4449 | /* |
| 4450 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4451 | * |
| 4452 | * The reason is to fix one race condition between |
| 4453 | * bus bandwidth work and cleaning up an adapter. |
| 4454 | * Under some conditions, it is possible for the bus bandwidth |
| 4455 | * work to access a particularly destroyed adapter, leading to |
| 4456 | * use-after-free. |
| 4457 | */ |
| 4458 | hdd_debug("wait for bus bw work to flush"); |
| 4459 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4460 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4461 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4462 | /* cleanup adapter */ |
| 4463 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4464 | adapter->device_mode); |
| 4465 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4466 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4468 | /* conditionally restart the bw timer */ |
| 4469 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4470 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4471 | /* Adapter removed. Decrement vdev count */ |
| 4472 | if (hdd_ctx->current_intf_count != 0) |
| 4473 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4474 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4475 | /* Fw will take care incase of concurrency */ |
| 4476 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4477 | } |
| 4478 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4479 | /** |
| 4480 | * hdd_close_all_adapters - Close all open adapters |
| 4481 | * @hdd_ctx: Hdd context |
| 4482 | * rtnl_held: True if RTNL lock held |
| 4483 | * |
| 4484 | * Close all open adapters. |
| 4485 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4486 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4487 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4488 | 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] | 4489 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4490 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4491 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4492 | |
| 4493 | ENTER(); |
| 4494 | |
| 4495 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4496 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4497 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4498 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4499 | adapter->mac_addr.bytes); |
| 4500 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4501 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4502 | /* Adapter removed. Decrement vdev count */ |
| 4503 | if (hdd_ctx->current_intf_count != 0) |
| 4504 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4506 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4507 | |
| 4508 | EXIT(); |
| 4509 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4510 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | } |
| 4512 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4513 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4514 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4515 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4516 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4517 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4518 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4519 | case QDF_STA_MODE: |
| 4520 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4521 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4522 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4523 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4524 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | break; |
| 4526 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4527 | case QDF_SAP_MODE: |
| 4528 | case QDF_P2P_GO_MODE: |
| 4529 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4530 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4531 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4532 | break; |
| 4533 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4534 | case QDF_FTM_MODE: |
| 4535 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4536 | default: |
| 4537 | /* |
| 4538 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4539 | * for these kind of devices |
| 4540 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4541 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4542 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4543 | return; |
| 4544 | } |
| 4545 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4546 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4547 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4548 | updateIE.ieBufferlength = 0; |
| 4549 | updateIE.pAdditionIEBuffer = NULL; |
| 4550 | updateIE.append = true; |
| 4551 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4552 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4553 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4554 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4555 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4556 | } |
| 4557 | } |
| 4558 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4559 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4560 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4561 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4562 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4563 | struct hdd_wext_state *pWextState = |
| 4564 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4565 | union iwreq_data wrqu; |
| 4566 | tSirUpdateIE updateIE; |
| 4567 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4568 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4569 | |
| 4570 | ENTER(); |
| 4571 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4572 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4573 | wlan_hdd_netif_queue_control(adapter, |
| 4574 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4575 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4576 | /* |
| 4577 | * if this is the last active connection check & stop the |
| 4578 | * opportunistic timer first |
| 4579 | */ |
| 4580 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4581 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4582 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4583 | adapter->device_mode), NULL) == 1)) || |
| 4584 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4585 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4586 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4587 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4588 | case QDF_STA_MODE: |
| 4589 | case QDF_P2P_CLIENT_MODE: |
| 4590 | case QDF_IBSS_MODE: |
| 4591 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4592 | case QDF_NDI_MODE: |
| 4593 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4594 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4595 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4596 | hdd_is_connecting( |
| 4597 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4598 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4599 | /* |
| 4600 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4601 | * extract from ndi_ctx. |
| 4602 | */ |
| 4603 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4604 | qdf_ret_status = sme_roam_disconnect( |
| 4605 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4606 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4607 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4608 | else if (pWextState->roamProfile.BSSType == |
| 4609 | eCSR_BSS_TYPE_START_IBSS) |
| 4610 | qdf_ret_status = sme_roam_disconnect( |
| 4611 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4612 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4613 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4614 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4615 | qdf_ret_status = |
| 4616 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4617 | hdd_debug("Send disconnected event to userspace"); |
| 4618 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4619 | adapter->dev, true, |
| 4620 | WLAN_REASON_UNSPECIFIED); |
| 4621 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4622 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4623 | qdf_ret_status = sme_roam_disconnect( |
| 4624 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4625 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4626 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4627 | /* success implies disconnect command got |
| 4628 | * queued up successfully |
| 4629 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4630 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4631 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4632 | rc = wait_for_completion_timeout( |
| 4633 | &adapter->disconnect_comp_var, |
| 4634 | msecs_to_jiffies |
| 4635 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4636 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4637 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4638 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4639 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4640 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4641 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4642 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4643 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4644 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4645 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4646 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4647 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4648 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4649 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4650 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4651 | |
| 4652 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4653 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4654 | #endif |
| 4655 | |
| 4656 | hdd_deregister_tx_flow_control(adapter); |
| 4657 | |
| 4658 | #ifdef WLAN_NS_OFFLOAD |
| 4659 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4660 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4661 | #endif |
| 4662 | #endif |
| 4663 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4664 | if (adapter->device_mode == QDF_STA_MODE) |
| 4665 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4666 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4667 | |
| 4668 | if (wlan_hdd_try_disconnect(adapter)) { |
| 4669 | hdd_err("Error: Can't disconnect adapter"); |
| 4670 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4671 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4672 | |
| 4673 | hdd_vdev_destroy(adapter); |
| 4674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4675 | break; |
| 4676 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4677 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4678 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4679 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4680 | sap_config = &adapter->session.ap.sap_config; |
| 4681 | if (sap_config) |
| 4682 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4683 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4684 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4685 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4686 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4687 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4688 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4689 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4690 | cds_flush_delayed_work( |
| 4691 | &adapter->acs_pending_work); |
| 4692 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4693 | } |
| 4694 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4695 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4696 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4697 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4698 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4699 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4701 | |
| 4702 | hdd_deregister_tx_flow_control(adapter); |
| 4703 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4704 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4705 | mutex_lock(&hdd_ctx->sap_lock); |
| 4706 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4707 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4708 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4709 | |
| 4710 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4711 | status = wlansap_stop_bss( |
| 4712 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4713 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4714 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4715 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4716 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4717 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4718 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4719 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4720 | qdf_wait_for_event_completion( |
| 4721 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4722 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4724 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4725 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4726 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4727 | } |
| 4728 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4729 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4730 | } |
| 4731 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4732 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4733 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4734 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4735 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4736 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4737 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4738 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4739 | updateIE.ieBufferlength = 0; |
| 4740 | updateIE.pAdditionIEBuffer = NULL; |
| 4741 | updateIE.append = false; |
| 4742 | updateIE.notify = false; |
| 4743 | /* Probe bcn reset */ |
| 4744 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4745 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4746 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4747 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4748 | } |
| 4749 | /* Assoc resp reset */ |
| 4750 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4751 | &updateIE, |
| 4752 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4753 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4754 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | } |
| 4756 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4757 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4759 | qdf_mem_free(adapter->session.ap.beacon); |
| 4760 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4761 | /* |
| 4762 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4763 | */ |
| 4764 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4765 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4766 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4767 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4768 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4769 | #endif |
| 4770 | |
| 4771 | #ifdef WLAN_NS_OFFLOAD |
| 4772 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4773 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4774 | #endif |
| 4775 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4776 | |
| 4777 | hdd_vdev_destroy(adapter); |
| 4778 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4779 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4780 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4781 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4782 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4783 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4784 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | break; |
| 4786 | default: |
| 4787 | break; |
| 4788 | } |
| 4789 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4790 | if (adapter->scan_info.default_scan_ies) { |
| 4791 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 4792 | adapter->scan_info.default_scan_ies = NULL; |
| 4793 | } |
| 4794 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4795 | EXIT(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4796 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4797 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4798 | } |
| 4799 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4800 | /** |
| 4801 | * hdd_deinit_all_adapters - deinit all adapters |
| 4802 | * @hdd_ctx: HDD context |
| 4803 | * @rtnl_held: True if RTNL lock held |
| 4804 | * |
| 4805 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4806 | 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] | 4807 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4808 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4809 | |
| 4810 | ENTER(); |
| 4811 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4812 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4813 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4814 | |
| 4815 | EXIT(); |
| 4816 | } |
| 4817 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4818 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4820 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4821 | |
| 4822 | ENTER(); |
| 4823 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4824 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4825 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4826 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4827 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4828 | |
| 4829 | EXIT(); |
| 4830 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4831 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | } |
| 4833 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4834 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 4835 | struct hdd_adapter *adapter) |
| 4836 | { |
| 4837 | switch (adapter->device_mode) { |
| 4838 | case QDF_STA_MODE: |
| 4839 | case QDF_P2P_CLIENT_MODE: |
| 4840 | case QDF_IBSS_MODE: |
| 4841 | case QDF_P2P_DEVICE_MODE: |
| 4842 | case QDF_NDI_MODE: |
| 4843 | wlan_hdd_scan_abort(adapter); |
| 4844 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4845 | if (adapter->device_mode == QDF_STA_MODE) |
| 4846 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4847 | adapter->dev); |
| 4848 | break; |
| 4849 | case QDF_P2P_GO_MODE: |
| 4850 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4851 | break; |
| 4852 | case QDF_SAP_MODE: |
| 4853 | wlan_hdd_undo_acs(adapter); |
| 4854 | break; |
| 4855 | default: |
| 4856 | break; |
| 4857 | } |
| 4858 | } |
| 4859 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4860 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4861 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4862 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4863 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4864 | struct qdf_mac_addr peerMacAddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4865 | |
| 4866 | ENTER(); |
| 4867 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4868 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4869 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4870 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4871 | hdd_notice("Disabling queues for adapter type: %d", |
| 4872 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4873 | |
| 4874 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4875 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4876 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4877 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4878 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4879 | if (hdd_ctx->config->sap_internal_restart && |
| 4880 | adapter->device_mode == QDF_SAP_MODE) { |
| 4881 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4882 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4883 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4884 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4885 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4886 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4887 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4888 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4889 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4890 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4891 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4892 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4894 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4895 | adapter->session.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | |
| 4897 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4898 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4899 | adapter->device_mode, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4901 | hdd_wmm_adapter_close(adapter); |
| 4902 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4903 | } |
| 4904 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4905 | if (adapter->device_mode == QDF_STA_MODE) |
| 4906 | hdd_clear_fils_connection_info(adapter); |
| 4907 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4908 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4909 | /* |
| 4910 | * If adapter is SAP, set session ID to invalid |
| 4911 | * since SAP session will be cleanup during SSR. |
| 4912 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4913 | wlansap_set_invalid_session( |
| 4914 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4915 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4916 | wlansap_cleanup_cac_timer( |
| 4917 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4918 | } |
| 4919 | |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4920 | /* Delete peers if any for STA and P2P client modes */ |
| 4921 | if (adapter->device_mode == QDF_STA_MODE || |
| 4922 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4923 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4924 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4925 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4926 | |
| 4927 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4928 | peerMacAddr.bytes); |
| 4929 | } |
| 4930 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4931 | /* Destroy vdev which will be recreated during reinit. */ |
| 4932 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4933 | } |
| 4934 | |
| 4935 | EXIT(); |
| 4936 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4937 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4938 | } |
| 4939 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4940 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4941 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4942 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4943 | bool close_modules = true; |
| 4944 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 4945 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4946 | hdd_info("FTM mode, don't close the module"); |
| 4947 | return false; |
| 4948 | } |
| 4949 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4950 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4951 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 4952 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4953 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4954 | close_modules = false; |
| 4955 | break; |
| 4956 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4957 | } |
| 4958 | |
| 4959 | return close_modules; |
| 4960 | } |
| 4961 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 4962 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4963 | { |
| 4964 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4965 | return true; |
| 4966 | else |
| 4967 | return false; |
| 4968 | } |
| 4969 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4970 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 4971 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4972 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4973 | struct ieee80211_channel *channel, |
| 4974 | const u8 *bssid, const u8 *ssid, |
| 4975 | size_t ssid_len) |
| 4976 | { |
| 4977 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4978 | ssid, ssid_len, |
| 4979 | WLAN_CAPABILITY_ESS, |
| 4980 | WLAN_CAPABILITY_ESS); |
| 4981 | } |
| 4982 | #else |
| 4983 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4984 | struct ieee80211_channel *channel, |
| 4985 | const u8 *bssid, const u8 *ssid, |
| 4986 | size_t ssid_len) |
| 4987 | { |
| 4988 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4989 | ssid, ssid_len, |
| 4990 | IEEE80211_BSS_TYPE_ESS, |
| 4991 | IEEE80211_PRIVACY_ANY); |
| 4992 | } |
| 4993 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4994 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4995 | #if defined CFG80211_CONNECT_BSS || \ |
| 4996 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4997 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4998 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4999 | /** |
| 5000 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5001 | * @timeout_reason: reason for connect timeout |
| 5002 | * |
| 5003 | * This function is used to convert host timeout |
| 5004 | * reason enum to kernel specific enum. |
| 5005 | * |
| 5006 | * Return: nl timeout enum |
| 5007 | */ |
| 5008 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5009 | tSirResultCodes timeout_reason) |
| 5010 | { |
| 5011 | switch (timeout_reason) { |
| 5012 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5013 | return NL80211_TIMEOUT_SCAN; |
| 5014 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5015 | return NL80211_TIMEOUT_AUTH; |
| 5016 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5017 | return NL80211_TIMEOUT_ASSOC; |
| 5018 | default: |
| 5019 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5020 | } |
| 5021 | } |
| 5022 | |
| 5023 | /** |
| 5024 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5025 | * @dev: network device |
| 5026 | * @bssid: bssid to which we want to associate |
| 5027 | * @timeout_reason: reason for connect timeout |
| 5028 | * |
| 5029 | * This API is used to send connection timeout reason to supplicant |
| 5030 | * |
| 5031 | * Return: void |
| 5032 | */ |
| 5033 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5034 | const u8 *bssid, |
| 5035 | tSirResultCodes timeout_reason) |
| 5036 | { |
| 5037 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5038 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5039 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5040 | |
| 5041 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5042 | nl_timeout_reason); |
| 5043 | } |
| 5044 | |
| 5045 | /** |
| 5046 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5047 | * @dev: network device |
| 5048 | * @bssid: bssid to which we want to associate |
| 5049 | * @req_ie: Request Information Element |
| 5050 | * @req_ie_len: len of the req IE |
| 5051 | * @resp_ie: Response IE |
| 5052 | * @resp_ie_len: len of ht response IE |
| 5053 | * @status: status |
| 5054 | * @gfp: Kernel Flag |
| 5055 | * @timeout_reason: reason for connect timeout |
| 5056 | * |
| 5057 | * Return: void |
| 5058 | */ |
| 5059 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5060 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5061 | size_t req_ie_len, const u8 *resp_ie, |
| 5062 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5063 | tSirResultCodes timeout_reason) |
| 5064 | { |
| 5065 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5066 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5067 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5068 | |
| 5069 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5070 | resp_ie, resp_ie_len, status, gfp, |
| 5071 | nl_timeout_reason); |
| 5072 | } |
| 5073 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5074 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5075 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5076 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5077 | const u8 *bssid, |
| 5078 | tSirResultCodes timeout_reason) |
| 5079 | { |
| 5080 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5081 | } |
| 5082 | #endif |
| 5083 | |
| 5084 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5085 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5086 | size_t req_ie_len, const u8 *resp_ie, |
| 5087 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5088 | tSirResultCodes timeout_reason) |
| 5089 | { |
| 5090 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5091 | resp_ie, resp_ie_len, status, gfp); |
| 5092 | } |
| 5093 | #endif |
| 5094 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5095 | /** |
| 5096 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5097 | * @dev: network device |
| 5098 | * @bssid: bssid to which we want to associate |
| 5099 | * @req_ie: Request Information Element |
| 5100 | * @req_ie_len: len of the req IE |
| 5101 | * @resp_ie: Response IE |
| 5102 | * @resp_ie_len: len of ht response IE |
| 5103 | * @status: status |
| 5104 | * @gfp: Kernel Flag |
| 5105 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5106 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5107 | * |
| 5108 | * The API is a wrapper to send connection status to supplicant |
| 5109 | * |
| 5110 | * Return: Void |
| 5111 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5112 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5113 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5114 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5115 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5116 | size_t req_ie_len, const u8 *resp_ie, |
| 5117 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5118 | bool connect_timeout, |
| 5119 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5120 | { |
| 5121 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5122 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5123 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5124 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5125 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5126 | } |
| 5127 | #else |
| 5128 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5129 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5130 | size_t req_ie_len, const u8 *resp_ie, |
| 5131 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5132 | bool connect_timeout, |
| 5133 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5134 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5135 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5136 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5137 | } |
| 5138 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5139 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5140 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5141 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5142 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5143 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5144 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5145 | /** |
| 5146 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5147 | * @fils_params: connect response to supplicant |
| 5148 | * @fils_kek: FILS kek |
| 5149 | * @fils_kek_len: FILS kek length |
| 5150 | * @pmk: FILS PMK |
| 5151 | * @pmk_len: FILS PMK length |
| 5152 | * @pmkid: PMKID |
| 5153 | * @fils_seq_num: FILS Seq number |
| 5154 | * |
| 5155 | * Return: None |
| 5156 | */ |
| 5157 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5158 | *fils_params, const uint8_t *fils_kek, |
| 5159 | size_t fils_kek_len, const uint8_t *pmk, |
| 5160 | size_t pmk_len, const uint8_t *pmkid, |
| 5161 | uint16_t fils_seq_num) |
| 5162 | { |
| 5163 | /* Increament seq number to be used for next FILS */ |
| 5164 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5165 | fils_params->update_erp_next_seq_num = true; |
| 5166 | fils_params->fils_kek = fils_kek; |
| 5167 | fils_params->fils_kek_len = fils_kek_len; |
| 5168 | fils_params->pmk = pmk; |
| 5169 | fils_params->pmk_len = pmk_len; |
| 5170 | fils_params->pmkid = pmkid; |
| 5171 | } |
| 5172 | #else |
| 5173 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5174 | *fils_params, const uint8_t |
| 5175 | *fils_kek, size_t fils_kek_len, |
| 5176 | const uint8_t *pmk, size_t pmk_len, |
| 5177 | const uint8_t *pmkid, |
| 5178 | uint16_t fils_seq_num) |
| 5179 | { } |
| 5180 | #endif |
| 5181 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5182 | void hdd_update_hlp_info(struct net_device *dev, |
| 5183 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5184 | { |
| 5185 | struct sk_buff *skb; |
| 5186 | uint16_t skb_len; |
| 5187 | struct llc_snap_hdr_t *llc_hdr; |
| 5188 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5189 | uint8_t *hlp_data; |
| 5190 | uint16_t hlp_data_len; |
| 5191 | struct fils_join_rsp_params *roam_fils_params |
| 5192 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5193 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5194 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5195 | if (!roam_fils_params) { |
| 5196 | hdd_err("FILS Roam Param NULL"); |
| 5197 | return; |
| 5198 | } |
| 5199 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5200 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5201 | hdd_err("FILS HLP Data NULL, len %d", |
| 5202 | roam_fils_params->hlp_data_len); |
| 5203 | return; |
| 5204 | } |
| 5205 | |
| 5206 | hlp_data = roam_fils_params->hlp_data; |
| 5207 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5208 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5209 | /* Calculate skb length */ |
| 5210 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5211 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5212 | if (skb == NULL) { |
| 5213 | hdd_err("HLP packet nbuf alloc fails"); |
| 5214 | return; |
| 5215 | } |
| 5216 | |
| 5217 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5218 | QDF_MAC_ADDR_SIZE); |
| 5219 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5220 | QDF_MAC_ADDR_SIZE); |
| 5221 | |
| 5222 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5223 | if (IS_SNAP(llc_hdr)) { |
| 5224 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5225 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5226 | } |
| 5227 | |
| 5228 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5229 | |
| 5230 | /* |
| 5231 | * This HLP packet is formed from HLP info encapsulated |
| 5232 | * in assoc response frame which is AEAD encrypted. |
| 5233 | * Hence, this checksum validation can be set unnecessary. |
| 5234 | * i.e. network layer need not worry about checksum. |
| 5235 | */ |
| 5236 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5237 | |
| 5238 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5239 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5240 | hdd_err("Sending HLP packet fails"); |
| 5241 | return; |
| 5242 | } |
| 5243 | hdd_debug("send HLP packet to netif successfully"); |
| 5244 | } |
| 5245 | |
| 5246 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5247 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5248 | * @dev: network device |
| 5249 | * @bssid: bssid to which we want to associate |
| 5250 | * @bss: cfg80211 bss info |
| 5251 | * @roam_info: information about connected bss |
| 5252 | * @req_ie: Request Information Element |
| 5253 | * @req_ie_len: len of the req IE |
| 5254 | * @resp_ie: Response IE |
| 5255 | * @resp_ie_len: len of ht response IE |
| 5256 | * @status: status |
| 5257 | * @gfp: allocation flags |
| 5258 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5259 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5260 | * |
| 5261 | * This API is used as wrapper to send FILS key/sequence number |
| 5262 | * params etc. to supplicant in case of FILS connection |
| 5263 | * |
| 5264 | * Return: None |
| 5265 | */ |
| 5266 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5267 | struct cfg80211_bss *bss, |
| 5268 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5269 | const u8 *req_ie, size_t req_ie_len, |
| 5270 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5271 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5272 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5273 | { |
| 5274 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5275 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5276 | struct fils_join_rsp_params *roam_fils_params = |
| 5277 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5278 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5279 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5280 | |
| 5281 | if (!roam_fils_params) { |
| 5282 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5283 | } else { |
| 5284 | fils_params.status = status; |
| 5285 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5286 | fils_params.timeout_reason = |
| 5287 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5288 | fils_params.req_ie = req_ie; |
| 5289 | fils_params.req_ie_len = req_ie_len; |
| 5290 | fils_params.resp_ie = resp_ie; |
| 5291 | fils_params.resp_ie_len = resp_ie_len; |
| 5292 | fils_params.bss = bss; |
| 5293 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5294 | roam_fils_params->kek_len, |
| 5295 | roam_fils_params->fils_pmk, |
| 5296 | roam_fils_params->fils_pmk_len, |
| 5297 | roam_fils_params->fils_pmkid, |
| 5298 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5299 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5300 | } |
| 5301 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5302 | fils_params.status, |
| 5303 | fils_params.fils_erp_next_seq_num); |
| 5304 | |
| 5305 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5306 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5307 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5308 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5309 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5310 | /* Clear all the FILS key info */ |
| 5311 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5312 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5313 | if (roam_fils_params) |
| 5314 | qdf_mem_free(roam_fils_params); |
| 5315 | roam_info->fils_join_rsp = NULL; |
| 5316 | } |
| 5317 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5318 | static inline void |
| 5319 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5320 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5321 | const u8 *req_ie, size_t req_ie_len, |
| 5322 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5323 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5324 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5325 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5326 | #endif |
| 5327 | #endif |
| 5328 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5329 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5330 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5331 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5332 | /** |
| 5333 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5334 | * supplicant. |
| 5335 | * @dev: network device |
| 5336 | * @bssid: bssid to which we want to associate |
| 5337 | * @bss: cfg80211 bss info |
| 5338 | * @roam_info: information about connected bss |
| 5339 | * @req_ie: Request Information Element |
| 5340 | * @req_ie_len: len of the req IE |
| 5341 | * @resp_ie: Response IE |
| 5342 | * @resp_ie_len: len of ht response IE |
| 5343 | * @status: status |
| 5344 | * @gfp: allocation flags |
| 5345 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5346 | * @timeout_reason: reason for connect timeout |
| 5347 | * |
| 5348 | * The API is a wrapper to send connection status to supplicant |
| 5349 | * |
| 5350 | * Return: 0 if success else failure |
| 5351 | */ |
| 5352 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5353 | const u8 *bssid, |
| 5354 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5355 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5356 | size_t req_ie_len, const u8 *resp_ie, |
| 5357 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5358 | bool connect_timeout, |
| 5359 | tSirResultCodes timeout_reason) |
| 5360 | { |
| 5361 | ENTER(); |
| 5362 | if (!roam_info || !roam_info->is_fils_connection) |
| 5363 | return -EINVAL; |
| 5364 | |
| 5365 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5366 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5367 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5368 | return 0; |
| 5369 | } |
| 5370 | #else |
| 5371 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5372 | const u8 *bssid, |
| 5373 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5374 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5375 | size_t req_ie_len, const u8 *resp_ie, |
| 5376 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5377 | bool connect_timeout, |
| 5378 | tSirResultCodes timeout_reason) |
| 5379 | { |
| 5380 | return -EINVAL; |
| 5381 | } |
| 5382 | #endif |
| 5383 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5384 | /** |
| 5385 | * hdd_connect_result() - API to send connection status to supplicant |
| 5386 | * @dev: network device |
| 5387 | * @bssid: bssid to which we want to associate |
| 5388 | * @roam_info: information about connected bss |
| 5389 | * @req_ie: Request Information Element |
| 5390 | * @req_ie_len: len of the req IE |
| 5391 | * @resp_ie: Response IE |
| 5392 | * @resp_ie_len: len of ht response IE |
| 5393 | * @status: status |
| 5394 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5395 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5396 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5397 | * |
| 5398 | * The API is a wrapper to send connection status to supplicant |
| 5399 | * and allow runtime suspend |
| 5400 | * |
| 5401 | * Return: Void |
| 5402 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5403 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5404 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5405 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5406 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5407 | bool connect_timeout, |
| 5408 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5409 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5410 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5411 | struct cfg80211_bss *bss = NULL; |
| 5412 | |
| 5413 | if (WLAN_STATUS_SUCCESS == status) { |
| 5414 | struct ieee80211_channel *chan; |
| 5415 | int freq; |
| 5416 | int chan_no = roam_info->pBssDesc->channelId; |
| 5417 | |
| 5418 | if (chan_no <= 14) |
| 5419 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5420 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5421 | else |
| 5422 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5423 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5424 | |
| 5425 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5426 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5427 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5428 | roam_info->u.pConnectedProfile->SSID.length); |
| 5429 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5430 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5431 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5432 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5433 | resp_ie_len, status, gfp, connect_timeout, |
| 5434 | timeout_reason) != 0) { |
| 5435 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5436 | req_ie_len, resp_ie, resp_ie_len, |
| 5437 | status, gfp, connect_timeout, timeout_reason); |
| 5438 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5439 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5440 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5441 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5442 | } |
| 5443 | #else |
| 5444 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5445 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5446 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5447 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5448 | bool connect_timeout, |
| 5449 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5450 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5451 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5452 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5453 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5454 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5455 | |
| 5456 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5457 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5458 | } |
| 5459 | #endif |
| 5460 | |
| 5461 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5462 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5463 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5464 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5465 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5466 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5467 | #endif |
| 5468 | eConnectionState connState; |
| 5469 | |
| 5470 | ENTER(); |
| 5471 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5472 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5473 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5474 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5475 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5476 | hdd_wmm_init(adapter); |
| 5477 | |
| 5478 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5479 | case QDF_STA_MODE: |
| 5480 | case QDF_P2P_CLIENT_MODE: |
| 5481 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5482 | |
| 5483 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5484 | ->conn_info.connState; |
| 5485 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5486 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5488 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5489 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5490 | /* Indicate disconnect event to supplicant |
| 5491 | * if associated previously |
| 5492 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5493 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5494 | eConnectionState_IbssConnected == connState || |
| 5495 | eConnectionState_NotConnected == connState || |
| 5496 | eConnectionState_IbssDisconnected == connState || |
| 5497 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5498 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5500 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5501 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5502 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5503 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5504 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5505 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5506 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5507 | |
| 5508 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5509 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5510 | adapter->dev, false, |
| 5511 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5512 | } else if (eConnectionState_Connecting == connState) { |
| 5513 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5514 | * Indicate connect failure to supplicant if we |
| 5515 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5516 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5517 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5518 | NULL, 0, NULL, 0, |
| 5519 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5520 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5521 | } |
| 5522 | |
| 5523 | hdd_register_tx_flow_control(adapter, |
| 5524 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5525 | hdd_tx_resume_cb, |
| 5526 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5527 | |
| 5528 | break; |
| 5529 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5530 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5531 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5532 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5533 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5534 | break; |
| 5535 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5536 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5537 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5538 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5539 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5540 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5541 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5542 | /* event supplicant to restart */ |
| 5543 | cfg80211_del_sta(adapter->dev, |
| 5544 | (const u8 *)&bcastMac.bytes[0], |
| 5545 | GFP_KERNEL); |
| 5546 | #endif |
| 5547 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5548 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5549 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5550 | hdd_set_mon_rx_cb(adapter->dev); |
| 5551 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5552 | adapter->mon_bandwidth); |
| 5553 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5554 | default: |
| 5555 | break; |
| 5556 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5557 | /* |
| 5558 | * Action frame registered in one adapter which will |
| 5559 | * applicable to all interfaces |
| 5560 | */ |
| 5561 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5562 | } |
| 5563 | |
| 5564 | EXIT(); |
| 5565 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5566 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5567 | } |
| 5568 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5569 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5570 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5571 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5572 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5573 | qdf_list_node_t *node; |
| 5574 | |
| 5575 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5576 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5577 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5578 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5579 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5580 | |
| 5581 | if (QDF_IS_STATUS_ERROR(status)) |
| 5582 | return status; |
| 5583 | |
| 5584 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5585 | |
| 5586 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5587 | } |
| 5588 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5589 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5590 | struct hdd_adapter *current_adapter, |
| 5591 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5592 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5593 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5594 | qdf_list_node_t *node; |
| 5595 | |
| 5596 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5597 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5598 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5599 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5600 | ¤t_adapter->node, |
| 5601 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5602 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5603 | |
| 5604 | if (QDF_IS_STATUS_ERROR(status)) |
| 5605 | return status; |
| 5606 | |
| 5607 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5608 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5609 | return status; |
| 5610 | } |
| 5611 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5612 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5613 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5614 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5615 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5616 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5617 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5618 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5619 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5620 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5621 | return status; |
| 5622 | } |
| 5623 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5624 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5625 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5626 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5627 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5628 | qdf_list_node_t *node; |
| 5629 | |
| 5630 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5631 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5632 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5633 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5634 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5635 | |
| 5636 | if (QDF_IS_STATUS_ERROR(status)) |
| 5637 | return status; |
| 5638 | |
| 5639 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5640 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5641 | return status; |
| 5642 | } |
| 5643 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5644 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5645 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5646 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5647 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5648 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5649 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5650 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5651 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5652 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5653 | return status; |
| 5654 | } |
| 5655 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5656 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5657 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5658 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5659 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5660 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5661 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5662 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5663 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5664 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5665 | return status; |
| 5666 | } |
| 5667 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5668 | 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] | 5669 | tSirMacAddr macAddr) |
| 5670 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5671 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5672 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5673 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5674 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5675 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5676 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5677 | } |
| 5678 | |
| 5679 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5680 | } |
| 5681 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5682 | 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] | 5683 | uint32_t vdev_id) |
| 5684 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5685 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5686 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5687 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5688 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5689 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5690 | } |
| 5691 | |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 5692 | hdd_err_ratelimited(RATE_LIMIT_ERROR_LOG, |
| 5693 | "vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5694 | |
| 5695 | return NULL; |
| 5696 | } |
| 5697 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5698 | /** |
| 5699 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5700 | * the sessionid |
| 5701 | * @hdd_ctx: hdd context. |
| 5702 | * @sme_session_id: sme session is for the adapter to get. |
| 5703 | * |
| 5704 | * This function is used to get the adapter with provided session id |
| 5705 | * |
| 5706 | * Return: adapter pointer if found |
| 5707 | * |
| 5708 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5709 | struct hdd_adapter * |
| 5710 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5711 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5712 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5713 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5714 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5715 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5716 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5717 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5718 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5719 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5720 | return NULL; |
| 5721 | } |
| 5722 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5723 | 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] | 5724 | const char *iface_name) |
| 5725 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5726 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5727 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5728 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5729 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5730 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5731 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5732 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5733 | return NULL; |
| 5734 | } |
| 5735 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5736 | /** |
| 5737 | * hdd_get_adapter() - to get adapter matching the mode |
| 5738 | * @hdd_ctx: hdd context |
| 5739 | * @mode: adapter mode |
| 5740 | * |
| 5741 | * This routine will return the pointer to adapter matching |
| 5742 | * with the passed mode. |
| 5743 | * |
| 5744 | * Return: pointer to adapter or null |
| 5745 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5746 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5747 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 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 (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5754 | } |
| 5755 | |
| 5756 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5757 | } |
| 5758 | |
| 5759 | /** |
| 5760 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5761 | * @hdd_ctx: Pointer to the HDD context. |
| 5762 | * @mode: Device mode for which operating channel is required. |
| 5763 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5764 | * QDF_STA_MODE, |
| 5765 | * QDF_P2P_CLIENT_MODE, |
| 5766 | * QDF_SAP_MODE, |
| 5767 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5768 | * |
| 5769 | * This API returns the operating channel of the requested device mode |
| 5770 | * |
| 5771 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5772 | * not connected. |
| 5773 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5774 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5775 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5776 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5777 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5778 | uint8_t operatingChannel = 0; |
| 5779 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5780 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5781 | if (mode == adapter->device_mode) { |
| 5782 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5783 | case QDF_STA_MODE: |
| 5784 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5785 | if (hdd_conn_is_connected |
| 5786 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5787 | (adapter))) { |
| 5788 | operatingChannel = |
| 5789 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5790 | (adapter))->conn_info. |
| 5791 | operationChannel; |
| 5792 | } |
| 5793 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5794 | case QDF_SAP_MODE: |
| 5795 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5796 | /* softap connection info */ |
| 5797 | if (test_bit |
| 5798 | (SOFTAP_BSS_STARTED, |
| 5799 | &adapter->event_flags)) |
| 5800 | operatingChannel = |
| 5801 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 5802 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5803 | break; |
| 5804 | default: |
| 5805 | break; |
| 5806 | } |
| 5807 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5808 | /* Found the device of interest. break the loop */ |
| 5809 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5810 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5811 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5813 | return operatingChannel; |
| 5814 | } |
| 5815 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5816 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5817 | hdd_ctx) |
| 5818 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5819 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5820 | |
| 5821 | ENTER(); |
| 5822 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5823 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5824 | if (adapter->device_mode == QDF_STA_MODE || |
| 5825 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5826 | adapter->device_mode == QDF_IBSS_MODE || |
| 5827 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5828 | adapter->device_mode == QDF_SAP_MODE || |
| 5829 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5830 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5831 | hdd_unregister_wext(adapter->dev); |
| 5832 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5833 | } |
| 5834 | |
| 5835 | EXIT(); |
| 5836 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5837 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5838 | } |
| 5839 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5840 | 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] | 5841 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5842 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5843 | |
| 5844 | ENTER(); |
| 5845 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5846 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5847 | if (adapter->device_mode == QDF_STA_MODE || |
| 5848 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5849 | adapter->device_mode == QDF_IBSS_MODE || |
| 5850 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5851 | adapter->device_mode == QDF_SAP_MODE || |
| 5852 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5853 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5854 | adapter->session_id, INVALID_SCAN_ID, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5855 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5856 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5857 | } |
| 5858 | |
| 5859 | EXIT(); |
| 5860 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5861 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5862 | } |
| 5863 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5864 | /** |
| 5865 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5866 | * adapters |
| 5867 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5868 | * |
| 5869 | * return: QDF_STATUS_SUCCESS |
| 5870 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5871 | 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] | 5872 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5873 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5874 | int err; |
| 5875 | |
| 5876 | ENTER(); |
| 5877 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5878 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5879 | if (adapter->device_mode == QDF_STA_MODE || |
| 5880 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5881 | adapter->device_mode == QDF_IBSS_MODE || |
| 5882 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5883 | adapter->device_mode == QDF_SAP_MODE || |
| 5884 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5885 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5886 | if (err) |
| 5887 | hdd_err("Unable to stop scheduled scan"); |
| 5888 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5889 | } |
| 5890 | |
| 5891 | EXIT(); |
| 5892 | |
| 5893 | return QDF_STATUS_SUCCESS; |
| 5894 | } |
| 5895 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5896 | #ifdef WLAN_NS_OFFLOAD |
| 5897 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5898 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5899 | * @hdd_ctx: Pointer to hdd context |
| 5900 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5901 | * Unregister for IPv6 address change notifications. |
| 5902 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5903 | * Return: None |
| 5904 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5905 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5906 | { |
| 5907 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5908 | } |
| 5909 | |
| 5910 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5911 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5912 | * @hdd_ctx: Pointer to hdd context |
| 5913 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5914 | * Register for IPv6 address change notifications. |
| 5915 | * |
| 5916 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5917 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5918 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5919 | { |
| 5920 | int ret; |
| 5921 | |
| 5922 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5923 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5924 | if (ret) { |
| 5925 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5926 | goto out; |
| 5927 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5929 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5930 | out: |
| 5931 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5932 | } |
| 5933 | #else |
| 5934 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5935 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5936 | * @hdd_ctx: Pointer to hdd context |
| 5937 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5938 | * Unregister for IPv6 address change notifications. |
| 5939 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | * Return: None |
| 5941 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5942 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | { |
| 5944 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5945 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5946 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5947 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5948 | * @hdd_ctx: Pointer to hdd context |
| 5949 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5950 | * Register for IPv6 address change notifications. |
| 5951 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5952 | * Return: None |
| 5953 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5954 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5955 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5956 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5957 | } |
| 5958 | #endif |
| 5959 | |
| 5960 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5961 | * hdd_register_notifiers - Register netdev notifiers. |
| 5962 | * @hdd_ctx: HDD context |
| 5963 | * |
| 5964 | * Register netdev notifiers like IPv4 and IPv6. |
| 5965 | * |
| 5966 | * Return: 0 on success and errno on failure |
| 5967 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5968 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5969 | { |
| 5970 | int ret; |
| 5971 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5972 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5973 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5974 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5975 | |
| 5976 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5977 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5978 | if (ret) { |
| 5979 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5980 | goto unregister_ip6_notifier; |
| 5981 | } |
| 5982 | |
| 5983 | return 0; |
| 5984 | |
| 5985 | unregister_ip6_notifier: |
| 5986 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5987 | out: |
| 5988 | return ret; |
| 5989 | |
| 5990 | } |
| 5991 | |
| 5992 | /** |
| 5993 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5994 | * @hdd_ctx: HDD context |
| 5995 | * |
| 5996 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5997 | * |
| 5998 | * Return: None. |
| 5999 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6000 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6001 | { |
| 6002 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6003 | |
| 6004 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6005 | } |
| 6006 | |
| 6007 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6008 | * hdd_exit_netlink_services - Exit netlink services |
| 6009 | * @hdd_ctx: HDD context |
| 6010 | * |
| 6011 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6012 | * nl service. |
| 6013 | * |
| 6014 | * Return: None. |
| 6015 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6016 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6017 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6018 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6019 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6020 | ptt_sock_deactivate_svc(); |
| 6021 | |
| 6022 | nl_srv_exit(); |
| 6023 | } |
| 6024 | |
| 6025 | /** |
| 6026 | * hdd_init_netlink_services- Init netlink services |
| 6027 | * @hdd_ctx: HDD context |
| 6028 | * |
| 6029 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6030 | * nl service. |
| 6031 | * |
| 6032 | * Return: 0 on success and errno on failure. |
| 6033 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6034 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6035 | { |
| 6036 | int ret; |
| 6037 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6038 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6039 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6040 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6041 | goto out; |
| 6042 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6043 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6044 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6045 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6046 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6047 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6048 | goto err_nl_srv; |
| 6049 | } |
| 6050 | |
| 6051 | ret = ptt_sock_activate_svc(); |
| 6052 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6053 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6054 | goto err_nl_srv; |
| 6055 | } |
| 6056 | |
| 6057 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6058 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6059 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6060 | |
| 6061 | ret = cnss_diag_activate_service(); |
| 6062 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6063 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6064 | goto err_close_cesium; |
| 6065 | } |
| 6066 | |
| 6067 | return 0; |
| 6068 | |
| 6069 | err_close_cesium: |
| 6070 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6071 | ptt_sock_deactivate_svc(); |
| 6072 | err_nl_srv: |
| 6073 | nl_srv_exit(); |
| 6074 | out: |
| 6075 | return ret; |
| 6076 | } |
| 6077 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6078 | /** |
| 6079 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6080 | * @hdd_ctx: HDD context. |
| 6081 | * |
| 6082 | * Destroy RX wakelock. |
| 6083 | * |
| 6084 | * Return: None. |
| 6085 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6086 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6087 | { |
| 6088 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6089 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6090 | |
| 6091 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6092 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6093 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6094 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6095 | * Create RX wakelock. |
| 6096 | * |
| 6097 | * Return: None. |
| 6098 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6099 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6100 | { |
| 6101 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6102 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6103 | |
| 6104 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6105 | * hdd_context_deinit() - Deinitialize HDD context |
| 6106 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6107 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6108 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6109 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6110 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6111 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6112 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6113 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6114 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6115 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6116 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6117 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6118 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6119 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6120 | hdd_sap_context_destroy(hdd_ctx); |
| 6121 | |
| 6122 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6123 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6124 | hdd_scan_context_destroy(hdd_ctx); |
| 6125 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6126 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6127 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6128 | return 0; |
| 6129 | } |
| 6130 | |
| 6131 | /** |
| 6132 | * hdd_context_destroy() - Destroy HDD context |
| 6133 | * @hdd_ctx: HDD context to be destroyed. |
| 6134 | * |
| 6135 | * Free config and HDD context as well as destroy all the resources. |
| 6136 | * |
| 6137 | * Return: None |
| 6138 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6139 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6140 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6141 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6142 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6143 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6144 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6145 | hdd_context_deinit(hdd_ctx); |
| 6146 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6147 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6148 | hdd_ctx->config = NULL; |
| 6149 | |
| 6150 | wiphy_free(hdd_ctx->wiphy); |
| 6151 | } |
| 6152 | |
| 6153 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6154 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6155 | * |
| 6156 | * This function is used to destroy bug report lock |
| 6157 | * |
| 6158 | * Return: None |
| 6159 | */ |
| 6160 | static void wlan_destroy_bug_report_lock(void) |
| 6161 | { |
| 6162 | p_cds_contextType p_cds_context; |
| 6163 | |
| 6164 | p_cds_context = cds_get_global_context(); |
| 6165 | if (!p_cds_context) { |
| 6166 | hdd_err("cds context is NULL"); |
| 6167 | return; |
| 6168 | } |
| 6169 | |
| 6170 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6171 | } |
| 6172 | |
| 6173 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6174 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6175 | * @hdd_ctx: Pointer to the HDD Context |
| 6176 | * |
| 6177 | * This is the driver exit point (invoked during rmmod) |
| 6178 | * |
| 6179 | * Return: None |
| 6180 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6181 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6182 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6183 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6184 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6185 | |
| 6186 | ENTER(); |
| 6187 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6188 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6189 | |
| 6190 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6191 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6192 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6193 | |
| 6194 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6195 | if (QDF_TIMER_STATE_RUNNING == |
| 6196 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6197 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6198 | } |
| 6199 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6200 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6201 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6202 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6203 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6204 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6205 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6206 | hdd_ctx->last_acs_channel_list = NULL; |
| 6207 | hdd_ctx->num_of_channels = 0; |
| 6208 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6209 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6211 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6212 | driver_status = hdd_ctx->driver_status; |
| 6213 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6214 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6215 | /* |
| 6216 | * Powersave Offload Case |
| 6217 | * Disable Idle Power Save Mode |
| 6218 | */ |
| 6219 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6220 | /* clear the scan queue in all the scenarios */ |
| 6221 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6222 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6223 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6224 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6225 | /* |
| 6226 | * Cancel any outstanding scan requests. We are about to close |
| 6227 | * all of our adapters, but an adapter structure is what SME |
| 6228 | * passes back to our callback function. Hence if there |
| 6229 | * are any outstanding scan requests then there is a |
| 6230 | * race condition between when the adapter is closed and |
| 6231 | * when the callback is invoked. We try to resolve that |
| 6232 | * race condition here by canceling any outstanding scans |
| 6233 | * before we close the adapters. |
| 6234 | * Note that the scans may be cancelled in an asynchronous |
| 6235 | * manner, so ideally there needs to be some kind of |
| 6236 | * synchronization. Rather than introduce a new |
| 6237 | * synchronization here, we will utilize the fact that we are |
| 6238 | * about to Request Full Power, and since that is synchronized, |
| 6239 | * the expectation is that by the time Request Full Power has |
| 6240 | * completed, all scans will be cancelled |
| 6241 | */ |
| 6242 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6243 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6244 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6245 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6246 | } |
| 6247 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6248 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6249 | |
Dustin Brown | 36e24e2 | 2017-12-21 12:34:13 -0800 | [diff] [blame] | 6250 | hdd_close_all_adapters(hdd_ctx, false); |
| 6251 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6252 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6253 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6254 | hdd_driver_memdump_deinit(); |
| 6255 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6256 | qdf_nbuf_deinit_replenish_timer(); |
| 6257 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6258 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6259 | hdd_info("Release wakelock for monitor mode!"); |
| 6260 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6261 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6262 | } |
| 6263 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6264 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6265 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6266 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6267 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | /* |
| 6269 | * Close CDS |
| 6270 | * This frees pMac(HAL) context. There should not be any call |
| 6271 | * that requires pMac access after this. |
| 6272 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6273 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 6274 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6275 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6276 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | hdd_ipa_cleanup(hdd_ctx); |
| 6278 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6279 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6280 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6281 | /* |
| 6282 | * If there is re_init failure wiphy would have already de-registered |
| 6283 | * check the wiphy status before un-registering again |
| 6284 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6285 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6286 | wiphy_unregister(wiphy); |
| 6287 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6288 | hdd_lpass_notify_stop(hdd_ctx); |
| 6289 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6290 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6291 | hdd_exit_netlink_services(hdd_ctx); |
| 6292 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6293 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6294 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6295 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6296 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6297 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6298 | if (driver_status) |
| 6299 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6300 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6301 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6302 | } |
| 6303 | |
| 6304 | void __hdd_wlan_exit(void) |
| 6305 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6306 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6307 | |
| 6308 | ENTER(); |
| 6309 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6310 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6311 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6312 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6313 | EXIT(); |
| 6314 | return; |
| 6315 | } |
| 6316 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6317 | /* Do all the cleanup before deregistering the driver */ |
| 6318 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6319 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6320 | EXIT(); |
| 6321 | } |
| 6322 | |
| 6323 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6324 | /** |
| 6325 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6326 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6327 | * |
| 6328 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6329 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6330 | * scan information. |
| 6331 | * |
| 6332 | * Return: void |
| 6333 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6334 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6335 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6336 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6337 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6338 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6339 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6340 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6341 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6342 | hdd_ctx->last_acs_channel_list = NULL; |
| 6343 | hdd_ctx->num_of_channels = 0; |
| 6344 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | |
| 6346 | if (!hdd_ctx->hHal) |
| 6347 | return; |
| 6348 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6349 | } |
| 6350 | #endif |
| 6351 | |
| 6352 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6353 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6354 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6355 | { |
| 6356 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6357 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6358 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | |
| 6360 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6361 | |
| 6362 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6363 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6364 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | if (!hdd_ctx->hHal) |
| 6367 | return -EINVAL; |
| 6368 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6369 | 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] | 6370 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6371 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6372 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6373 | return -EINVAL; |
| 6374 | } |
| 6375 | |
| 6376 | return 0; |
| 6377 | } |
| 6378 | #endif |
| 6379 | |
| 6380 | /** |
| 6381 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6382 | * @state: state |
| 6383 | * |
| 6384 | * This function notifies FW with modem power status |
| 6385 | * |
| 6386 | * Return: 0 if successful, error number otherwise |
| 6387 | */ |
| 6388 | int hdd_wlan_notify_modem_power_state(int state) |
| 6389 | { |
| 6390 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6391 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6392 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6393 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6394 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6395 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6396 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6398 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6399 | if (!hdd_ctx->hHal) |
| 6400 | return -EINVAL; |
| 6401 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6402 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6403 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6404 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6405 | state); |
| 6406 | return -EINVAL; |
| 6407 | } |
| 6408 | return 0; |
| 6409 | } |
| 6410 | |
| 6411 | /** |
| 6412 | * |
| 6413 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6414 | * @adapter - Pointer to the HDD |
| 6415 | * |
| 6416 | * Return: None |
| 6417 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6418 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6419 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6420 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6421 | |
| 6422 | /* |
| 6423 | * Send ready indication to the HDD. This will kick off the MAC |
| 6424 | * into a 'running' state and should kick off an initial scan. |
| 6425 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6426 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6427 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6428 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6429 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6430 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6431 | } |
| 6432 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6433 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6434 | } |
| 6435 | |
| 6436 | /* wake lock APIs for HDD */ |
| 6437 | void hdd_prevent_suspend(uint32_t reason) |
| 6438 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6439 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6440 | } |
| 6441 | |
| 6442 | void hdd_allow_suspend(uint32_t reason) |
| 6443 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6444 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6445 | } |
| 6446 | |
| 6447 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6448 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6449 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6450 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6451 | } |
| 6452 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6453 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6454 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6455 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6456 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6457 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6458 | hdd_ctx->reg.alpha2, |
| 6459 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6460 | } |
| 6461 | |
| 6462 | /** |
| 6463 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6464 | * @hdd_ctx: Pointer to the hdd context |
| 6465 | * |
| 6466 | * HDD function to know if hardware supports 5GHz |
| 6467 | * |
| 6468 | * Return: true if hardware supports 5GHz |
| 6469 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6470 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6471 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6472 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6473 | return true; |
| 6474 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6475 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6476 | return true; |
| 6477 | else |
| 6478 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6479 | } |
| 6480 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6481 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | { |
| 6483 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6484 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6485 | |
| 6486 | wiphy = hdd_ctx->wiphy; |
| 6487 | |
| 6488 | /* |
| 6489 | * The channel information in |
| 6490 | * wiphy needs to be initialized before wiphy registration |
| 6491 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6492 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6493 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6494 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6495 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | } |
| 6497 | |
| 6498 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6499 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6500 | #else |
| 6501 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6502 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6503 | WIPHY_WOWLAN_DISCONNECT | |
| 6504 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6505 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6506 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6507 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6508 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6509 | |
| 6510 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6511 | WOW_MAX_FILTERS_PER_LIST); |
| 6512 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6513 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6514 | #endif |
| 6515 | |
| 6516 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6517 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6518 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6519 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6520 | return ret_val; |
| 6521 | } |
| 6522 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6523 | if (!hdd_ctx->reg_offload) |
| 6524 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6525 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6526 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6527 | } |
| 6528 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6529 | #ifdef MSM_PLATFORM |
| 6530 | /** |
| 6531 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6532 | * @hdd_ctx - handle to hdd context |
| 6533 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6534 | * |
| 6535 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6536 | * Stats show up in wlan driver logs. |
| 6537 | * |
| 6538 | * Returns: None |
| 6539 | */ |
| 6540 | static inline |
| 6541 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6542 | bool data_in_interval) |
| 6543 | { |
| 6544 | static u32 counter; |
| 6545 | static bool data_in_time_period; |
| 6546 | ol_txrx_pdev_handle pdev; |
| 6547 | |
| 6548 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6549 | return; |
| 6550 | |
| 6551 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6552 | if (!pdev) { |
| 6553 | hdd_err("pdev is NULL"); |
| 6554 | return; |
| 6555 | } |
| 6556 | |
| 6557 | counter++; |
| 6558 | if (data_in_interval) |
| 6559 | data_in_time_period = data_in_interval; |
| 6560 | |
| 6561 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6562 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6563 | if (data_in_time_period) { |
| 6564 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6565 | CDP_TXRX_PATH_STATS, |
| 6566 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6567 | wlan_hdd_display_netif_queue_history |
| 6568 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6569 | qdf_dp_trace_dump_stats(); |
| 6570 | } |
| 6571 | counter = 0; |
| 6572 | data_in_time_period = false; |
| 6573 | } |
| 6574 | } |
| 6575 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6576 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6577 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6578 | * @hdd_ctx - handle to hdd context |
| 6579 | * @tx_packets - transmit packet count |
| 6580 | * @rx_packets - receive packet count |
| 6581 | * |
| 6582 | * The function controls the bus bandwidth and dynamic control of |
| 6583 | * tcp delayed ack configuration |
| 6584 | * |
| 6585 | * Returns: None |
| 6586 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6587 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6588 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6589 | const uint64_t tx_packets, |
| 6590 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6592 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6593 | uint64_t temp_rx = 0; |
| 6594 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6595 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6596 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6597 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6598 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6599 | uint16_t index = 0; |
| 6600 | bool vote_level_change = false; |
| 6601 | bool rx_level_change = false; |
| 6602 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6603 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6604 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6605 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6606 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6607 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6608 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6609 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6610 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6611 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6612 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6614 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6615 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6616 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6617 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6618 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6619 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6620 | if (hdd_ctx->hbw_requested) { |
| 6621 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6622 | hdd_ctx->hbw_requested = false; |
| 6623 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6624 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6625 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6626 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6627 | if (!hdd_ctx->hbw_requested) { |
| 6628 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6629 | hdd_ctx->hbw_requested = true; |
| 6630 | } |
| 6631 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6632 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6633 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6634 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6635 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6637 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6638 | qdf_dp_trace_throttle_live_mode( |
| 6639 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6640 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6641 | /* fine-tuning parameters for RX Flows */ |
| 6642 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6644 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6645 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6646 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6647 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6648 | else |
| 6649 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6650 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6651 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6652 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6653 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6654 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6655 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6656 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6657 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6658 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6659 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6661 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6662 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 6663 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6664 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6665 | next_rx_level, temp_rx); |
| 6666 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6667 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6668 | /* Send throughput indication only if it is enabled. |
| 6669 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6670 | * to default delayed ack. Note that this will disable the |
| 6671 | * dynamic delayed ack mechanism across the system |
| 6672 | */ |
| 6673 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6674 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 6675 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 6676 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 6677 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 6678 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6679 | rx_tp_data.level = next_rx_level; |
| 6680 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6681 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 6682 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6683 | } |
| 6684 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6685 | /* fine-tuning parameters for TX Flows */ |
| 6686 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6687 | hdd_ctx->prev_tx = tx_packets; |
| 6688 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6689 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6690 | else |
| 6691 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6692 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6693 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6694 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6695 | next_tx_level, temp_tx); |
| 6696 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6697 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6698 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6699 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6700 | &next_tx_level, |
| 6701 | sizeof(next_tx_level)); |
| 6702 | } |
| 6703 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6704 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6705 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6706 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6707 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6708 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6709 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6710 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6711 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6712 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6713 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6714 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6715 | |
| 6716 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6717 | } |
| 6718 | |
| 6719 | #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] | 6720 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6721 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6722 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6723 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6724 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6725 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6726 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6727 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6729 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6730 | bool connected = false; |
| 6731 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6732 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6733 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6734 | return; |
| 6735 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 6736 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6737 | goto restart_timer; |
| 6738 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6739 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6740 | /* |
| 6741 | * Validate magic so we don't end up accessing |
| 6742 | * an invalid adapter. |
| 6743 | */ |
| 6744 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6745 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6746 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6747 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6748 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6749 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6750 | != eConnectionState_Associated) { |
| 6751 | |
| 6752 | continue; |
| 6753 | } |
| 6754 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6755 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6756 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 6757 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6758 | |
| 6759 | continue; |
| 6760 | } |
| 6761 | |
| 6762 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6763 | adapter->prev_tx_packets); |
| 6764 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6765 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6766 | |
| 6767 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6768 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6769 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6770 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6771 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6772 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6773 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6774 | &fwd_tx_packets, &fwd_rx_packets); |
| 6775 | if (ret == A_OK) { |
| 6776 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6777 | fwd_tx_packets, |
| 6778 | adapter->prev_fwd_tx_packets); |
| 6779 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6780 | fwd_tx_packets, |
| 6781 | adapter->prev_fwd_rx_packets); |
| 6782 | } |
| 6783 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6784 | |
| 6785 | total_rx += adapter->stats.rx_packets; |
| 6786 | total_tx += adapter->stats.tx_packets; |
| 6787 | |
| 6788 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6789 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6790 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6791 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6792 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6793 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6794 | connected = true; |
| 6795 | } |
| 6796 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6797 | /* add intra bss forwarded tx and rx packets */ |
| 6798 | tx_packets += fwd_tx_packets_diff; |
| 6799 | rx_packets += fwd_rx_packets_diff; |
| 6800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6801 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6802 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6803 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6804 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6805 | if (adapter) { |
| 6806 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6807 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6808 | } |
| 6809 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6810 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6811 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6812 | return; |
| 6813 | } |
| 6814 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6815 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6816 | |
| 6817 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6818 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6819 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6820 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6821 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6822 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6823 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6824 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6825 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6826 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6827 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6828 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6829 | /** |
| 6830 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6831 | * @arg: Argument of timer function |
| 6832 | * |
| 6833 | * Schedule a workqueue in this function where all the processing is done. |
| 6834 | * |
| 6835 | * Return: None. |
| 6836 | */ |
| 6837 | static void __hdd_bus_bw_cbk(void *arg) |
| 6838 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6839 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6840 | |
| 6841 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6842 | return; |
| 6843 | |
| 6844 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6845 | } |
| 6846 | |
| 6847 | /** |
| 6848 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6849 | * @arg: Argument of timer function |
| 6850 | * |
| 6851 | * Return: None. |
| 6852 | */ |
| 6853 | static void hdd_bus_bw_cbk(void *arg) |
| 6854 | { |
| 6855 | cds_ssr_protect(__func__); |
| 6856 | __hdd_bus_bw_cbk(arg); |
| 6857 | cds_ssr_unprotect(__func__); |
| 6858 | } |
| 6859 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6860 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6861 | { |
| 6862 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6863 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6864 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6865 | hdd_ctx->bus_bw_timer_running = false; |
| 6866 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6867 | qdf_timer_init(NULL, |
| 6868 | &hdd_ctx->bus_bw_timer, |
| 6869 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6870 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6871 | |
| 6872 | return 0; |
| 6873 | } |
| 6874 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6875 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6876 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6877 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6878 | hdd_reset_tcp_delack(hdd_ctx); |
| 6879 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6880 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6881 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6882 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6883 | hdd_ctx->bus_bw_timer_running = false; |
| 6884 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6885 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6886 | |
| 6887 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6888 | { |
| 6889 | if (hdd_ctx) |
| 6890 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6891 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 6892 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6893 | #endif |
| 6894 | |
| 6895 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6896 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6897 | * @hdd_ctx: hdd context |
| 6898 | * |
| 6899 | * Return: 0 for success or error code |
| 6900 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6901 | 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] | 6902 | { |
| 6903 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6904 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6905 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6906 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6907 | return -ENOMEM; |
| 6908 | } |
| 6909 | return 0; |
| 6910 | } |
| 6911 | |
| 6912 | /** |
| 6913 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6914 | * @hdd_ctx: hdd context |
| 6915 | * |
| 6916 | * Return: none |
| 6917 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6918 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6919 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6920 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6921 | return; |
| 6922 | |
| 6923 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6924 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6925 | } |
| 6926 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6927 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6928 | { |
| 6929 | switch (level) { |
| 6930 | /* initialize the wlan sub system */ |
| 6931 | case WLAN_SVC_TP_NONE: |
| 6932 | return "NONE"; |
| 6933 | case WLAN_SVC_TP_LOW: |
| 6934 | return "LOW"; |
| 6935 | case WLAN_SVC_TP_MEDIUM: |
| 6936 | return "MED"; |
| 6937 | case WLAN_SVC_TP_HIGH: |
| 6938 | return "HIGH"; |
| 6939 | default: |
| 6940 | return "INVAL"; |
| 6941 | } |
| 6942 | } |
| 6943 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6944 | |
| 6945 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6946 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6947 | * @hdd_ctx: hdd context |
| 6948 | * |
| 6949 | * Return: none |
| 6950 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6951 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6952 | { |
| 6953 | int i; |
| 6954 | |
| 6955 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6956 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6957 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6958 | 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] | 6959 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6960 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6961 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6962 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6963 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6964 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6966 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6967 | 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] | 6968 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6969 | #endif |
| 6970 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6971 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6972 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6973 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6974 | 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] | 6975 | |
| 6976 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6977 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6978 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6979 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6980 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6981 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6982 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6983 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6984 | convert_level_to_string( |
| 6985 | hdd_ctx->hdd_txrx_hist[i]. |
| 6986 | next_vote_level), |
| 6987 | convert_level_to_string( |
| 6988 | hdd_ctx->hdd_txrx_hist[i]. |
| 6989 | next_rx_level), |
| 6990 | convert_level_to_string( |
| 6991 | hdd_ctx->hdd_txrx_hist[i]. |
| 6992 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | } |
| 6995 | |
| 6996 | /** |
| 6997 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6998 | * @hdd_ctx: hdd context |
| 6999 | * |
| 7000 | * Return: none |
| 7001 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7002 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7003 | { |
| 7004 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7005 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7006 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | } |
| 7008 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7009 | /* length of the netif queue log needed per adapter */ |
| 7010 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7011 | |
| 7012 | /** |
| 7013 | * |
| 7014 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7015 | * @hdd_ctx: hdd context |
| 7016 | * |
| 7017 | * Return: none |
| 7018 | */ |
| 7019 | static void |
| 7020 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7021 | { |
| 7022 | int adapter_num = 0; |
| 7023 | int i; |
| 7024 | int bytes_written; |
| 7025 | u32 tbytes; |
| 7026 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7027 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
| 7028 | char comb_log_str[(ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1]; |
| 7029 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7030 | |
| 7031 | bytes_written = 0; |
| 7032 | qdf_mem_set(comb_log_str, 0, sizeof(comb_log_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7033 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7034 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7035 | curr_time = qdf_system_ticks(); |
| 7036 | total = curr_time - adapter->start_time; |
| 7037 | delta = curr_time - adapter->last_time; |
| 7038 | |
| 7039 | if (adapter->pause_map) { |
| 7040 | pause = adapter->total_pause_time + delta; |
| 7041 | unpause = adapter->total_unpause_time; |
| 7042 | } else { |
| 7043 | unpause = adapter->total_unpause_time + delta; |
| 7044 | pause = adapter->total_pause_time; |
| 7045 | } |
| 7046 | |
| 7047 | tbytes = 0; |
| 7048 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7049 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7050 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7051 | continue; |
| 7052 | tbytes += |
| 7053 | snprintf( |
| 7054 | &temp_str[tbytes], |
| 7055 | (tbytes >= sizeof(temp_str) ? |
| 7056 | 0 : sizeof(temp_str) - tbytes), |
| 7057 | "%d(%d,%d) ", |
| 7058 | i, |
| 7059 | adapter->queue_oper_stats[i]. |
| 7060 | pause_count, |
| 7061 | adapter->queue_oper_stats[i]. |
| 7062 | unpause_count); |
| 7063 | } |
| 7064 | if (tbytes >= sizeof(temp_str)) |
| 7065 | hdd_warn("log truncated"); |
| 7066 | |
| 7067 | bytes_written += snprintf(&comb_log_str[bytes_written], |
| 7068 | bytes_written >= sizeof(comb_log_str) ? 0 : |
| 7069 | sizeof(comb_log_str) - bytes_written, |
| 7070 | "[%d %d] (%d) %u/%ums %s|", |
| 7071 | adapter->session_id, adapter->device_mode, |
| 7072 | adapter->pause_map, |
| 7073 | qdf_system_ticks_to_msecs(pause), |
| 7074 | qdf_system_ticks_to_msecs(total), |
| 7075 | temp_str); |
| 7076 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7077 | adapter_num++; |
| 7078 | } |
| 7079 | |
| 7080 | /* using QDF_TRACE to avoid printing function name */ |
| 7081 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7082 | "STATS |%s", comb_log_str); |
| 7083 | |
| 7084 | if (bytes_written >= sizeof(comb_log_str)) |
| 7085 | hdd_warn("log string truncated"); |
| 7086 | } |
| 7087 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7088 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7089 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7090 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7091 | * |
| 7092 | * Return: none |
| 7093 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7094 | void |
| 7095 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7096 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7097 | { |
| 7098 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7099 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7100 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7101 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7102 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7103 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7104 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7105 | return; |
| 7106 | } |
| 7107 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7108 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7109 | hdd_debug("Netif queue operation statistics:"); |
| 7110 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7111 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7112 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7113 | curr_time = qdf_system_ticks(); |
| 7114 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7115 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7116 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7117 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7118 | unpause = adapter->total_unpause_time; |
| 7119 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7120 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7121 | pause = adapter->total_pause_time; |
| 7122 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7123 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7124 | qdf_system_ticks_to_msecs(total), |
| 7125 | qdf_system_ticks_to_msecs(pause), |
| 7126 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7127 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7128 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7129 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7130 | qdf_time_t pause_delta = 0; |
| 7131 | |
| 7132 | if (adapter->pause_map & (1 << i)) |
| 7133 | pause_delta = delta; |
| 7134 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7135 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7136 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7137 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | hdd_reason_type_to_string(i), |
| 7139 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7140 | adapter->queue_oper_stats[i].unpause_count, |
| 7141 | qdf_system_ticks_to_msecs( |
| 7142 | adapter->queue_oper_stats[i].total_pause_time + |
| 7143 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7144 | } |
| 7145 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7146 | hdd_debug("Netif queue operation history:"); |
| 7147 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7148 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7149 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7150 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7151 | |
| 7152 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7153 | /* using hdd_log to avoid printing function name */ |
| 7154 | if (adapter->queue_oper_history[i].time == 0) |
| 7155 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7156 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7157 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 7158 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7159 | adapter->queue_oper_history[i].time), |
| 7160 | hdd_action_type_to_string( |
| 7161 | adapter->queue_oper_history[i].netif_action), |
| 7162 | hdd_reason_type_to_string( |
| 7163 | adapter->queue_oper_history[i].netif_reason), |
| 7164 | adapter->queue_oper_history[i].pause_map); |
| 7165 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7166 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | } |
| 7168 | |
| 7169 | /** |
| 7170 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7171 | * @hdd_ctx: hdd context |
| 7172 | * |
| 7173 | * Return: none |
| 7174 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7175 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7176 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7177 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7178 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7179 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7180 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7181 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7182 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7183 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7184 | adapter->history_index = 0; |
| 7185 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7186 | adapter->total_pause_time = 0; |
| 7187 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7188 | } |
| 7189 | } |
| 7190 | |
| 7191 | /** |
| 7192 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7193 | * @halHandle: Hal handle |
| 7194 | * @pContext: Pointer to the context |
| 7195 | * @sessionId: Session ID |
| 7196 | * @scanId: Scan ID |
| 7197 | * @status: Status |
| 7198 | * |
| 7199 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7200 | * the scan results |
| 7201 | * |
| 7202 | * 11d scan is done during driver load and is a passive scan on all |
| 7203 | * channels supported by the device, 11d scans may find some APs on |
| 7204 | * frequencies which are forbidden to be used in the regulatory domain |
| 7205 | * the device is operating in. If these APs are notified to the supplicant |
| 7206 | * it may try to connect to these APs, thus flush out all the scan results |
| 7207 | * which are present in SME after 11d scan is done. |
| 7208 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7209 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7210 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7211 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7212 | uint8_t sessionId, uint32_t scanId, |
| 7213 | eCsrScanStatus status) |
| 7214 | { |
| 7215 | ENTER(); |
| 7216 | |
| 7217 | sme_scan_flush_result(halHandle); |
| 7218 | |
| 7219 | EXIT(); |
| 7220 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7221 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7222 | } |
| 7223 | |
| 7224 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7225 | /** |
| 7226 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7227 | * @hdd_ctx: hdd global context |
| 7228 | * |
| 7229 | * Return: none |
| 7230 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7231 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7232 | { |
| 7233 | uint8_t i; |
| 7234 | |
| 7235 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7236 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7237 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7238 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7239 | } |
| 7240 | } |
| 7241 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7242 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7243 | { |
| 7244 | } |
| 7245 | #endif |
| 7246 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7247 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7248 | /** |
| 7249 | * 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] | 7250 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7251 | * @enable: enable or disable this behaviour |
| 7252 | * |
| 7253 | * Return: int |
| 7254 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7255 | 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] | 7256 | { |
| 7257 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7258 | struct wow_pulse_mode wow_pulse_set_info; |
| 7259 | QDF_STATUS status; |
| 7260 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7261 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7262 | |
| 7263 | if (false == phddctx->config->wow_pulse_support) |
| 7264 | return 0; |
| 7265 | |
| 7266 | /* prepare the request to send to SME */ |
| 7267 | if (enable == true) { |
| 7268 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7269 | wow_pulse_set_info.wow_pulse_pin = |
| 7270 | pcfg_ini->wow_pulse_pin; |
| 7271 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7272 | pcfg_ini->wow_pulse_interval_low; |
| 7273 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7274 | pcfg_ini->wow_pulse_interval_high; |
| 7275 | } else { |
| 7276 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7277 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7278 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7279 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7280 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7281 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7282 | wow_pulse_set_info.wow_pulse_enable, |
| 7283 | wow_pulse_set_info.wow_pulse_pin, |
| 7284 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7285 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7286 | |
| 7287 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7288 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7289 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7290 | return -EIO; |
| 7291 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7292 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7293 | return 0; |
| 7294 | } |
| 7295 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7296 | 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] | 7297 | { |
| 7298 | return 0; |
| 7299 | } |
| 7300 | #endif |
| 7301 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7302 | #ifdef WLAN_FEATURE_FASTPATH |
| 7303 | /** |
| 7304 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7305 | * @hdd_cfg: hdd config |
| 7306 | * @context: lower layer context |
| 7307 | * |
| 7308 | * Return: none |
| 7309 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7310 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7311 | void *context) |
| 7312 | { |
| 7313 | if (hdd_cfg->fastpath_enable) |
| 7314 | hif_enable_fastpath(context); |
| 7315 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7316 | #endif |
| 7317 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7318 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7319 | /** |
| 7320 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7321 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7322 | * @level: thermal level |
| 7323 | * |
| 7324 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7325 | * than 0, and restore the original data path when throttle level is 0 |
| 7326 | * |
| 7327 | * Return: none |
| 7328 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7329 | 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] | 7330 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7331 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7332 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7333 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7334 | if (level > THROTTLE_LEVEL_0) |
| 7335 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7336 | else |
| 7337 | /* restore original concurrency mode */ |
| 7338 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7339 | } |
| 7340 | |
| 7341 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7342 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7343 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7344 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7345 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7346 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7347 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7348 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7349 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7350 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7351 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7352 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7353 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7354 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7356 | struct sir_pcl_list pcl; |
| 7357 | QDF_STATUS status; |
| 7358 | uint32_t i, j; |
| 7359 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7360 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7361 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7362 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7363 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7364 | if (!hdd_ctx) { |
| 7365 | hdd_err("invalid HDD context"); |
| 7366 | return INVALID_CHANNEL_ID; |
| 7367 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7368 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7369 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7370 | if (!hal_handle) { |
| 7371 | hdd_err("invalid HAL handle"); |
| 7372 | return INVALID_CHANNEL_ID; |
| 7373 | } |
| 7374 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7375 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7376 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7377 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7378 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7379 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7380 | hdd_err("Get PCL failed"); |
| 7381 | return INVALID_CHANNEL_ID; |
| 7382 | } |
| 7383 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7384 | /* |
| 7385 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7386 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7387 | * try to choose a safe channel from acs range. |
| 7388 | */ |
| 7389 | if (!pcl.pcl_len) |
| 7390 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7391 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7392 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7393 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7394 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7395 | |
| 7396 | /* PCL already takes unsafe channel into account */ |
| 7397 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7398 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7399 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7400 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7401 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7402 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7403 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7404 | return pcl.pcl_list[i]; |
| 7405 | } |
| 7406 | } |
| 7407 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7408 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7409 | |
| 7410 | /* Try for safe channel from all valid channel */ |
| 7411 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7412 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7413 | &pcl.pcl_len); |
| 7414 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7415 | hdd_err("error in getting valid channel list"); |
| 7416 | return INVALID_CHANNEL_ID; |
| 7417 | } |
| 7418 | |
| 7419 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7420 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7421 | found = false; |
| 7422 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7423 | if (pcl.pcl_list[i] == |
| 7424 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7425 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7426 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7427 | break; |
| 7428 | } |
| 7429 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7430 | |
| 7431 | if (found) |
| 7432 | continue; |
| 7433 | |
| 7434 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7435 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7436 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7437 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7438 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7439 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7440 | } |
| 7441 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7442 | |
| 7443 | return INVALID_CHANNEL_ID; |
| 7444 | } |
| 7445 | |
| 7446 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7447 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7448 | * @adapter: AP adapter |
| 7449 | * @channel: Channel |
| 7450 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7451 | * Moves the SAP interface by invoking the function which |
| 7452 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7453 | * |
| 7454 | * Return: None |
| 7455 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7456 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7457 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7458 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7459 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7460 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7461 | |
| 7462 | if (!adapter) { |
| 7463 | hdd_err("invalid adapter"); |
| 7464 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7465 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7466 | |
| 7467 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7468 | |
| 7469 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7470 | if (!hal_handle) { |
| 7471 | hdd_err("invalid HAL handle"); |
| 7472 | return; |
| 7473 | } |
| 7474 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7475 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7476 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7477 | hdd_ap_ctx->sap_config.channel = channel; |
| 7478 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7479 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7480 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7481 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7482 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7483 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7484 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7485 | hdd_ap_ctx->sap_config.channel, |
| 7486 | hdd_ap_ctx->sap_config.sec_ch, |
| 7487 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7488 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7489 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7490 | adapter->session_id, channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7491 | hdd_ap_ctx->sap_config.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7492 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7493 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7494 | 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] | 7495 | { |
| 7496 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7497 | int status; |
| 7498 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7499 | |
| 7500 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7501 | |
| 7502 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7503 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7504 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7505 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7506 | } |
| 7507 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7508 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7509 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7510 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7511 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7512 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7513 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7514 | hdd_err("failed to start external acs timer"); |
| 7515 | return -ENOSPC; |
| 7516 | } |
| 7517 | /* Update config to application */ |
| 7518 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7519 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7520 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7521 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7522 | } |
| 7523 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7524 | /** |
| 7525 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7526 | * @hdd_ctx: hdd context pointer |
| 7527 | * |
| 7528 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7529 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7530 | * sap. User space on LTE coex indication restart driver. |
| 7531 | * |
| 7532 | * Return - none |
| 7533 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7534 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7535 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7536 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7537 | uint32_t i; |
| 7538 | bool found = false; |
| 7539 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7540 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7541 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7542 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7543 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7544 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7545 | adapter->device_mode, |
| 7546 | adapter->session.ap.sap_config. |
| 7547 | acs_cfg.acs_mode); |
| 7548 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7549 | } |
| 7550 | |
| 7551 | found = false; |
| 7552 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7553 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7554 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7555 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7556 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7557 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7558 | break; |
| 7559 | } |
| 7560 | } |
| 7561 | |
| 7562 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7563 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7564 | adapter->session.ap.operating_channel); |
| 7565 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7566 | } |
| 7567 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7568 | if (hdd_ctxt->config->vendor_acs_support && |
| 7569 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7570 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7571 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7572 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7573 | } else |
| 7574 | restart_chan = |
| 7575 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7576 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7577 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7578 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7579 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7580 | /* |
| 7581 | * SAP restart due to unsafe channel. While |
| 7582 | * restarting the SAP, make sure to clear |
| 7583 | * acs_channel, channel to reset to |
| 7584 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7585 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7586 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7587 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7588 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7589 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7590 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7591 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7592 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7593 | hdd_debug("driver to start sap: %d", |
| 7594 | hdd_ctxt->config->sap_internal_restart); |
| 7595 | if (hdd_ctxt->config->sap_internal_restart) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7596 | hdd_switch_sap_channel(adapter, restart_chan); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7597 | else |
| 7598 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7599 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7600 | } |
| 7601 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7602 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7603 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7604 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7605 | * @hdd_ctx: HDD global context |
| 7606 | * |
| 7607 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7608 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7609 | * down to the lower layers. Then subscribe to subsequent channel |
| 7610 | * avoidance events. |
| 7611 | * |
| 7612 | * Return: None |
| 7613 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7614 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7615 | { |
| 7616 | uint16_t unsafe_channel_count; |
| 7617 | int index; |
| 7618 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7619 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7620 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7621 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7622 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7623 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7624 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7625 | hdd_ctx->unsafe_channel_count); |
| 7626 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7627 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7628 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7629 | |
| 7630 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7631 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7632 | hdd_ctx->unsafe_channel_list[index]); |
| 7633 | |
| 7634 | } |
| 7635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7636 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7637 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7638 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7639 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7640 | { |
| 7641 | uint8_t restart_chan; |
| 7642 | |
| 7643 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7644 | if (!restart_chan) { |
| 7645 | hdd_alert("fail to restart SAP"); |
| 7646 | return; |
| 7647 | } |
| 7648 | |
| 7649 | /* SAP restart due to unsafe channel. While restarting |
| 7650 | * the SAP, make sure to clear acs_channel, channel to |
| 7651 | * reset to 0. Otherwise these settings will override |
| 7652 | * the ACS while restart. |
| 7653 | */ |
| 7654 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7655 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7656 | |
| 7657 | hdd_debug("sending coex indication"); |
| 7658 | |
| 7659 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7660 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7661 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7662 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7663 | |
| 7664 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7665 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7666 | { |
| 7667 | uint32_t size; |
| 7668 | uint16_t *unsafe_list; |
| 7669 | uint16_t chan_count; |
| 7670 | |
| 7671 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7672 | return -EINVAL; |
| 7673 | |
| 7674 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7675 | NUM_CHANNELS); |
| 7676 | if (chan_count) { |
| 7677 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7678 | unsafe_list = qdf_mem_malloc(size); |
| 7679 | if (!unsafe_list) { |
| 7680 | hdd_err("No memory for unsafe chan list size%d", |
| 7681 | size); |
| 7682 | return -ENOMEM; |
| 7683 | } |
| 7684 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7685 | } else { |
| 7686 | unsafe_list = NULL; |
| 7687 | } |
| 7688 | |
| 7689 | *local_unsafe_list = unsafe_list; |
| 7690 | *local_unsafe_list_count = chan_count; |
| 7691 | |
| 7692 | return 0; |
| 7693 | } |
| 7694 | |
| 7695 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7696 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7697 | { |
| 7698 | int i, j; |
| 7699 | |
| 7700 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7701 | return true; |
| 7702 | if (local_unsafe_list_count == 0) |
| 7703 | return false; |
| 7704 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7705 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7706 | if (local_unsafe_list[i] == |
| 7707 | hdd_ctx->unsafe_channel_list[j]) |
| 7708 | break; |
| 7709 | if (j >= local_unsafe_list_count) |
| 7710 | break; |
| 7711 | } |
| 7712 | if (i >= local_unsafe_list_count) { |
| 7713 | hdd_info("unsafe chan list same"); |
| 7714 | return false; |
| 7715 | } |
| 7716 | |
| 7717 | return true; |
| 7718 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7719 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7720 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7721 | { |
| 7722 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7723 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7724 | 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] | 7725 | { |
| 7726 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7727 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7728 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7729 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7730 | { |
| 7731 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7732 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7733 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7734 | |
| 7735 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7736 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7737 | * user space |
| 7738 | * @frame_ind: Management frame data to be informed. |
| 7739 | * |
| 7740 | * This function is used to indicate management frame to |
| 7741 | * user space |
| 7742 | * |
| 7743 | * Return: None |
| 7744 | * |
| 7745 | */ |
| 7746 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7747 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7748 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7749 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7750 | int i; |
| 7751 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7752 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7753 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7754 | |
| 7755 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7756 | return; |
| 7757 | |
| 7758 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7759 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7760 | adapter = |
| 7761 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7762 | if (adapter) |
| 7763 | break; |
| 7764 | } |
| 7765 | } else { |
| 7766 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7767 | frame_ind->sessionId); |
| 7768 | } |
| 7769 | |
| 7770 | if ((NULL != adapter) && |
| 7771 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7772 | __hdd_indicate_mgmt_frame(adapter, |
| 7773 | frame_ind->frame_len, |
| 7774 | frame_ind->frameBuf, |
| 7775 | frame_ind->frameType, |
| 7776 | frame_ind->rxChan, |
| 7777 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7778 | } |
| 7779 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7780 | void hdd_acs_response_timeout_handler(void *context) |
| 7781 | { |
| 7782 | struct hdd_external_acs_timer_context *timer_context = |
| 7783 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7784 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7785 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7786 | uint8_t reason; |
| 7787 | |
| 7788 | ENTER(); |
| 7789 | if (!timer_context) { |
| 7790 | hdd_err("invlaid timer context"); |
| 7791 | return; |
| 7792 | } |
| 7793 | adapter = timer_context->adapter; |
| 7794 | reason = timer_context->reason; |
| 7795 | |
| 7796 | |
| 7797 | if ((!adapter) || |
| 7798 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7799 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7800 | return; |
| 7801 | } |
| 7802 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7803 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7804 | return; |
| 7805 | |
| 7806 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7807 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7808 | else |
| 7809 | return; |
| 7810 | |
| 7811 | hdd_err("ACS timeout happened for %s reason %d", |
| 7812 | adapter->dev->name, reason); |
| 7813 | switch (reason) { |
| 7814 | /* SAP init case */ |
| 7815 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7816 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7817 | false); |
| 7818 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7819 | break; |
| 7820 | /* DFS detected on current channel */ |
| 7821 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7822 | wlan_sap_update_next_channel( |
| 7823 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7824 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7825 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7826 | break; |
| 7827 | /* LTE coex event on current channel */ |
| 7828 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7829 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7830 | break; |
| 7831 | default: |
| 7832 | hdd_info("invalid reason for timer invoke"); |
| 7833 | |
| 7834 | } |
| 7835 | } |
| 7836 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7837 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7839 | * @hdd_ctx: HDD context |
| 7840 | * |
| 7841 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7842 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7843 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7844 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7845 | 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] | 7846 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7847 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7848 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7849 | |
| 7850 | if (!hdd_ctx) { |
| 7851 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7852 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7853 | } |
| 7854 | |
| 7855 | cfg.scan_config = 0; |
| 7856 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7857 | 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] | 7858 | |
| 7859 | hdd_debug("Disabling all dual mac features..."); |
| 7860 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7861 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7862 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7863 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7864 | return status; |
| 7865 | } |
| 7866 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7867 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7868 | } |
| 7869 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7870 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7871 | 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] | 7872 | { |
| 7873 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7874 | QDF_STATUS status; |
| 7875 | |
| 7876 | if (!hdd_ctx) { |
| 7877 | hdd_err("HDD context is NULL"); |
| 7878 | return QDF_STATUS_E_FAILURE; |
| 7879 | } |
| 7880 | |
| 7881 | cfg.scan_config = 0; |
| 7882 | cfg.fw_mode_config = 0; |
| 7883 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7884 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7885 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7886 | &cfg.fw_mode_config, |
| 7887 | hdd_ctx->config->dual_mac_feature_disable); |
| 7888 | |
| 7889 | if (status != QDF_STATUS_SUCCESS) { |
| 7890 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7891 | status); |
| 7892 | return status; |
| 7893 | } |
| 7894 | |
| 7895 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7896 | cfg.scan_config, cfg.fw_mode_config); |
| 7897 | |
| 7898 | status = sme_soc_set_dual_mac_config(cfg); |
| 7899 | if (status != QDF_STATUS_SUCCESS) { |
| 7900 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7901 | return status; |
| 7902 | } |
| 7903 | |
| 7904 | return QDF_STATUS_SUCCESS; |
| 7905 | } |
| 7906 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7907 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7908 | * hdd_override_ini_config - Override INI config |
| 7909 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7910 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7911 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7912 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7913 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7914 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7915 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7916 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7917 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7918 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7919 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7920 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7921 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7922 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7923 | if (0 == enable_11d || 1 == enable_11d) { |
| 7924 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7925 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7926 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7927 | |
| 7928 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7929 | hdd_ctx->config->IpaConfig = 0; |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 7930 | |
| 7931 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 7932 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 7933 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 7934 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 7935 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 7936 | hdd_ctx->config->oce_sta_enabled = 0; |
| 7937 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7938 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7939 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7940 | /** |
| 7941 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7942 | * @hdd_ctx - HDD context |
| 7943 | * |
| 7944 | * Set trace level for each module based on INI config. |
| 7945 | * |
| 7946 | * Return: None |
| 7947 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7948 | 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] | 7949 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7950 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7951 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7952 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7953 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7954 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7955 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7956 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7957 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7958 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7959 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7960 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7961 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7962 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7963 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7964 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7965 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7966 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7967 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7968 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7969 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7970 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7971 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7972 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7973 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7974 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7975 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7976 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 7977 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 7978 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 7979 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7980 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7981 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7982 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7983 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7984 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7985 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7986 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7987 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7988 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7989 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7990 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7991 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 7992 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 7993 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 7994 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7995 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7996 | } |
| 7997 | |
| 7998 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7999 | * hdd_context_init() - Initialize HDD context |
| 8000 | * @hdd_ctx: HDD context. |
| 8001 | * |
| 8002 | * Initialize HDD context along with all the feature specific contexts. |
| 8003 | * |
| 8004 | * return: 0 on success and errno on failure. |
| 8005 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8006 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8007 | { |
| 8008 | int ret; |
| 8009 | |
| 8010 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8011 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8012 | |
| 8013 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8014 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8015 | |
| 8016 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8017 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8018 | |
| 8019 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8020 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8021 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8022 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8023 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8024 | |
| 8025 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8026 | |
| 8027 | ret = hdd_scan_context_init(hdd_ctx); |
| 8028 | if (ret) |
| 8029 | goto list_destroy; |
| 8030 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8031 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8032 | |
| 8033 | ret = hdd_sap_context_init(hdd_ctx); |
| 8034 | if (ret) |
| 8035 | goto scan_destroy; |
| 8036 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8037 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8038 | |
| 8039 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8040 | |
| 8041 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8042 | hdd_ctx->config); |
| 8043 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8044 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8045 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8046 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8047 | "monitor_mode_wakelock"); |
| 8048 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8049 | return 0; |
| 8050 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8051 | sap_destroy: |
| 8052 | hdd_sap_context_destroy(hdd_ctx); |
| 8053 | |
| 8054 | scan_destroy: |
| 8055 | hdd_scan_context_destroy(hdd_ctx); |
| 8056 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8057 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8058 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8059 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8060 | return ret; |
| 8061 | } |
| 8062 | |
| 8063 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8064 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8065 | * @hdd_ctx: pointer to hdd context |
| 8066 | * |
| 8067 | * Return: status of initialization |
| 8068 | * 0 - success |
| 8069 | * negative value - failure |
| 8070 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8071 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8072 | { |
| 8073 | int ret; |
| 8074 | |
| 8075 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8076 | return 0; |
| 8077 | |
| 8078 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8079 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8080 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8081 | return -EINVAL; |
| 8082 | } |
| 8083 | |
| 8084 | /* parse ini string probe req oui */ |
| 8085 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8086 | if (ret) { |
| 8087 | hdd_err("parsing error: disable ie whitelisting"); |
| 8088 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8089 | } |
| 8090 | |
| 8091 | return ret; |
| 8092 | } |
| 8093 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8094 | |
| 8095 | /** |
| 8096 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8097 | * @priv: pointer to hdd context |
| 8098 | * |
| 8099 | * This function is invoked when the timer waiting for the interface change |
| 8100 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8101 | * |
| 8102 | * Return: void |
| 8103 | */ |
| 8104 | static void hdd_iface_change_callback(void *priv) |
| 8105 | { |
| 8106 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8107 | int ret; |
| 8108 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8109 | |
| 8110 | if (status) |
| 8111 | return; |
| 8112 | |
| 8113 | ENTER(); |
| 8114 | hdd_debug("Interface change timer expired close the modules!"); |
| 8115 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8116 | if (ret) |
| 8117 | hdd_err("Failed to stop modules"); |
| 8118 | EXIT(); |
| 8119 | } |
| 8120 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8121 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8122 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8123 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8124 | * |
| 8125 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8126 | * wiphy allocation and then context is initialized. |
| 8127 | * |
| 8128 | * Return: HDD context on success and ERR_PTR on failure |
| 8129 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8130 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8131 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8132 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8133 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8134 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8135 | |
| 8136 | ENTER(); |
| 8137 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8138 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8139 | if (hdd_ctx == NULL) { |
| 8140 | ret = -ENOMEM; |
| 8141 | goto err_out; |
| 8142 | } |
| 8143 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8144 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8145 | hdd_iface_change_callback, |
| 8146 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8147 | |
| 8148 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8149 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8150 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8151 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8152 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8153 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8154 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8155 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8156 | ret = -ENOMEM; |
| 8157 | goto err_free_hdd_context; |
| 8158 | } |
| 8159 | |
| 8160 | /* Read and parse the qcom_cfg.ini file */ |
| 8161 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8162 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8163 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8164 | WLAN_INI_FILE); |
| 8165 | ret = -EINVAL; |
| 8166 | goto err_free_config; |
| 8167 | } |
| 8168 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8169 | ie_whitelist_attrs_init(hdd_ctx); |
| 8170 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8171 | hdd_debug("setting timer multiplier: %u", |
| 8172 | hdd_ctx->config->timer_multiplier); |
| 8173 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8174 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8175 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8176 | if (hdd_ctx->config->fhostNSOffload) |
| 8177 | hdd_ctx->ns_offload_enable = true; |
| 8178 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8179 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8180 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8181 | hdd_override_ini_config(hdd_ctx); |
| 8182 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8183 | ret = hdd_context_init(hdd_ctx); |
| 8184 | |
| 8185 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8186 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8187 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8188 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8189 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8190 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8191 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8192 | goto skip_multicast_logging; |
| 8193 | |
| 8194 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8195 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8196 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8197 | if (ret) |
| 8198 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8199 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8200 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8201 | if (ret) |
| 8202 | goto err_deinit_txrx_histogram; |
| 8203 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 8204 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 8205 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8206 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8207 | skip_multicast_logging: |
| 8208 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8209 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8210 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8211 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8212 | EXIT(); |
| 8213 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8214 | return hdd_ctx; |
| 8215 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8216 | err_deinit_txrx_histogram: |
| 8217 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8218 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8219 | err_deinit_hdd_context: |
| 8220 | hdd_context_deinit(hdd_ctx); |
| 8221 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8222 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8223 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8224 | |
| 8225 | err_free_hdd_context: |
| 8226 | wiphy_free(hdd_ctx->wiphy); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8227 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8228 | |
| 8229 | err_out: |
| 8230 | return ERR_PTR(ret); |
| 8231 | } |
| 8232 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8233 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8234 | /** |
| 8235 | * hdd_open_p2p_interface - Open P2P interface |
| 8236 | * @hdd_ctx: HDD context |
| 8237 | * @rtnl_held: True if RTNL lock held |
| 8238 | * |
| 8239 | * Open P2P interface during probe. This function called to open the P2P |
| 8240 | * interface at probe along with STA interface. |
| 8241 | * |
| 8242 | * Return: 0 on success and errno on failure |
| 8243 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8244 | 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] | 8245 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8246 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8247 | uint8_t *p2p_dev_addr; |
| 8248 | |
| 8249 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8250 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8251 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8252 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8253 | sizeof(tSirMacAddr)); |
| 8254 | |
| 8255 | /* |
| 8256 | * Generate the P2P Device Address. This consists of |
| 8257 | * the device's primary MAC address with the locally |
| 8258 | * administered bit set. |
| 8259 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8260 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8261 | } else { |
| 8262 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8263 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8264 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8265 | return -ENOSPC; |
| 8266 | } |
| 8267 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8268 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8269 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8270 | } |
| 8271 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8272 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8273 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8274 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8275 | |
| 8276 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8277 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8278 | return -ENOSPC; |
| 8279 | } |
| 8280 | |
| 8281 | return 0; |
| 8282 | } |
| 8283 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8284 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8285 | bool rtnl_held) |
| 8286 | { |
| 8287 | return 0; |
| 8288 | } |
| 8289 | #endif |
| 8290 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8291 | 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] | 8292 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8293 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8294 | int ret = 0; |
| 8295 | |
| 8296 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8297 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8298 | NET_NAME_UNKNOWN, rtnl_held); |
| 8299 | if (adapter == NULL) { |
| 8300 | hdd_err("Failed to open 802.11p interface"); |
| 8301 | ret = -ENOSPC; |
| 8302 | } |
| 8303 | |
| 8304 | return ret; |
| 8305 | } |
| 8306 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8307 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8308 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8309 | * @adapter: HDD adapter |
| 8310 | * |
| 8311 | * This function initializes the adapter for the station mode. |
| 8312 | * |
| 8313 | * Return: 0 on success or errno on failure. |
| 8314 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8315 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8316 | { |
| 8317 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8318 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8319 | |
| 8320 | ENTER_DEV(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8321 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8322 | hdd_err("session is already opened, %d", |
| 8323 | adapter->session_id); |
| 8324 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8325 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8326 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8327 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8328 | if (ret) { |
| 8329 | hdd_err("failed to create vdev: %d", ret); |
| 8330 | return ret; |
| 8331 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8332 | status = hdd_init_station_mode(adapter); |
| 8333 | |
| 8334 | if (QDF_STATUS_SUCCESS != status) { |
| 8335 | hdd_err("Error Initializing station mode: %d", status); |
| 8336 | return qdf_status_to_os_return(status); |
| 8337 | } |
| 8338 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8339 | hdd_register_tx_flow_control(adapter, |
| 8340 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8341 | hdd_tx_resume_cb, |
| 8342 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8343 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8344 | EXIT(); |
| 8345 | return 0; |
| 8346 | } |
| 8347 | |
| 8348 | /** |
| 8349 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8350 | * @adapter: HDD adapter |
| 8351 | * |
| 8352 | * This function initializes the adapter for the AP mode. |
| 8353 | * |
| 8354 | * Return: 0 on success errno on failure. |
| 8355 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8356 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8357 | { |
| 8358 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8359 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8360 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8361 | |
| 8362 | ENTER(); |
| 8363 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8364 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8365 | hdd_err("session is already opened, %d", |
| 8366 | adapter->session_id); |
| 8367 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8368 | } |
| 8369 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8370 | * In SSR case no need to create new sap context. |
| 8371 | * Otherwise create sap context first and then create |
| 8372 | * vdev as while creating the vdev, driver needs to |
| 8373 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8374 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8375 | if (adapter->session.ap.sap_context) { |
| 8376 | is_ssr = true; |
| 8377 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8378 | hdd_err("sap creation failed"); |
| 8379 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8380 | } |
| 8381 | |
| 8382 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8383 | adapter->session.ap.sap_context); |
| 8384 | if (ret) { |
| 8385 | hdd_err("failed to create vdev, status:%d", ret); |
| 8386 | hdd_sap_destroy_ctx(adapter); |
| 8387 | return ret; |
| 8388 | } |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8389 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8390 | |
| 8391 | if (QDF_STATUS_SUCCESS != status) { |
| 8392 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8393 | return qdf_status_to_os_return(status); |
| 8394 | } |
| 8395 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8396 | hdd_register_tx_flow_control(adapter, |
| 8397 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8398 | hdd_softap_tx_resume_cb, |
| 8399 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8400 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8401 | EXIT(); |
| 8402 | return 0; |
| 8403 | } |
| 8404 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8405 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8406 | bool rtnl_held) |
| 8407 | { |
| 8408 | struct hdd_adapter *adapter; |
| 8409 | |
| 8410 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8411 | hdd_ctx->config->enableConcurrentSTA, |
| 8412 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8413 | NET_NAME_UNKNOWN, rtnl_held); |
| 8414 | |
| 8415 | if (!adapter) |
| 8416 | return -ENOSPC; |
| 8417 | |
| 8418 | return 0; |
| 8419 | } |
| 8420 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8421 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8422 | * hdd_open_interfaces - Open all required interfaces |
| 8423 | * hdd_ctx: HDD context |
| 8424 | * rtnl_held: True if RTNL lock is held |
| 8425 | * |
| 8426 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8427 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8428 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8429 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8430 | 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] | 8431 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8432 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8433 | int ret; |
| 8434 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8435 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8436 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8437 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8438 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8439 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8440 | |
| 8441 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8442 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8443 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8444 | if (!adapter) { |
| 8445 | hdd_err("open adapter failed"); |
| 8446 | return -ENOSPC; |
| 8447 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8448 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8449 | return 0; |
| 8450 | } |
| 8451 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8452 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8453 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8454 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8455 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8456 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8457 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8458 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8459 | |
| 8460 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8461 | return -ENOSPC; |
| 8462 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 8463 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 8464 | adapter->fast_roaming_allowed = true; |
| 8465 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8466 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8467 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8468 | if (ret) |
| 8469 | hdd_err("Cannot create concurrent STA interface"); |
| 8470 | } |
| 8471 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8472 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8473 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8474 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8475 | |
| 8476 | /* Open 802.11p Interface */ |
| 8477 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8478 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8479 | if (ret) |
| 8480 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8481 | } |
| 8482 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8483 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8484 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8485 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8486 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8487 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8488 | } |
| 8489 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8490 | /** |
| 8491 | * hdd_update_country_code - Update country code |
| 8492 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8493 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8494 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8495 | * |
| 8496 | * Return: 0 on success and errno on failure |
| 8497 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8498 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8499 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8500 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8501 | return 0; |
| 8502 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8503 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8504 | } |
| 8505 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8506 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8507 | /** |
| 8508 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8509 | * @cds_cfg: CDS Configuration |
| 8510 | * @hdd_ctx: Pointer to hdd context |
| 8511 | * |
| 8512 | * Return: none |
| 8513 | */ |
| 8514 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8515 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8516 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8517 | { |
| 8518 | cds_cfg->tx_flow_stop_queue_th = |
| 8519 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8520 | cds_cfg->tx_flow_start_queue_offset = |
| 8521 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8522 | } |
| 8523 | #else |
| 8524 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8525 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8526 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8527 | { |
| 8528 | } |
| 8529 | #endif |
| 8530 | |
| 8531 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8532 | /** |
| 8533 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8534 | * @cds_cfg: CDS Configuration |
| 8535 | * @hdd_ctx: Pointer to hdd context |
| 8536 | * |
| 8537 | * Return: none |
| 8538 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8539 | 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] | 8540 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8541 | { |
| 8542 | cds_cfg->ra_ratelimit_interval = |
| 8543 | hdd_ctx->config->RArateLimitInterval; |
| 8544 | cds_cfg->is_ra_ratelimit_enabled = |
| 8545 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8546 | } |
| 8547 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8548 | 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] | 8549 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8550 | { |
| 8551 | } |
| 8552 | #endif |
| 8553 | |
| 8554 | /** |
| 8555 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8556 | * @hdd_ctx: HDD Context |
| 8557 | * |
| 8558 | * Return: 0 for Success, errno on failure |
| 8559 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8560 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8561 | { |
| 8562 | struct cds_config_info *cds_cfg; |
| 8563 | |
| 8564 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8565 | if (!cds_cfg) { |
| 8566 | hdd_err("failed to allocate cds config"); |
| 8567 | return -ENOMEM; |
| 8568 | } |
| 8569 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8570 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8571 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8572 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8573 | cds_cfg->powersave_offload_enabled = |
| 8574 | hdd_ctx->config->enablePowersaveOffload; |
| 8575 | } else { |
| 8576 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8577 | PS_QPOWER_NODEEPSLEEP) || |
| 8578 | (hdd_ctx->config->enablePowersaveOffload == |
| 8579 | PS_LEGACY_NODEEPSLEEP)) |
| 8580 | cds_cfg->powersave_offload_enabled = |
| 8581 | PS_LEGACY_NODEEPSLEEP; |
| 8582 | else |
| 8583 | cds_cfg->powersave_offload_enabled = |
| 8584 | PS_LEGACY_DEEPSLEEP; |
| 8585 | hdd_info("Qpower disabled in cds config, %d", |
| 8586 | cds_cfg->powersave_offload_enabled); |
| 8587 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8588 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8589 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8590 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8591 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8592 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8593 | |
| 8594 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8595 | * ns offload and others. Currently 1st bit is used for arp |
| 8596 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8597 | */ |
| 8598 | if (hdd_ctx->config->fhostArpOffload) |
| 8599 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8600 | if (hdd_ctx->config->fhostNSOffload) |
| 8601 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8602 | |
| 8603 | /* |
| 8604 | * Copy the DFS Phyerr Filtering Offload status. |
| 8605 | * This parameter reflects the value of the |
| 8606 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8607 | */ |
| 8608 | cds_cfg->dfs_phyerr_filter_offload = |
| 8609 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8610 | if (hdd_ctx->config->ssdp) |
| 8611 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8612 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8613 | cds_cfg->force_target_assert_enabled = |
| 8614 | hdd_ctx->config->crash_inject_enabled; |
| 8615 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8616 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8617 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8618 | |
| 8619 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8620 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8621 | |
| 8622 | cds_cfg->ap_disable_intrabss_fwd = |
| 8623 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8624 | |
| 8625 | cds_cfg->dfs_pri_multiplier = |
| 8626 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8627 | cds_cfg->reorder_offload = |
| 8628 | hdd_ctx->config->reorderOffloadSupport; |
| 8629 | |
| 8630 | /* IPA micro controller data path offload resource config item */ |
| 8631 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8632 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8633 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8634 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8635 | hdd_ctx->config->IpaUcTxBufCount); |
| 8636 | hdd_ctx->config->IpaUcTxBufCount = |
| 8637 | rounddown_pow_of_two( |
| 8638 | hdd_ctx->config->IpaUcTxBufCount); |
| 8639 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8640 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8641 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8642 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8643 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8644 | hdd_ctx->config->IpaUcTxBufCount); |
| 8645 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8646 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8647 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8648 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8649 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8650 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8651 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8652 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8653 | rounddown_pow_of_two( |
| 8654 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8655 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8656 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8657 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8658 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8659 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8660 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8661 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8662 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8663 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8664 | cds_cfg->uc_tx_partition_base = |
| 8665 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8666 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8667 | |
| 8668 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8669 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8670 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8671 | cds_cfg->ce_classify_enabled = |
| 8672 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8673 | cds_cfg->bpf_packet_filter_enable = |
| 8674 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8675 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8676 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8677 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8678 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8679 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8680 | cds_cfg->max_msdus_per_rxinorderind = |
| 8681 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8682 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8683 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8684 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8685 | 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] | 8686 | cds_cfg->auto_power_save_fail_mode = |
| 8687 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8688 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8689 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8690 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8691 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8692 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8693 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8694 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8695 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8696 | cds_init_ini_config(cds_cfg); |
| 8697 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8698 | |
| 8699 | exit: |
| 8700 | qdf_mem_free(cds_cfg); |
| 8701 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8702 | } |
| 8703 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8704 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8705 | * hdd_update_user_config() - API to update user configuration |
| 8706 | * parameters to obj mgr which are used by multiple components |
| 8707 | * @hdd_ctx: HDD Context |
| 8708 | * |
| 8709 | * Return: 0 for Success, errno on failure |
| 8710 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8711 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8712 | { |
| 8713 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8714 | |
| 8715 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8716 | if (user_config == NULL) { |
| 8717 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8718 | return -ENOMEM; |
| 8719 | } |
| 8720 | |
| 8721 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8722 | user_config->dual_mac_feature_disable = |
| 8723 | hdd_ctx->config->dual_mac_feature_disable; |
| 8724 | user_config->indoor_channel_support = |
| 8725 | hdd_ctx->config->indoor_channel_support; |
| 8726 | user_config->is_11d_support_enabled = |
| 8727 | hdd_ctx->config->Is11dSupportEnabled; |
| 8728 | user_config->is_11h_support_enabled = |
| 8729 | hdd_ctx->config->Is11hSupportEnabled; |
| 8730 | user_config->optimize_chan_avoid_event = |
| 8731 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8732 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8733 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8734 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8735 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8736 | |
| 8737 | qdf_mem_free(user_config); |
| 8738 | return 0; |
| 8739 | } |
| 8740 | |
| 8741 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8742 | * hdd_init_thermal_info - Initialize thermal level |
| 8743 | * @hdd_ctx: HDD context |
| 8744 | * |
| 8745 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8746 | * which would be called when a configured thermal threshold is hit. |
| 8747 | * |
| 8748 | * Return: 0 on success and errno on failure |
| 8749 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8750 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8751 | { |
| 8752 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8753 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8754 | |
| 8755 | thermal_param.smeThermalMgmtEnabled = |
| 8756 | hdd_ctx->config->thermalMitigationEnable; |
| 8757 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8758 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8759 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8760 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8761 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8762 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8763 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8764 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8765 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8766 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8767 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8768 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8769 | hdd_ctx->config->thermalTempMinLevel0; |
| 8770 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8771 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8772 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8773 | hdd_ctx->config->thermalTempMinLevel1; |
| 8774 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8775 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8776 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8777 | hdd_ctx->config->thermalTempMinLevel2; |
| 8778 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8779 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8780 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8781 | hdd_ctx->config->thermalTempMinLevel3; |
| 8782 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8783 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8784 | |
| 8785 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8786 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8787 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8788 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8789 | |
| 8790 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8791 | hdd_set_thermal_level_cb); |
| 8792 | |
| 8793 | return 0; |
| 8794 | |
| 8795 | } |
| 8796 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8797 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8798 | /** |
| 8799 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8800 | * |
| 8801 | * Hold RTNL lock |
| 8802 | * |
| 8803 | * Return: True if held and false otherwise |
| 8804 | */ |
| 8805 | static inline bool hdd_hold_rtnl_lock(void) |
| 8806 | { |
| 8807 | rtnl_lock(); |
| 8808 | return true; |
| 8809 | } |
| 8810 | |
| 8811 | /** |
| 8812 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8813 | * |
| 8814 | * Release RTNL lock |
| 8815 | * |
| 8816 | * Return: None |
| 8817 | */ |
| 8818 | static inline void hdd_release_rtnl_lock(void) |
| 8819 | { |
| 8820 | rtnl_unlock(); |
| 8821 | } |
| 8822 | #else |
| 8823 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8824 | static inline void hdd_release_rtnl_lock(void) { } |
| 8825 | #endif |
| 8826 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8827 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8828 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8829 | /* MAX iwpriv command support */ |
| 8830 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8831 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8832 | #define MAX_PKTLOG_SIZE 16 |
| 8833 | |
| 8834 | /** |
| 8835 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8836 | * @hdd_ctx: hdd context |
| 8837 | * @set_value2: pktlog buffer size value |
| 8838 | * |
| 8839 | * |
| 8840 | * Return: 0 for success or error. |
| 8841 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8842 | 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] | 8843 | { |
| 8844 | struct sir_wifi_start_log start_log = { 0 }; |
| 8845 | QDF_STATUS status; |
| 8846 | |
| 8847 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8848 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8849 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8850 | start_log.user_triggered = 1; |
| 8851 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8852 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8853 | |
| 8854 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8855 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8856 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8857 | EXIT(); |
| 8858 | return -EINVAL; |
| 8859 | } |
| 8860 | |
| 8861 | return 0; |
| 8862 | } |
| 8863 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8864 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8865 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8866 | * @hdd_ctx: hdd context |
| 8867 | * |
| 8868 | * Return: 0 for success or error. |
| 8869 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8870 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8871 | { |
| 8872 | struct sir_wifi_start_log start_log; |
| 8873 | QDF_STATUS status; |
| 8874 | |
| 8875 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8876 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8877 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8878 | start_log.user_triggered = 1; |
| 8879 | start_log.size = 0; |
| 8880 | start_log.is_pktlog_buff_clear = true; |
| 8881 | |
| 8882 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8883 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8884 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8885 | EXIT(); |
| 8886 | return -EINVAL; |
| 8887 | } |
| 8888 | |
| 8889 | return 0; |
| 8890 | } |
| 8891 | |
| 8892 | |
| 8893 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8894 | * hdd_process_pktlog_command() - process pktlog command |
| 8895 | * @hdd_ctx: hdd context |
| 8896 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8897 | * @set_value2: pktlog buffer size value |
| 8898 | * |
| 8899 | * This function process pktlog command. |
| 8900 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8901 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8902 | * |
| 8903 | * Return: 0 for success or error. |
| 8904 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8905 | 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] | 8906 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8907 | { |
| 8908 | int ret; |
| 8909 | bool enable; |
| 8910 | uint8_t user_triggered = 0; |
| 8911 | |
| 8912 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8913 | if (0 != ret) |
| 8914 | return ret; |
| 8915 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8916 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8917 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8918 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8919 | hdd_err("invalid pktlog value %d", set_value); |
| 8920 | return -EINVAL; |
| 8921 | } |
| 8922 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8923 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8924 | if (set_value2 <= 0) { |
| 8925 | hdd_err("invalid pktlog size %d", set_value2); |
| 8926 | return -EINVAL; |
| 8927 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8928 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8929 | return -EINVAL; |
| 8930 | } |
| 8931 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8932 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8933 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8934 | } |
| 8935 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8936 | /* |
| 8937 | * set_value = 0 then disable packetlog |
| 8938 | * set_value = 1 enable packetlog forcefully |
| 8939 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8940 | * enable packetlog with AUTO type. |
| 8941 | */ |
| 8942 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8943 | true : false; |
| 8944 | |
| 8945 | if (1 == set_value) { |
| 8946 | enable = true; |
| 8947 | user_triggered = 1; |
| 8948 | } |
| 8949 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8950 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8951 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 8952 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8953 | /** |
| 8954 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8955 | * @hdd_ctx: HDD context |
| 8956 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8957 | * @user_triggered: triggered through iwpriv |
| 8958 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8959 | * |
| 8960 | * Return: 0 on success; error number otherwise |
| 8961 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8962 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8963 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8964 | { |
| 8965 | struct sir_wifi_start_log start_log; |
| 8966 | QDF_STATUS status; |
| 8967 | |
| 8968 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8969 | start_log.verbose_level = |
| 8970 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8971 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8972 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8973 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8974 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8975 | /* |
| 8976 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8977 | * commands. Host uses this flag to decide whether to send pktlog |
| 8978 | * disable command to fw without sending pktlog enable command |
| 8979 | * previously. For eg, If vendor sends pktlog disable command without |
| 8980 | * sending pktlog enable command, then host discards the packet |
| 8981 | * but for iwpriv command, host will send it to fw. |
| 8982 | */ |
| 8983 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8984 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8985 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8986 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8987 | EXIT(); |
| 8988 | return -EINVAL; |
| 8989 | } |
| 8990 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 8991 | if (enable == true) |
| 8992 | hdd_ctx->is_pktlog_enabled = 1; |
| 8993 | else |
| 8994 | hdd_ctx->is_pktlog_enabled = 0; |
| 8995 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8996 | return 0; |
| 8997 | } |
| 8998 | #endif /* REMOVE_PKT_LOG */ |
| 8999 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9000 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9001 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9002 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9003 | * @dev: Device Pointer |
| 9004 | * @num: Number of Valid Mac address |
| 9005 | * |
| 9006 | * Return: Pointer to MAC address buffer |
| 9007 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9008 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9009 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9010 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9011 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9012 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9013 | |
| 9014 | /** |
| 9015 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9016 | * @hdd_ctx: HDD Context |
| 9017 | * @num: Number of random mac addresses needed |
| 9018 | * |
| 9019 | * Generate random addresses using bit manipulation on the base mac address |
| 9020 | * |
| 9021 | * Return: None |
| 9022 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9023 | 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] | 9024 | { |
| 9025 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9026 | uint32_t iter; |
| 9027 | struct hdd_config *ini = hdd_ctx->config; |
| 9028 | uint8_t *buf = NULL; |
| 9029 | uint8_t macaddr_b3, tmp_br3; |
| 9030 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9031 | |
| 9032 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9033 | buf = ini->intfMacAddr[iter].bytes; |
| 9034 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9035 | macaddr_b3 = buf[3]; |
| 9036 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9037 | INTF_MACADDR_MASK; |
| 9038 | macaddr_b3 += tmp_br3; |
| 9039 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9040 | buf[0] |= 0x02; |
| 9041 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9042 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9043 | } |
| 9044 | } |
| 9045 | |
| 9046 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9047 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9048 | * @hdd_ctx: HDD Context |
| 9049 | * |
| 9050 | * API to get mac addresses from platform driver and update the driver |
| 9051 | * structures and configure FW with the base mac address. |
| 9052 | * Return: int |
| 9053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9054 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9055 | { |
| 9056 | uint32_t no_of_mac_addr, iter; |
| 9057 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9058 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9059 | uint8_t *addr, *buf; |
| 9060 | struct device *dev = hdd_ctx->parent_dev; |
| 9061 | struct hdd_config *ini = hdd_ctx->config; |
| 9062 | tSirMacAddr mac_addr; |
| 9063 | QDF_STATUS status; |
| 9064 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9065 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9066 | |
| 9067 | if (no_of_mac_addr == 0 || !addr) { |
| 9068 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9069 | return -EINVAL; |
| 9070 | } |
| 9071 | |
| 9072 | if (no_of_mac_addr > max_mac_addr) |
| 9073 | no_of_mac_addr = max_mac_addr; |
| 9074 | |
| 9075 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9076 | |
| 9077 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9078 | buf = ini->intfMacAddr[iter].bytes; |
| 9079 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9080 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9081 | } |
| 9082 | |
| 9083 | status = sme_set_custom_mac_addr(mac_addr); |
| 9084 | |
| 9085 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9086 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9087 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9088 | if (no_of_mac_addr < max_mac_addr) |
| 9089 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9090 | no_of_mac_addr); |
| 9091 | return 0; |
| 9092 | } |
| 9093 | |
| 9094 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9095 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9096 | * @hdd_ctx: HDD Context |
| 9097 | * |
| 9098 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9099 | * will generate its own MAC and update it to FW. |
| 9100 | * |
| 9101 | * Return: 0 for success |
| 9102 | * Non-zero error code for failure |
| 9103 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9104 | 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] | 9105 | { |
| 9106 | tSirMacAddr customMacAddr; |
| 9107 | QDF_STATUS status; |
| 9108 | |
| 9109 | qdf_mem_copy(&customMacAddr, |
| 9110 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9111 | sizeof(tSirMacAddr)); |
| 9112 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9113 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9114 | return -EAGAIN; |
| 9115 | return 0; |
| 9116 | } |
| 9117 | |
| 9118 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9119 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9120 | * @hdd_ctx: HDD Context |
| 9121 | * |
| 9122 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9123 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9124 | * wlan_mac.bin to update HW MAC addresses. |
| 9125 | * |
| 9126 | * Return: None |
| 9127 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9128 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9129 | { |
| 9130 | QDF_STATUS status; |
| 9131 | int ret; |
| 9132 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9133 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9134 | if (ret == 0) |
| 9135 | return; |
| 9136 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9137 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9138 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9139 | |
| 9140 | status = hdd_update_mac_config(hdd_ctx); |
| 9141 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9142 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9143 | return; |
| 9144 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9145 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9146 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9147 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9148 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9149 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9150 | if (ret != 0) { |
| 9151 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9152 | QDF_ASSERT(ret); |
| 9153 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9154 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9155 | } |
| 9156 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9157 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9158 | { |
| 9159 | int vdev_id = 0; |
| 9160 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9161 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9162 | int vpdev = PDEV_CMD; |
| 9163 | int ret; |
| 9164 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9165 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9166 | if (ret) |
| 9167 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9168 | |
| 9169 | return ret; |
| 9170 | } |
| 9171 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9172 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9173 | { |
| 9174 | int vdev_id = 0; |
| 9175 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9176 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9177 | int vpdev = PDEV_CMD; |
| 9178 | int ret; |
| 9179 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9180 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9181 | if (ret) |
| 9182 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9183 | ret); |
| 9184 | |
| 9185 | return ret; |
| 9186 | } |
| 9187 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9188 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9189 | { |
| 9190 | int vdev_id = 0; |
| 9191 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9192 | int value = hdd_ctx->config->ani_enabled; |
| 9193 | int vpdev = PDEV_CMD; |
| 9194 | int ret; |
| 9195 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9196 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9197 | if (ret) |
| 9198 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9199 | |
| 9200 | return ret; |
| 9201 | } |
| 9202 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9203 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9204 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9205 | * @hdd_ctx: HDD context |
| 9206 | * |
| 9207 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9208 | * |
| 9209 | * Return: 0 on success and errno on failure. |
| 9210 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9211 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9212 | { |
| 9213 | int ret; |
| 9214 | QDF_STATUS status; |
| 9215 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9216 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9217 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9218 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9219 | /* |
| 9220 | * Set 802.11p config |
| 9221 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9222 | * parameter is set in CSR when we init the channel list. This should |
| 9223 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9224 | * domain. |
| 9225 | */ |
| 9226 | hdd_set_dot11p_config(hdd_ctx); |
| 9227 | |
| 9228 | /* |
| 9229 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9230 | * The cfg download must occur before we update the SME config |
| 9231 | * since the SME config operation must access the cfg database |
| 9232 | */ |
| 9233 | status = hdd_set_sme_config(hdd_ctx); |
| 9234 | |
| 9235 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9236 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9237 | ret = qdf_status_to_os_return(status); |
| 9238 | goto out; |
| 9239 | } |
| 9240 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9241 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9242 | if (QDF_STATUS_SUCCESS != status) { |
| 9243 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9244 | ret = qdf_status_to_os_return(status); |
| 9245 | goto out; |
| 9246 | } |
| 9247 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9248 | 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] | 9249 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9250 | PDEV_CMD); |
| 9251 | if (0 != ret) { |
| 9252 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9253 | goto out; |
| 9254 | } |
| 9255 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9256 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9257 | if (ret) |
| 9258 | goto out; |
| 9259 | |
| 9260 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9261 | if (ret) |
| 9262 | goto out; |
| 9263 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9264 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9265 | if (ret) |
| 9266 | goto out; |
| 9267 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9268 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9269 | hdd_ctx->config->arp_ac_category, |
| 9270 | PDEV_CMD); |
| 9271 | if (0 != ret) { |
| 9272 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9273 | hdd_ctx->config->arp_ac_category, ret); |
| 9274 | goto out; |
| 9275 | } |
| 9276 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9277 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9278 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9279 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9280 | ret = qdf_status_to_os_return(status); |
| 9281 | goto out; |
| 9282 | } |
| 9283 | |
| 9284 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9285 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9286 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9287 | ret = -EINVAL; |
| 9288 | goto out; |
| 9289 | } |
| 9290 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9291 | /* |
| 9292 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9293 | * Remove this once self sta is added as part of session open. |
| 9294 | */ |
| 9295 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9296 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9297 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9298 | |
| 9299 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9300 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9301 | hal_status, hal_status); |
| 9302 | ret = -EINVAL; |
| 9303 | goto out; |
| 9304 | } |
| 9305 | |
| 9306 | hdd_init_channel_avoidance(hdd_ctx); |
| 9307 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9308 | /* update enable sap mandatory chan list */ |
| 9309 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9310 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9311 | out: |
| 9312 | return ret; |
| 9313 | } |
| 9314 | |
| 9315 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9316 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9317 | * @context_ptr - hdd context pointer |
| 9318 | * @event_ptr - event structure pointer |
| 9319 | * |
| 9320 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9321 | * event back to supplicant to notify the stop reason. |
| 9322 | * |
| 9323 | * Return: None |
| 9324 | */ |
| 9325 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9326 | void *event_ptr) |
| 9327 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9328 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9329 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9330 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9331 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9332 | |
| 9333 | ENTER(); |
| 9334 | |
| 9335 | if (hdd_ctx == NULL) { |
| 9336 | hdd_err("Invalid HDD context pointer"); |
| 9337 | return; |
| 9338 | } |
| 9339 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9340 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9341 | if (!adapter) { |
| 9342 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9343 | evt->vdev_id); |
| 9344 | return; |
| 9345 | } |
| 9346 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9347 | vendor_event = |
| 9348 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9349 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9350 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9351 | GFP_KERNEL); |
| 9352 | |
| 9353 | if (!vendor_event) { |
| 9354 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9355 | return; |
| 9356 | } |
| 9357 | |
| 9358 | if (nla_put_u32(vendor_event, |
| 9359 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9360 | evt->reason_code)) { |
| 9361 | hdd_err("nla put failed"); |
| 9362 | kfree_skb(vendor_event); |
| 9363 | return; |
| 9364 | } |
| 9365 | |
| 9366 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9367 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9368 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9369 | } |
| 9370 | |
| 9371 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9372 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9373 | * @hdd_ctx: HDD context |
| 9374 | * |
| 9375 | * This function sends the adaptive dwell time config configuration to the |
| 9376 | * firmware via WMA |
| 9377 | * |
| 9378 | * Return: 0 - success, < 0 - failure |
| 9379 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9380 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9381 | { |
| 9382 | QDF_STATUS status; |
| 9383 | struct adaptive_dwelltime_params dwelltime_params; |
| 9384 | |
| 9385 | dwelltime_params.is_enabled = |
| 9386 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9387 | dwelltime_params.dwelltime_mode = |
| 9388 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9389 | dwelltime_params.lpf_weight = |
| 9390 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9391 | dwelltime_params.passive_mon_intval = |
| 9392 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9393 | dwelltime_params.wifi_act_threshold = |
| 9394 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9395 | |
| 9396 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9397 | &dwelltime_params); |
| 9398 | |
| 9399 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9400 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9401 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9402 | return -EAGAIN; |
| 9403 | } |
| 9404 | return 0; |
| 9405 | } |
| 9406 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9407 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9408 | { |
| 9409 | QDF_STATUS status; |
| 9410 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9411 | uint32_t i = 0; |
| 9412 | uint8_t count = 0, numentries = 0; |
| 9413 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9414 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9415 | |
| 9416 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9417 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9418 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9419 | return -EINVAL; |
| 9420 | |
| 9421 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9422 | dbs_scan_config, &numentries, |
| 9423 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9424 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9425 | |
| 9426 | hdd_info("numentries %hu", numentries); |
| 9427 | if (!numentries) { |
| 9428 | hdd_info("Donot send scan_selection_config"); |
| 9429 | return 0; |
| 9430 | } |
| 9431 | |
| 9432 | /* hdd_set_fw_log_params */ |
| 9433 | dbs_scan_params.num_clients = 0; |
| 9434 | while (count < (numentries - 2)) { |
| 9435 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9436 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9437 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9438 | dbs_scan_config[count + 2]; |
| 9439 | dbs_scan_params.num_clients++; |
| 9440 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9441 | dbs_scan_params.module_id[i], |
| 9442 | dbs_scan_params.num_dbs_scans[i], |
| 9443 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9444 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9445 | i++; |
| 9446 | } |
| 9447 | |
| 9448 | dbs_scan_params.pdev_id = 0; |
| 9449 | |
| 9450 | hdd_debug("clients:%d pdev:%d", |
| 9451 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9452 | |
| 9453 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9454 | &dbs_scan_params); |
| 9455 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9456 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9457 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9458 | return -EAGAIN; |
| 9459 | } |
| 9460 | return 0; |
| 9461 | } |
| 9462 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9463 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9464 | /** |
| 9465 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9466 | * @hdd_ctx: HDD context |
| 9467 | * |
| 9468 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9469 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9470 | * |
| 9471 | * Return: 0 on success and errno on failure. |
| 9472 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9473 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9474 | { |
| 9475 | QDF_STATUS status; |
| 9476 | |
| 9477 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9478 | return 0; |
| 9479 | |
| 9480 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9481 | wlan_hdd_auto_shutdown_cb); |
| 9482 | if (status != QDF_STATUS_SUCCESS) |
| 9483 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9484 | status); |
| 9485 | |
| 9486 | return qdf_status_to_os_return(status); |
| 9487 | } |
| 9488 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9489 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9490 | { |
| 9491 | return 0; |
| 9492 | } |
| 9493 | #endif |
| 9494 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9495 | 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] | 9496 | { |
| 9497 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9498 | |
| 9499 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9500 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9501 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9502 | if (status != QDF_STATUS_SUCCESS) |
| 9503 | hdd_err("Failed to disable dual mac features"); |
| 9504 | break; |
| 9505 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9506 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9507 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9508 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9509 | if (status != QDF_STATUS_SUCCESS) |
| 9510 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9511 | break; |
| 9512 | default: |
| 9513 | break; |
| 9514 | } |
| 9515 | |
| 9516 | return status; |
| 9517 | } |
| 9518 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9519 | /** |
| 9520 | * hdd_features_init() - Init features |
| 9521 | * @hdd_ctx: HDD context |
| 9522 | * @adapter: Primary adapter context |
| 9523 | * |
| 9524 | * Initialize features and their feature context after WLAN firmware is up. |
| 9525 | * |
| 9526 | * Return: 0 on success and errno on failure. |
| 9527 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9528 | 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] | 9529 | { |
| 9530 | tSirTxPowerLimit hddtxlimit; |
| 9531 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9532 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9533 | int ret; |
| 9534 | |
| 9535 | ENTER(); |
| 9536 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9537 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9538 | if (ret) { |
| 9539 | hdd_err("Failed to update country code: %d", ret); |
| 9540 | goto out; |
| 9541 | } |
| 9542 | |
| 9543 | /* FW capabilities received, Set the Dot11 mode */ |
| 9544 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9545 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9546 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9547 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9548 | |
| 9549 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9550 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9551 | else |
| 9552 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9553 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9554 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9555 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9556 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9557 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9558 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9559 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9560 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9561 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9562 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9563 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9564 | if (hdd_lro_init(hdd_ctx)) |
| 9565 | hdd_err("Unable to initialize LRO in fw"); |
| 9566 | |
| 9567 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9568 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9569 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9570 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9571 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9572 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9573 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9574 | if (ret) { |
| 9575 | hdd_err("Error while initializing thermal information"); |
| 9576 | goto deregister_frames; |
| 9577 | } |
| 9578 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9579 | /** |
| 9580 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9581 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9582 | * device up. |
| 9583 | */ |
| 9584 | if (cds_is_driver_recovering()) { |
| 9585 | if (hdd_ctx->is_pktlog_enabled) |
| 9586 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9587 | } else if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9588 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9589 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9590 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9591 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9592 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9593 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9594 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9595 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9596 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9597 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9598 | ret = hdd_register_cb(hdd_ctx); |
| 9599 | if (ret) { |
| 9600 | hdd_err("Failed to register HDD callbacks!"); |
| 9601 | goto deregister_frames; |
| 9602 | } |
| 9603 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9604 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9605 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9606 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9607 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9608 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9609 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9610 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9611 | status = sme_enable_disable_chanavoidind_event( |
| 9612 | hdd_ctx->hHal, 0); |
| 9613 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9614 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9615 | goto deregister_cb; |
| 9616 | } |
| 9617 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9618 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9619 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9620 | band_pref_params.rssi_boost_threshold_5g = |
| 9621 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9622 | band_pref_params.rssi_boost_factor_5g = |
| 9623 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9624 | band_pref_params.max_rssi_boost_5g = |
| 9625 | hdd_ctx->config->max_rssi_boost_5g; |
| 9626 | band_pref_params.rssi_penalize_threshold_5g = |
| 9627 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9628 | band_pref_params.rssi_penalize_factor_5g = |
| 9629 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9630 | band_pref_params.max_rssi_penalize_5g = |
| 9631 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9632 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9633 | } |
| 9634 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9635 | /* register P2P Listen Offload event callback */ |
| 9636 | if (wma_is_p2p_lo_capable()) |
| 9637 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9638 | wlan_hdd_p2p_lo_event_callback); |
| 9639 | |
| 9640 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9641 | |
| 9642 | if (ret) |
| 9643 | goto deregister_cb; |
| 9644 | |
| 9645 | EXIT(); |
| 9646 | return 0; |
| 9647 | |
| 9648 | deregister_cb: |
| 9649 | hdd_deregister_cb(hdd_ctx); |
| 9650 | deregister_frames: |
| 9651 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9652 | out: |
| 9653 | return -EINVAL; |
| 9654 | |
| 9655 | } |
| 9656 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9657 | /** |
| 9658 | * hdd_features_deinit() - Deinit features |
| 9659 | * @hdd_ctx: HDD context |
| 9660 | * |
| 9661 | * De-Initialize features and their feature context. |
| 9662 | * |
| 9663 | * Return: none. |
| 9664 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9665 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9666 | { |
| 9667 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9668 | } |
| 9669 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9670 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9671 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9672 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9673 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9674 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9675 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9676 | 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] | 9677 | { |
| 9678 | QDF_STATUS status; |
| 9679 | |
| 9680 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9681 | wlan_cfg80211_inform_bss_frame, |
| 9682 | SCAN_CB_TYPE_INFORM_BCN); |
| 9683 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9684 | hdd_err("failed with status code %08d [x%08x]", |
| 9685 | status, status); |
| 9686 | return status; |
| 9687 | } |
| 9688 | |
| 9689 | return QDF_STATUS_SUCCESS; |
| 9690 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9691 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9692 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9693 | * hdd_configure_cds() - Configure cds modules |
| 9694 | * @hdd_ctx: HDD context |
| 9695 | * @adapter: Primary adapter context |
| 9696 | * |
| 9697 | * Enable Cds modules after WLAN firmware is up. |
| 9698 | * |
| 9699 | * Return: 0 on success and errno on failure. |
| 9700 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9701 | 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] | 9702 | { |
| 9703 | int ret; |
| 9704 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9705 | int set_value; |
| 9706 | uint32_t num_abg_tx_chains = 0; |
| 9707 | uint32_t num_11b_tx_chains = 0; |
| 9708 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9709 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9710 | |
| 9711 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9712 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9713 | hdd_ctx->config->sifs_burst_duration; |
| 9714 | |
| 9715 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9716 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9717 | set_value, PDEV_CMD); |
| 9718 | } |
| 9719 | |
| 9720 | if (hdd_ctx->config->is_force_1x1) |
| 9721 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9722 | 1, PDEV_CMD); |
| 9723 | /* set chip power save failure detected callback */ |
| 9724 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9725 | hdd_chip_pwr_save_fail_detected_cb); |
| 9726 | |
| 9727 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9728 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9729 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9730 | set_value, PDEV_CMD); |
| 9731 | } |
| 9732 | |
| 9733 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9734 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9735 | sme_cli_set_command(0, |
| 9736 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9737 | set_value, PDEV_CMD); |
| 9738 | } |
| 9739 | |
| 9740 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9741 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9742 | sme_cli_set_command(0, |
| 9743 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9744 | set_value, PDEV_CMD); |
| 9745 | } |
| 9746 | |
| 9747 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9748 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9749 | if (!hdd_ctx->config->enable2x2) { |
| 9750 | if (num_11b_tx_chains > 1) |
| 9751 | num_11b_tx_chains = 1; |
| 9752 | if (num_11ag_tx_chains > 1) |
| 9753 | num_11ag_tx_chains = 1; |
| 9754 | } |
| 9755 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9756 | num_11b_tx_chains); |
| 9757 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9758 | num_11ag_tx_chains); |
| 9759 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9760 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9761 | |
| 9762 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9763 | if (ret) { |
| 9764 | hdd_err("Failed to pre-configure cds"); |
| 9765 | goto out; |
| 9766 | } |
| 9767 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9768 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9769 | * IPA module before configuring them to FW. Sequence required as crash |
| 9770 | * observed otherwise. |
| 9771 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9772 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9773 | hdd_err("Failed to setup pipes"); |
| 9774 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9775 | } |
| 9776 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9777 | /* |
| 9778 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9779 | * else |
| 9780 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9781 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9782 | |
| 9783 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9784 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9785 | goto out; |
| 9786 | } |
| 9787 | |
| 9788 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9789 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9790 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9791 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9792 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9793 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9794 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9795 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9796 | goto cds_disable; |
| 9797 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9798 | |
| 9799 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9800 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9801 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9802 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9803 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9804 | 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] | 9805 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9806 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9807 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9808 | goto cds_disable; |
| 9809 | } |
| 9810 | |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9811 | if (hdd_enable_egap(hdd_ctx)) |
| 9812 | hdd_debug("enhance green ap is not enabled"); |
| 9813 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9814 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9815 | hdd_debug("Failed to set wow pulse"); |
| 9816 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9817 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9818 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9819 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9820 | |
| 9821 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9822 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9823 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9824 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9825 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9826 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9827 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9828 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9829 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9830 | out: |
| 9831 | return -EINVAL; |
| 9832 | } |
| 9833 | |
| 9834 | /** |
| 9835 | * hdd_deconfigure_cds() -De-Configure cds |
| 9836 | * @hdd_ctx: HDD context |
| 9837 | * |
| 9838 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9839 | * |
| 9840 | * Return: 0 on success and errno on failure. |
| 9841 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9842 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9843 | { |
| 9844 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9845 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9846 | |
| 9847 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9848 | |
| 9849 | /* De-init features */ |
| 9850 | hdd_features_deinit(hdd_ctx); |
| 9851 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9852 | /* De-register the SME callbacks */ |
| 9853 | hdd_deregister_cb(hdd_ctx); |
| 9854 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9855 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9856 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9857 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9858 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9859 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9860 | } |
| 9861 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9862 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9863 | hdd_err("Failed to disconnect pipes"); |
| 9864 | ret = -EINVAL; |
| 9865 | } |
| 9866 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9867 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9868 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9869 | } |
| 9870 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9871 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9872 | static void hdd_deregister_policy_manager_callback( |
| 9873 | struct wlan_objmgr_psoc *psoc) |
| 9874 | { |
| 9875 | if (QDF_STATUS_SUCCESS != |
| 9876 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9877 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9878 | } |
| 9879 | } |
| 9880 | #else |
| 9881 | static void hdd_deregister_policy_manager_callback( |
| 9882 | struct wlan_objmgr_psoc *psoc) |
| 9883 | { |
| 9884 | } |
| 9885 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9886 | |
| 9887 | /** |
| 9888 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9889 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9890 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9891 | * |
| 9892 | * This function maintains the driver state machine it will be invoked from |
| 9893 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9894 | * shall perform the stopping/closing of the modules. |
| 9895 | * |
| 9896 | * Return: 0 for success; non-zero for failure |
| 9897 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9898 | 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] | 9899 | { |
| 9900 | void *hif_ctx; |
| 9901 | qdf_device_t qdf_ctx; |
| 9902 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9903 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 9904 | bool is_recovery_stop = cds_is_driver_recovering(); |
| 9905 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9906 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9907 | |
| 9908 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9909 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 9910 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9911 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9912 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 9913 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9914 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9915 | if (!qdf_ctx) { |
| 9916 | hdd_err("QDF device context NULL"); |
| 9917 | return -EINVAL; |
| 9918 | } |
| 9919 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9920 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 9921 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9922 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9923 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9924 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9925 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9926 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9927 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9928 | |
| 9929 | cds_print_external_threads(); |
| 9930 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9931 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9932 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 9933 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 9934 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9935 | hdd_prevent_suspend_timeout( |
| 9936 | hdd_ctx->config->iface_change_wait_time, |
| 9937 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9938 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9939 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9940 | return 0; |
| 9941 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9942 | } |
| 9943 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9944 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 9945 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 9946 | /* free user wowl patterns */ |
| 9947 | hdd_free_user_wowl_ptrns(); |
| 9948 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9949 | switch (hdd_ctx->driver_status) { |
| 9950 | case DRIVER_MODULES_UNINITIALIZED: |
| 9951 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9952 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9953 | case DRIVER_MODULES_CLOSED: |
| 9954 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9955 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9956 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9957 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 9958 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 9959 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9960 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9961 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9962 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9963 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9964 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9965 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9966 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9967 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9968 | hdd_info("Wlan transitioned (now OPENED)"); |
| 9969 | |
| 9970 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9971 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9972 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9973 | break; |
| 9974 | default: |
| 9975 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 9976 | hdd_ctx->driver_status); |
| 9977 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9978 | ret = -EINVAL; |
| 9979 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9980 | } |
| 9981 | |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9982 | hdd_debug("Closing CDS modules!"); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 9983 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9984 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9985 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 9986 | qdf_status); |
| 9987 | ret = -EINVAL; |
| 9988 | QDF_ASSERT(0); |
| 9989 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 9990 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 9991 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 9992 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 9993 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 9994 | if (ret) { |
| 9995 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 9996 | QDF_ASSERT(0); |
| 9997 | } |
| 9998 | |
| 9999 | /* |
| 10000 | * Reset total mac phy during module stop such that during |
| 10001 | * next module start same psoc is used to populate new service |
| 10002 | * ready data |
| 10003 | */ |
| 10004 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
| 10005 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10006 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10007 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10008 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10009 | ret = -EINVAL; |
| 10010 | QDF_ASSERT(0); |
| 10011 | } |
| 10012 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10013 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10014 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10015 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10016 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10017 | QDF_ASSERT(0); |
| 10018 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10019 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10020 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10021 | if (!hif_ctx) { |
| 10022 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10023 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10024 | } |
| 10025 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10026 | if (hdd_ctx->target_hw_name) { |
| 10027 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10028 | hdd_ctx->target_hw_name = NULL; |
| 10029 | } |
| 10030 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10031 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10032 | |
| 10033 | ol_cds_free(); |
| 10034 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10035 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10036 | ret = pld_power_off(qdf_ctx->dev); |
| 10037 | if (ret) |
| 10038 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10039 | ret); |
| 10040 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10041 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10042 | /* many adapter resources are not freed by design in SSR case */ |
| 10043 | if (!is_recovery_stop) |
| 10044 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10045 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10046 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10047 | /* Once the firmware sequence is completed reset this flag */ |
| 10048 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10049 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10050 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10051 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10052 | done: |
| 10053 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10054 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10055 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10056 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10057 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10058 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10059 | EXIT(); |
| 10060 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10061 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10062 | } |
| 10063 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10064 | |
| 10065 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10066 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10067 | * @buf: buffer pointer |
| 10068 | * @size: size of buffer to be filled |
| 10069 | * |
| 10070 | * This function is used to dump state information of hdd layer |
| 10071 | * |
| 10072 | * Return: None |
| 10073 | */ |
| 10074 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10075 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10076 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10077 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10078 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10079 | uint16_t len = 0; |
| 10080 | char *buf = *buf_ptr; |
| 10081 | |
| 10082 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10083 | if (!hdd_ctx) { |
| 10084 | hdd_err("Failed to get hdd context "); |
| 10085 | return; |
| 10086 | } |
| 10087 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10088 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10089 | |
| 10090 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10091 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10092 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10093 | "\n is_scheduler_suspended %d", |
| 10094 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10095 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10096 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10097 | if (adapter->dev) |
| 10098 | len += scnprintf(buf + len, *size - len, |
| 10099 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10100 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10101 | "\n device_mode: %d", adapter->device_mode); |
| 10102 | switch (adapter->device_mode) { |
| 10103 | case QDF_STA_MODE: |
| 10104 | case QDF_P2P_CLIENT_MODE: |
| 10105 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10106 | len += scnprintf(buf + len, *size - len, |
| 10107 | "\n connState: %d", |
| 10108 | hdd_sta_ctx->conn_info.connState); |
| 10109 | break; |
| 10110 | |
| 10111 | default: |
| 10112 | break; |
| 10113 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10114 | } |
| 10115 | |
| 10116 | *size -= len; |
| 10117 | *buf_ptr += len; |
| 10118 | } |
| 10119 | |
| 10120 | /** |
| 10121 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10122 | * to print hdd state information |
| 10123 | * |
| 10124 | * Return: None |
| 10125 | */ |
| 10126 | static void hdd_register_debug_callback(void) |
| 10127 | { |
| 10128 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10129 | } |
| 10130 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10131 | /* |
| 10132 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10133 | * |
| 10134 | * This function is used to create bug report lock |
| 10135 | * |
| 10136 | * Return: None |
| 10137 | */ |
| 10138 | static void wlan_init_bug_report_lock(void) |
| 10139 | { |
| 10140 | p_cds_contextType p_cds_context; |
| 10141 | |
| 10142 | p_cds_context = cds_get_global_context(); |
| 10143 | if (!p_cds_context) { |
| 10144 | hdd_err("cds context is NULL"); |
| 10145 | return; |
| 10146 | } |
| 10147 | |
| 10148 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10149 | } |
| 10150 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10151 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10152 | { |
| 10153 | |
| 10154 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10155 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10156 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10157 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10158 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10159 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10160 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10161 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10162 | |
| 10163 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10164 | &num_entries, sizeof(config_params)); |
| 10165 | |
| 10166 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10167 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10168 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10169 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10170 | else if (bw_compute_interval > 1000) { |
| 10171 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10172 | thresh_time_limit = 1; |
| 10173 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10174 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10175 | |
| 10176 | switch (num_entries) { |
| 10177 | case 4: |
| 10178 | proto_bitmap = config_params[3]; |
| 10179 | case 3: |
| 10180 | verbosity = config_params[2]; |
| 10181 | case 2: |
| 10182 | thresh = config_params[1]; |
| 10183 | case 1: |
| 10184 | live_mode = config_params[0]; |
| 10185 | default: |
| 10186 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 10187 | live_mode, thresh, thresh_time_limit, |
| 10188 | verbosity, proto_bitmap); |
| 10189 | }; |
| 10190 | |
| 10191 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10192 | verbosity, proto_bitmap); |
| 10193 | |
| 10194 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10195 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10196 | * hdd_wlan_startup() - HDD init function |
| 10197 | * @dev: Pointer to the underlying device |
| 10198 | * |
| 10199 | * This is the driver startup code executed once a WLAN device has been detected |
| 10200 | * |
| 10201 | * Return: 0 for success, < 0 for failure |
| 10202 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10203 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10204 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10205 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10206 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10207 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10208 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10209 | |
| 10210 | ENTER(); |
| 10211 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10212 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10213 | |
| 10214 | if (IS_ERR(hdd_ctx)) |
| 10215 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10216 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10217 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10218 | DEFAULT_PSOC_ID); |
| 10219 | if (ret) { |
| 10220 | hdd_err("Psoc creation fails!"); |
| 10221 | QDF_BUG(0); |
| 10222 | goto err_hdd_free_context; |
| 10223 | } |
| 10224 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10225 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10226 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10227 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10228 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10229 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10230 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 10231 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10232 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10233 | hdd_driver_memdump_init(); |
| 10234 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10235 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10236 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10237 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10238 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10239 | } |
| 10240 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10241 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10242 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10243 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10244 | |
| 10245 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10246 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10247 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10248 | } |
| 10249 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10250 | ret = hdd_wiphy_init(hdd_ctx); |
| 10251 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10252 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10253 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10254 | } |
| 10255 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10256 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10257 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10258 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10259 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10260 | goto err_wiphy_unregister; |
| 10261 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 10262 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10263 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10264 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10265 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10266 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10267 | if (ret) { |
| 10268 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10269 | goto err_ipa_cleanup; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10270 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10271 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10272 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10273 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10274 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10275 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10276 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10277 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10278 | } |
| 10279 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10280 | hdd_release_rtnl_lock(); |
| 10281 | rtnl_held = false; |
| 10282 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10283 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10284 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10285 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10286 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10287 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10288 | hdd_skip_acs_scan_timer_handler, |
| 10289 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10290 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10291 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10292 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10293 | #endif |
| 10294 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10295 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10296 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10297 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10298 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10299 | if (hdd_ctx->rps) |
| 10300 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10301 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10302 | ret = hdd_register_notifiers(hdd_ctx); |
| 10303 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10304 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10305 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10306 | status = wlansap_global_init(); |
| 10307 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10308 | hdd_unregister_notifiers(hdd_ctx); |
| 10309 | goto err_close_adapters; |
| 10310 | } |
| 10311 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10312 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10313 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10314 | else |
| 10315 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10316 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10317 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10318 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10319 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10320 | hdd_prevent_suspend_timeout( |
| 10321 | hdd_ctx->config->iface_change_wait_time, |
| 10322 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10323 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10324 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10325 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10326 | goto success; |
| 10327 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10328 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10329 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10330 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10331 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10332 | if (rtnl_held) |
| 10333 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10334 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10335 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10336 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10337 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10338 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10339 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10340 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10341 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10342 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10343 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10344 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10345 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10346 | err_memdump_deinit: |
| 10347 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10348 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 10349 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10350 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10351 | hdd_exit_netlink_services(hdd_ctx); |
| 10352 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10353 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10354 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10355 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10356 | if (cds_is_fw_down()) |
| 10357 | hdd_err("Not setting the complete event as fw is down"); |
| 10358 | else |
| 10359 | hdd_start_complete(ret); |
| 10360 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10361 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10362 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10363 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10364 | |
| 10365 | success: |
| 10366 | EXIT(); |
| 10367 | return 0; |
| 10368 | } |
| 10369 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10370 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10371 | * hdd_wlan_update_target_info() - update target type info |
| 10372 | * @hdd_ctx: HDD context |
| 10373 | * @context: hif context |
| 10374 | * |
| 10375 | * Update target info received from firmware in hdd context |
| 10376 | * Return:None |
| 10377 | */ |
| 10378 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10379 | 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] | 10380 | { |
| 10381 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10382 | |
| 10383 | if (!tgt_info) { |
| 10384 | hdd_err("Target info is Null"); |
| 10385 | return; |
| 10386 | } |
| 10387 | |
| 10388 | hdd_ctx->target_type = tgt_info->target_type; |
| 10389 | } |
| 10390 | |
| 10391 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10392 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10393 | * received from the firmware |
| 10394 | * @data: pointer to adapter. |
| 10395 | * @rsp: pointer to data received from FW. |
| 10396 | * |
| 10397 | * This is called when wlan driver received response event for |
| 10398 | * get arp stats to firmware. |
| 10399 | * |
| 10400 | * Return: None |
| 10401 | */ |
| 10402 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10403 | { |
| 10404 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10405 | struct hdd_nud_stats_context *context; |
| 10406 | int status; |
| 10407 | struct hdd_adapter *adapter = NULL; |
| 10408 | |
| 10409 | ENTER(); |
| 10410 | |
| 10411 | if (!rsp) { |
| 10412 | hdd_err("data is null"); |
| 10413 | return; |
| 10414 | } |
| 10415 | |
| 10416 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10417 | if (0 != status) |
| 10418 | return; |
| 10419 | |
| 10420 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10421 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10422 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10423 | return; |
| 10424 | } |
| 10425 | |
| 10426 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10427 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10428 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10429 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10430 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10431 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10432 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10433 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10434 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10435 | rsp->ba_session_establishment_status); |
| 10436 | |
| 10437 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10438 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10439 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10440 | adapter->dad |= rsp->dad_detected; |
| 10441 | adapter->con_status = rsp->connect_status; |
| 10442 | |
| 10443 | spin_lock(&hdd_context_lock); |
| 10444 | context = &hdd_ctx->nud_stats_context; |
| 10445 | complete(&context->response_event); |
| 10446 | spin_unlock(&hdd_context_lock); |
| 10447 | |
| 10448 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10449 | } |
| 10450 | |
| 10451 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10452 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10453 | * @hdd_ctx: HDD context |
| 10454 | * |
| 10455 | * Register the HDD callbacks to CDS/SME. |
| 10456 | * |
| 10457 | * Return: 0 for success or Error code for failure |
| 10458 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10459 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10460 | { |
| 10461 | QDF_STATUS status; |
| 10462 | int ret = 0; |
| 10463 | |
| 10464 | ENTER(); |
| 10465 | |
| 10466 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10467 | |
| 10468 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10469 | hdd_send_oem_data_rsp_msg); |
| 10470 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10471 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10472 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10473 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10474 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10475 | wlan_hdd_cfg80211_nan_callback); |
| 10476 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10477 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10478 | |
| 10479 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10480 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10481 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10482 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10483 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10484 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10485 | hdd_rssi_threshold_breached); |
| 10486 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10487 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10488 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10489 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10490 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10491 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10492 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10493 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10494 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10495 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10496 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10497 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10498 | hdd_lost_link_info_cb); |
| 10499 | /* print error and not block the startup process */ |
| 10500 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10501 | hdd_err("set lost link info callback failed"); |
| 10502 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10503 | ret = hdd_register_data_stall_detect_cb(); |
| 10504 | if (ret) { |
| 10505 | hdd_err("Register data stall detect detect callback failed."); |
| 10506 | return ret; |
| 10507 | } |
| 10508 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10509 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10510 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10511 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10512 | hdd_set_connection_in_progress, |
| 10513 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10514 | |
| 10515 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10516 | hdd_update_cca_info_cb); |
| 10517 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10518 | hdd_err("set congestion callback failed"); |
| 10519 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10520 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10521 | hdd_bt_activity_cb); |
| 10522 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10523 | hdd_err("set bt activity info callback failed"); |
| 10524 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10525 | EXIT(); |
| 10526 | |
| 10527 | return ret; |
| 10528 | } |
| 10529 | |
| 10530 | /** |
| 10531 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10532 | * @hdd_ctx: HDD context |
| 10533 | * |
| 10534 | * De-Register the HDD callbacks to CDS/SME. |
| 10535 | * |
| 10536 | * Return: void |
| 10537 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10538 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10539 | { |
| 10540 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10541 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10542 | |
| 10543 | ENTER(); |
| 10544 | |
| 10545 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10546 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10547 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10548 | status); |
| 10549 | |
| 10550 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10551 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10552 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10553 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10554 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10555 | |
| 10556 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10557 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10558 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10559 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10560 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10561 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10562 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10563 | if (ret) |
| 10564 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10565 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10566 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10567 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10568 | |
| 10569 | EXIT(); |
| 10570 | } |
| 10571 | |
| 10572 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10573 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10574 | * @adapter: Pointer to the HDD |
| 10575 | * @enable: bool value |
| 10576 | * |
| 10577 | * This to take counter measure to handle deauth req from HDD |
| 10578 | * |
| 10579 | * Return: None |
| 10580 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10581 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10582 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10583 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10584 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10585 | |
| 10586 | ENTER(); |
| 10587 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10588 | /* Ignore request to deauth bcmc station */ |
| 10589 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10590 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10591 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10592 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10593 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10594 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10595 | |
| 10596 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10597 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10598 | } |
| 10599 | |
| 10600 | /** |
| 10601 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10602 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10603 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10604 | * |
| 10605 | * This to take counter measure to handle deauth req from HDD |
| 10606 | * |
| 10607 | * Return: None |
| 10608 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10609 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10610 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10611 | { |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10612 | struct sir_peer_sta_info peer_sta_info; |
| 10613 | struct hdd_station_info *stainfo; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10614 | ENTER(); |
| 10615 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10616 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10617 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10618 | return; |
| 10619 | |
Ashish Kumar Dhanotiya | 443d31f | 2017-10-13 12:41:19 +0530 | [diff] [blame] | 10620 | wlan_hdd_get_peer_rssi(adapter, &pDelStaParams->peerMacAddr, |
| 10621 | &peer_sta_info); |
| 10622 | stainfo = hdd_get_stainfo(adapter->cache_sta_info, |
| 10623 | pDelStaParams->peerMacAddr); |
| 10624 | if (stainfo) { |
| 10625 | stainfo->rssi = peer_sta_info.info[0].rssi; |
| 10626 | stainfo->tx_rate = peer_sta_info.info[0].tx_rate; |
| 10627 | stainfo->rx_rate = peer_sta_info.info[0].rx_rate; |
| 10628 | } |
| 10629 | |
| 10630 | stainfo->reason_code = pDelStaParams->reason_code; |
| 10631 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10632 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10633 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10634 | } |
| 10635 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10636 | /** |
| 10637 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10638 | * @hdd_ctx: HDD Context |
| 10639 | * |
| 10640 | * API to find if there is any STA or P2P-Client is connected |
| 10641 | * |
| 10642 | * Return: true if connected; false otherwise |
| 10643 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10644 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10645 | { |
| 10646 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10647 | } |
| 10648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10649 | /** |
| 10650 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10651 | * @adapter: HDD adapter pointer |
| 10652 | * |
| 10653 | * This function loop through each adapter and disable roaming on each STA |
| 10654 | * device mode except the input adapter. |
| 10655 | * |
| 10656 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10657 | * disable. |
| 10658 | * |
| 10659 | * Return: None |
| 10660 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10661 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10662 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10663 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10664 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10665 | |
| 10666 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10667 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10668 | QDF_STA_MODE == adapter->device_mode && |
| 10669 | policy_mgr_is_sta_active_connection_exists( |
| 10670 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10671 | hdd_debug("Connect received on STA session Id(%d)", |
| 10672 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10673 | /* |
| 10674 | * Loop through adapter and disable roaming for each STA device |
| 10675 | * mode except the input adapter. |
| 10676 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10677 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10678 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10679 | adapter->session_id != adapterIdx->session_id) { |
| 10680 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10681 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10682 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10683 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10684 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10685 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10686 | } |
| 10687 | } |
| 10688 | } |
| 10689 | |
| 10690 | /** |
| 10691 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10692 | * @adapter: HDD adapter pointer |
| 10693 | * |
| 10694 | * This function loop through each adapter and enable roaming on each STA |
| 10695 | * device mode except the input adapter. |
| 10696 | * Note: On the input adapter no need to enable roaming because link got |
| 10697 | * disconnected on this. |
| 10698 | * |
| 10699 | * Return: None |
| 10700 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10701 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10702 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10703 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10704 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10705 | |
| 10706 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10707 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10708 | QDF_STA_MODE == adapter->device_mode && |
| 10709 | policy_mgr_is_sta_active_connection_exists( |
| 10710 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10711 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10712 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10713 | /* |
| 10714 | * Loop through adapter and enable roaming for each STA device |
| 10715 | * mode except the input adapter. |
| 10716 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10717 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10718 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10719 | adapter->session_id != adapterIdx->session_id) { |
| 10720 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10721 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10722 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10723 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10724 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10725 | REASON_CONNECT); |
| 10726 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10727 | } |
| 10728 | } |
| 10729 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10730 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10731 | /** |
| 10732 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10733 | * @skb: sk buffer pointer |
| 10734 | * |
| 10735 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10736 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10737 | * |
| 10738 | * Return: None |
| 10739 | */ |
| 10740 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10741 | { |
| 10742 | #ifdef CNSS_GENL |
| 10743 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10744 | #else |
| 10745 | nl_srv_bcast(skb); |
| 10746 | #endif |
| 10747 | } |
| 10748 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10749 | 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] | 10750 | { |
| 10751 | struct sk_buff *skb; |
| 10752 | struct nlmsghdr *nlh; |
| 10753 | tAniMsgHdr *ani_hdr; |
| 10754 | void *nl_data = NULL; |
| 10755 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10756 | struct radio_index_tlv *radio_info; |
| 10757 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10758 | |
| 10759 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10760 | flags = GFP_ATOMIC; |
| 10761 | |
| 10762 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10763 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10764 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10765 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10766 | |
| 10767 | nlh = (struct nlmsghdr *)skb->data; |
| 10768 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10769 | nlh->nlmsg_flags = 0; |
| 10770 | nlh->nlmsg_seq = 0; |
| 10771 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10772 | |
| 10773 | ani_hdr = NLMSG_DATA(nlh); |
| 10774 | ani_hdr->type = type; |
| 10775 | |
| 10776 | switch (type) { |
| 10777 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10778 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10779 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10780 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10781 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10782 | ani_hdr->length = 0; |
| 10783 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10784 | break; |
| 10785 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10786 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10787 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10788 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10789 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10790 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10791 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10792 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10793 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 10794 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10795 | ani_hdr->length = len; |
| 10796 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10797 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10798 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10799 | break; |
| 10800 | |
| 10801 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10802 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10803 | type); |
| 10804 | kfree_skb(skb); |
| 10805 | return; |
| 10806 | } |
| 10807 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10808 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10809 | * Add radio index at the end of the svc event in TLV format |
| 10810 | * to maintain the backward compatibility with userspace |
| 10811 | * applications. |
| 10812 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10813 | |
| 10814 | tlv_len = 0; |
| 10815 | |
| 10816 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10817 | < WLAN_NL_MAX_PAYLOAD) { |
| 10818 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10819 | sizeof(*ani_hdr) + len); |
| 10820 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10821 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10822 | radio_info->radio = radio; |
| 10823 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10824 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10825 | "Added radio index tlv - radio index %d", |
| 10826 | radio_info->radio); |
| 10827 | } |
| 10828 | |
| 10829 | nlh->nlmsg_len += tlv_len; |
| 10830 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10831 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10832 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10833 | } |
| 10834 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10835 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10836 | void wlan_hdd_auto_shutdown_cb(void) |
| 10837 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10838 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10839 | |
| 10840 | if (!hdd_ctx) |
| 10841 | return; |
| 10842 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10843 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10844 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10845 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10846 | } |
| 10847 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10848 | 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] | 10849 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10850 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10851 | bool ap_connected = false, sta_connected = false; |
| 10852 | tHalHandle hal_handle; |
| 10853 | |
| 10854 | hal_handle = hdd_ctx->hHal; |
| 10855 | if (hal_handle == NULL) |
| 10856 | return; |
| 10857 | |
| 10858 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10859 | return; |
| 10860 | |
| 10861 | if (enable == false) { |
| 10862 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10863 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10864 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10865 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10866 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10867 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10868 | return; |
| 10869 | } |
| 10870 | |
| 10871 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10872 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 10873 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10874 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10875 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10876 | conn_info.connState == |
| 10877 | eConnectionState_Associated) { |
| 10878 | sta_connected = true; |
| 10879 | break; |
| 10880 | } |
| 10881 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10882 | |
| 10883 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10884 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10885 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10886 | ap_connected = true; |
| 10887 | break; |
| 10888 | } |
| 10889 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10890 | } |
| 10891 | } |
| 10892 | |
| 10893 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10894 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10895 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10896 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10897 | |
| 10898 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10899 | hdd_ctx->config->WlanAutoShutdown) |
| 10900 | != QDF_STATUS_SUCCESS) |
| 10901 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10902 | else |
| 10903 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10904 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10905 | } |
| 10906 | #endif |
| 10907 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10908 | struct hdd_adapter * |
| 10909 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 10910 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10911 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10912 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10913 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10914 | |
| 10915 | con_sap_adapter = NULL; |
| 10916 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10917 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10918 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 10919 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10920 | adapter != this_sap_adapter) { |
| 10921 | if (check_start_bss) { |
| 10922 | if (test_bit(SOFTAP_BSS_STARTED, |
| 10923 | &adapter->event_flags)) { |
| 10924 | con_sap_adapter = adapter; |
| 10925 | break; |
| 10926 | } |
| 10927 | } else { |
| 10928 | con_sap_adapter = adapter; |
| 10929 | break; |
| 10930 | } |
| 10931 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10932 | } |
| 10933 | |
| 10934 | return con_sap_adapter; |
| 10935 | } |
| 10936 | |
| 10937 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10938 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10939 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10940 | return adapter->device_mode == QDF_STA_MODE || |
| 10941 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10942 | } |
| 10943 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10944 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10945 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10946 | return adapter->device_mode == QDF_SAP_MODE || |
| 10947 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 10948 | } |
| 10949 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10950 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10951 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10952 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10953 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10954 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10955 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10956 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10957 | conn_info.connState == eConnectionState_Associated) { |
| 10958 | return true; |
| 10959 | } |
| 10960 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10961 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10962 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10963 | return true; |
| 10964 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10965 | } |
| 10966 | |
| 10967 | return false; |
| 10968 | } |
| 10969 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10970 | 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] | 10971 | { |
| 10972 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10973 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10974 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10975 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10976 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10977 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10978 | return is_running; |
| 10979 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10980 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10981 | 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] | 10982 | { |
| 10983 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10984 | hdd_ctx->bus_bw_timer_running = true; |
| 10985 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 10986 | hdd_ctx->config->busBandwidthComputeInterval); |
| 10987 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10988 | } |
| 10989 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10990 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10991 | { |
| 10992 | ENTER(); |
| 10993 | |
| 10994 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10995 | hdd_debug("Bandwidth compute timer already started"); |
| 10996 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10997 | } |
| 10998 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10999 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11000 | |
| 11001 | EXIT(); |
| 11002 | } |
| 11003 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11004 | 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] | 11005 | { |
| 11006 | ENTER(); |
| 11007 | |
| 11008 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11009 | hdd_debug("Bandwidth compute timer already started"); |
| 11010 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11011 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11012 | |
| 11013 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11014 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11015 | |
| 11016 | EXIT(); |
| 11017 | } |
| 11018 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11019 | 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] | 11020 | { |
| 11021 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 11022 | |
| 11023 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11024 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11025 | hdd_ctx->bus_bw_timer_running = false; |
| 11026 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11027 | |
| 11028 | hdd_reset_tcp_delack(hdd_ctx); |
| 11029 | } |
| 11030 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11031 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11032 | { |
| 11033 | ENTER(); |
| 11034 | |
| 11035 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11036 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11037 | return; |
| 11038 | } |
| 11039 | |
| 11040 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11041 | |
| 11042 | EXIT(); |
| 11043 | } |
| 11044 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11045 | 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] | 11046 | { |
| 11047 | ENTER(); |
| 11048 | |
| 11049 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11050 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11051 | return; |
| 11052 | } |
| 11053 | |
| 11054 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11055 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11056 | |
| 11057 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11058 | } |
| 11059 | #endif |
| 11060 | |
| 11061 | /** |
| 11062 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11063 | * and sta's operating channel. |
| 11064 | * @sta_adapter: Describe the first argument to foobar. |
| 11065 | * @ap_adapter: Describe the second argument to foobar. |
| 11066 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11067 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11068 | * set this flag to true else false. |
| 11069 | * |
| 11070 | * This function checks the sap's operating channel and sta's operating channel. |
| 11071 | * if both are same then it will return false else it will restart the sap in |
| 11072 | * sta's channel and return true. |
| 11073 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11074 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11075 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11076 | QDF_STATUS |
| 11077 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11078 | struct hdd_adapter *ap_adapter, |
| 11079 | tCsrRoamProfile *roam_profile, |
| 11080 | tScanResultHandle *scan_cache, |
| 11081 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11082 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11083 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11084 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11085 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11086 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11087 | *concurrent_chnl_same = true; |
| 11088 | |
| 11089 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11090 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11091 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11092 | scan_cache, |
| 11093 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11094 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11095 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11096 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11097 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11098 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11099 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11100 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11101 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11102 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11103 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11104 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11105 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11106 | } |
| 11107 | } |
| 11108 | } else { |
| 11109 | /* |
| 11110 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11111 | * failed so we have to stop the SAP to avoid any channel |
| 11112 | * discrepancy between SAP's channel and STA's channel. |
| 11113 | * Return the status as failure so caller function could know |
| 11114 | * that scan look up is failed. |
| 11115 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11116 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11117 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11118 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11119 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11120 | } |
| 11121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11122 | /** |
| 11123 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11124 | * @ap_adapter: SAP adapter |
| 11125 | * |
| 11126 | * This function will process the stopping of sap adapter. |
| 11127 | * |
| 11128 | * Return: None |
| 11129 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11130 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11131 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11132 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11133 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11134 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11135 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11136 | |
| 11137 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11138 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11139 | return; |
| 11140 | } |
| 11141 | |
| 11142 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11143 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11144 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11145 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11147 | mutex_lock(&hdd_ctx->sap_lock); |
| 11148 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11149 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11150 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11151 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11152 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11153 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11154 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11155 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11156 | qdf_stop_bss_event, |
| 11157 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11158 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11159 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11160 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11161 | return; |
| 11162 | } |
| 11163 | } |
| 11164 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11165 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11166 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11167 | ap_adapter->session_id); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11168 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11169 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11170 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11171 | } |
| 11172 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11173 | } |
| 11174 | |
| 11175 | /** |
| 11176 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11177 | * @ap_adapter: SAP adapter |
| 11178 | * |
| 11179 | * This function will process the starting of sap adapter. |
| 11180 | * |
| 11181 | * Return: None |
| 11182 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11183 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11184 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11185 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11186 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11187 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11188 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11189 | tsap_Config_t *sap_config; |
| 11190 | |
| 11191 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11192 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11193 | return; |
| 11194 | } |
| 11195 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11196 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11197 | hdd_err("SoftAp role has not been enabled"); |
| 11198 | return; |
| 11199 | } |
| 11200 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11201 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11202 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11203 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11204 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11206 | mutex_lock(&hdd_ctx->sap_lock); |
| 11207 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11208 | goto end; |
| 11209 | |
| 11210 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11211 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11212 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 11213 | goto end; |
| 11214 | } |
| 11215 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11216 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11217 | 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] | 11218 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11219 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11220 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | goto end; |
| 11222 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11223 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11224 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11225 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11226 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11227 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11228 | goto end; |
| 11229 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11230 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11231 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 11232 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11233 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11234 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11235 | ap_adapter->session_id); |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11236 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11237 | |
| 11238 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11239 | end: |
| 11240 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11241 | /* SAP context and beacon cleanup will happen during driver unload |
| 11242 | * in hdd_stop_adapter |
| 11243 | */ |
| 11244 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11245 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11246 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11247 | |
| 11248 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11249 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11250 | * mac scan config |
| 11251 | * @status: Status of set antenna mode |
| 11252 | * |
| 11253 | * Callback on setting the dual mac configuration |
| 11254 | * |
| 11255 | * Return: None |
| 11256 | */ |
| 11257 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11258 | enum set_antenna_mode_status status) |
| 11259 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11260 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11261 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11262 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11263 | |
| 11264 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11265 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11266 | return; |
| 11267 | |
| 11268 | /* Signal the completion of set dual mac config */ |
| 11269 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11270 | } |
| 11271 | |
| 11272 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11273 | * hdd_get_fw_version() - Get FW version |
| 11274 | * @hdd_ctx: pointer to HDD context. |
| 11275 | * @major_spid: FW version - major spid. |
| 11276 | * @minor_spid: FW version - minor spid |
| 11277 | * @ssid: FW version - ssid |
| 11278 | * @crmid: FW version - crmid |
| 11279 | * |
| 11280 | * This function is called to get the firmware build version stored |
| 11281 | * as part of the HDD context |
| 11282 | * |
| 11283 | * Return: None |
| 11284 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11285 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11286 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11287 | uint32_t *siid, uint32_t *crmid) |
| 11288 | { |
| 11289 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11290 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11291 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11292 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11293 | } |
| 11294 | |
| 11295 | #ifdef QCA_CONFIG_SMP |
| 11296 | /** |
| 11297 | * wlan_hdd_get_cpu() - get cpu_index |
| 11298 | * |
| 11299 | * Return: cpu_index |
| 11300 | */ |
| 11301 | int wlan_hdd_get_cpu(void) |
| 11302 | { |
| 11303 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11304 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11305 | put_cpu(); |
| 11306 | return cpu_index; |
| 11307 | } |
| 11308 | #endif |
| 11309 | |
| 11310 | /** |
| 11311 | * hdd_get_fwpath() - get framework path |
| 11312 | * |
| 11313 | * This function is used to get the string written by |
| 11314 | * userspace to start the wlan driver |
| 11315 | * |
| 11316 | * Return: string |
| 11317 | */ |
| 11318 | const char *hdd_get_fwpath(void) |
| 11319 | { |
| 11320 | return fwpath.string; |
| 11321 | } |
| 11322 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11323 | static int hdd_qdf_print_init(void) |
| 11324 | { |
| 11325 | int qdf_print_idx; |
| 11326 | QDF_STATUS status; |
| 11327 | |
| 11328 | status = qdf_print_setup(); |
| 11329 | if (status != QDF_STATUS_SUCCESS) { |
| 11330 | pr_err("qdf_print_setup failed\n"); |
| 11331 | return -EINVAL; |
| 11332 | } |
| 11333 | |
| 11334 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11335 | |
| 11336 | if (qdf_print_idx < 0) { |
| 11337 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11338 | qdf_print_idx); |
| 11339 | return -EINVAL; |
| 11340 | } |
| 11341 | |
| 11342 | qdf_set_pidx(qdf_print_idx); |
| 11343 | |
| 11344 | return 0; |
| 11345 | } |
| 11346 | |
| 11347 | static void hdd_qdf_print_deinit(void) |
| 11348 | { |
| 11349 | int qdf_print_idx; |
| 11350 | |
| 11351 | qdf_print_idx = qdf_get_pidx(); |
| 11352 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11353 | } |
| 11354 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11355 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11356 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11357 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11358 | * This function initilizes CDS global context with the help of cds_init. This |
| 11359 | * has to be the first function called after probe to get a valid global |
| 11360 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11361 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11362 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11363 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11364 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11365 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11366 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11367 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11368 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11369 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11370 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11371 | hdd_err("Failed to allocate CDS context"); |
| 11372 | ret = -ENOMEM; |
| 11373 | goto err_out; |
| 11374 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11375 | |
| 11376 | wlan_init_bug_report_lock(); |
| 11377 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11378 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11379 | wlan_logging_sock_init_svc(); |
| 11380 | #endif |
| 11381 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11382 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11383 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11384 | QDF_TIMER_TYPE_SW); |
| 11385 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11386 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11387 | hdd_qdf_print_init(); |
| 11388 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11389 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11390 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11391 | err_out: |
| 11392 | return ret; |
| 11393 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11394 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11395 | /** |
| 11396 | * hdd_deinit() - Deinitialize Driver |
| 11397 | * |
| 11398 | * This function frees CDS global context with the help of cds_deinit. This |
| 11399 | * has to be the last function call in remove callback to free the global |
| 11400 | * context. |
| 11401 | */ |
| 11402 | void hdd_deinit(void) |
| 11403 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11404 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11405 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11406 | wlan_destroy_bug_report_lock(); |
| 11407 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11408 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11409 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11410 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11411 | wlan_logging_sock_deinit_svc(); |
| 11412 | #endif |
| 11413 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11414 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11415 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11416 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11417 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11418 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11419 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11420 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11421 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11422 | struct file *file) |
| 11423 | { |
| 11424 | return 0; |
| 11425 | } |
| 11426 | |
| 11427 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11428 | const char __user *user_buf, |
| 11429 | size_t count, |
| 11430 | loff_t *f_pos) |
| 11431 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11432 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11433 | static const char wlan_off_str[] = "OFF"; |
| 11434 | static const char wlan_on_str[] = "ON"; |
| 11435 | int ret; |
| 11436 | unsigned long rc; |
| 11437 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11438 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11439 | pr_err("Failed to read buffer\n"); |
| 11440 | return -EINVAL; |
| 11441 | } |
| 11442 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11443 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11444 | pr_debug("Wifi turning off from UI\n"); |
| 11445 | goto exit; |
| 11446 | } |
| 11447 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11448 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11449 | pr_err("Invalid value received from framework"); |
| 11450 | goto exit; |
| 11451 | } |
| 11452 | |
| 11453 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11454 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11455 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11456 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11457 | if (!rc) { |
| 11458 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11459 | ret = -EINVAL; |
| 11460 | hdd_start_complete(ret); |
| 11461 | return ret; |
| 11462 | } |
| 11463 | |
| 11464 | hdd_start_complete(0); |
| 11465 | } |
| 11466 | |
| 11467 | exit: |
| 11468 | return count; |
| 11469 | } |
| 11470 | |
| 11471 | |
| 11472 | const struct file_operations wlan_hdd_state_fops = { |
| 11473 | .owner = THIS_MODULE, |
| 11474 | .open = wlan_hdd_state_ctrl_param_open, |
| 11475 | .write = wlan_hdd_state_ctrl_param_write, |
| 11476 | }; |
| 11477 | |
| 11478 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11479 | { |
| 11480 | unsigned int wlan_hdd_state_major = 0; |
| 11481 | int ret; |
| 11482 | struct device *dev; |
| 11483 | |
| 11484 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11485 | |
| 11486 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11487 | if (ret) { |
| 11488 | pr_err("Failed to register qcwlanstate"); |
| 11489 | goto dev_alloc_err; |
| 11490 | } |
| 11491 | wlan_hdd_state_major = MAJOR(device); |
| 11492 | |
| 11493 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11494 | if (IS_ERR(class)) { |
| 11495 | pr_err("wlan_hdd_state class_create error"); |
| 11496 | goto class_err; |
| 11497 | } |
| 11498 | |
| 11499 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11500 | if (IS_ERR(dev)) { |
| 11501 | pr_err("wlan_hdd_statedevice_create error"); |
| 11502 | goto err_class_destroy; |
| 11503 | } |
| 11504 | |
| 11505 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11506 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11507 | if (ret) { |
| 11508 | pr_err("Failed to add cdev error"); |
| 11509 | goto cdev_add_err; |
| 11510 | } |
| 11511 | |
| 11512 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11513 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11514 | |
| 11515 | return 0; |
| 11516 | |
| 11517 | cdev_add_err: |
| 11518 | device_destroy(class, device); |
| 11519 | err_class_destroy: |
| 11520 | class_destroy(class); |
| 11521 | class_err: |
| 11522 | unregister_chrdev_region(device, dev_num); |
| 11523 | dev_alloc_err: |
| 11524 | return -ENODEV; |
| 11525 | } |
| 11526 | |
| 11527 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11528 | { |
| 11529 | cdev_del(&wlan_hdd_state_cdev); |
| 11530 | device_destroy(class, device); |
| 11531 | class_destroy(class); |
| 11532 | unregister_chrdev_region(device, dev_num); |
| 11533 | |
| 11534 | pr_info("Device node unregistered"); |
| 11535 | } |
| 11536 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11537 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11538 | * component_init - API to init cld component's |
| 11539 | * |
| 11540 | * Return: None |
| 11541 | */ |
| 11542 | static void component_init(void) |
| 11543 | { |
| 11544 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame^] | 11545 | #ifdef WLAN_FEATURE_DISA |
| 11546 | disa_init(); |
| 11547 | #endif |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11548 | } |
| 11549 | |
| 11550 | /** |
| 11551 | * component_deinit - API to deinit cld component's |
| 11552 | * |
| 11553 | * Return: None |
| 11554 | */ |
| 11555 | static void component_deinit(void) |
| 11556 | { |
| 11557 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame^] | 11558 | #ifdef WLAN_FEATURE_DISA |
| 11559 | disa_deinit(); |
| 11560 | #endif |
| 11561 | } |
| 11562 | |
| 11563 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11564 | { |
| 11565 | #ifdef WLAN_FEATURE_DISA |
| 11566 | disa_psoc_enable(psoc); |
| 11567 | #endif |
| 11568 | } |
| 11569 | |
| 11570 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11571 | { |
| 11572 | #ifdef WLAN_FEATURE_DISA |
| 11573 | disa_psoc_disable(psoc); |
| 11574 | #endif |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11575 | } |
| 11576 | |
| 11577 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11578 | * __hdd_module_init - Module init helper |
| 11579 | * |
| 11580 | * Module init helper function used by both module and static driver. |
| 11581 | * |
| 11582 | * Return: 0 for success, errno on failure |
| 11583 | */ |
| 11584 | static int __hdd_module_init(void) |
| 11585 | { |
| 11586 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11587 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11588 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11589 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11590 | g_wlan_driver_version, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11591 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11592 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11593 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11594 | if (ret) { |
| 11595 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11596 | goto err_dev_state; |
| 11597 | } |
| 11598 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11599 | pld_init(); |
| 11600 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11601 | ret = hdd_init(); |
| 11602 | if (ret) { |
| 11603 | pr_err("hdd_init failed %x\n", ret); |
| 11604 | goto err_hdd_init; |
| 11605 | } |
| 11606 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11607 | dispatcher_init(); |
| 11608 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11609 | /* Ensure to call post objmgr init */ |
| 11610 | component_init(); |
| 11611 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11612 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11613 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11614 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11615 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11616 | ret = wlan_hdd_register_driver(); |
| 11617 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11618 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11619 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11620 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11621 | } |
| 11622 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11623 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11624 | |
| 11625 | return 0; |
| 11626 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11627 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11628 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11629 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11630 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11631 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11632 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11633 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11634 | wlan_hdd_state_ctrl_param_destroy(); |
| 11635 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11636 | return ret; |
| 11637 | } |
| 11638 | |
| 11639 | /** |
| 11640 | * __hdd_module_exit - Module exit helper |
| 11641 | * |
| 11642 | * Module exit helper function used by both module and static driver. |
| 11643 | */ |
| 11644 | static void __hdd_module_exit(void) |
| 11645 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11646 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11647 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11648 | QWLAN_VERSIONSTR); |
| 11649 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11650 | hdd_wait_for_recovery_completion(); |
| 11651 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11652 | wlan_hdd_unregister_driver(); |
| 11653 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11654 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11655 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11656 | /* Ensure to call prior to objmgr deinit */ |
| 11657 | component_deinit(); |
| 11658 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11659 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11660 | |
| 11661 | hdd_sysfs_destroy_version_interface(); |
| 11662 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11663 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11664 | pld_deinit(); |
| 11665 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11666 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11667 | } |
| 11668 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11669 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11670 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11671 | * wlan_boot_cb() - Wlan boot callback |
| 11672 | * @kobj: object whose directory we're creating the link in. |
| 11673 | * @attr: attribute the user is interacting with |
| 11674 | * @buff: the buffer containing the user data |
| 11675 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11676 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11677 | * This callback is invoked when the fs is ready to start the |
| 11678 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11679 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11680 | * 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] | 11681 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11682 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11683 | struct kobj_attribute *attr, |
| 11684 | const char *buf, |
| 11685 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11686 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11687 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11688 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11689 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11690 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11691 | } |
| 11692 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11693 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11694 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11695 | return -EIO; |
| 11696 | } |
| 11697 | |
| 11698 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11699 | |
| 11700 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11701 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11702 | |
| 11703 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11704 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11705 | * |
| 11706 | * Return: None |
| 11707 | * |
| 11708 | */ |
| 11709 | static void hdd_sysfs_cleanup(void) |
| 11710 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11711 | /* remove from group */ |
| 11712 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11713 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11714 | wlan_loader->attr_group); |
| 11715 | |
| 11716 | /* unlink the object from parent */ |
| 11717 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11718 | |
| 11719 | /* free the object */ |
| 11720 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11721 | |
| 11722 | kfree(wlan_loader->attr_group); |
| 11723 | kfree(wlan_loader); |
| 11724 | |
| 11725 | wlan_loader = NULL; |
| 11726 | } |
| 11727 | |
| 11728 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11729 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11730 | * ready |
| 11731 | * |
| 11732 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11733 | * when the filesystem is ready. |
| 11734 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11735 | * QDF API cannot be used here since this function is called even before |
| 11736 | * initializing WLAN driver. |
| 11737 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11738 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11739 | */ |
| 11740 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11741 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11742 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11743 | |
| 11744 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11745 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11746 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11747 | |
| 11748 | wlan_loader->boot_wlan_obj = NULL; |
| 11749 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11750 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11751 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11752 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11753 | |
| 11754 | wlan_loader->loaded_state = 0; |
| 11755 | wlan_loader->attr_group->attrs = attrs; |
| 11756 | |
| 11757 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11758 | kernel_kobj); |
| 11759 | if (!wlan_loader->boot_wlan_obj) { |
| 11760 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11761 | goto error_return; |
| 11762 | } |
| 11763 | |
| 11764 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11765 | wlan_loader->attr_group); |
| 11766 | if (ret) { |
| 11767 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11768 | goto error_return; |
| 11769 | } |
| 11770 | |
| 11771 | return 0; |
| 11772 | |
| 11773 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11774 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11775 | |
| 11776 | return ret; |
| 11777 | } |
| 11778 | |
| 11779 | /** |
| 11780 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11781 | * |
| 11782 | * Return: 0 on success or errno on failure |
| 11783 | */ |
| 11784 | static int wlan_deinit_sysfs(void) |
| 11785 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11786 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11787 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11788 | return -EINVAL; |
| 11789 | } |
| 11790 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11791 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11792 | return 0; |
| 11793 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11794 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11795 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11796 | |
| 11797 | #ifdef MODULE |
| 11798 | /** |
| 11799 | * __hdd_module_init - Module init helper |
| 11800 | * |
| 11801 | * Module init helper function used by both module and static driver. |
| 11802 | * |
| 11803 | * Return: 0 for success, errno on failure |
| 11804 | */ |
| 11805 | static int hdd_module_init(void) |
| 11806 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11807 | if (__hdd_module_init()) { |
| 11808 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11809 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11810 | } |
| 11811 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11812 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11813 | } |
| 11814 | #else |
| 11815 | static int __init hdd_module_init(void) |
| 11816 | { |
| 11817 | int ret = -EINVAL; |
| 11818 | |
| 11819 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11820 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11821 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11822 | |
| 11823 | return ret; |
| 11824 | } |
| 11825 | #endif |
| 11826 | |
| 11827 | |
| 11828 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11829 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11830 | * hdd_module_exit() - Exit function |
| 11831 | * |
| 11832 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11833 | * |
| 11834 | * Return: None |
| 11835 | */ |
| 11836 | static void __exit hdd_module_exit(void) |
| 11837 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11838 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11839 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11840 | #else |
| 11841 | static void __exit hdd_module_exit(void) |
| 11842 | { |
| 11843 | __hdd_module_exit(); |
| 11844 | wlan_deinit_sysfs(); |
| 11845 | } |
| 11846 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11847 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11848 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11849 | { |
| 11850 | return param_set_copystring(kmessage, kp); |
| 11851 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11852 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11853 | /** |
| 11854 | * is_con_mode_valid() check con mode is valid or not |
| 11855 | * @mode: global con mode |
| 11856 | * |
| 11857 | * Return: TRUE on success FALSE on failure |
| 11858 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11859 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11860 | { |
| 11861 | switch (mode) { |
| 11862 | case QDF_GLOBAL_MONITOR_MODE: |
| 11863 | case QDF_GLOBAL_FTM_MODE: |
| 11864 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11865 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11866 | return true; |
| 11867 | default: |
| 11868 | return false; |
| 11869 | } |
| 11870 | } |
| 11871 | |
| 11872 | /** |
| 11873 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11874 | * @mode: global con mode |
| 11875 | * |
| 11876 | * Return: adapter mode |
| 11877 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11878 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11879 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11880 | { |
| 11881 | |
| 11882 | switch (mode) { |
| 11883 | case QDF_GLOBAL_MISSION_MODE: |
| 11884 | return QDF_STA_MODE; |
| 11885 | case QDF_GLOBAL_MONITOR_MODE: |
| 11886 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11887 | case QDF_GLOBAL_EPPING_MODE: |
| 11888 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11889 | case QDF_GLOBAL_FTM_MODE: |
| 11890 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11891 | case QDF_GLOBAL_QVIT_MODE: |
| 11892 | return QDF_QVIT_MODE; |
| 11893 | default: |
| 11894 | return QDF_MAX_NO_OF_MODE; |
| 11895 | } |
| 11896 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11897 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11898 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11899 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11900 | { |
| 11901 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11902 | return; |
| 11903 | |
| 11904 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11905 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 11906 | hdd_info("Release wakelock for monitor mode!"); |
| 11907 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 11908 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 11909 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11910 | case QDF_GLOBAL_FTM_MODE: |
| 11911 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11912 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 11913 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11914 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11915 | break; |
| 11916 | default: |
| 11917 | break; |
| 11918 | } |
| 11919 | } |
| 11920 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11921 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11922 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11923 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 11924 | int driver_status; |
| 11925 | |
| 11926 | driver_status = hdd_ctx->driver_status; |
| 11927 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11928 | switch (curr_mode) { |
| 11929 | case QDF_GLOBAL_MISSION_MODE: |
| 11930 | case QDF_GLOBAL_MONITOR_MODE: |
| 11931 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11932 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 11933 | hdd_close_all_adapters(hdd_ctx, false); |
| 11934 | break; |
| 11935 | case QDF_GLOBAL_EPPING_MODE: |
| 11936 | epping_disable(); |
| 11937 | epping_close(); |
| 11938 | break; |
| 11939 | default: |
| 11940 | return; |
| 11941 | } |
| 11942 | } |
| 11943 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11944 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11945 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11946 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11947 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11948 | int ret = 0; |
| 11949 | bool rtnl_held; |
| 11950 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11951 | QDF_STATUS status; |
| 11952 | |
| 11953 | if (!qdf_dev) { |
| 11954 | hdd_err("qdf device context is Null return!"); |
| 11955 | return -EINVAL; |
| 11956 | } |
| 11957 | |
| 11958 | rtnl_held = hdd_hold_rtnl_lock(); |
| 11959 | switch (mode) { |
| 11960 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11961 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11962 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11963 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11964 | break; |
| 11965 | case QDF_GLOBAL_FTM_MODE: |
| 11966 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11967 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11968 | NET_NAME_UNKNOWN, rtnl_held); |
| 11969 | if (adapter == NULL) |
| 11970 | ret = -EINVAL; |
| 11971 | break; |
| 11972 | case QDF_GLOBAL_MONITOR_MODE: |
| 11973 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11974 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11975 | NET_NAME_UNKNOWN, rtnl_held); |
| 11976 | if (adapter == NULL) |
| 11977 | ret = -EINVAL; |
| 11978 | break; |
| 11979 | case QDF_GLOBAL_EPPING_MODE: |
| 11980 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11981 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11982 | hdd_err("Failed to open in eeping mode: %d", status); |
| 11983 | ret = -EINVAL; |
| 11984 | break; |
| 11985 | } |
| 11986 | ret = epping_enable(qdf_dev->dev); |
| 11987 | if (ret) { |
| 11988 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 11989 | epping_close(); |
| 11990 | } |
| 11991 | break; |
| 11992 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11993 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11994 | ret = -ENOTSUPP; |
| 11995 | break; |
| 11996 | } |
| 11997 | hdd_release_rtnl_lock(); |
| 11998 | rtnl_held = false; |
| 11999 | return ret; |
| 12000 | } |
| 12001 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12002 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12003 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12004 | * @kmessage: con mode name on which driver to be bring up |
| 12005 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12006 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12007 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12008 | * This function is invoked when user updates con mode using sys entry, |
| 12009 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12010 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12011 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12012 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12013 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12014 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12015 | { |
| 12016 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12017 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12018 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12019 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12020 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12021 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12022 | hdd_info("con_mode handler: %s", kmessage); |
| 12023 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12024 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12025 | if (ret) |
| 12026 | return ret; |
| 12027 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12028 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12029 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12030 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12031 | if (ret) { |
| 12032 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12033 | goto reset_flags; |
| 12034 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12035 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12036 | if (!is_con_mode_valid(new_con_mode)) { |
| 12037 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12038 | ret = -EINVAL; |
| 12039 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12040 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12041 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12042 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12043 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12044 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12045 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12046 | ret = 0; |
| 12047 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12048 | } |
| 12049 | |
Sourav Mohapatra | 3bc5e98 | 2017-11-24 15:53:49 +0530 | [diff] [blame] | 12050 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12051 | hdd_warn("Waiting for monitor mode: External threads are active"); |
| 12052 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12053 | /* ensure adapters are stopped */ |
| 12054 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12055 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12056 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12057 | if (ret) { |
| 12058 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12059 | goto reset_flags; |
| 12060 | } |
| 12061 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12062 | /* Cleanup present mode before switching to new mode */ |
| 12063 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12064 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12065 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12066 | |
| 12067 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12068 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12069 | if (ret) { |
| 12070 | hdd_err("Failed to register for new mode"); |
| 12071 | goto reset_flags; |
| 12072 | } |
| 12073 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12074 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12075 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12076 | hdd_err("invalid adapter"); |
| 12077 | ret = -EINVAL; |
| 12078 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12079 | } |
| 12080 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12081 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12082 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12083 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12084 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12085 | } |
| 12086 | |
| 12087 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12088 | if (ret) { |
| 12089 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12090 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12091 | } |
| 12092 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12093 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12094 | if (hdd_start_adapter(adapter)) { |
| 12095 | hdd_err("Failed to start %s adapter", kmessage); |
| 12096 | ret = -EINVAL; |
| 12097 | goto reset_flags; |
| 12098 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12099 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12100 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12101 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12102 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12103 | } |
| 12104 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12105 | /* con_mode is a global module parameter */ |
| 12106 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12107 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12108 | ret = 0; |
| 12109 | |
| 12110 | reset_flags: |
| 12111 | cds_set_load_in_progress(false); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12112 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12113 | return ret; |
| 12114 | } |
| 12115 | |
| 12116 | |
| 12117 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12118 | { |
| 12119 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12120 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12121 | |
| 12122 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12123 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12124 | if (ret) |
| 12125 | return ret; |
| 12126 | |
| 12127 | cds_ssr_protect(__func__); |
| 12128 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12129 | cds_ssr_unprotect(__func__); |
| 12130 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12131 | return ret; |
| 12132 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12133 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12134 | static int con_mode_handler_ftm(const char *kmessage, |
| 12135 | struct kernel_param *kp) |
| 12136 | { |
| 12137 | int ret; |
| 12138 | |
| 12139 | ret = param_set_int(kmessage, kp); |
| 12140 | |
| 12141 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12142 | pr_err("Only FTM mode supported!"); |
| 12143 | return -ENOTSUPP; |
| 12144 | } |
| 12145 | |
| 12146 | hdd_set_conparam(con_mode_ftm); |
| 12147 | con_mode = con_mode_ftm; |
| 12148 | |
| 12149 | return ret; |
| 12150 | } |
| 12151 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12152 | static int con_mode_handler_monitor(const char *kmessage, |
| 12153 | struct kernel_param *kp) |
| 12154 | { |
| 12155 | int ret; |
| 12156 | |
| 12157 | ret = param_set_int(kmessage, kp); |
| 12158 | |
| 12159 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12160 | pr_err("Only Monitor mode supported!"); |
| 12161 | return -ENOTSUPP; |
| 12162 | } |
| 12163 | |
| 12164 | hdd_set_conparam(con_mode_monitor); |
| 12165 | con_mode = con_mode_monitor; |
| 12166 | |
| 12167 | return ret; |
| 12168 | } |
| 12169 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12170 | /** |
| 12171 | * hdd_get_conparam() - driver exit point |
| 12172 | * |
| 12173 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12174 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12175 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12176 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12177 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12178 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12179 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12180 | } |
| 12181 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12182 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12183 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12184 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12185 | } |
| 12186 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12187 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12188 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12189 | * @hdd_ctx: HDD context |
| 12190 | * |
| 12191 | * Cleans up the pre cac interface, if it exists |
| 12192 | * |
| 12193 | * Return: None |
| 12194 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12195 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12196 | { |
| 12197 | uint8_t session_id; |
| 12198 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12199 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12200 | |
| 12201 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12202 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12203 | hdd_err("failed to get pre cac vdev id"); |
| 12204 | return; |
| 12205 | } |
| 12206 | |
| 12207 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12208 | if (!precac_adapter) { |
| 12209 | hdd_err("invalid pre cac adapater"); |
| 12210 | return; |
| 12211 | } |
| 12212 | |
| 12213 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12214 | wlan_hdd_sap_pre_cac_failure, |
| 12215 | (void *)precac_adapter); |
| 12216 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12217 | |
| 12218 | } |
| 12219 | |
| 12220 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12221 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12222 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12223 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12224 | * Return: void |
| 12225 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12226 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12227 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12228 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12229 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12230 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12231 | if (!ol_ctx) |
| 12232 | return; |
| 12233 | |
| 12234 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12235 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12236 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12237 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12238 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12239 | |
| 12240 | ol_init_ini_config(ol_ctx, &cfg); |
| 12241 | } |
| 12242 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12243 | #ifdef FEATURE_RUNTIME_PM |
| 12244 | /** |
| 12245 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12246 | * @hdd_ctx: hdd context |
| 12247 | * @cfg: pointer to the configuration memory being populated |
| 12248 | * |
| 12249 | * Return: void |
| 12250 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12251 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12252 | struct hif_config_info *cfg) |
| 12253 | { |
| 12254 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12255 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12256 | } |
| 12257 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12258 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12259 | struct hif_config_info *cfg) |
| 12260 | { |
| 12261 | } |
| 12262 | #endif |
| 12263 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12264 | /** |
| 12265 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12266 | * @hdd_ctx: HDD Context |
| 12267 | * |
| 12268 | * Return: void |
| 12269 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12270 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12271 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12272 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12273 | struct hif_config_info cfg; |
| 12274 | |
| 12275 | if (!scn) |
| 12276 | return; |
| 12277 | |
| 12278 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12279 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12280 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12281 | |
| 12282 | if (hdd_ctx->config->prevent_link_down) |
| 12283 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12284 | } |
| 12285 | |
| 12286 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12287 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12288 | * datapath |
| 12289 | * @hdd_ctx: HDD Context |
| 12290 | * |
| 12291 | * Return: 0 for success/errno for failure |
| 12292 | */ |
| 12293 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12294 | { |
| 12295 | struct cdp_config_params params; |
| 12296 | QDF_STATUS status; |
| 12297 | |
| 12298 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12299 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12300 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12301 | params.tx_flow_stop_queue_threshold = |
| 12302 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12303 | params.tx_flow_start_queue_offset = |
| 12304 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12305 | #endif |
| 12306 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12307 | params.napi_enable = hdd_ctx->napi_enable; |
| 12308 | params.tcp_udp_checksumoffload = |
| 12309 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12310 | |
| 12311 | status = cdp_update_config_parameters( |
| 12312 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12313 | ¶ms); |
| 12314 | if (status) { |
| 12315 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 12316 | "%s: Failed to attach config parameters", __func__); |
| 12317 | return status; |
| 12318 | } |
| 12319 | |
| 12320 | return 0; |
| 12321 | } |
| 12322 | |
| 12323 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12324 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12325 | * @hdd_ctx: HDD Context |
| 12326 | * |
| 12327 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12328 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12329 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12330 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12331 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12332 | int ret; |
| 12333 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12334 | hdd_update_ol_config(hdd_ctx); |
| 12335 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12336 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12337 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12338 | else |
| 12339 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12340 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12341 | |
| 12342 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12343 | } |
| 12344 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12345 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12346 | /** |
| 12347 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12348 | * @psoc_cfg: pmo psoc Configuration |
| 12349 | * @hdd_ctx: Pointer to hdd context |
| 12350 | * |
| 12351 | * Return: none |
| 12352 | */ |
| 12353 | static inline void hdd_ra_populate_pmo_config( |
| 12354 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12355 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12356 | { |
| 12357 | psoc_cfg->ra_ratelimit_interval = |
| 12358 | hdd_ctx->config->RArateLimitInterval; |
| 12359 | psoc_cfg->ra_ratelimit_enable = |
| 12360 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12361 | } |
| 12362 | #else |
| 12363 | static inline void hdd_ra_populate_pmo_config( |
| 12364 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12365 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12366 | { |
| 12367 | } |
| 12368 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12369 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12370 | /** |
| 12371 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12372 | * @hdd_ctx: HDD context |
| 12373 | * |
| 12374 | * Return: void |
| 12375 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12376 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12377 | { |
| 12378 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12379 | struct pmo_psoc_cfg psoc_cfg; |
| 12380 | QDF_STATUS status; |
| 12381 | |
| 12382 | /* |
| 12383 | * Value of hdd_ctx->wowEnable can be, |
| 12384 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12385 | * 1 - Enable magic pattern match on all interfaces. |
| 12386 | * 2 - Enable pattern byte match on all interfaces. |
| 12387 | * 3 - Enable both magic patter and pattern byte match on |
| 12388 | * all interfaces. |
| 12389 | */ |
| 12390 | psoc_cfg.magic_ptrn_enable = |
| 12391 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12392 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12393 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12394 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12395 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12396 | psoc_cfg.bpf_enable = |
| 12397 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12398 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12399 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12400 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12401 | if (hdd_ctx->config->fhostNSOffload) |
| 12402 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12403 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12404 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12405 | psoc_cfg.active_mode_offload = |
| 12406 | hdd_ctx->config->active_mode_offload; |
| 12407 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12408 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12409 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12410 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12411 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12412 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12413 | psoc_cfg.power_save_mode = |
| 12414 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12415 | psoc_cfg.auto_power_save_fail_mode = |
| 12416 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12417 | |
| 12418 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12419 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12420 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Rajeev Kumar | d1a7ac4 | 2017-11-08 14:54:22 -0800 | [diff] [blame] | 12421 | status = ucfg_pmo_update_psoc_config(psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12422 | if (status != QDF_STATUS_SUCCESS) { |
| 12423 | hdd_err("failed pmo psoc configuration"); |
| 12424 | return -EINVAL; |
| 12425 | } |
| 12426 | |
| 12427 | return 0; |
| 12428 | } |
| 12429 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12430 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12431 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12432 | struct hdd_config *cfg) |
| 12433 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12434 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12435 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12436 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12437 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12438 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12439 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12440 | pno_cfg->channel_prediction_full_scan = |
| 12441 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12442 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12443 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12444 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12445 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12446 | } |
| 12447 | #else |
| 12448 | static inline void |
| 12449 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12450 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12451 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12452 | } |
| 12453 | #endif |
| 12454 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12455 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12456 | struct hdd_config *cfg) |
| 12457 | { |
| 12458 | uint8_t i = 0; |
| 12459 | |
| 12460 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12461 | if (!ie_whitelist->white_list) |
| 12462 | return; |
| 12463 | |
| 12464 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12465 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12466 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12467 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12468 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12469 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12470 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12471 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12472 | |
| 12473 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12474 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12475 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12476 | } |
| 12477 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12478 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12479 | { |
| 12480 | uint8_t i, score; |
| 12481 | |
| 12482 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12483 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12484 | if (score > MAX_INDEX_SCORE) |
| 12485 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12486 | MAX_INDEX_SCORE, i); |
| 12487 | } |
| 12488 | |
| 12489 | return per_index_score; |
| 12490 | } |
| 12491 | |
| 12492 | /** |
| 12493 | * hdd_update_score_config - API to update candidate scoring related params |
| 12494 | * configuration parameters |
| 12495 | * @score_config: score config to update |
| 12496 | * @cfg: config params |
| 12497 | * |
| 12498 | * Return: 0 if success else err |
| 12499 | */ |
| 12500 | static void hdd_update_score_config( |
| 12501 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12502 | { |
| 12503 | int total_weight; |
| 12504 | |
| 12505 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12506 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12507 | score_config->weight_cfg.vht_caps_weightage = |
| 12508 | cfg->vht_caps_weightage; |
| 12509 | score_config->weight_cfg.he_caps_weightage = |
| 12510 | cfg->he_caps_weightage; |
| 12511 | score_config->weight_cfg.chan_width_weightage = |
| 12512 | cfg->chan_width_weightage; |
| 12513 | score_config->weight_cfg.chan_band_weightage = |
| 12514 | cfg->chan_band_weightage; |
| 12515 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12516 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12517 | cfg->beamforming_cap_weightage; |
| 12518 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12519 | score_config->weight_cfg.channel_congestion_weightage = |
| 12520 | cfg->channel_congestion_weightage; |
| 12521 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12522 | |
| 12523 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12524 | score_config->weight_cfg.ht_caps_weightage + |
| 12525 | score_config->weight_cfg.vht_caps_weightage + |
| 12526 | score_config->weight_cfg.he_caps_weightage + |
| 12527 | score_config->weight_cfg.chan_width_weightage + |
| 12528 | score_config->weight_cfg.chan_band_weightage + |
| 12529 | score_config->weight_cfg.nss_weightage + |
| 12530 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12531 | score_config->weight_cfg.pcl_weightage + |
| 12532 | score_config->weight_cfg.channel_congestion_weightage + |
| 12533 | score_config->weight_cfg.oce_wan_weightage; |
| 12534 | |
| 12535 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12536 | hdd_err("total weight is greater than %d fallback to default values", |
| 12537 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12538 | |
| 12539 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12540 | score_config->weight_cfg.ht_caps_weightage = |
| 12541 | HT_CAPABILITY_WEIGHTAGE; |
| 12542 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12543 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12544 | score_config->weight_cfg.chan_width_weightage = |
| 12545 | CHAN_WIDTH_WEIGHTAGE; |
| 12546 | score_config->weight_cfg.chan_band_weightage = |
| 12547 | CHAN_BAND_WEIGHTAGE; |
| 12548 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12549 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12550 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12551 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12552 | score_config->weight_cfg.channel_congestion_weightage = |
| 12553 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12554 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12555 | } |
| 12556 | |
| 12557 | score_config->bandwidth_weight_per_index = |
| 12558 | hdd_limit_max_per_index_score( |
| 12559 | cfg->bandwidth_weight_per_index); |
| 12560 | score_config->nss_weight_per_index = |
| 12561 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12562 | score_config->band_weight_per_index = |
| 12563 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12564 | |
| 12565 | score_config->rssi_score.best_rssi_threshold = |
| 12566 | cfg->best_rssi_threshold; |
| 12567 | score_config->rssi_score.good_rssi_threshold = |
| 12568 | cfg->good_rssi_threshold; |
| 12569 | score_config->rssi_score.bad_rssi_threshold = |
| 12570 | cfg->bad_rssi_threshold; |
| 12571 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12572 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12573 | score_config->rssi_score.good_rssi_bucket_size = |
| 12574 | cfg->good_rssi_bucket_size; |
| 12575 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12576 | cfg->bad_rssi_bucket_size; |
| 12577 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12578 | cfg->rssi_pref_5g_rssi_thresh; |
| 12579 | |
| 12580 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12581 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12582 | hdd_limit_max_per_index_score( |
| 12583 | cfg->esp_qbss_score_slots3_to_0); |
| 12584 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12585 | hdd_limit_max_per_index_score( |
| 12586 | cfg->esp_qbss_score_slots7_to_4); |
| 12587 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12588 | hdd_limit_max_per_index_score( |
| 12589 | cfg->esp_qbss_score_slots11_to_8); |
| 12590 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12591 | hdd_limit_max_per_index_score( |
| 12592 | cfg->esp_qbss_score_slots15_to_12); |
| 12593 | |
| 12594 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12595 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12596 | hdd_limit_max_per_index_score( |
| 12597 | cfg->oce_wan_score_slots3_to_0); |
| 12598 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12599 | hdd_limit_max_per_index_score( |
| 12600 | cfg->oce_wan_score_slots7_to_4); |
| 12601 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12602 | hdd_limit_max_per_index_score( |
| 12603 | cfg->oce_wan_score_slots11_to_8); |
| 12604 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12605 | hdd_limit_max_per_index_score( |
| 12606 | cfg->oce_wan_score_slots15_to_12); |
| 12607 | |
| 12608 | |
| 12609 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12610 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12611 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12612 | |
| 12613 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12614 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12615 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12616 | score_config->he_cap = 1; |
| 12617 | |
| 12618 | if (score_config->he_cap || |
| 12619 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12620 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12621 | score_config->vht_cap = 1; |
| 12622 | |
| 12623 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12624 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12625 | score_config->ht_cap = 1; |
| 12626 | |
| 12627 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12628 | score_config->vht_24G_cap = 1; |
| 12629 | |
| 12630 | if (cfg->enableTxBF) |
| 12631 | score_config->beamformee_cap = 1; |
| 12632 | |
| 12633 | } |
| 12634 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12635 | /** |
| 12636 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12637 | * @hdd_ctx: HDD context |
| 12638 | * |
| 12639 | * Return: 0 if success else err |
| 12640 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12641 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12642 | { |
| 12643 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12644 | struct scan_user_cfg scan_cfg; |
| 12645 | struct hdd_config *cfg = hdd_ctx->config; |
| 12646 | QDF_STATUS status; |
| 12647 | |
| 12648 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12649 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12650 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12651 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12652 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12653 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12654 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12655 | /* convert to ms */ |
| 12656 | scan_cfg.scan_cache_aging_time = |
| 12657 | cfg->scanAgingTimeout * 1000; |
| 12658 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12659 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12660 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12661 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12662 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12663 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12664 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12665 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12666 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12667 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12668 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12669 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12670 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12671 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12672 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12673 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12674 | if (status != QDF_STATUS_SUCCESS) { |
| 12675 | hdd_err("failed pmo psoc configuration"); |
| 12676 | return -EINVAL; |
| 12677 | } |
| 12678 | |
| 12679 | return 0; |
| 12680 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12681 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12682 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12683 | { |
| 12684 | int ret; |
| 12685 | |
| 12686 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12687 | if (ret) |
| 12688 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12689 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12690 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12691 | if (ret) |
| 12692 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12693 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12694 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12695 | if (ret) |
| 12696 | return ret; |
| 12697 | |
| 12698 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12699 | |
| 12700 | return ret; |
| 12701 | } |
| 12702 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12703 | /** |
| 12704 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12705 | * @mode : cfg80211 DFS mode |
| 12706 | * |
| 12707 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12708 | */ |
| 12709 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12710 | { |
| 12711 | switch (mode) { |
| 12712 | case DFS_MODE_ENABLE: |
| 12713 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12714 | case DFS_MODE_DISABLE: |
| 12715 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12716 | case DFS_MODE_DEPRIORITIZE: |
| 12717 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12718 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12719 | hdd_debug("ACS dfs mode is NONE"); |
| 12720 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12721 | } |
| 12722 | } |
| 12723 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12724 | /** |
| 12725 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12726 | * @hddctx: pointer to hdd context |
| 12727 | * @set_value: enable/disable |
| 12728 | * |
| 12729 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12730 | * Host(even though it is duplicate). When Host send vendor command |
| 12731 | * disable,FW doesn't perform any action. Whenever any change in |
| 12732 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12733 | * |
| 12734 | * return - 0 on success, appropriate error values on failure. |
| 12735 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12736 | 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] | 12737 | { |
| 12738 | QDF_STATUS status; |
| 12739 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12740 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12741 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12742 | |
| 12743 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12744 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12745 | return -EINVAL; |
| 12746 | } |
| 12747 | |
| 12748 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12749 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12750 | hdd_err("Failed to send chan avoid command to SME"); |
| 12751 | return -EINVAL; |
| 12752 | } |
| 12753 | return 0; |
| 12754 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12755 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12756 | /** |
| 12757 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12758 | * @value: value to set |
| 12759 | * |
| 12760 | * This function will set the passed value to roaming in progress flag. |
| 12761 | * |
| 12762 | * Return: None |
| 12763 | */ |
| 12764 | void hdd_set_roaming_in_progress(bool value) |
| 12765 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12766 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12767 | |
| 12768 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12769 | if (!hdd_ctx) { |
| 12770 | hdd_err("HDD context is NULL"); |
| 12771 | return; |
| 12772 | } |
| 12773 | |
| 12774 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12775 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12776 | } |
| 12777 | |
| 12778 | /** |
| 12779 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12780 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12781 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12782 | * 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] | 12783 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12784 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12785 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12786 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12787 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12788 | |
| 12789 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12790 | if (!hdd_ctx) { |
| 12791 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12792 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12793 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12794 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12795 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12796 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12797 | hdd_ctx->roaming_in_progress); |
| 12798 | |
| 12799 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12800 | } |
| 12801 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12802 | /** |
| 12803 | * hdd_is_connection_in_progress() - check if connection is in |
| 12804 | * progress |
| 12805 | * @session_id: session id |
| 12806 | * @reason: scan reject reason |
| 12807 | * |
| 12808 | * Go through each adapter and check if Connection is in progress |
| 12809 | * |
| 12810 | * Return: true if connection is in progress else false |
| 12811 | */ |
| 12812 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12813 | enum scan_reject_states *reason) |
| 12814 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12815 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12816 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12817 | uint8_t sta_id = 0; |
| 12818 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12819 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12820 | |
| 12821 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12822 | if (!hdd_ctx) { |
| 12823 | hdd_err("HDD context is NULL"); |
| 12824 | return false; |
| 12825 | } |
| 12826 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12827 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12828 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12829 | hdd_device_mode_to_string(adapter->device_mode), |
| 12830 | adapter->device_mode); |
| 12831 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12832 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12833 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12834 | && (eConnectionState_Connecting == |
| 12835 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12836 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12837 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12838 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12839 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12840 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12841 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12842 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12843 | } |
| 12844 | return true; |
| 12845 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12846 | /* |
| 12847 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12848 | * hdd_is_roaming_in_progress is for LFR3 |
| 12849 | */ |
| 12850 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12851 | sme_neighbor_middle_of_roaming( |
| 12852 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12853 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12854 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12855 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12856 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12857 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12858 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12859 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12860 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12861 | } |
| 12862 | return true; |
| 12863 | } |
| 12864 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12865 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12866 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12867 | hdd_sta_ctx = |
| 12868 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12869 | if ((eConnectionState_Associated == |
| 12870 | hdd_sta_ctx->conn_info.connState) |
| 12871 | && (false == |
| 12872 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12873 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 12874 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12875 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12876 | " is in middle of WPS/EAPOL exchange.", |
| 12877 | MAC_ADDR_ARRAY(sta_mac)); |
| 12878 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12879 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12880 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12881 | } |
| 12882 | return true; |
| 12883 | } |
| 12884 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12885 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12886 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12887 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12888 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12889 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12890 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12891 | continue; |
| 12892 | |
| 12893 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12894 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 12895 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12896 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12897 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12898 | MAC_ADDR_ARRAY(sta_mac)); |
| 12899 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12900 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12901 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12902 | } |
| 12903 | return true; |
| 12904 | } |
| 12905 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12906 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12907 | return true; |
| 12908 | } |
| 12909 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12910 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12911 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12912 | return false; |
| 12913 | } |
| 12914 | |
| 12915 | /** |
| 12916 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12917 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12918 | * |
| 12919 | * Return: None |
| 12920 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12921 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12922 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12923 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12924 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12925 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12926 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12927 | tsap_Config_t *sap_config; |
| 12928 | void *sap_ctx; |
| 12929 | |
| 12930 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 12931 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12932 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12933 | |
| 12934 | mutex_lock(&hdd_ctx->sap_lock); |
| 12935 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 12936 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12937 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 12938 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 12939 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 12940 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12941 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12942 | qdf_stop_bss_event, |
| 12943 | SME_CMD_TIMEOUT_VALUE); |
| 12944 | |
| 12945 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12946 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12947 | goto end; |
| 12948 | } |
| 12949 | } |
| 12950 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12951 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12952 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12953 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12954 | |
| 12955 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12956 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12957 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12958 | eUPDATE_IE_ALL); |
| 12959 | goto end; |
| 12960 | } |
| 12961 | |
| 12962 | qdf_event_reset(&hostapd_state->qdf_event); |
| 12963 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 12964 | sap_config, |
| 12965 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12966 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12967 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12968 | eUPDATE_IE_ALL); |
| 12969 | goto end; |
| 12970 | } |
| 12971 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12972 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12973 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12974 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12975 | SME_CMD_TIMEOUT_VALUE); |
| 12976 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12977 | eUPDATE_IE_ALL); |
| 12978 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12979 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12980 | goto end; |
| 12981 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12982 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12983 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 12984 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12985 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12986 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12987 | ap_adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12988 | } |
| 12989 | end: |
| 12990 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12991 | } |
| 12992 | |
| 12993 | /** |
| 12994 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 12995 | * with non dfs acs |
| 12996 | * |
| 12997 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 12998 | * |
| 12999 | * Return: None |
| 13000 | */ |
| 13001 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13002 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13003 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13004 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13005 | cds_context_type *cds_ctx; |
| 13006 | |
| 13007 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13008 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13009 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13010 | return; |
| 13011 | } |
| 13012 | |
| 13013 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13014 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13015 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13016 | return; |
| 13017 | } |
| 13018 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13019 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13020 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13021 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13022 | return; |
| 13023 | } |
| 13024 | |
| 13025 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13026 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13027 | &ap_adapter->event_flags) && |
| 13028 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13029 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13030 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13031 | 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] | 13032 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13033 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13034 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13035 | acs_cfg.acs_mode = true; |
| 13036 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13037 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13038 | } |
| 13039 | } |
| 13040 | |
| 13041 | /** |
| 13042 | * hdd_set_connection_in_progress() - to set the connection in |
| 13043 | * progress flag |
| 13044 | * @value: value to set |
| 13045 | * |
| 13046 | * This function will set the passed value to connection in progress flag. |
| 13047 | * If value is previously being set to true then no need to set it again. |
| 13048 | * |
| 13049 | * Return: true if value is being set correctly and false otherwise. |
| 13050 | */ |
| 13051 | bool hdd_set_connection_in_progress(bool value) |
| 13052 | { |
| 13053 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13054 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13055 | |
| 13056 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13057 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13058 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13059 | return false; |
| 13060 | } |
| 13061 | |
| 13062 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13063 | /* |
| 13064 | * if the value is set to true previously and if someone is |
| 13065 | * trying to make it true again then it could be some race |
| 13066 | * condition being triggered. Avoid this situation by returning |
| 13067 | * false |
| 13068 | */ |
| 13069 | if (hdd_ctx->connection_in_progress && value) |
| 13070 | status = false; |
| 13071 | else |
| 13072 | hdd_ctx->connection_in_progress = value; |
| 13073 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13074 | return status; |
| 13075 | } |
| 13076 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13077 | 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] | 13078 | { |
| 13079 | if (!adapter) { |
| 13080 | hdd_err("Invalid adapter"); |
| 13081 | return -EINVAL; |
| 13082 | } |
| 13083 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13084 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13085 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13086 | set_value, VDEV_CMD); |
| 13087 | return 0; |
| 13088 | |
| 13089 | } |
| 13090 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13091 | 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] | 13092 | { |
| 13093 | if (!adapter) { |
| 13094 | hdd_err("Invalid adapter"); |
| 13095 | return -EINVAL; |
| 13096 | } |
| 13097 | |
| 13098 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13099 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13100 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13101 | set_value, VDEV_CMD); |
| 13102 | return 0; |
| 13103 | } |
| 13104 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13105 | 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] | 13106 | *psoc, uint8_t vdev_id) |
| 13107 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13108 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13109 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13110 | |
| 13111 | /* |
| 13112 | * Currently PSOC is not being used. But this logic will |
| 13113 | * change once we have the converged implementation of |
| 13114 | * HDD context per PSOC in place. This would break if |
| 13115 | * multiple vdev objects reuse the vdev id. |
| 13116 | */ |
| 13117 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13118 | if (!adapter) |
| 13119 | hdd_err("Get adapter by vdev id failed"); |
| 13120 | |
| 13121 | return adapter; |
| 13122 | } |
| 13123 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13124 | 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] | 13125 | int8_t *rssi, int8_t *snr) |
| 13126 | { |
| 13127 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 13128 | struct hdd_wext_state *wext_state = |
| 13129 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13130 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 13131 | |
| 13132 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 13133 | profile, bssid, rssi, snr); |
| 13134 | if (QDF_STATUS_SUCCESS != status) { |
| 13135 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13136 | return -EINVAL; |
| 13137 | } |
| 13138 | |
| 13139 | return 0; |
| 13140 | } |
| 13141 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13142 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13143 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13144 | * @adapter - HDD adapter |
| 13145 | * @tos - type of service |
| 13146 | * @status - status of the traffic |
| 13147 | * |
| 13148 | * Return: 0 on success and non zero value on failure |
| 13149 | */ |
| 13150 | |
| 13151 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13152 | bool is_tos_active) |
| 13153 | { |
| 13154 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13155 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13156 | uint32_t max_off_chan_time = 0; |
| 13157 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13158 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13159 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13160 | |
| 13161 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13162 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13163 | |
| 13164 | if (ret < 0) { |
| 13165 | hdd_err("failed to set limit off chan params"); |
| 13166 | return ret; |
| 13167 | } |
| 13168 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13169 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13170 | |
| 13171 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13172 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13173 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13174 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13175 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13176 | if (adapter->active_ac) { |
| 13177 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13178 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13179 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13180 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13181 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13182 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13183 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13184 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13185 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13186 | PM_LATENCY); |
| 13187 | } else { |
| 13188 | /*ignore this command if only BE/BK is active */ |
| 13189 | is_tos_active = false; |
| 13190 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13191 | hdd_ctx->config->conc_system_pref); |
| 13192 | } |
| 13193 | } else { |
| 13194 | /* No active tos */ |
| 13195 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13196 | hdd_ctx->config->conc_system_pref); |
| 13197 | } |
| 13198 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13199 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13200 | is_tos_active, max_off_chan_time, |
| 13201 | hdd_ctx->config->nRestTimeConc, true); |
| 13202 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13203 | hdd_err("failed to set limit off chan params"); |
| 13204 | ret = -EINVAL; |
| 13205 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13206 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13207 | return ret; |
| 13208 | } |
| 13209 | |
| 13210 | /** |
| 13211 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13212 | * @adapter - HDD adapter |
| 13213 | * |
| 13214 | * Return: 0 on success and non zero value on failure |
| 13215 | */ |
| 13216 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13217 | { |
| 13218 | struct hdd_context *hdd_ctx; |
| 13219 | int ret; |
| 13220 | QDF_STATUS status; |
| 13221 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13222 | |
| 13223 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13224 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13225 | if (ret < 0) |
| 13226 | return ret; |
| 13227 | |
| 13228 | /* set the system preferece to default */ |
| 13229 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13230 | hdd_ctx->config->conc_system_pref); |
| 13231 | |
| 13232 | /* clear the bitmap */ |
| 13233 | adapter->active_ac = 0; |
| 13234 | |
| 13235 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13236 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13237 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13238 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13239 | false, 0, 0, false); |
| 13240 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13241 | hdd_err("failed to reset limit off chan params"); |
| 13242 | ret = -EINVAL; |
| 13243 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13244 | |
| 13245 | return ret; |
| 13246 | } |
| 13247 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13248 | /** |
| 13249 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13250 | * @drv_op: Enum indicating driver op |
| 13251 | * |
| 13252 | * Return: none |
| 13253 | */ |
| 13254 | void hdd_start_driver_ops_timer(int drv_op) |
| 13255 | { |
| 13256 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13257 | switch (drv_op) { |
| 13258 | case eHDD_DRV_OP_PROBE: |
| 13259 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13260 | break; |
| 13261 | case eHDD_DRV_OP_REMOVE: |
| 13262 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13263 | break; |
| 13264 | case eHDD_DRV_OP_SHUTDOWN: |
| 13265 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13266 | break; |
| 13267 | case eHDD_DRV_OP_REINIT: |
| 13268 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13269 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13270 | case eHDD_DRV_OP_IFF_UP: |
| 13271 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13272 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13273 | } |
| 13274 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13275 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13276 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13277 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13278 | } |
| 13279 | |
| 13280 | /** |
| 13281 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13282 | * |
| 13283 | * Return: none |
| 13284 | */ |
| 13285 | void hdd_stop_driver_ops_timer(void) |
| 13286 | { |
| 13287 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13288 | } |
| 13289 | |
| 13290 | /** |
| 13291 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13292 | * inactivity timer |
| 13293 | * |
| 13294 | * Return: None |
| 13295 | */ |
| 13296 | void hdd_drv_ops_inactivity_handler(void) |
| 13297 | { |
| 13298 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13299 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13300 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13301 | if (hdd_drv_ops_task) { |
| 13302 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13303 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13304 | } else { |
| 13305 | hdd_err("hdd_drv_ops_task is null"); |
| 13306 | } |
| 13307 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13308 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13309 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13310 | sizeof("shutdown"))) |
| 13311 | QDF_BUG(0); |
| 13312 | |
| 13313 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13314 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13315 | else |
| 13316 | QDF_BUG(0); |
| 13317 | } |
| 13318 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13319 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13320 | { |
| 13321 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13322 | |
| 13323 | if (!hdd_ctx) |
| 13324 | return; |
| 13325 | |
| 13326 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13327 | } |
| 13328 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13329 | /** |
| 13330 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13331 | * @struct hdd_context *hdd_ctx |
| 13332 | * @struct hdd_adapter *padapter |
| 13333 | * @bool enble |
| 13334 | * |
| 13335 | * Return: none |
| 13336 | */ |
| 13337 | void hdd_set_rx_mode_rps(bool enable) |
| 13338 | { |
| 13339 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13340 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13341 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13342 | |
| 13343 | if (adapter && hdd_ctx && |
| 13344 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13345 | if (enable && !cds_cfg->rps_enabled) |
| 13346 | hdd_send_rps_ind(adapter); |
| 13347 | else if (!enable && cds_cfg->rps_enabled) |
| 13348 | hdd_send_rps_disable_ind(adapter); |
| 13349 | } |
| 13350 | } |
| 13351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13352 | /* Register the module init/exit functions */ |
| 13353 | module_init(hdd_module_init); |
| 13354 | module_exit(hdd_module_exit); |
| 13355 | |
| 13356 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13357 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13358 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13359 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13360 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13361 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13362 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13363 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13364 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13365 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13366 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13367 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13368 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13369 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13370 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13371 | |
| 13372 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13373 | |
| 13374 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13375 | |
| 13376 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |