Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | d9f0860 | 2016-12-02 11:31:30 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2017 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 | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 60 | #include "qdf_debug_domain.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 61 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 62 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 63 | #include <cdp_txrx_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 64 | |
| 65 | #include <net/addrconf.h> |
| 66 | #include <linux/wireless.h> |
| 67 | #include <net/cfg80211.h> |
| 68 | #include <linux/inetdevice.h> |
| 69 | #include <net/addrconf.h> |
| 70 | #include "wlan_hdd_cfg80211.h" |
| 71 | #include "wlan_hdd_ext_scan.h" |
| 72 | #include "wlan_hdd_p2p.h" |
| 73 | #include <linux/rtnetlink.h> |
| 74 | #include "sap_api.h" |
| 75 | #include <linux/semaphore.h> |
| 76 | #include <linux/ctype.h> |
| 77 | #include <linux/compat.h> |
| 78 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include <soc/qcom/subsystem_restart.h> |
| 80 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #include <wlan_hdd_hostapd.h> |
| 82 | #include <wlan_hdd_softap_tx_rx.h> |
| 83 | #include "cfg_api.h" |
| 84 | #include "qwlan_version.h" |
| 85 | #include "wma_types.h" |
| 86 | #include "wlan_hdd_tdls.h" |
| 87 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 88 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 90 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 91 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 92 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 93 | #include "wlan_hdd_nan.h" |
| 94 | #include "wlan_hdd_debugfs.h" |
| 95 | #include "wlan_hdd_driver_ops.h" |
| 96 | #include "epping_main.h" |
| 97 | #include "wlan_hdd_memdump.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 98 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | |
| 100 | #include <wlan_hdd_ipa.h> |
| 101 | #include "hif.h" |
| 102 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 103 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 104 | #include "wlan_hdd_tsf.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 105 | #include "wlan_hdd_green_ap.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 106 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 108 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 109 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 110 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 111 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 112 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 113 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 114 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 115 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 116 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 117 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 118 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 119 | #include "os_if_wifi_pos.h" |
| 120 | #include "wifi_pos_api.h" |
| 121 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 122 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 123 | #include "os_if_nan.h" |
| 124 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 125 | #include "wlan_reg_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 126 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 127 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 128 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 129 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 130 | #include "wlan_hdd_sysfs.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 131 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 132 | #ifdef CNSS_GENL |
| 133 | #include <net/cnss_nl.h> |
| 134 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 135 | #include "wlan_reg_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 136 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 137 | #ifdef MODULE |
| 138 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 139 | #else |
| 140 | #define WLAN_MODULE_NAME "wlan" |
| 141 | #endif |
| 142 | |
| 143 | #ifdef TIMER_MANAGER |
| 144 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 145 | #else |
| 146 | #define TIMER_MANAGER_STR "" |
| 147 | #endif |
| 148 | |
| 149 | #ifdef MEMORY_DEBUG |
| 150 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 151 | #else |
| 152 | #define MEMORY_DEBUG_STR "" |
| 153 | #endif |
| 154 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 155 | int wlan_start_ret_val; |
| 156 | static DECLARE_COMPLETION(wlan_start_comp); |
| 157 | static unsigned int dev_num = 1; |
| 158 | static struct cdev wlan_hdd_state_cdev; |
| 159 | static struct class *class; |
| 160 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 161 | #ifndef MODULE |
| 162 | static struct gwlan_loader *wlan_loader; |
| 163 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 164 | struct kobj_attribute *attr, |
| 165 | const char *buf, size_t count); |
| 166 | struct gwlan_loader { |
| 167 | bool loaded_state; |
| 168 | struct kobject *boot_wlan_obj; |
| 169 | struct attribute_group *attr_group; |
| 170 | }; |
| 171 | |
| 172 | static struct kobj_attribute wlan_boot_attribute = |
| 173 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 174 | |
| 175 | static struct attribute *attrs[] = { |
| 176 | &wlan_boot_attribute.attr, |
| 177 | NULL, |
| 178 | }; |
| 179 | |
| 180 | #define MODULE_INITIALIZED 1 |
| 181 | #endif |
| 182 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 183 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 184 | #define MAX_OPS_NAME_STRING_SIZE 20 |
| 185 | |
| 186 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 187 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 188 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 189 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 190 | /* the Android framework expects this param even though we don't use it */ |
| 191 | #define BUF_LEN 20 |
| 192 | static char fwpath_buffer[BUF_LEN]; |
| 193 | static struct kparam_string fwpath = { |
| 194 | .string = fwpath_buffer, |
| 195 | .maxlen = BUF_LEN, |
| 196 | }; |
| 197 | |
| 198 | static char *country_code; |
| 199 | static int enable_11d = -1; |
| 200 | static int enable_dfs_chan_scan = -1; |
| 201 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 202 | /* |
| 203 | * spinlock for synchronizing asynchronous request/response |
| 204 | * (full description of use in wlan_hdd_main.h) |
| 205 | */ |
| 206 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 207 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 208 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 209 | #define WLAN_NLINK_CESIUM 30 |
| 210 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 211 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 212 | |
| 213 | #define WOW_MAX_FILTER_LISTS 1 |
| 214 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 215 | #define WOW_MIN_PATTERN_SIZE 6 |
| 216 | #define WOW_MAX_PATTERN_SIZE 64 |
| 217 | |
| 218 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 219 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 220 | .flags = WIPHY_WOWLAN_ANY | |
| 221 | WIPHY_WOWLAN_MAGIC_PKT | |
| 222 | WIPHY_WOWLAN_DISCONNECT | |
| 223 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 224 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 225 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 226 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 227 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 228 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 229 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 230 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 231 | }; |
| 232 | #endif |
| 233 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 234 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 235 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 236 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 237 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 238 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 239 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 240 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 241 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 242 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 243 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 244 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 245 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 246 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 247 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 248 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 249 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 250 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 251 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 269 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 270 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 271 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 272 | }; |
| 273 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 274 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 275 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 276 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 277 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 278 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 279 | }; |
| 280 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 281 | /* internal function declaration */ |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 282 | struct notifier_block hdd_netdev_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 283 | |
| 284 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 285 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 286 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 287 | #endif |
| 288 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 289 | void hdd_start_complete(int ret) |
| 290 | { |
| 291 | wlan_start_ret_val = ret; |
| 292 | |
| 293 | complete(&wlan_start_comp); |
| 294 | } |
| 295 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 296 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 297 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 298 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 299 | * |
| 300 | * Return: none |
| 301 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 302 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 303 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 304 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 305 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 306 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 307 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 311 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 312 | * @vdev_id: vdev_id |
| 313 | * @action: action type |
| 314 | * @reason: reason type |
| 315 | * |
| 316 | * Return: none |
| 317 | */ |
| 318 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 319 | enum netif_action_type action, enum netif_reason_type reason) |
| 320 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 321 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 322 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 323 | |
| 324 | if (!hdd_ctx) { |
| 325 | hdd_err("hdd ctx is NULL"); |
| 326 | return; |
| 327 | } |
| 328 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 329 | |
| 330 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 334 | * Store WLAN driver version and timestamp info in global variables such that |
| 335 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 336 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 337 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 338 | #ifdef BUILD_TAG |
| 339 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 340 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 341 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 342 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 343 | |
| 344 | /** |
| 345 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 346 | * @device_mode: device mode |
| 347 | * |
| 348 | * This utility function helps log string conversion of device mode. |
| 349 | * |
| 350 | * Return: string conversion of device mode, if match found; |
| 351 | * "Unknown" otherwise. |
| 352 | */ |
| 353 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 354 | { |
| 355 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 356 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 357 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 358 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 359 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 360 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 361 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 362 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 363 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 364 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | default: |
| 366 | return "Unknown"; |
| 367 | } |
| 368 | } |
| 369 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 370 | /** |
| 371 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 372 | * @adapter: HDD adapter |
| 373 | * @chan_number: Channel number |
| 374 | * @chan_bw: Bandwidth |
| 375 | * |
| 376 | * Checks if the given bandwidth is valid for the given channel number. |
| 377 | * |
| 378 | * Return: 0 for success, non-zero for failure |
| 379 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 380 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 381 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 382 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 383 | { |
| 384 | uint8_t chan[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 385 | uint32_t len = WNI_CFG_VALID_CHANNEL_LIST_LEN, i; |
| 386 | bool found = false; |
| 387 | tHalHandle hal; |
| 388 | |
| 389 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 390 | if (!hal) { |
| 391 | hdd_err("Invalid HAL context"); |
| 392 | return -EINVAL; |
| 393 | } |
| 394 | |
| 395 | if (0 != sme_cfg_get_str(hal, WNI_CFG_VALID_CHANNEL_LIST, chan, &len)) { |
| 396 | hdd_err("No valid channel list"); |
| 397 | return -EOPNOTSUPP; |
| 398 | } |
| 399 | |
| 400 | for (i = 0; i < len; i++) { |
| 401 | if (chan[i] == chan_number) { |
| 402 | found = true; |
| 403 | break; |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | if (found == false) { |
| 408 | hdd_err("Channel not in driver's valid channel list"); |
| 409 | return -EOPNOTSUPP; |
| 410 | } |
| 411 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 412 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 413 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 414 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 415 | return -EINVAL; |
| 416 | } |
| 417 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 418 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 419 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 420 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 421 | return -EINVAL; |
| 422 | } |
| 423 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 424 | (chan_bw != CH_WIDTH_MAX)) { |
| 425 | hdd_err("Only BW20 possible on channel 14"); |
| 426 | return -EINVAL; |
| 427 | } |
| 428 | } |
| 429 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 430 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 431 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 432 | (chan_bw != CH_WIDTH_MAX)) { |
| 433 | hdd_err("Only BW20 possible on channel 165"); |
| 434 | return -EINVAL; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 441 | /** |
| 442 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 443 | * |
| 444 | * Block the unloading of the driver (or) interface up until the |
| 445 | * cds recovery is completed |
| 446 | * |
| 447 | * Return: true for recovery completion else false |
| 448 | */ |
| 449 | static bool hdd_wait_for_recovery_completion(void) |
| 450 | { |
| 451 | int retry = 0; |
| 452 | |
| 453 | /* Wait for recovery to complete */ |
| 454 | while (cds_is_driver_recovering()) { |
| 455 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 456 | hdd_err("Recovery in progress; wait here!!!"); |
| 457 | msleep(1000); |
| 458 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 459 | hdd_err("SSR never completed, error"); |
| 460 | /* |
| 461 | * Trigger the bug_on in the internal builds, in the |
| 462 | * customer builds self-recovery will be enabled |
| 463 | * in those cases just return error. |
| 464 | */ |
| 465 | if (cds_is_self_recovery_enabled()) |
| 466 | return false; |
| 467 | QDF_BUG(0); |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | hdd_info("Recovery completed successfully!"); |
| 472 | return true; |
| 473 | } |
| 474 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 475 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 476 | unsigned long state, void *data) |
| 477 | { |
| 478 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 479 | struct netdev_notifier_info *dev_notif_info = data; |
| 480 | struct net_device *dev = dev_notif_info->dev; |
| 481 | #else |
| 482 | struct net_device *dev = data; |
| 483 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 484 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 485 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 486 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 487 | ENTER_DEV(dev); |
| 488 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 489 | /* Make sure that this callback corresponds to our device. */ |
| 490 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 491 | return NOTIFY_DONE; |
| 492 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 493 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 495 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 496 | return NOTIFY_DONE; |
| 497 | } |
| 498 | |
| 499 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 500 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 501 | return NOTIFY_DONE; |
| 502 | } |
| 503 | |
| 504 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 505 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 506 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 507 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 508 | return NOTIFY_DONE; |
| 509 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 510 | |
| 511 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 512 | hdd_err("%s: Driver module is closed", __func__); |
| 513 | return NOTIFY_DONE; |
| 514 | } |
| 515 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 516 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 517 | return NOTIFY_DONE; |
| 518 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 519 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 520 | dev->name, state); |
| 521 | |
| 522 | switch (state) { |
| 523 | case NETDEV_REGISTER: |
| 524 | break; |
| 525 | |
| 526 | case NETDEV_UNREGISTER: |
| 527 | break; |
| 528 | |
| 529 | case NETDEV_UP: |
| 530 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 531 | break; |
| 532 | |
| 533 | case NETDEV_DOWN: |
| 534 | break; |
| 535 | |
| 536 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 537 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 538 | complete(&adapter->linkup_event_var); |
| 539 | break; |
| 540 | |
| 541 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 542 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 543 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 544 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 545 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 547 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 548 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 549 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 550 | /* |
| 551 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 552 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 553 | * flag after which driver does not send the cfg80211_scan_done. |
| 554 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 555 | */ |
| 556 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 557 | break; |
| 558 | |
| 559 | default: |
| 560 | break; |
| 561 | } |
| 562 | |
| 563 | return NOTIFY_DONE; |
| 564 | } |
| 565 | |
| 566 | /** |
| 567 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 568 | * @nb: pointer to notifier block |
| 569 | * @state: state |
| 570 | * @ndev: ndev pointer |
| 571 | * |
| 572 | * Return: 0 on success, error number otherwise. |
| 573 | */ |
| 574 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 575 | unsigned long state, |
| 576 | void *ndev) |
| 577 | { |
| 578 | int ret; |
| 579 | |
| 580 | cds_ssr_protect(__func__); |
| 581 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 582 | cds_ssr_unprotect(__func__); |
| 583 | |
| 584 | return ret; |
| 585 | } |
| 586 | |
| 587 | struct notifier_block hdd_netdev_notifier = { |
| 588 | .notifier_call = hdd_netdev_notifier_call, |
| 589 | }; |
| 590 | |
| 591 | /* variable to hold the insmod parameters */ |
| 592 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 593 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 594 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 595 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 596 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 597 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 600 | /** |
| 601 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 602 | * @ch_width: NL channel width |
| 603 | * |
| 604 | * Converts the NL channel width to the driver's internal representation |
| 605 | * |
| 606 | * Return: Converted channel width. In case of non matching NL channel width, |
| 607 | * CH_WIDTH_MAX will be returned. |
| 608 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 609 | 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] | 610 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 611 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 612 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 613 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 614 | switch (ch_width) { |
| 615 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 616 | case NL80211_CHAN_WIDTH_20: |
| 617 | return CH_WIDTH_20MHZ; |
| 618 | case NL80211_CHAN_WIDTH_40: |
| 619 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 620 | case NL80211_CHAN_WIDTH_80: |
| 621 | return CH_WIDTH_80MHZ; |
| 622 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 623 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 624 | return CH_WIDTH_80P80MHZ; |
| 625 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 626 | return CH_WIDTH_160MHZ; |
| 627 | else |
| 628 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 629 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 630 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 631 | return CH_WIDTH_160MHZ; |
| 632 | else |
| 633 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 634 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 635 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 636 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 637 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 638 | default: |
| 639 | hdd_err("Invalid channel width %d, setting to default", |
| 640 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 641 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 645 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 646 | * @hal: handler to HAL |
| 647 | * @channel: channel id |
| 648 | * @bw_offset: bandwidth offset |
| 649 | * |
| 650 | * Function invokes sme api to find the operating class |
| 651 | * |
| 652 | * Return: operating class |
| 653 | */ |
| 654 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 655 | uint8_t bw_offset) |
| 656 | { |
| 657 | uint8_t opclass = 0; |
| 658 | |
| 659 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 660 | return opclass; |
| 661 | } |
| 662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 664 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 665 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 666 | * @bitmask: Bitmask of log levels to be enabled |
| 667 | * |
| 668 | * Called immediately after the cfg.ini is read in order to configure |
| 669 | * the desired trace levels. |
| 670 | * |
| 671 | * Return: None |
| 672 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 673 | 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] | 674 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 675 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 676 | int qdf_print_idx = -1; |
| 677 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 678 | /* |
| 679 | * if the bitmask is the default value, then a bitmask was not |
| 680 | * specified in cfg.ini, so leave the logging level alone (it |
| 681 | * will remain at the "compiled in" default value) |
| 682 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 683 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 684 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 685 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 686 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 687 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 688 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 689 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 690 | QDF_TRACE_LEVEL_NONE, 0); |
| 691 | |
| 692 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 693 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 695 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 696 | while (0 != bitmask) { |
| 697 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 698 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 699 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 700 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 701 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 702 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 703 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 704 | level++; |
| 705 | bitmask >>= 1; |
| 706 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 707 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 711 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 712 | * @hdd_ctx: HDD context pointer |
| 713 | * |
| 714 | * Return: 0 if the context is valid. Error code otherwise |
| 715 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 716 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 717 | { |
| 718 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 719 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 720 | return -ENODEV; |
| 721 | } |
| 722 | |
| 723 | if (cds_is_driver_recovering()) { |
| 724 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 725 | (void *)_RET_IP_, cds_get_driver_state()); |
| 726 | return -EAGAIN; |
| 727 | } |
| 728 | |
| 729 | if (hdd_ctx->start_modules_in_progress || |
| 730 | hdd_ctx->stop_modules_in_progress) { |
| 731 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 732 | (void *)_RET_IP_); |
| 733 | return -EAGAIN; |
| 734 | } |
| 735 | |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | |
| 740 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 741 | * wlan_hdd_validate_context() - check the HDD context |
| 742 | * @hdd_ctx: HDD context pointer |
| 743 | * |
| 744 | * Return: 0 if the context is valid. Error code otherwise |
| 745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 746 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 748 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 749 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 750 | return -ENODEV; |
| 751 | } |
| 752 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 753 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 754 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 755 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 756 | return -EAGAIN; |
| 757 | } |
| 758 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 759 | if (cds_is_load_or_unload_in_progress()) { |
| 760 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 761 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 763 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 764 | |
| 765 | if (hdd_ctx->start_modules_in_progress || |
| 766 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 767 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 768 | (void *)_RET_IP_); |
| 769 | return -EAGAIN; |
| 770 | } |
| 771 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 772 | if (cds_is_driver_in_bad_state()) { |
| 773 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 774 | (void *)_RET_IP_, cds_get_driver_state()); |
| 775 | return -ENODEV; |
| 776 | } |
| 777 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 778 | return 0; |
| 779 | } |
| 780 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 781 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 782 | { |
| 783 | if (!adapter) { |
| 784 | hdd_err("adapter is null"); |
| 785 | return -EINVAL; |
| 786 | } |
| 787 | |
| 788 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 789 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 790 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 791 | return -EINVAL; |
| 792 | } |
| 793 | |
| 794 | if (!adapter->dev) { |
| 795 | hdd_err("adapter net_device is null"); |
| 796 | return -EINVAL; |
| 797 | } |
| 798 | |
| 799 | if (!(adapter->dev->flags & IFF_UP)) { |
| 800 | hdd_info("adapter net_device is not up"); |
| 801 | return -EAGAIN; |
| 802 | } |
| 803 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 804 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 805 | hdd_info("adapter session is not open"); |
| 806 | return -EAGAIN; |
| 807 | } |
| 808 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 809 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 810 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 811 | return -EINVAL; |
| 812 | } |
| 813 | |
| 814 | return 0; |
| 815 | } |
| 816 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 817 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 818 | * wlan_hdd_validate_modules_state() - Check modules status |
| 819 | * @hdd_ctx: HDD context pointer |
| 820 | * |
| 821 | * Check's the driver module's state and returns true if the |
| 822 | * modules are enabled returns false if modules are closed. |
| 823 | * |
| 824 | * Return: True if modules are enabled or false. |
| 825 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 826 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 827 | { |
| 828 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 829 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 830 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 831 | hdd_notice("Modules not enabled, Present status: %d", |
| 832 | hdd_ctx->driver_status); |
| 833 | return false; |
| 834 | } |
| 835 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 836 | return true; |
| 837 | } |
| 838 | |
| 839 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 840 | * 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] | 841 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 842 | * |
| 843 | * This function sets the IBSS power save config parameters to WMA |
| 844 | * which will send it to firmware if FW supports IBSS power save |
| 845 | * before vdev start. |
| 846 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 847 | * 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] | 848 | * on failure. |
| 849 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 850 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | { |
| 852 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 853 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 854 | |
| 855 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 856 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 857 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | } |
| 859 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 860 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 861 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 862 | hdd_ctx->config->ibssATIMWinSize, |
| 863 | VDEV_CMD); |
| 864 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 865 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 866 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 867 | } |
| 868 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 869 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 871 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 872 | VDEV_CMD); |
| 873 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 874 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 875 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 876 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | } |
| 878 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 879 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 880 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 881 | hdd_ctx->config-> |
| 882 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 883 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 884 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 885 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 886 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 887 | } |
| 888 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 889 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 890 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 891 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 892 | VDEV_CMD); |
| 893 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 894 | 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] | 895 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 896 | } |
| 897 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 898 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 899 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 900 | hdd_ctx->config->ibssInactivityCount, |
| 901 | VDEV_CMD); |
| 902 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 903 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 904 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 905 | } |
| 906 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 907 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 908 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 909 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 910 | VDEV_CMD); |
| 911 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 912 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 913 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 914 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 915 | } |
| 916 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 917 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 918 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 919 | hdd_ctx->config->ibssPsWarmupTime, |
| 920 | VDEV_CMD); |
| 921 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 922 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 923 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 924 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 925 | } |
| 926 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 927 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 928 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 929 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 930 | VDEV_CMD); |
| 931 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 932 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 933 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 934 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 935 | } |
| 936 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 937 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 938 | } |
| 939 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 940 | #ifdef FEATURE_RUNTIME_PM |
| 941 | /** |
| 942 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 943 | * @hdd_ctx: HDD context |
| 944 | * |
| 945 | * Return: None |
| 946 | */ |
| 947 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 948 | { |
| 949 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 950 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 951 | qdf_runtime_lock_init(&ctx->dfs); |
| 952 | |
| 953 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 954 | } |
| 955 | |
| 956 | /** |
| 957 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 958 | * @hdd_ctx: HDD Context |
| 959 | * |
| 960 | * Return: None |
| 961 | */ |
| 962 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 963 | { |
| 964 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 965 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 966 | qdf_runtime_lock_deinit(&ctx->dfs); |
| 967 | |
| 968 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 969 | } |
| 970 | |
| 971 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) |
| 972 | { |
| 973 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 974 | |
| 975 | qdf_runtime_lock_init(&ctx->connect); |
| 976 | } |
| 977 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 978 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 979 | { |
| 980 | struct hdd_connect_pm_context *ctx = &adapter->connect_rpm_ctx; |
| 981 | |
| 982 | qdf_runtime_lock_deinit(&ctx->connect); |
| 983 | } |
| 984 | #else /* FEATURE_RUNTIME_PM */ |
| 985 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 986 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
| 987 | static void hdd_adapter_runtime_suspend_init(struct hdd_adapter *adapter) {} |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 988 | static void hdd_adapter_runtime_suspend_deinit(struct hdd_adapter *adapter) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 989 | #endif /* FEATURE_RUNTIME_PM */ |
| 990 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 991 | #define INTF_MACADDR_MASK 0x7 |
| 992 | |
| 993 | /** |
| 994 | * hdd_update_macaddr() - update mac address |
| 995 | * @config: hdd configuration |
| 996 | * @hw_macaddr: mac address |
| 997 | * |
| 998 | * Mac address for multiple virtual interface is found as following |
| 999 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1000 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1001 | * define the mac address for the remaining interfaces and locally |
| 1002 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1003 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1004 | * interface). |
| 1005 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1006 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1007 | * |
| 1008 | * Return: None |
| 1009 | */ |
| 1010 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1011 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | { |
| 1013 | int8_t i; |
| 1014 | uint8_t macaddr_b3, tmp_br3; |
| 1015 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1016 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1017 | QDF_MAC_ADDR_SIZE); |
| 1018 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1019 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1020 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1022 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1023 | INTF_MACADDR_MASK; |
| 1024 | macaddr_b3 += tmp_br3; |
| 1025 | |
| 1026 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1027 | * mac address range before collision |
| 1028 | */ |
| 1029 | macaddr_b3 ^= (1 << 7); |
| 1030 | |
| 1031 | /* Set locally administered bit */ |
| 1032 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1033 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1034 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | MAC_ADDRESS_STR, i, |
| 1036 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1037 | } |
| 1038 | } |
| 1039 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1040 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1041 | { |
| 1042 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1043 | struct tdls_start_params tdls_cfg; |
| 1044 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1045 | struct hdd_config *cfg = hdd_ctx->config; |
| 1046 | QDF_STATUS status; |
| 1047 | |
| 1048 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1049 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1050 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1051 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1052 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1053 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1054 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1055 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1056 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1057 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1058 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1059 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1060 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1061 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1062 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1063 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1064 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1065 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1066 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1067 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1068 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1069 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1070 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1071 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1072 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1073 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1074 | (cfg->fTDLSExternalControl ? |
| 1075 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1076 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1077 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1078 | |
| 1079 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1080 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1081 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1082 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1083 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1084 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1085 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1086 | tdls_cfg.tdls_evt_cb_data = psoc; |
| 1087 | tdls_cfg.tdls_tl_peer_data = hdd_ctx; |
| 1088 | tdls_cfg.tdls_reg_tl_peer = hdd_tdls_register_tdls_peer; |
| 1089 | tdls_cfg.tdls_dereg_tl_peer = hdd_tdls_deregister_tdl_peer; |
| 1090 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1091 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1092 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1093 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1094 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1095 | |
| 1096 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1097 | if (status != QDF_STATUS_SUCCESS) { |
| 1098 | hdd_err("failed pmo psoc configuration"); |
| 1099 | return -EINVAL; |
| 1100 | } |
| 1101 | |
| 1102 | hdd_ctx->tdls_umac_comp_active = true; |
| 1103 | /* enable napier specific tdls data path */ |
| 1104 | hdd_ctx->tdls_nap_active = true; |
| 1105 | |
| 1106 | return 0; |
| 1107 | } |
| 1108 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1109 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1110 | struct wma_tgt_services *cfg) |
| 1111 | { |
| 1112 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1113 | |
| 1114 | /* Set up UAPSD */ |
| 1115 | config->apUapsdEnabled &= cfg->uapsd; |
| 1116 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1117 | /* 11AX mode support */ |
| 1118 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1119 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1120 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1122 | /* 11AC mode support */ |
| 1123 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1124 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1125 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1126 | |
| 1127 | /* ARP offload: override user setting if invalid */ |
| 1128 | config->fhostArpOffload &= cfg->arp_offload; |
| 1129 | |
| 1130 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1131 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1132 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1133 | if (cfg->pno_offload) |
| 1134 | config->PnoOffload = true; |
| 1135 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1136 | #ifdef FEATURE_WLAN_TDLS |
| 1137 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1138 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1139 | cfg->en_tdls_offchan; |
| 1140 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1141 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1142 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1143 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1144 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1145 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1146 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1147 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1148 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1149 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1150 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1151 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1152 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1153 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1154 | |
| 1155 | } |
| 1156 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1157 | /** |
| 1158 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1159 | * @hdd_ctx: HDD context |
| 1160 | * |
| 1161 | * Sets the Nss per vdev type based on INI |
| 1162 | * |
| 1163 | * Return: None |
| 1164 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1165 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1166 | { |
| 1167 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1168 | uint8_t max_supp_nss = 1; |
| 1169 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1170 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1171 | max_supp_nss = 2; |
| 1172 | |
| 1173 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1174 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1175 | |
| 1176 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1177 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1178 | } |
| 1179 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1180 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1181 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1182 | * @hdd_ctx: HDD context |
| 1183 | * |
| 1184 | * Updates wiphy vhtcap fields |
| 1185 | * |
| 1186 | * Return: None |
| 1187 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1188 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1189 | { |
| 1190 | struct ieee80211_supported_band *band_5g = |
| 1191 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1192 | uint32_t val; |
| 1193 | |
| 1194 | if (!band_5g) { |
| 1195 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1196 | return; |
| 1197 | } |
| 1198 | |
| 1199 | val = hdd_ctx->config->txBFCsnValue; |
| 1200 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1201 | |
| 1202 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1203 | band_5g->vht_cap.cap |= |
| 1204 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1205 | |
| 1206 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1207 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1208 | } |
| 1209 | |
| 1210 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1211 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1212 | * @hdd_ctx: HDD context |
| 1213 | * |
| 1214 | * Sets the DBS capability as per INI and firmware capability |
| 1215 | * |
| 1216 | * Return: None |
| 1217 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1218 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1219 | { |
| 1220 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1221 | uint8_t hw_dbs_capable = 0; |
| 1222 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1223 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1224 | ((cfg_ini->dual_mac_feature_disable == |
| 1225 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1226 | (cfg_ini->dual_mac_feature_disable == |
| 1227 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1228 | hw_dbs_capable = 1; |
| 1229 | |
| 1230 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1231 | } |
| 1232 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1233 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1234 | struct wma_tgt_ht_cap *cfg) |
| 1235 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1236 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | uint32_t value, val32; |
| 1238 | uint16_t val16; |
| 1239 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1240 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1241 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1242 | uint8_t enable_tx_stbc; |
| 1243 | |
| 1244 | /* check and update RX STBC */ |
| 1245 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1246 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1247 | |
| 1248 | /* get the MPDU density */ |
| 1249 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1250 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1251 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1252 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1253 | value = 0; |
| 1254 | } |
| 1255 | |
| 1256 | /* |
| 1257 | * MPDU density: |
| 1258 | * override user's setting if value is larger |
| 1259 | * than the one supported by target |
| 1260 | */ |
| 1261 | if (value > cfg->mpdu_density) { |
| 1262 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1263 | cfg->mpdu_density); |
| 1264 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1265 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1266 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1267 | } |
| 1268 | |
| 1269 | /* get the HT capability info */ |
| 1270 | 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] | 1271 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1272 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1273 | return; |
| 1274 | } |
| 1275 | val16 = (uint16_t) val32; |
| 1276 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1277 | |
| 1278 | /* Set the LDPC capability */ |
| 1279 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1280 | |
| 1281 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1282 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1283 | |
| 1284 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1285 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1286 | |
| 1287 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1288 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1289 | |
| 1290 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1291 | |
| 1292 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1293 | pconfig->enable2x2 = 1; |
| 1294 | } else { |
| 1295 | pconfig->enable2x2 = 0; |
| 1296 | enable_tx_stbc = 0; |
| 1297 | |
| 1298 | /* 1x1 */ |
| 1299 | /* Update Rx Highest Long GI data Rate */ |
| 1300 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1301 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1302 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1303 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1304 | 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] | 1305 | } |
| 1306 | |
| 1307 | /* Update Tx Highest Long GI data Rate */ |
| 1308 | if (sme_cfg_set_int |
| 1309 | (hdd_ctx->hHal, |
| 1310 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1311 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1312 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1313 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1314 | } |
| 1315 | } |
| 1316 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1317 | enable_tx_stbc = 0; |
| 1318 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1319 | |
| 1320 | val32 = val16; |
| 1321 | 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] | 1322 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1323 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1324 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1325 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1326 | 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] | 1327 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1328 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1329 | |
| 1330 | if (pconfig->enable2x2) { |
| 1331 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1332 | mcs_set[value] = |
| 1333 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1334 | |
| 1335 | status = |
| 1336 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1337 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1338 | mcs_set, |
| 1339 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1340 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1341 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1342 | } |
| 1343 | } |
| 1344 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1345 | } |
| 1346 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1347 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1348 | struct wma_tgt_vht_cap *cfg) |
| 1349 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1350 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | uint32_t value = 0; |
| 1352 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1353 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1354 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1355 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1356 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1357 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1358 | uint32_t hw_rx_ldpc_enabled; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1359 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1360 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1361 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1362 | return; |
| 1363 | } |
| 1364 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1365 | /* Get the current MPDU length */ |
| 1366 | status = |
| 1367 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1368 | &value); |
| 1369 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1370 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1371 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1372 | value = 0; |
| 1373 | } |
| 1374 | |
| 1375 | /* |
| 1376 | * VHT max MPDU length: |
| 1377 | * override if user configured value is too high |
| 1378 | * that the target cannot support |
| 1379 | */ |
| 1380 | if (value > cfg->vht_max_mpdu) { |
| 1381 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1382 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1383 | cfg->vht_max_mpdu); |
| 1384 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1385 | if (status == QDF_STATUS_E_FAILURE) |
| 1386 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1387 | } |
| 1388 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1389 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1390 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1391 | |
| 1392 | if (pconfig->enable2x2) |
| 1393 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1394 | |
| 1395 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1396 | QDF_STATUS_E_FAILURE) { |
| 1397 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1398 | } |
| 1399 | |
| 1400 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1401 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1402 | if (pconfig->enable2x2) |
| 1403 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1404 | |
| 1405 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1406 | QDF_STATUS_E_FAILURE) { |
| 1407 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1408 | } |
| 1409 | |
| 1410 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1411 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1412 | if (pconfig->enable2x2) |
| 1413 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1414 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1415 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1416 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1417 | |
| 1418 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1419 | QDF_STATUS_E_FAILURE) { |
| 1420 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1421 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1423 | 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] | 1424 | &value); |
| 1425 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1426 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1427 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | value = 0; |
| 1429 | } |
| 1430 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1431 | /* Set HW RX LDPC capability */ |
| 1432 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1433 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1434 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1435 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1436 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1438 | if (status == QDF_STATUS_E_FAILURE) |
| 1439 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | } |
| 1441 | |
| 1442 | /* Get current GI 80 value */ |
| 1443 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1444 | &value); |
| 1445 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1446 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1447 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | value = 0; |
| 1449 | } |
| 1450 | |
| 1451 | /* set the Guard interval 80MHz */ |
| 1452 | if (value && !cfg->vht_short_gi_80) { |
| 1453 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1454 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1455 | cfg->vht_short_gi_80); |
| 1456 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1457 | if (status == QDF_STATUS_E_FAILURE) |
| 1458 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1459 | } |
| 1460 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | /* Get VHT TX STBC cap */ |
| 1462 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1463 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1464 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1465 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | value = 0; |
| 1467 | } |
| 1468 | |
| 1469 | /* VHT TX STBC cap */ |
| 1470 | if (value && !cfg->vht_tx_stbc) { |
| 1471 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1472 | cfg->vht_tx_stbc); |
| 1473 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1474 | if (status == QDF_STATUS_E_FAILURE) |
| 1475 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | } |
| 1477 | |
| 1478 | /* Get VHT RX STBC cap */ |
| 1479 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1480 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1481 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1482 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1483 | value = 0; |
| 1484 | } |
| 1485 | |
| 1486 | /* VHT RX STBC cap */ |
| 1487 | if (value && !cfg->vht_rx_stbc) { |
| 1488 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1489 | cfg->vht_rx_stbc); |
| 1490 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1491 | if (status == QDF_STATUS_E_FAILURE) |
| 1492 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | } |
| 1494 | |
| 1495 | /* Get VHT SU Beamformer cap */ |
| 1496 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1497 | &value); |
| 1498 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1499 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1500 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1501 | value = 0; |
| 1502 | } |
| 1503 | |
| 1504 | /* set VHT SU Beamformer cap */ |
| 1505 | if (value && !cfg->vht_su_bformer) { |
| 1506 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1507 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1508 | cfg->vht_su_bformer); |
| 1509 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1510 | if (status == QDF_STATUS_E_FAILURE) |
| 1511 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1512 | } |
| 1513 | |
| 1514 | /* check and update SU BEAMFORMEE capabality */ |
| 1515 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1516 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1517 | |
| 1518 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1519 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1520 | pconfig->enableTxBF); |
| 1521 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1522 | if (status == QDF_STATUS_E_FAILURE) |
| 1523 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1524 | |
| 1525 | /* Get VHT MU Beamformer cap */ |
| 1526 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1527 | &value); |
| 1528 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1529 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1530 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1531 | value = 0; |
| 1532 | } |
| 1533 | |
| 1534 | /* set VHT MU Beamformer cap */ |
| 1535 | if (value && !cfg->vht_mu_bformer) { |
| 1536 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1537 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1538 | cfg->vht_mu_bformer); |
| 1539 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1540 | if (status == QDF_STATUS_E_FAILURE) |
| 1541 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | /* Get VHT MU Beamformee cap */ |
| 1545 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1546 | &value); |
| 1547 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1548 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1549 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | value = 0; |
| 1551 | } |
| 1552 | |
| 1553 | /* set VHT MU Beamformee cap */ |
| 1554 | if (value && !cfg->vht_mu_bformee) { |
| 1555 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1556 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1557 | cfg->vht_mu_bformee); |
| 1558 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1559 | if (status == QDF_STATUS_E_FAILURE) |
| 1560 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1561 | } |
| 1562 | |
| 1563 | /* Get VHT MAX AMPDU Len exp */ |
| 1564 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1565 | &value); |
| 1566 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1567 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1568 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | value = 0; |
| 1570 | } |
| 1571 | |
| 1572 | /* |
| 1573 | * VHT max AMPDU len exp: |
| 1574 | * override if user configured value is too high |
| 1575 | * that the target cannot support. |
| 1576 | * Even though Rome publish ampdu_len=7, it can |
| 1577 | * only support 4 because of some h/w bug. |
| 1578 | */ |
| 1579 | |
| 1580 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1581 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1582 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1583 | cfg->vht_max_ampdu_len_exp); |
| 1584 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1585 | if (status == QDF_STATUS_E_FAILURE) |
| 1586 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1587 | } |
| 1588 | |
| 1589 | /* Get VHT TXOP PS CAP */ |
| 1590 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1591 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1592 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1593 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | value = 0; |
| 1595 | } |
| 1596 | |
| 1597 | /* set VHT TXOP PS cap */ |
| 1598 | if (value && !cfg->vht_txop_ps) { |
| 1599 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1600 | cfg->vht_txop_ps); |
| 1601 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1602 | if (status == QDF_STATUS_E_FAILURE) |
| 1603 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1607 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1608 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1609 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1610 | else |
| 1611 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1612 | |
| 1613 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1614 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1615 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1616 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1617 | VHT_CAP_160_AND_80P80_SUPP); |
| 1618 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1619 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1620 | band_5g->vht_cap.cap |= |
| 1621 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1622 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1623 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1624 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1625 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1626 | VHT_CAP_160_SUPP); |
| 1627 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1628 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | band_5g->vht_cap.cap |= |
| 1630 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1631 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1632 | } |
| 1633 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1634 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1635 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1636 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1637 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1638 | &value); |
| 1639 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1640 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1641 | value = 0; |
| 1642 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1643 | /* set the Guard interval 160MHz */ |
| 1644 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1645 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1646 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1647 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1648 | |
| 1649 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1650 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1651 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | |
| 1653 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) |
| 1654 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1655 | |
| 1656 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1657 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1658 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1659 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1660 | |
| 1661 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1662 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1663 | |
| 1664 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1665 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1666 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1667 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1668 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1669 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1670 | |
| 1671 | band_5g->vht_cap.cap |= |
| 1672 | (cfg->vht_max_ampdu_len_exp << |
| 1673 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1674 | |
| 1675 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1676 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1677 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1678 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1679 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1680 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1681 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1682 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1683 | |
| 1684 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1685 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1686 | |
| 1687 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1689 | /** |
| 1690 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1691 | * @hdd_ctx: Pointer to the HDD context |
| 1692 | * |
| 1693 | * Auto-generate mac address using device serial number. |
| 1694 | * Keep the first 3 bytes of OUI as before and replace |
| 1695 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1696 | * |
| 1697 | * Return: 0 for success |
| 1698 | * Non zero failure code for errors |
| 1699 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1700 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1701 | { |
| 1702 | unsigned int serialno = 0; |
| 1703 | struct qdf_mac_addr mac_addr = { |
| 1704 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1705 | }; |
| 1706 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1707 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1708 | if (serialno == 0) |
| 1709 | return -EINVAL; |
| 1710 | |
| 1711 | serialno &= 0x00ffffff; |
| 1712 | |
| 1713 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1714 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1715 | mac_addr.bytes[5] = serialno & 0xff; |
| 1716 | |
| 1717 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1718 | return 0; |
| 1719 | } |
| 1720 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1721 | /** |
| 1722 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1723 | * configuration to cfg_ini in HDD |
| 1724 | * @hdd_ctx: Pointer to hdd_ctx |
| 1725 | * @cfg: target configuration |
| 1726 | * |
| 1727 | * Return: None |
| 1728 | */ |
| 1729 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1730 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1731 | struct wma_tgt_cfg *cfg) |
| 1732 | { |
| 1733 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1734 | } |
| 1735 | #else |
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 | } |
| 1740 | #endif |
| 1741 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1742 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1743 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1744 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1745 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1746 | struct wma_tgt_cfg *cfg = param; |
| 1747 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1748 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1749 | uint8_t antenna_mode; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1750 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1751 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1752 | if (ret) { |
| 1753 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1754 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1755 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1756 | hdd_debug("New pdev has been created with pdev_id = %u", |
| 1757 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1758 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1759 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1760 | if (cds_cfg) { |
| 1761 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1762 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1763 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1764 | cds_cfg->sub_20_channel_width = |
| 1765 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1766 | } else { |
| 1767 | cds_cfg->sub_20_channel_width = |
| 1768 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1769 | } |
| 1770 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1771 | |
| 1772 | /* first store the INI band capability */ |
| 1773 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1774 | |
| 1775 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1776 | hdd_ctx->is_fils_roaming_supported = |
| 1777 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1778 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1779 | /* |
| 1780 | * now overwrite the target band capability with INI |
| 1781 | * setting if INI setting is a subset |
| 1782 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1783 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1784 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1785 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1786 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1787 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1788 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1789 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1790 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1791 | } |
| 1792 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1793 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1794 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1795 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1796 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1797 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1798 | } |
| 1799 | |
| 1800 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1801 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1802 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1803 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1804 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1805 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1806 | static struct qdf_mac_addr default_mac_addr = { |
| 1807 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1808 | }; |
| 1809 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1810 | &default_mac_addr)) { |
| 1811 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1812 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1813 | MAC_ADDRESS_STR, |
| 1814 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1815 | intfMacAddr[0].bytes)); |
| 1816 | } else { |
| 1817 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1818 | MAC_ADDRESS_STR, |
| 1819 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1820 | intfMacAddr[0].bytes)); |
| 1821 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1822 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1823 | } |
| 1824 | |
| 1825 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1826 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1827 | |
| 1828 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1829 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1830 | hdd_lpass_target_config(hdd_ctx, cfg); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 1831 | hdd_green_ap_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1832 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1833 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1834 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1835 | |
| 1836 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1837 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1838 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1839 | if (cfg->services.en_11ax) { |
| 1840 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1841 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1842 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1843 | |
| 1844 | hdd_update_vdev_nss(hdd_ctx); |
| 1845 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1846 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1847 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1848 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1849 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1850 | hdd_debug("fine_time_meas_cap: 0x%x", |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1851 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1852 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1853 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1854 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1855 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1856 | hdd_debug("Init current antenna mode: %d", |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1857 | hdd_ctx->current_antenna_mode); |
| 1858 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1859 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1860 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1861 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1862 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1863 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1864 | if ((hdd_ctx->config->txBFCsnValue > |
| 1865 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1866 | !cfg->tx_bfee_8ss_enabled) |
| 1867 | hdd_ctx->config->txBFCsnValue = |
| 1868 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 1869 | |
| 1870 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1871 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 1872 | hdd_ctx->config->txBFCsnValue) == QDF_STATUS_E_FAILURE) |
| 1873 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 1874 | |
| 1875 | |
| 1876 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
| 1877 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 1878 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1879 | |
| 1880 | /* |
| 1881 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 1882 | */ |
| 1883 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 1884 | |
| 1885 | hdd_ctx->fw_mem_dump_enabled = cfg->fw_mem_dump_enabled; |
| 1886 | |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1887 | /* |
| 1888 | * If BPF is enabled, maxWowFilters set to WMA_STA_WOW_DEFAULT_PTRN_MAX |
| 1889 | * because we need atleast WMA_STA_WOW_DEFAULT_PTRN_MAX free slots to |
| 1890 | * configure the STA mode wow pattern. |
| 1891 | */ |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1892 | if (hdd_ctx->bpf_enabled) |
Arun Khandavalli | d454d42 | 2016-08-17 12:47:05 +0530 | [diff] [blame] | 1893 | hdd_ctx->config->maxWoWFilters = WMA_STA_WOW_DEFAULT_PTRN_MAX; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1894 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 1895 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 1896 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1897 | /* |
| 1898 | * This needs to be done after HDD pdev is created and stored since |
| 1899 | * it will access the HDD pdev object lock. |
| 1900 | */ |
| 1901 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 1902 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 1903 | /* Configure NAN datapath features */ |
| 1904 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 1905 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 1906 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1907 | } |
| 1908 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1909 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1910 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1911 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 1912 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1913 | |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1914 | if (!hdd_ctx || hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 1915 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1916 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1917 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1918 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 1920 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1921 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 1922 | |
| 1923 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 1924 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 1925 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 1926 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 1927 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 1928 | true; |
| 1929 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1930 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1931 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1932 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 1933 | |
| 1934 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1935 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | |
| 1937 | /** |
| 1938 | * hdd_is_valid_mac_address() - validate MAC address |
| 1939 | * @pMacAddr: Pointer to the input MAC address |
| 1940 | * |
| 1941 | * This function validates whether the given MAC address is valid or not |
| 1942 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 1943 | * where X is the hexa decimal digit character and separated by ':' |
| 1944 | * This algorithm works even if MAC address is not separated by ':' |
| 1945 | * |
| 1946 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 1947 | * digits and a separator colon : appears in the input string only after |
| 1948 | * an even number of hex digits. |
| 1949 | * |
| 1950 | * Return: 1 for valid and 0 for invalid |
| 1951 | */ |
| 1952 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 1953 | { |
| 1954 | int xdigit = 0; |
| 1955 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | while (*pMacAddr) { |
| 1958 | if (isxdigit(*pMacAddr)) { |
| 1959 | xdigit++; |
| 1960 | } else if (':' == *pMacAddr) { |
| 1961 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 1962 | break; |
| 1963 | |
| 1964 | ++separator; |
| 1965 | } else { |
| 1966 | /* Invalid MAC found */ |
| 1967 | return 0; |
| 1968 | } |
| 1969 | ++pMacAddr; |
| 1970 | } |
| 1971 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 1972 | } |
| 1973 | |
| 1974 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 1975 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 1976 | * @dev: Handle to struct net_device to be updated. |
| 1977 | * |
| 1978 | * Return: None |
| 1979 | */ |
| 1980 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 1981 | { |
| 1982 | dev->header_ops = NULL; |
| 1983 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 1984 | dev->hard_header_len = ETH_HLEN; |
| 1985 | dev->mtu = ETH_DATA_LEN; |
| 1986 | dev->addr_len = ETH_ALEN; |
| 1987 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 1988 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 1989 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 1990 | |
| 1991 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 1992 | } |
| 1993 | |
| 1994 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 1995 | * __hdd__mon_open() - HDD Open function |
| 1996 | * @dev: Pointer to net_device structure |
| 1997 | * |
| 1998 | * This is called in response to ifconfig up |
| 1999 | * |
| 2000 | * Return: 0 for success; non-zero for failure |
| 2001 | */ |
| 2002 | static int __hdd_mon_open(struct net_device *dev) |
| 2003 | { |
| 2004 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2005 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2006 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2007 | |
| 2008 | ENTER_DEV(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2009 | |
| 2010 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2011 | if (ret) |
| 2012 | return ret; |
| 2013 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2014 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2015 | |
| 2016 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2017 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2018 | if (ret) { |
| 2019 | hdd_err("Failed to start WLAN modules return"); |
| 2020 | return ret; |
| 2021 | } |
| 2022 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2023 | |
| 2024 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2025 | ret = hdd_start_adapter(adapter); |
| 2026 | if (ret) { |
| 2027 | hdd_err("Failed to start adapter :%d", |
| 2028 | adapter->device_mode); |
| 2029 | return ret; |
| 2030 | } |
| 2031 | hdd_err("hdd_start_adapters() successful !"); |
| 2032 | } |
| 2033 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2034 | } |
| 2035 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2036 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2037 | |
| 2038 | if (!ret) |
| 2039 | ret = hdd_enable_monitor_mode(dev); |
| 2040 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2041 | return ret; |
| 2042 | } |
| 2043 | |
| 2044 | /** |
| 2045 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2046 | * @dev: Pointer to net_device structure |
| 2047 | * |
| 2048 | * This is called in response to ifconfig up |
| 2049 | * |
| 2050 | * Return: 0 for success; non-zero for failure |
| 2051 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2052 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2053 | { |
| 2054 | int ret; |
| 2055 | |
| 2056 | cds_ssr_protect(__func__); |
| 2057 | ret = __hdd_mon_open(dev); |
| 2058 | cds_ssr_unprotect(__func__); |
| 2059 | |
| 2060 | return ret; |
| 2061 | } |
| 2062 | |
| 2063 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2064 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2065 | * @adapter: pointer to HDD adapter |
| 2066 | * |
| 2067 | * This function is called to start the device specific adapter for |
| 2068 | * the mode passed in the adapter's device_mode. |
| 2069 | * |
| 2070 | * Return: 0 for success; non-zero for failure |
| 2071 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2072 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2073 | { |
| 2074 | |
| 2075 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2076 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2077 | |
| 2078 | ENTER_DEV(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2079 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2080 | |
| 2081 | switch (device_mode) { |
| 2082 | case QDF_P2P_CLIENT_MODE: |
| 2083 | case QDF_P2P_DEVICE_MODE: |
| 2084 | case QDF_OCB_MODE: |
| 2085 | case QDF_STA_MODE: |
| 2086 | case QDF_MONITOR_MODE: |
| 2087 | ret = hdd_start_station_adapter(adapter); |
| 2088 | if (ret) |
| 2089 | goto err_start_adapter; |
| 2090 | break; |
| 2091 | case QDF_P2P_GO_MODE: |
| 2092 | case QDF_SAP_MODE: |
| 2093 | ret = hdd_start_ap_adapter(adapter); |
| 2094 | if (ret) |
| 2095 | goto err_start_adapter; |
| 2096 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2097 | case QDF_IBSS_MODE: |
| 2098 | /* |
| 2099 | * For IBSS interface is initialized as part of |
| 2100 | * hdd_init_station_mode() |
| 2101 | */ |
| 2102 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2103 | case QDF_FTM_MODE: |
| 2104 | ret = hdd_start_ftm_adapter(adapter); |
| 2105 | if (ret) |
| 2106 | goto err_start_adapter; |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 2107 | else |
| 2108 | goto ftm_complete; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2109 | break; |
| 2110 | default: |
| 2111 | hdd_err("Invalid session type %d", device_mode); |
| 2112 | QDF_ASSERT(0); |
| 2113 | goto err_start_adapter; |
| 2114 | } |
| 2115 | if (hdd_set_fw_params(adapter)) |
| 2116 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2117 | |
| 2118 | /* |
| 2119 | * Action frame registered in one adapter which will |
| 2120 | * applicable to all interfaces |
| 2121 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2122 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2123 | if (ret < 0) { |
| 2124 | hdd_err("Failed to register frames - ret %d", ret); |
| 2125 | goto err_start_adapter; |
| 2126 | } |
| 2127 | |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 2128 | ftm_complete: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2129 | EXIT(); |
| 2130 | return 0; |
| 2131 | err_start_adapter: |
| 2132 | return -EINVAL; |
| 2133 | } |
| 2134 | |
| 2135 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2136 | * hdd_enable_power_management() - API to Enable Power Management |
| 2137 | * |
| 2138 | * API invokes Bus Interface Layer power management functionality |
| 2139 | * |
| 2140 | * Return: None |
| 2141 | */ |
| 2142 | static void hdd_enable_power_management(void) |
| 2143 | { |
| 2144 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2145 | |
| 2146 | if (!hif_ctx) { |
| 2147 | hdd_err("Bus Interface Context is Invalid"); |
| 2148 | return; |
| 2149 | } |
| 2150 | |
| 2151 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2152 | } |
| 2153 | |
| 2154 | /** |
| 2155 | * hdd_disable_power_management() - API to disable Power Management |
| 2156 | * |
| 2157 | * API disable Bus Interface Layer Power management functionality |
| 2158 | * |
| 2159 | * Return: None |
| 2160 | */ |
| 2161 | static void hdd_disable_power_management(void) |
| 2162 | { |
| 2163 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2164 | |
| 2165 | if (!hif_ctx) { |
| 2166 | hdd_err("Bus Interface Context is Invalid"); |
| 2167 | return; |
| 2168 | } |
| 2169 | |
| 2170 | hif_disable_power_management(hif_ctx); |
| 2171 | } |
| 2172 | |
| 2173 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2174 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2175 | * |
| 2176 | * API to update the HW and SW information in the driver |
| 2177 | * |
| 2178 | * Return: None |
| 2179 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2180 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2181 | { |
| 2182 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2183 | size_t target_hw_name_len; |
| 2184 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2185 | |
| 2186 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2187 | if (!hif_sc) { |
| 2188 | hdd_err("HIF context is NULL"); |
| 2189 | return; |
| 2190 | } |
| 2191 | |
| 2192 | /* |
| 2193 | * target hw version/revision would only be retrieved after firmware |
| 2194 | * download |
| 2195 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2196 | hif_get_hw_info(hif_sc, |
| 2197 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2198 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2199 | &target_hw_name); |
| 2200 | |
| 2201 | if (hdd_ctx->target_hw_name) |
| 2202 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2203 | |
| 2204 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2205 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2206 | if (hdd_ctx->target_hw_name) |
| 2207 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2208 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2209 | |
| 2210 | /* Get the wlan hw/fw version */ |
| 2211 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2212 | } |
| 2213 | |
| 2214 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2215 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2216 | * @hdd_ctx: Pointer to hdd context |
| 2217 | * |
| 2218 | * Return: none |
| 2219 | */ |
| 2220 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2221 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2222 | { |
| 2223 | uint8_t num_entries = 0; |
| 2224 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2225 | uint8_t *tx_sched_wrr_ac; |
| 2226 | int i; |
| 2227 | cds_context_type *cds_ctx; |
| 2228 | |
| 2229 | if (NULL == hdd_ctx) |
| 2230 | return; |
| 2231 | |
| 2232 | if (NULL == hdd_ctx->config) { |
| 2233 | /* Do nothing if hdd_ctx is invalid */ |
| 2234 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2235 | return; |
| 2236 | } |
| 2237 | |
| 2238 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2239 | |
| 2240 | if (!cds_ctx) { |
| 2241 | hdd_err("Invalid CDS Context"); |
| 2242 | return; |
| 2243 | } |
| 2244 | |
| 2245 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2246 | switch (i) { |
| 2247 | case OL_TX_WMM_AC_BE: |
| 2248 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2249 | break; |
| 2250 | case OL_TX_WMM_AC_BK: |
| 2251 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2252 | break; |
| 2253 | case OL_TX_WMM_AC_VI: |
| 2254 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2255 | break; |
| 2256 | case OL_TX_WMM_AC_VO: |
| 2257 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2258 | break; |
| 2259 | default: |
| 2260 | tx_sched_wrr_ac = NULL; |
| 2261 | break; |
| 2262 | } |
| 2263 | |
| 2264 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2265 | tx_sched_wrr_param, |
| 2266 | &num_entries, |
| 2267 | sizeof(tx_sched_wrr_param)); |
| 2268 | |
| 2269 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2270 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2271 | tx_sched_wrr_param[0]; |
| 2272 | cds_ctx->ac_specs[i].credit_threshold = |
| 2273 | tx_sched_wrr_param[1]; |
| 2274 | cds_ctx->ac_specs[i].send_limit = |
| 2275 | tx_sched_wrr_param[2]; |
| 2276 | cds_ctx->ac_specs[i].credit_reserve = |
| 2277 | tx_sched_wrr_param[3]; |
| 2278 | cds_ctx->ac_specs[i].discard_weight = |
| 2279 | tx_sched_wrr_param[4]; |
| 2280 | } |
| 2281 | |
| 2282 | num_entries = 0; |
| 2283 | } |
| 2284 | } |
| 2285 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2286 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2287 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2288 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2289 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2290 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2291 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2292 | |
| 2293 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2294 | if (!adapter) { |
| 2295 | hdd_err("Adapter is NULL"); |
| 2296 | return PM_MAX_NUM_OF_MODE; |
| 2297 | } |
| 2298 | |
| 2299 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2300 | adapter->device_mode); |
| 2301 | } |
| 2302 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2303 | static void hdd_register_policy_manager_callback( |
| 2304 | struct wlan_objmgr_psoc *psoc) |
| 2305 | { |
| 2306 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2307 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2308 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2309 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2310 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2311 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2312 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2313 | wlan_hdd_get_mode_for_non_connected_vdev; |
| 2314 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2315 | if (QDF_STATUS_SUCCESS != |
| 2316 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2317 | hdd_err("HDD callback registration with policy manager failed"); |
| 2318 | } |
| 2319 | } |
| 2320 | #else |
| 2321 | static void hdd_register_policy_manager_callback( |
| 2322 | struct wlan_objmgr_psoc *psoc) |
| 2323 | { |
| 2324 | } |
| 2325 | #endif |
| 2326 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2327 | #ifdef WLAN_FEATURE_NAN_CONVERGENCE |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2328 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2329 | { |
| 2330 | struct nan_callbacks cb_obj = {0}; |
| 2331 | |
| 2332 | cb_obj.ndi_open = hdd_ndi_open; |
| 2333 | cb_obj.ndi_close = hdd_ndi_close; |
| 2334 | cb_obj.ndi_start = hdd_ndi_start; |
| 2335 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2336 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2337 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2338 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2339 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2340 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2341 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2342 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2343 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2344 | } |
| 2345 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2346 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2347 | { |
| 2348 | } |
| 2349 | #endif |
| 2350 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2351 | static void hdd_check_for_leaks(void) |
| 2352 | { |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2353 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2354 | } |
| 2355 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2356 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2357 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2358 | * @hdd_ctx: HDD context |
| 2359 | * @adapter: HDD adapter |
| 2360 | * @reinit: flag to indicate from SSR or normal path |
| 2361 | * |
| 2362 | * This function maintains the driver state machine it will be invoked from |
| 2363 | * startup, reinit and change interface. Depending on the driver state shall |
| 2364 | * perform the opening of the modules. |
| 2365 | * |
| 2366 | * Return: 0 for success; non-zero for failure |
| 2367 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2368 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2369 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2370 | bool reinit) |
| 2371 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2372 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2373 | qdf_device_t qdf_dev; |
| 2374 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2375 | bool unint = false; |
| 2376 | void *hif_ctx; |
| 2377 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2378 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2379 | |
| 2380 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2381 | if (!qdf_dev) { |
| 2382 | hdd_err("QDF Device Context is Invalid return"); |
| 2383 | return -EINVAL; |
| 2384 | } |
| 2385 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2386 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2387 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2388 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2389 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2390 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2391 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2392 | hdd_info("Driver modules already Enabled"); |
| 2393 | EXIT(); |
| 2394 | return 0; |
| 2395 | } |
| 2396 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2397 | hdd_ctx->start_modules_in_progress = true; |
| 2398 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2399 | switch (hdd_ctx->driver_status) { |
| 2400 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2401 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2402 | unint = true; |
| 2403 | /* Fall through dont add break here */ |
| 2404 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2405 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2406 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2407 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
| 2408 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2409 | if (!reinit && !unint) { |
| 2410 | ret = pld_power_on(qdf_dev->dev); |
| 2411 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2412 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2413 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2414 | goto release_lock; |
| 2415 | } |
| 2416 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2417 | |
| 2418 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2419 | hdd_ctx->config->enable_fw_log); |
| 2420 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2421 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2422 | qdf_dev->bus_type, |
| 2423 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2424 | HIF_ENABLE_TYPE_PROBE); |
| 2425 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2426 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2427 | goto power_down; |
| 2428 | } |
| 2429 | |
| 2430 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2431 | if (!hif_ctx) { |
| 2432 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2433 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2434 | goto power_down; |
| 2435 | } |
| 2436 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2437 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2438 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2439 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2440 | status); |
| 2441 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2442 | goto hif_close; |
| 2443 | } |
| 2444 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2445 | ret = hdd_update_config(hdd_ctx); |
| 2446 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2447 | hdd_err("Failed to update configuration; errno: %d", |
| 2448 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2449 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2450 | } |
| 2451 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2452 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2453 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2454 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2455 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2456 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2457 | ret = qdf_status_to_os_return(status); |
| 2458 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2459 | } |
| 2460 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2461 | /* initalize components configurations after psoc open */ |
| 2462 | ret = hdd_update_components_config(hdd_ctx); |
| 2463 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2464 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2465 | ret); |
| 2466 | goto close; |
| 2467 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2468 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2469 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2470 | hdd_err("Failed to Open cds post open; status: %d", |
| 2471 | status); |
| 2472 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2473 | goto close; |
| 2474 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2475 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2476 | /* |
| 2477 | * NAN compoenet requires certian operations like, open adapter, |
| 2478 | * close adapter, etc. to be initiated by HDD, for those |
| 2479 | * register HDD callbacks with UMAC's NAN componenet. |
| 2480 | */ |
| 2481 | hdd_nan_register_callbacks(hdd_ctx); |
| 2482 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2483 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2484 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2485 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2486 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2487 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2488 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2489 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2490 | } |
| 2491 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2492 | hdd_register_policy_manager_callback( |
| 2493 | hdd_ctx->hdd_psoc); |
| 2494 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2495 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2496 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2497 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2498 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2499 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2500 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2501 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2502 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2503 | hdd_ftm_mc_process_msg); |
| 2504 | break; |
| 2505 | } |
| 2506 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2507 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2508 | break; |
| 2509 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2510 | |
| 2511 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2512 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2513 | if (ret) { |
| 2514 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2515 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2516 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2517 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2518 | } |
| 2519 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2520 | /* Fall through dont add break here */ |
| 2521 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2522 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2523 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2524 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2525 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2526 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2527 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2528 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2529 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2530 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2531 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2532 | break; |
| 2533 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2534 | |
| 2535 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2536 | if (ret) { |
| 2537 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2538 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2539 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2540 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2541 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2542 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2543 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2544 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2545 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2546 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2547 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2548 | default: |
| 2549 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2550 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2551 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2552 | goto release_lock; |
| 2553 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2554 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2555 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2556 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2557 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2558 | EXIT(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2559 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2560 | return 0; |
| 2561 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2562 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2563 | cds_post_disable(); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2564 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2565 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2566 | cds_txrx_free: |
| 2567 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2568 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2569 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2570 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2571 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2572 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2573 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2574 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2575 | deinit_config: |
| 2576 | cds_deinit_ini_config(); |
| 2577 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2578 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2579 | ol_cds_free(); |
| 2580 | |
| 2581 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2582 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2583 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2584 | power_down: |
| 2585 | if (!reinit && !unint) |
| 2586 | pld_power_off(qdf_dev->dev); |
| 2587 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2588 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2589 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2590 | |
| 2591 | /* many adapter resources are not freed by design in SSR case */ |
| 2592 | if (!reinit) |
| 2593 | hdd_check_for_leaks(); |
| 2594 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
| 2595 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2596 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2597 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2598 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2599 | } |
| 2600 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2601 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2602 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2603 | { |
| 2604 | int ret = os_if_wifi_pos_register_nl(); |
| 2605 | |
| 2606 | if (ret) |
| 2607 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2608 | |
| 2609 | return ret; |
| 2610 | } |
| 2611 | |
| 2612 | static int hdd_deactivate_wifi_pos(void) |
| 2613 | { |
| 2614 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2615 | |
| 2616 | if (ret) |
| 2617 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2618 | |
| 2619 | return ret; |
| 2620 | } |
| 2621 | |
| 2622 | /** |
| 2623 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2624 | * @hdd_ctx: hdd context |
| 2625 | * |
| 2626 | * Return: status of operation |
| 2627 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2628 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2629 | { |
| 2630 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2631 | struct hdd_config *cfg = hdd_ctx->config; |
| 2632 | |
| 2633 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2634 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2635 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2636 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2637 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2638 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2639 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2640 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2641 | } |
| 2642 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2643 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2644 | { |
| 2645 | return oem_activate_service(hdd_ctx); |
| 2646 | } |
| 2647 | |
| 2648 | static int hdd_deactivate_wifi_pos(void) |
| 2649 | { |
| 2650 | return 0; |
| 2651 | } |
| 2652 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2653 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2654 | { |
| 2655 | } |
| 2656 | #endif |
| 2657 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2658 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2659 | * __hdd_open() - HDD Open function |
| 2660 | * @dev: Pointer to net_device structure |
| 2661 | * |
| 2662 | * This is called in response to ifconfig up |
| 2663 | * |
| 2664 | * Return: 0 for success; non-zero for failure |
| 2665 | */ |
| 2666 | static int __hdd_open(struct net_device *dev) |
| 2667 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2668 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2669 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2670 | int ret; |
| 2671 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2672 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2673 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2674 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2675 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2676 | /* Nothing to be done if device is unloading */ |
| 2677 | if (cds_is_driver_unloading()) { |
| 2678 | hdd_err("Driver is unloading can not open the hdd"); |
| 2679 | return -EBUSY; |
| 2680 | } |
| 2681 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2682 | if (cds_is_driver_recovering()) { |
| 2683 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2684 | return -EBUSY; |
| 2685 | } |
| 2686 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2687 | mutex_lock(&hdd_init_deinit_lock); |
| 2688 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2689 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2690 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2691 | /* |
| 2692 | * This scenario can be hit in cases where in the wlan driver after |
| 2693 | * registering the netdevices and there is a failure in driver |
| 2694 | * initialization. So return error gracefully because the netdevices |
| 2695 | * will be de-registered as part of the load failure. |
| 2696 | */ |
| 2697 | |
| 2698 | if (!cds_is_driver_loaded()) { |
| 2699 | hdd_err("Failed to start the wlan driver!!"); |
| 2700 | ret = -EIO; |
| 2701 | goto err_hdd_hdd_init_deinit_lock; |
| 2702 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2703 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2704 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2705 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2706 | if (ret) { |
| 2707 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2708 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2709 | } |
| 2710 | |
| 2711 | |
| 2712 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2713 | ret = hdd_start_adapter(adapter); |
| 2714 | if (ret) { |
| 2715 | hdd_err("Failed to start adapter :%d", |
| 2716 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2717 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2718 | } |
| 2719 | } |
| 2720 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2721 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2722 | 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] | 2723 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2724 | /* Enable TX queues only when we are connected */ |
| 2725 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2726 | WLAN_START_ALL_NETIF_QUEUE, |
| 2727 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2728 | } |
| 2729 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2730 | /* Enable carrier and transmit queues for NDI */ |
| 2731 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2732 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2733 | wlan_hdd_netif_queue_control(adapter, |
| 2734 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2735 | WLAN_CONTROL_PATH); |
| 2736 | } |
| 2737 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2738 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2739 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2740 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2741 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2742 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2743 | return ret; |
| 2744 | } |
| 2745 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2746 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2747 | /** |
| 2748 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2749 | * @dev: Pointer to net_device structure |
| 2750 | * |
| 2751 | * This is called in response to ifconfig up |
| 2752 | * |
| 2753 | * Return: 0 for success; non-zero for failure |
| 2754 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2755 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2756 | { |
| 2757 | int ret; |
| 2758 | |
| 2759 | cds_ssr_protect(__func__); |
| 2760 | ret = __hdd_open(dev); |
| 2761 | cds_ssr_unprotect(__func__); |
| 2762 | |
| 2763 | return ret; |
| 2764 | } |
| 2765 | |
| 2766 | /** |
| 2767 | * __hdd_stop() - HDD stop function |
| 2768 | * @dev: Pointer to net_device structure |
| 2769 | * |
| 2770 | * This is called in response to ifconfig down |
| 2771 | * |
| 2772 | * Return: 0 for success; non-zero for failure |
| 2773 | */ |
| 2774 | static int __hdd_stop(struct net_device *dev) |
| 2775 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2776 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2777 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2778 | int ret; |
| 2779 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2780 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2781 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2782 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2783 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2784 | |
| 2785 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2786 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2787 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2788 | |
| 2789 | /* Nothing to be done if the interface is not opened */ |
| 2790 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2791 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2792 | return -ENODEV; |
| 2793 | } |
| 2794 | |
| 2795 | /* Make sure the interface is marked as closed */ |
| 2796 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2797 | |
| 2798 | hdd_debug("Disabling Auto Power save timer"); |
| 2799 | sme_ps_disable_auto_ps_timer( |
| 2800 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2801 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2802 | |
| 2803 | /* |
| 2804 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2805 | * be called on that interface |
| 2806 | */ |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 2807 | hdd_notice("Disabling queues, adapter device mode: %s(%d)", |
| 2808 | hdd_device_mode_to_string(adapter->device_mode), |
| 2809 | adapter->device_mode); |
| 2810 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2811 | wlan_hdd_netif_queue_control(adapter, |
| 2812 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2813 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2814 | |
| 2815 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2816 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2817 | * bursty in nature and depends on the need to transfer. The service |
| 2818 | * layer may down the interface after the usage and up again when |
| 2819 | * required. In some sense, the NDI is expected to be available |
| 2820 | * (like SAP) iface until NDI delete request is issued by the service |
| 2821 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2822 | * interface (NDI). |
| 2823 | */ |
| 2824 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2825 | return 0; |
| 2826 | |
Tushnim Bhattacharyya | 8629489 | 2017-10-25 16:29:11 -0700 | [diff] [blame] | 2827 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->hdd_psoc); |
| 2828 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2829 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2830 | * The interface is marked as down for outside world (aka kernel) |
| 2831 | * But the driver is pretty much alive inside. The driver needs to |
| 2832 | * tear down the existing connection on the netdev (session) |
| 2833 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2834 | * for this interface. The call also needs to wait until the above |
| 2835 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2836 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2837 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2838 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2839 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2840 | |
| 2841 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2842 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2843 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2844 | |
| 2845 | /* |
| 2846 | * Find if any iface is up. If any iface is up then can't put device to |
| 2847 | * sleep/power save mode |
| 2848 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2849 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2850 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2851 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 2852 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2853 | hdd_prevent_suspend_timeout( |
| 2854 | hdd_ctx->config->iface_change_wait_time, |
| 2855 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2856 | } |
| 2857 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2858 | EXIT(); |
| 2859 | return 0; |
| 2860 | } |
| 2861 | |
| 2862 | /** |
| 2863 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2864 | * @dev: pointer to net_device structure |
| 2865 | * |
| 2866 | * This is called in response to ifconfig down |
| 2867 | * |
| 2868 | * Return: 0 for success and error number for failure |
| 2869 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2870 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2871 | { |
| 2872 | int ret; |
| 2873 | |
| 2874 | cds_ssr_protect(__func__); |
| 2875 | ret = __hdd_stop(dev); |
| 2876 | cds_ssr_unprotect(__func__); |
| 2877 | |
| 2878 | return ret; |
| 2879 | } |
| 2880 | |
| 2881 | /** |
| 2882 | * __hdd_uninit() - HDD uninit function |
| 2883 | * @dev: Pointer to net_device structure |
| 2884 | * |
| 2885 | * This is called during the netdev unregister to uninitialize all data |
| 2886 | * associated with the device |
| 2887 | * |
| 2888 | * Return: None |
| 2889 | */ |
| 2890 | static void __hdd_uninit(struct net_device *dev) |
| 2891 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2892 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2893 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2894 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2895 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2896 | |
| 2897 | do { |
| 2898 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2899 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2900 | break; |
| 2901 | } |
| 2902 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2903 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2904 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2905 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2906 | break; |
| 2907 | } |
| 2908 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2909 | if (dev != adapter->dev) |
| 2910 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2912 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2913 | |
| 2914 | /* after uninit our adapter structure will no longer be valid */ |
| 2915 | adapter->dev = NULL; |
| 2916 | adapter->magic = 0; |
| 2917 | } while (0); |
| 2918 | |
| 2919 | EXIT(); |
| 2920 | } |
| 2921 | |
| 2922 | /** |
| 2923 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2924 | * @dev: pointer to net_device structure |
| 2925 | * |
| 2926 | * This is called during the netdev unregister to uninitialize all data |
| 2927 | * associated with the device |
| 2928 | * |
| 2929 | * Return: none |
| 2930 | */ |
| 2931 | static void hdd_uninit(struct net_device *dev) |
| 2932 | { |
| 2933 | cds_ssr_protect(__func__); |
| 2934 | __hdd_uninit(dev); |
| 2935 | cds_ssr_unprotect(__func__); |
| 2936 | } |
| 2937 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2938 | static int hdd_open_cesium_nl_sock(void) |
| 2939 | { |
| 2940 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2941 | struct netlink_kernel_cfg cfg = { |
| 2942 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2943 | .input = NULL |
| 2944 | }; |
| 2945 | #endif |
| 2946 | int ret = 0; |
| 2947 | |
| 2948 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2949 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2950 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2951 | THIS_MODULE, |
| 2952 | #endif |
| 2953 | &cfg); |
| 2954 | #else |
| 2955 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2956 | WLAN_NLINK_MCAST_GRP_ID, |
| 2957 | NULL, NULL, THIS_MODULE); |
| 2958 | #endif |
| 2959 | |
| 2960 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2961 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2962 | ret = -ECONNREFUSED; |
| 2963 | } |
| 2964 | |
| 2965 | return ret; |
| 2966 | } |
| 2967 | |
| 2968 | static void hdd_close_cesium_nl_sock(void) |
| 2969 | { |
| 2970 | if (NULL != cesium_nl_srv_sock) { |
| 2971 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2972 | cesium_nl_srv_sock = NULL; |
| 2973 | } |
| 2974 | } |
| 2975 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2976 | /** |
| 2977 | * __hdd_set_mac_address() - set the user specified mac address |
| 2978 | * @dev: Pointer to the net device. |
| 2979 | * @addr: Pointer to the sockaddr. |
| 2980 | * |
| 2981 | * This function sets the user specified mac address using |
| 2982 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2983 | * |
| 2984 | * Return: 0 for success, non zero for failure |
| 2985 | */ |
| 2986 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 2987 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2988 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2989 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2990 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 2991 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2992 | int ret; |
| 2993 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2994 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2995 | |
| 2996 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2997 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2998 | if (0 != ret) |
| 2999 | return ret; |
| 3000 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3001 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3002 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3003 | |
| 3004 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3005 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3006 | } |
| 3007 | |
| 3008 | /** |
| 3009 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3010 | * function from SSR |
| 3011 | * @dev: pointer to net_device structure |
| 3012 | * @addr: Pointer to the sockaddr |
| 3013 | * |
| 3014 | * This function sets the user specified mac address using |
| 3015 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3016 | * |
| 3017 | * Return: 0 for success. |
| 3018 | */ |
| 3019 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3020 | { |
| 3021 | int ret; |
| 3022 | |
| 3023 | cds_ssr_protect(__func__); |
| 3024 | ret = __hdd_set_mac_address(dev, addr); |
| 3025 | cds_ssr_unprotect(__func__); |
| 3026 | |
| 3027 | return ret; |
| 3028 | } |
| 3029 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3030 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3031 | { |
| 3032 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3033 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3034 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3035 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3036 | break; |
| 3037 | } |
| 3038 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3039 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3040 | return NULL; |
| 3041 | |
| 3042 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3043 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3044 | } |
| 3045 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3046 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3047 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3048 | { |
| 3049 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3050 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3051 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3052 | if (!memcmp(releaseAddr, |
| 3053 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3054 | 6)) { |
| 3055 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3056 | break; |
| 3057 | } |
| 3058 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3059 | } |
| 3060 | |
| 3061 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3062 | /** |
| 3063 | * __hdd_set_multicast_list() - set the multicast address list |
| 3064 | * @dev: Pointer to the WLAN device. |
| 3065 | * @skb: Pointer to OS packet (sk_buff). |
| 3066 | * |
| 3067 | * This funciton sets the multicast address list. |
| 3068 | * |
| 3069 | * Return: None |
| 3070 | */ |
| 3071 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3072 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3073 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | int i = 0, status; |
| 3075 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3076 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3077 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3078 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3079 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3080 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3081 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3082 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3083 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3085 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3086 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3087 | goto out; |
| 3088 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3089 | status = hdd_validate_adapter(adapter); |
| 3090 | if (status) |
| 3091 | goto out; |
| 3092 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3093 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3094 | hdd_err("%s: Driver module is closed", __func__); |
| 3095 | return; |
| 3096 | } |
| 3097 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3098 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3099 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3100 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3101 | goto out; |
| 3102 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3103 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3104 | /* Delete already configured multicast address list */ |
| 3105 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3106 | hdd_info("clear previously configured MC address list"); |
| 3107 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3108 | pmo_mc_list_change_notify); |
| 3109 | } |
| 3110 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3111 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3112 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3113 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3114 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | } else { |
| 3116 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3117 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3118 | 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] | 3119 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3120 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3121 | pmo_mc_list_change_notify); |
| 3122 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3123 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3125 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3126 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | if (i == mc_count) |
| 3128 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3129 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3130 | 0, ETH_ALEN); |
| 3131 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3132 | ha->addr, ETH_ALEN); |
| 3133 | hdd_info("mlist[%d] = %pM", i, |
| 3134 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3135 | i++; |
| 3136 | } |
| 3137 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3138 | |
| 3139 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3140 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3141 | mc_list_request->count = mc_count; |
| 3142 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3143 | if (status == 0) { |
| 3144 | hdd_enable_mc_addr_filtering(adapter, |
| 3145 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3146 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3147 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3149 | out: |
| 3150 | if (mc_list_request) |
| 3151 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3152 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3153 | } |
| 3154 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3155 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | /** |
| 3157 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3158 | * @dev: pointer to net_device |
| 3159 | * |
| 3160 | * Return: none |
| 3161 | */ |
| 3162 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3163 | { |
| 3164 | cds_ssr_protect(__func__); |
| 3165 | __hdd_set_multicast_list(dev); |
| 3166 | cds_ssr_unprotect(__func__); |
| 3167 | } |
| 3168 | #endif |
| 3169 | |
| 3170 | /** |
| 3171 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3172 | * @dev: Pointer to the WLAN device. |
| 3173 | * @skb: Pointer to OS packet (sk_buff). |
| 3174 | * |
| 3175 | * This function is registered with the Linux OS for network |
| 3176 | * core to decide which queue to use first. |
| 3177 | * |
| 3178 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3179 | */ |
| 3180 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3181 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3182 | , void *accel_priv |
| 3183 | #endif |
| 3184 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3185 | , select_queue_fallback_t fallback |
| 3186 | #endif |
| 3187 | ) |
| 3188 | { |
| 3189 | return hdd_wmm_select_queue(dev, skb); |
| 3190 | } |
| 3191 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3192 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3193 | .ndo_open = hdd_open, |
| 3194 | .ndo_stop = hdd_stop, |
| 3195 | .ndo_uninit = hdd_uninit, |
| 3196 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3197 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3198 | .ndo_get_stats = hdd_get_stats, |
| 3199 | .ndo_do_ioctl = hdd_ioctl, |
| 3200 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3201 | .ndo_select_queue = hdd_select_queue, |
| 3202 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | #endif |
| 3205 | }; |
| 3206 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3207 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3208 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3209 | .ndo_open = hdd_mon_open, |
| 3210 | .ndo_stop = hdd_stop, |
| 3211 | .ndo_get_stats = hdd_get_stats, |
| 3212 | }; |
| 3213 | |
| 3214 | /** |
| 3215 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3216 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3217 | * Return: None |
| 3218 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3219 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3220 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3221 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3222 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3223 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3224 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3225 | } |
| 3226 | |
| 3227 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3228 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3229 | * @hdd_ctx: global hdd context |
| 3230 | * @macAddr: mac address to assign to the interface |
| 3231 | * @name: User-visible name of the interface |
| 3232 | * |
| 3233 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3234 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3235 | * |
| 3236 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3237 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3238 | 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] | 3239 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3240 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3241 | const char *name) |
| 3242 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3243 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3244 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3245 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3246 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3247 | /* |
| 3248 | * cfg80211 initialization and registration.... |
| 3249 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3250 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3251 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3252 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3253 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3254 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3255 | hdd_mon_mode_ether_setup : ether_setup), |
| 3256 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3257 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3258 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3259 | |
| 3260 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3261 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3263 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3264 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3265 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3266 | sizeof(sta_ctx->conn_info.staId), |
| 3267 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3268 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3269 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3270 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3271 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3273 | qdf_status = qdf_event_create( |
| 3274 | &adapter->qdf_session_open_event); |
| 3275 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3276 | hdd_err("Session open QDF event init failed!"); |
| 3277 | free_netdev(adapter->dev); |
| 3278 | return NULL; |
| 3279 | } |
| 3280 | |
| 3281 | qdf_status = qdf_event_create( |
| 3282 | &adapter->qdf_session_close_event); |
| 3283 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3284 | hdd_err("Session close QDF event init failed!"); |
| 3285 | free_netdev(adapter->dev); |
| 3286 | return NULL; |
| 3287 | } |
| 3288 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3289 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3290 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3291 | init_completion(&adapter->linkup_event_var); |
| 3292 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3293 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3294 | init_completion(&adapter->sta_authorized_event); |
| 3295 | init_completion(&adapter->offchannel_tx_event); |
| 3296 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3297 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3298 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3299 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3300 | |
| 3301 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3302 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3303 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3304 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3305 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3306 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3307 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3308 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3309 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3310 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3311 | |
| 3312 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3313 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3314 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3315 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3317 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3318 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3319 | hdd_set_station_ops(adapter->dev); |
| 3320 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3321 | hdd_dev_setup_destructor(dev); |
| 3322 | dev->ieee80211_ptr = &adapter->wdev; |
| 3323 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3325 | adapter->wdev.netdev = dev; |
| 3326 | /* set dev's parent to underlying device */ |
| 3327 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3329 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3330 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3331 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3332 | } |
| 3333 | |
| 3334 | return adapter; |
| 3335 | } |
| 3336 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3337 | 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] | 3338 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3339 | struct net_device *dev = adapter->dev; |
| 3340 | int ret; |
| 3341 | |
| 3342 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3344 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3345 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3346 | |
| 3347 | ret = dev_alloc_name(dev, dev->name); |
| 3348 | if (ret < 0) { |
| 3349 | hdd_err( |
| 3350 | "unable to get dev name: %s, err = 0x%x", |
| 3351 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3352 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3353 | } |
| 3354 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3355 | |
| 3356 | ret = register_netdevice(dev); |
| 3357 | if (ret) { |
| 3358 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3359 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3360 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | } |
| 3362 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3363 | ret = register_netdev(dev); |
| 3364 | if (ret) { |
| 3365 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3366 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3367 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3368 | } |
| 3369 | } |
| 3370 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3371 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3372 | EXIT(); |
| 3373 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3374 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | } |
| 3376 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3377 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3378 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3379 | struct hdd_adapter *adapter; |
| 3380 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3381 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3382 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3383 | if (!hdd_ctx) { |
| 3384 | hdd_err("Invalid HDD_CTX"); |
| 3385 | return QDF_STATUS_E_FAILURE; |
| 3386 | } |
| 3387 | |
| 3388 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3389 | if (NULL == adapter) { |
| 3390 | hdd_err("NULL adapter"); |
| 3391 | return QDF_STATUS_E_INVAL; |
| 3392 | } |
| 3393 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3394 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3395 | hdd_debug("session %d opened", adapter->session_id); |
| 3396 | |
| 3397 | return QDF_STATUS_SUCCESS; |
| 3398 | } |
| 3399 | |
| 3400 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3401 | { |
| 3402 | struct hdd_adapter *adapter; |
| 3403 | struct hdd_context *hdd_ctx; |
| 3404 | |
| 3405 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3406 | if (!hdd_ctx) { |
| 3407 | hdd_err("Invalid HDD_CTX"); |
| 3408 | return QDF_STATUS_E_FAILURE; |
| 3409 | } |
| 3410 | |
| 3411 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3412 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3413 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3414 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3415 | } |
| 3416 | |
| 3417 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3418 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3419 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3420 | } |
| 3421 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3422 | /* |
| 3423 | * For NAN Data interface, the close session results in the final |
| 3424 | * indication to the userspace |
| 3425 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3426 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3427 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3428 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3430 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3431 | /* |
| 3432 | * We can be blocked while waiting for scheduled work to be |
| 3433 | * flushed, and the adapter structure can potentially be freed, in |
| 3434 | * which case the magic will have been reset. So make sure the |
| 3435 | * magic is still good, and hence the adapter structure is still |
| 3436 | * valid, before signaling completion |
| 3437 | */ |
| 3438 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3439 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3440 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3441 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | } |
| 3443 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3444 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3445 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3446 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3447 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3448 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3449 | if (QDF_IS_STATUS_ERROR(status)) |
| 3450 | return qdf_status_to_os_return(status); |
| 3451 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3452 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3453 | if (QDF_IS_STATUS_ERROR(status)) |
| 3454 | return qdf_status_to_os_return(status); |
| 3455 | |
| 3456 | if (wma_capability_enhanced_mcast_filter()) |
| 3457 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3458 | else |
| 3459 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3460 | |
| 3461 | return qdf_status_to_os_return(status); |
| 3462 | } |
| 3463 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3464 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3465 | { |
| 3466 | QDF_STATUS status; |
| 3467 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3468 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3469 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3470 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3471 | vdev_id = adapter->session_id; |
| 3472 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3473 | |
| 3474 | /* vdev created sanity check */ |
| 3475 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3476 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3477 | return -EINVAL; |
| 3478 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3479 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3480 | /* |
| 3481 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3482 | * it has already asserted. vdev can be released directly. |
| 3483 | */ |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3484 | if (cds_is_driver_recovering()) { |
| 3485 | hdd_debug("SSR: silently release the vdev for session-id: %d", |
| 3486 | adapter->session_id); |
| 3487 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3488 | goto release_vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3489 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3490 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3491 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3492 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3493 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3494 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3495 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3496 | hdd_err("failed to close sme session: %d", status); |
| 3497 | return qdf_status_to_os_return(status); |
| 3498 | } |
| 3499 | |
| 3500 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3501 | status = qdf_wait_for_event_completion( |
| 3502 | &adapter->qdf_session_close_event, |
| 3503 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3504 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3505 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3506 | hdd_ndp_session_end_handler(adapter); |
| 3507 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3508 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3509 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3510 | hdd_err("timed out waiting for close sme session: %u", status); |
| 3511 | return -ETIMEDOUT; |
| 3512 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3513 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
| 3514 | return -EINVAL; |
| 3515 | } else { |
| 3516 | hdd_err("Failed to close sme session (%u)", status); |
| 3517 | return -EINVAL; |
| 3518 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3519 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3520 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3521 | /* do vdev logical destroy via objmgr */ |
| 3522 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3523 | if (errno) { |
| 3524 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3525 | return errno; |
| 3526 | } |
| 3527 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3528 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3529 | errno = hdd_objmgr_release_vdev(adapter); |
| 3530 | if (errno) { |
| 3531 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3532 | return errno; |
| 3533 | } |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3534 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3535 | |
| 3536 | return 0; |
| 3537 | } |
| 3538 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3539 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3540 | struct sme_session_params *session_param, |
| 3541 | csr_roam_completeCallback callback, |
| 3542 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3543 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3544 | uint32_t type; |
| 3545 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3546 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3547 | |
| 3548 | /* determine vdev (sub)type */ |
| 3549 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3550 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3551 | hdd_err("failed to get vdev type: %d", status); |
| 3552 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3554 | session_param->sme_session_id = adapter->session_id; |
| 3555 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3556 | session_param->type_of_persona = type; |
| 3557 | session_param->subtype_of_persona = sub_type; |
| 3558 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3559 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3560 | session_param->callback = callback; |
| 3561 | session_param->callback_ctx = callback_ctx; |
| 3562 | |
| 3563 | return 0; |
| 3564 | } |
| 3565 | |
| 3566 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3567 | csr_roam_completeCallback callback, void *ctx) |
| 3568 | { |
| 3569 | QDF_STATUS status; |
| 3570 | int errno; |
| 3571 | struct hdd_context *hdd_ctx; |
| 3572 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3573 | |
| 3574 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3575 | |
| 3576 | /* do vdev create via objmgr */ |
| 3577 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3578 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3579 | if (errno) { |
| 3580 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3581 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3582 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3583 | |
| 3584 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3585 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3586 | if (QDF_STATUS_SUCCESS != status) { |
| 3587 | hdd_err("failed to reinit session open event"); |
| 3588 | return -EINVAL; |
| 3589 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3590 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3591 | callback, ctx); |
| 3592 | if (errno) { |
| 3593 | hdd_err("failed to populating SME params"); |
| 3594 | goto objmgr_vdev_destroy_procedure; |
| 3595 | } |
| 3596 | |
| 3597 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3598 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3599 | hdd_err("failed to open sme session: %d", status); |
| 3600 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3601 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3602 | } |
| 3603 | |
| 3604 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3605 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3606 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3607 | if (QDF_STATUS_SUCCESS != status) { |
| 3608 | if (adapter->qdf_session_open_event.force_set) { |
| 3609 | /* |
| 3610 | * SSR/PDR has caused shutdown, which has forcefully |
| 3611 | * set the event. Return without the closing session. |
| 3612 | */ |
| 3613 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3614 | hdd_err("Session open event forcefully set"); |
| 3615 | return -EINVAL; |
| 3616 | } else { |
| 3617 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3618 | hdd_err("Session failed to open within timeout period"); |
| 3619 | else |
| 3620 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3621 | status); |
| 3622 | errno = -ETIMEDOUT; |
| 3623 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3624 | goto hdd_vdev_destroy_procedure; |
| 3625 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3626 | } |
| 3627 | |
| 3628 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3629 | errno = hdd_vdev_ready(adapter); |
| 3630 | if (errno) { |
| 3631 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3632 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3633 | } |
| 3634 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3635 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3636 | |
| 3637 | return 0; |
| 3638 | |
| 3639 | /* |
| 3640 | * Due to legacy constraints, we need to destroy in the same order as |
| 3641 | * create. So, split error handling into 2 cases to accommodate. |
| 3642 | */ |
| 3643 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3644 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3645 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3646 | |
| 3647 | return errno; |
| 3648 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3649 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3650 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3651 | |
| 3652 | return errno; |
| 3653 | } |
| 3654 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3655 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3656 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3657 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3658 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3659 | QDF_STATUS status; |
| 3660 | int ret_val; |
| 3661 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3662 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3663 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3664 | 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] | 3665 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3666 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3668 | status = hdd_register_wext(adapter->dev); |
| 3669 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3670 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3671 | goto error_register_wext; |
| 3672 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3673 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3674 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3675 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3676 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3677 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3678 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3679 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3680 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3682 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3683 | hdd_ctx->config->OperatingChannel; |
| 3684 | |
| 3685 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3686 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3687 | |
| 3688 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3689 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3690 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | status, status); |
| 3692 | goto error_init_txrx; |
| 3693 | } |
| 3694 | |
| 3695 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3696 | |
| 3697 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3698 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3699 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | status, status); |
| 3701 | goto error_wmm_init; |
| 3702 | } |
| 3703 | |
| 3704 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3705 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3706 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3707 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3708 | hdd_ctx->config->enableSifsBurst, |
| 3709 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3710 | if (ret_val) |
| 3711 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3712 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3713 | /* |
| 3714 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3715 | * during that time, then as part of SSR init, do not enable |
| 3716 | * the LRO again. Keep the LRO state same as before SSR. |
| 3717 | */ |
| 3718 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3719 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3720 | |
| 3721 | /* rcpi info initialization */ |
| 3722 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3723 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3724 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | error_wmm_init: |
| 3727 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3728 | hdd_deinit_tx_rx(adapter); |
| 3729 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3730 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3731 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3732 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3733 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3734 | return status; |
| 3735 | } |
| 3736 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3737 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3738 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3739 | * @hdd_ctx: global hdd context |
| 3740 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3741 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3742 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3743 | * |
| 3744 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3745 | * |
| 3746 | * Return: None. |
| 3747 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3748 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3749 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3750 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3751 | { |
| 3752 | ENTER_DEV(adapter->dev); |
| 3753 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3754 | if (adapter->dev) { |
| 3755 | if (rtnl_held) |
| 3756 | adapter->dev->wireless_handlers = NULL; |
| 3757 | else { |
| 3758 | rtnl_lock(); |
| 3759 | adapter->dev->wireless_handlers = NULL; |
| 3760 | rtnl_unlock(); |
| 3761 | } |
| 3762 | } |
| 3763 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3764 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3765 | hdd_deinit_tx_rx(adapter); |
| 3766 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3767 | } |
| 3768 | |
| 3769 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3770 | hdd_wmm_adapter_close(adapter); |
| 3771 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3772 | } |
| 3773 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3774 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3775 | EXIT(); |
| 3776 | } |
| 3777 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3778 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 3779 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | bool rtnl_held) |
| 3781 | { |
| 3782 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3783 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3785 | case QDF_STA_MODE: |
| 3786 | case QDF_P2P_CLIENT_MODE: |
| 3787 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3788 | case QDF_IBSS_MODE: |
| 3789 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3790 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3791 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3792 | break; |
| 3793 | } |
| 3794 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3795 | case QDF_SAP_MODE: |
| 3796 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3797 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3798 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | break; |
| 3800 | } |
| 3801 | |
| 3802 | default: |
| 3803 | break; |
| 3804 | } |
| 3805 | |
| 3806 | EXIT(); |
| 3807 | } |
| 3808 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3809 | 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] | 3810 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3811 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3812 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | |
| 3814 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3815 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3816 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3817 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3818 | return; |
| 3819 | } |
| 3820 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3821 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3822 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 3823 | hdd_adapter_runtime_suspend_deinit(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3824 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3825 | /* |
| 3826 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3827 | * the driver is almost closed and cannot handle either control |
| 3828 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3829 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3830 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3831 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3832 | * the interface is closed and restricts any operations on that |
| 3833 | */ |
| 3834 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3835 | |
| 3836 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3837 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3838 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3839 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3840 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3841 | /* |
| 3842 | * Note that the adapter is no longer valid at this point |
| 3843 | * since the memory has been reclaimed |
| 3844 | */ |
| 3845 | } |
| 3846 | } |
| 3847 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3848 | 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] | 3849 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3851 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3852 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3853 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3854 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 3855 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3856 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3857 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3859 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3860 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3861 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3862 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3863 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3864 | /** |
| 3865 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3866 | * @hdd_ctx: HDD Context |
| 3867 | * @adapter: HDD Adapter |
| 3868 | * |
| 3869 | * This function set the FW Debug log level based on the INI. |
| 3870 | * |
| 3871 | * Return: None |
| 3872 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3873 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3874 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3875 | { |
| 3876 | uint8_t count = 0, numentries = 0, |
| 3877 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3878 | uint32_t value = 0; |
| 3879 | int ret; |
| 3880 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3881 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3882 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3883 | 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] | 3884 | return; |
| 3885 | } |
| 3886 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3887 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3888 | hdd_ctx->fw_log_settings.dl_type = |
| 3889 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3890 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3891 | WMI_DBGLOG_TYPE, |
| 3892 | hdd_ctx->config->enableFwLogType, |
| 3893 | DBG_CMD); |
| 3894 | if (ret != 0) |
| 3895 | hdd_err("Failed to enable FW log type ret %d", |
| 3896 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3897 | |
| 3898 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3899 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3900 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3901 | WMI_DBGLOG_LOG_LEVEL, |
| 3902 | hdd_ctx->config->enableFwLogLevel, |
| 3903 | DBG_CMD); |
| 3904 | if (ret != 0) |
| 3905 | hdd_err("Failed to enable FW log level ret %d", |
| 3906 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3907 | |
| 3908 | hdd_string_to_u8_array( |
| 3909 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3910 | moduleloglevel, |
| 3911 | &numentries, |
| 3912 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3913 | |
| 3914 | while (count < numentries) { |
| 3915 | /* |
| 3916 | * FW module log level input string looks like |
| 3917 | * below: |
| 3918 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3919 | * <Log Level>,... |
| 3920 | * For example: |
| 3921 | * gFwDebugModuleLoglevel= |
| 3922 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3923 | * Above input string means : |
| 3924 | * For FW module ID 1 enable log level 0 |
| 3925 | * For FW module ID 2 enable log level 1 |
| 3926 | * For FW module ID 3 enable log level 2 |
| 3927 | * For FW module ID 4 enable log level 3 |
| 3928 | * For FW module ID 5 enable log level 4 |
| 3929 | * For FW module ID 6 enable log level 5 |
| 3930 | * For FW module ID 7 enable log level 6 |
| 3931 | */ |
| 3932 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3933 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3934 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3935 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3936 | moduleloglevel[count], |
| 3937 | moduleloglevel[count + 1]); |
| 3938 | return; |
| 3939 | } |
| 3940 | |
| 3941 | value = moduleloglevel[count] << 16; |
| 3942 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3943 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3944 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3945 | value, DBG_CMD); |
| 3946 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3947 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3948 | value, ret); |
| 3949 | |
| 3950 | count += 2; |
| 3951 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3952 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3953 | } |
| 3954 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3955 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3956 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3957 | { |
| 3958 | } |
| 3959 | |
| 3960 | #endif |
| 3961 | |
| 3962 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 3963 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 3964 | * @adapter: HDD adapter |
| 3965 | * |
| 3966 | * Return: 0 on success or errno on failure |
| 3967 | */ |
| 3968 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 3969 | { |
| 3970 | int ret_val; |
| 3971 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3972 | |
| 3973 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 3974 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 3975 | hdd_ctx->config->txchainmask1x1, |
| 3976 | hdd_ctx->config->rxchainmask1x1); |
| 3977 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 3978 | hdd_ctx->config->dual_mac_feature_disable, |
| 3979 | hdd_ctx->config->tx_chain_mask_2g, |
| 3980 | hdd_ctx->config->rx_chain_mask_2g); |
| 3981 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 3982 | hdd_ctx->config->tx_chain_mask_5g, |
| 3983 | hdd_ctx->config->rx_chain_mask_5g); |
| 3984 | |
| 3985 | if (hdd_ctx->config->enable2x2) { |
| 3986 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 3987 | return 0; |
| 3988 | } |
| 3989 | |
| 3990 | if (hdd_ctx->config->txchainmask1x1) { |
| 3991 | ret_val = sme_cli_set_command(adapter->session_id, |
| 3992 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 3993 | hdd_ctx->config->txchainmask1x1, |
| 3994 | PDEV_CMD); |
| 3995 | if (ret_val) |
| 3996 | goto error; |
| 3997 | } |
| 3998 | |
| 3999 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4000 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4001 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4002 | hdd_ctx->config->rxchainmask1x1, |
| 4003 | PDEV_CMD); |
| 4004 | if (ret_val) |
| 4005 | goto error; |
| 4006 | } |
| 4007 | |
| 4008 | if (hdd_ctx->lte_coex_ant_share) { |
| 4009 | hdd_info("lte ant sharing enabled. skip per band chain mask"); |
| 4010 | return 0; |
| 4011 | } |
| 4012 | |
| 4013 | if (hdd_ctx->config->txchainmask1x1 || |
| 4014 | hdd_ctx->config->rxchainmask1x1) { |
| 4015 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4016 | return 0; |
| 4017 | } |
| 4018 | |
| 4019 | if (!hdd_ctx->config->dual_mac_feature_disable) { |
| 4020 | hdd_info("DBS enabled. skip per band chain mask"); |
| 4021 | return 0; |
| 4022 | } |
| 4023 | |
| 4024 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4025 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4026 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4027 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4028 | if (0 != ret_val) |
| 4029 | goto error; |
| 4030 | } |
| 4031 | |
| 4032 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4033 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4034 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4035 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4036 | if (0 != ret_val) |
| 4037 | goto error; |
| 4038 | } |
| 4039 | |
| 4040 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4041 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4042 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4043 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4044 | if (0 != ret_val) |
| 4045 | goto error; |
| 4046 | } |
| 4047 | |
| 4048 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4049 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4050 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4051 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4052 | if (0 != ret_val) |
| 4053 | goto error; |
| 4054 | } |
| 4055 | |
| 4056 | return 0; |
| 4057 | |
| 4058 | error: |
| 4059 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4060 | return -EINVAL; |
| 4061 | } |
| 4062 | |
| 4063 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4064 | * hdd_set_fw_params() - Set parameters to firmware |
| 4065 | * @adapter: HDD adapter |
| 4066 | * |
| 4067 | * This function Sets various parameters to fw once the |
| 4068 | * adapter is started. |
| 4069 | * |
| 4070 | * Return: 0 on success or errno on failure |
| 4071 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4072 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4073 | { |
| 4074 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4075 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4076 | |
| 4077 | ENTER_DEV(adapter->dev); |
| 4078 | |
| 4079 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4080 | if (!hdd_ctx) |
| 4081 | return -EINVAL; |
| 4082 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4083 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4084 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4085 | return 0; |
| 4086 | } |
| 4087 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4088 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4089 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4090 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4091 | if (ret) { |
| 4092 | hdd_err("Failed to set LPRx"); |
| 4093 | goto error; |
| 4094 | } |
| 4095 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4096 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4097 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4098 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4099 | hdd_ctx->config->upper_brssi_thresh); |
| 4100 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4101 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4102 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4103 | hdd_ctx->config->lower_brssi_thresh); |
| 4104 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4105 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4106 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4107 | hdd_ctx->config->enable_dtim_1chrx); |
| 4108 | } |
| 4109 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4110 | if (hdd_ctx->config->enable2x2) { |
| 4111 | hdd_debug("configuring 2x2 mode fw params"); |
| 4112 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4113 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4114 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4115 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4116 | PDEV_CMD); |
| 4117 | if (ret) { |
| 4118 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4119 | ret); |
| 4120 | goto error; |
| 4121 | } |
| 4122 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4123 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4124 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4125 | hdd_debug("configuring 1x1 mode fw params"); |
| 4126 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4127 | /* |
| 4128 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4129 | * we are passing two value |
| 4130 | * as param_id << 29 | param_value. |
| 4131 | * Below param_value = 0(disable) |
| 4132 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4133 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4134 | WMI_STA_SMPS_PARAM_CMDID, |
| 4135 | HDD_DTIM_1CHAIN_RX_ID << |
| 4136 | HDD_SMPS_PARAM_VALUE_S, |
| 4137 | VDEV_CMD); |
| 4138 | if (ret) { |
| 4139 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4140 | goto error; |
| 4141 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4142 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4143 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4144 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4145 | |
| 4146 | if (hdd_configure_chain_mask(adapter)) |
| 4147 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4148 | } |
| 4149 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4150 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4151 | WMI_PDEV_PARAM_HYST_EN, |
| 4152 | hdd_ctx->config->enableMemDeepSleep, |
| 4153 | PDEV_CMD); |
| 4154 | if (ret) { |
| 4155 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4156 | goto error; |
| 4157 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4158 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4159 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4160 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4161 | hdd_ctx->config->rts_profile, |
| 4162 | VDEV_CMD); |
| 4163 | if (ret) { |
| 4164 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4165 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4166 | } |
| 4167 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4168 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4169 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4170 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4171 | GEN_VDEV_PARAM_AMSDU, |
| 4172 | hdd_ctx->config->max_amsdu_num, |
| 4173 | GEN_CMD); |
| 4174 | if (ret != 0) { |
| 4175 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4176 | goto error; |
| 4177 | } |
| 4178 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4179 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4180 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4181 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4182 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4183 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4184 | error: |
| 4185 | return -EINVAL; |
| 4186 | } |
| 4187 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4188 | /** |
| 4189 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4190 | * @hdd_ctx: global hdd context |
| 4191 | * @session_type: type of the interface to be created |
| 4192 | * @iface_name: User-visible name of the interface |
| 4193 | * @macAddr: MAC address to assign to the interface |
| 4194 | * @name_assign_type: the name of assign type of the netdev |
| 4195 | * @rtnl_held: the rtnl lock hold flag |
| 4196 | * |
| 4197 | * This function open and setup the hdd adpater according to the device |
| 4198 | * type request, assign the name, the mac address assigned, and then prepared |
| 4199 | * the hdd related parameters, queue, lock and ready to start. |
| 4200 | * |
| 4201 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4202 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4203 | 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] | 4204 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4205 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4206 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4207 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4208 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4209 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4210 | |
| 4211 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4212 | /* |
| 4213 | * Max limit reached on the number of vdevs configured by the |
| 4214 | * host. Return error |
| 4215 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4216 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4217 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4218 | return NULL; |
| 4219 | } |
| 4220 | |
| 4221 | if (macAddr == NULL) { |
| 4222 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4223 | 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] | 4224 | return NULL; |
| 4225 | } |
| 4226 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4227 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4228 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4229 | " already exists", |
| 4230 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4231 | return NULL; |
| 4232 | } |
| 4233 | |
| 4234 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4235 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4236 | /* Reset locally administered bit if the device mode is STA */ |
| 4237 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4238 | hdd_info("locally administered bit reset in sta mode: " |
| 4239 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4240 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4241 | case QDF_P2P_CLIENT_MODE: |
| 4242 | case QDF_P2P_DEVICE_MODE: |
| 4243 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4244 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4245 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4246 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4247 | name_assign_type, |
| 4248 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4249 | |
| 4250 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4251 | hdd_err("failed to allocate adapter for session %d", |
| 4252 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | return NULL; |
| 4254 | } |
| 4255 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4256 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4257 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4258 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4260 | else if (QDF_MONITOR_MODE == session_type) |
| 4261 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4262 | else |
| 4263 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4264 | |
| 4265 | adapter->device_mode = session_type; |
| 4266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4267 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4268 | /* |
| 4269 | * Workqueue which gets scheduled in IPv4 notification |
| 4270 | * callback |
| 4271 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4272 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4273 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | |
| 4275 | #ifdef WLAN_NS_OFFLOAD |
| 4276 | /* |
| 4277 | * Workqueue which gets scheduled in IPv6 |
| 4278 | * notification callback. |
| 4279 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4280 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4281 | hdd_ipv6_notifier_work_queue); |
| 4282 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4283 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4284 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4285 | goto err_deinit_adapter_runtime_pm; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4286 | |
| 4287 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4288 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4290 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4291 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4292 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4293 | /* Initialize NAN Data Interface */ |
| 4294 | if (QDF_NDI_MODE == session_type) { |
| 4295 | status = hdd_init_nan_data_mode(adapter); |
| 4296 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4297 | goto err_deinit_adapter_runtime_pm; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4298 | } |
| 4299 | |
| 4300 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4301 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4302 | case QDF_P2P_GO_MODE: |
| 4303 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4304 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4305 | name_assign_type, |
| 4306 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4307 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4308 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4309 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4310 | return NULL; |
| 4311 | } |
| 4312 | |
| 4313 | adapter->wdev.iftype = |
| 4314 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4315 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4316 | NL80211_IFTYPE_P2P_GO; |
| 4317 | adapter->device_mode = session_type; |
| 4318 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4319 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4320 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4321 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4322 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4323 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4324 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4325 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4326 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4327 | |
| 4328 | /* |
| 4329 | * Workqueue which gets scheduled in IPv4 notification |
| 4330 | * callback |
| 4331 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4332 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4333 | hdd_ipv4_notifier_work_queue); |
| 4334 | |
| 4335 | #ifdef WLAN_NS_OFFLOAD |
| 4336 | /* |
| 4337 | * Workqueue which gets scheduled in IPv6 |
| 4338 | * notification callback. |
| 4339 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4340 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4341 | hdd_ipv6_notifier_work_queue); |
| 4342 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4343 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4344 | case QDF_FTM_MODE: |
| 4345 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4346 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4347 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4348 | if (NULL == adapter) { |
| 4349 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4350 | return NULL; |
| 4351 | } |
| 4352 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4353 | adapter->device_mode = session_type; |
| 4354 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4355 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4356 | goto err_deinit_adapter_runtime_pm; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4357 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4358 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4359 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4360 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4361 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4362 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4363 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4364 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4365 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4366 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4367 | return NULL; |
| 4368 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4369 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4370 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4371 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4372 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4373 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4374 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4375 | } |
| 4376 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4377 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4378 | if (NULL != adapter) { |
| 4379 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4380 | adapter = NULL; |
| 4381 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4382 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4383 | return NULL; |
| 4384 | } |
| 4385 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4386 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4387 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4388 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4389 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4390 | /* Adapter successfully added. Increment the vdev count */ |
| 4391 | hdd_ctx->current_intf_count++; |
| 4392 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4393 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4394 | hdd_ctx->current_intf_count); |
| 4395 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4396 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4397 | } |
| 4398 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4399 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4400 | hdd_err("Interface %s wow debug_fs init failed", |
| 4401 | netdev_name(adapter->dev)); |
| 4402 | |
| 4403 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4404 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | |
| 4406 | return adapter; |
| 4407 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4408 | err_deinit_adapter_runtime_pm: |
| 4409 | /* |
| 4410 | * For certain error cases that hdd_alloc_station_adapter() |
| 4411 | * is used to allocate the adapter. |
| 4412 | */ |
| 4413 | hdd_adapter_runtime_suspend_deinit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4414 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4415 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4416 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4417 | |
| 4418 | return NULL; |
| 4419 | } |
| 4420 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4421 | 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] | 4422 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4423 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4424 | /* |
| 4425 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4426 | * |
| 4427 | * The reason is to fix one race condition between |
| 4428 | * bus bandwidth work and cleaning up an adapter. |
| 4429 | * Under some conditions, it is possible for the bus bandwidth |
| 4430 | * work to access a particularly destroyed adapter, leading to |
| 4431 | * use-after-free. |
| 4432 | */ |
| 4433 | hdd_debug("wait for bus bw work to flush"); |
| 4434 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4435 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4436 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4437 | /* cleanup adapter */ |
| 4438 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4439 | adapter->device_mode); |
| 4440 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4441 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4442 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4443 | /* conditionally restart the bw timer */ |
| 4444 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4445 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4446 | /* Adapter removed. Decrement vdev count */ |
| 4447 | if (hdd_ctx->current_intf_count != 0) |
| 4448 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4449 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4450 | /* Fw will take care incase of concurrency */ |
| 4451 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4452 | } |
| 4453 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4454 | /** |
| 4455 | * hdd_close_all_adapters - Close all open adapters |
| 4456 | * @hdd_ctx: Hdd context |
| 4457 | * rtnl_held: True if RTNL lock held |
| 4458 | * |
| 4459 | * Close all open adapters. |
| 4460 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4461 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4462 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4463 | 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] | 4464 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4465 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4466 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | |
| 4468 | ENTER(); |
| 4469 | |
| 4470 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4471 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4472 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4473 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4474 | adapter->mac_addr.bytes); |
| 4475 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4476 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4477 | /* Adapter removed. Decrement vdev count */ |
| 4478 | if (hdd_ctx->current_intf_count != 0) |
| 4479 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4480 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4481 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | |
| 4483 | EXIT(); |
| 4484 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4485 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4486 | } |
| 4487 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4488 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4489 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4490 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4491 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4492 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4493 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4494 | case QDF_STA_MODE: |
| 4495 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4496 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4497 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4498 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4499 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4500 | break; |
| 4501 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4502 | case QDF_SAP_MODE: |
| 4503 | case QDF_P2P_GO_MODE: |
| 4504 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4505 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4506 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4507 | break; |
| 4508 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4509 | case QDF_FTM_MODE: |
| 4510 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | default: |
| 4512 | /* |
| 4513 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4514 | * for these kind of devices |
| 4515 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4516 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4517 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4518 | return; |
| 4519 | } |
| 4520 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4521 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4522 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4523 | updateIE.ieBufferlength = 0; |
| 4524 | updateIE.pAdditionIEBuffer = NULL; |
| 4525 | updateIE.append = true; |
| 4526 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4527 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4528 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4529 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4530 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4531 | } |
| 4532 | } |
| 4533 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4534 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4535 | const bool bCloseSession) |
| 4536 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4537 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4538 | struct hdd_wext_state *pWextState = |
| 4539 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4540 | union iwreq_data wrqu; |
| 4541 | tSirUpdateIE updateIE; |
| 4542 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4543 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4544 | |
| 4545 | ENTER(); |
| 4546 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4547 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4548 | wlan_hdd_netif_queue_control(adapter, |
| 4549 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4550 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4551 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4552 | case QDF_STA_MODE: |
| 4553 | case QDF_P2P_CLIENT_MODE: |
| 4554 | case QDF_IBSS_MODE: |
| 4555 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4556 | case QDF_NDI_MODE: |
| 4557 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4558 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4560 | hdd_is_connecting( |
| 4561 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4562 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4563 | /* |
| 4564 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4565 | * extract from ndi_ctx. |
| 4566 | */ |
| 4567 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4568 | qdf_ret_status = sme_roam_disconnect( |
| 4569 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4570 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4571 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4572 | else if (pWextState->roamProfile.BSSType == |
| 4573 | eCSR_BSS_TYPE_START_IBSS) |
| 4574 | qdf_ret_status = sme_roam_disconnect( |
| 4575 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4576 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4577 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4578 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4579 | qdf_ret_status = |
| 4580 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4581 | hdd_debug("Send disconnected event to userspace"); |
| 4582 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4583 | adapter->dev, true, |
| 4584 | WLAN_REASON_UNSPECIFIED); |
| 4585 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4586 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4587 | qdf_ret_status = sme_roam_disconnect( |
| 4588 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4589 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4590 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4591 | /* success implies disconnect command got |
| 4592 | * queued up successfully |
| 4593 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4594 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4595 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4596 | rc = wait_for_completion_timeout( |
| 4597 | &adapter->disconnect_comp_var, |
| 4598 | msecs_to_jiffies |
| 4599 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4600 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4601 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4602 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4603 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4604 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4605 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4606 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4607 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4608 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4609 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4610 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4611 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4612 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4613 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4614 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4615 | |
| 4616 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4617 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4618 | #endif |
| 4619 | |
| 4620 | hdd_deregister_tx_flow_control(adapter); |
| 4621 | |
| 4622 | #ifdef WLAN_NS_OFFLOAD |
| 4623 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4624 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | #endif |
| 4626 | #endif |
| 4627 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4628 | if (adapter->device_mode == QDF_STA_MODE) |
| 4629 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4630 | adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4631 | /* |
| 4632 | * It is possible that the caller of this function does not |
| 4633 | * wish to close the session |
| 4634 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4635 | if (true == bCloseSession) { |
| 4636 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 4637 | hdd_err("Error: Can't disconnect adapter"); |
| 4638 | return QDF_STATUS_E_FAILURE; |
| 4639 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4640 | hdd_debug("Destroying adapter: %d", |
| 4641 | adapter->session_id); |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4642 | hdd_vdev_destroy(adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4643 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4644 | break; |
| 4645 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4646 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4647 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4648 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4649 | sap_config = &adapter->session.ap.sap_config; |
| 4650 | if (sap_config) |
| 4651 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4652 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4653 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4654 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4655 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4656 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4657 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4658 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4659 | cds_flush_delayed_work( |
| 4660 | &adapter->acs_pending_work); |
| 4661 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4662 | } |
| 4663 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4664 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4665 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4666 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4667 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4668 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4669 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4670 | |
| 4671 | hdd_deregister_tx_flow_control(adapter); |
| 4672 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4673 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4674 | mutex_lock(&hdd_ctx->sap_lock); |
| 4675 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4676 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4677 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4678 | |
| 4679 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4680 | status = wlansap_stop_bss( |
| 4681 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4682 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4683 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4684 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4685 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4686 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4687 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4688 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4689 | qdf_wait_for_event_completion( |
| 4690 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4691 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4692 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4693 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4694 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4695 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | } |
| 4697 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4698 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4699 | } |
| 4700 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4701 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4702 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4703 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4705 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4706 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4707 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4708 | updateIE.ieBufferlength = 0; |
| 4709 | updateIE.pAdditionIEBuffer = NULL; |
| 4710 | updateIE.append = false; |
| 4711 | updateIE.notify = false; |
| 4712 | /* Probe bcn reset */ |
| 4713 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4714 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4715 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4716 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4717 | } |
| 4718 | /* Assoc resp reset */ |
| 4719 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4720 | &updateIE, |
| 4721 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4722 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4723 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4724 | } |
| 4725 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4726 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4727 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4728 | qdf_mem_free(adapter->session.ap.beacon); |
| 4729 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4730 | /* |
| 4731 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4732 | */ |
| 4733 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4734 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4735 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4736 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4737 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4738 | #endif |
| 4739 | |
| 4740 | #ifdef WLAN_NS_OFFLOAD |
| 4741 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4742 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4743 | #endif |
| 4744 | #endif |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4745 | if (true == bCloseSession) { |
| 4746 | hdd_debug("Destroying adapter: %d", |
| 4747 | adapter->session_id); |
| 4748 | hdd_vdev_destroy(adapter); |
| 4749 | } |
| 4750 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4751 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4752 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4753 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4754 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4755 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4756 | break; |
| 4757 | default: |
| 4758 | break; |
| 4759 | } |
| 4760 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4761 | if (adapter->scan_info.default_scan_ies) { |
| 4762 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 4763 | adapter->scan_info.default_scan_ies = NULL; |
| 4764 | } |
| 4765 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | EXIT(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4767 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4768 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | } |
| 4770 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4771 | /** |
| 4772 | * hdd_deinit_all_adapters - deinit all adapters |
| 4773 | * @hdd_ctx: HDD context |
| 4774 | * @rtnl_held: True if RTNL lock held |
| 4775 | * |
| 4776 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4777 | 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] | 4778 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4779 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4780 | |
| 4781 | ENTER(); |
| 4782 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4783 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4784 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4785 | |
| 4786 | EXIT(); |
| 4787 | } |
| 4788 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4789 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx, |
| 4790 | bool close_session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4792 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | |
| 4794 | ENTER(); |
| 4795 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4796 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4797 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4798 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4799 | hdd_stop_adapter(hdd_ctx, adapter, close_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4800 | |
| 4801 | EXIT(); |
| 4802 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4803 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4804 | } |
| 4805 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4806 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 4807 | struct hdd_adapter *adapter) |
| 4808 | { |
| 4809 | switch (adapter->device_mode) { |
| 4810 | case QDF_STA_MODE: |
| 4811 | case QDF_P2P_CLIENT_MODE: |
| 4812 | case QDF_IBSS_MODE: |
| 4813 | case QDF_P2P_DEVICE_MODE: |
| 4814 | case QDF_NDI_MODE: |
| 4815 | wlan_hdd_scan_abort(adapter); |
| 4816 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4817 | if (adapter->device_mode == QDF_STA_MODE) |
| 4818 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4819 | adapter->dev); |
| 4820 | break; |
| 4821 | case QDF_P2P_GO_MODE: |
| 4822 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4823 | break; |
| 4824 | case QDF_SAP_MODE: |
| 4825 | wlan_hdd_undo_acs(adapter); |
| 4826 | break; |
| 4827 | default: |
| 4828 | break; |
| 4829 | } |
| 4830 | } |
| 4831 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4832 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4833 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4834 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4835 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4836 | struct qdf_mac_addr peerMacAddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4837 | |
| 4838 | ENTER(); |
| 4839 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4840 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4841 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4842 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4843 | hdd_notice("Disabling queues for adapter type: %d", |
| 4844 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4845 | |
| 4846 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4847 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4848 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4849 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4850 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4851 | if (hdd_ctx->config->sap_internal_restart && |
| 4852 | adapter->device_mode == QDF_SAP_MODE) { |
| 4853 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4854 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4855 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4856 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4857 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4858 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4859 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4860 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4861 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4862 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4863 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4864 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4865 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4866 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4867 | adapter->session.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4868 | |
| 4869 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4870 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4871 | adapter->device_mode, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4872 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4873 | hdd_wmm_adapter_close(adapter); |
| 4874 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4875 | } |
| 4876 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4877 | if (adapter->device_mode == QDF_STA_MODE) |
| 4878 | hdd_clear_fils_connection_info(adapter); |
| 4879 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4880 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4881 | /* |
| 4882 | * If adapter is SAP, set session ID to invalid |
| 4883 | * since SAP session will be cleanup during SSR. |
| 4884 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4885 | wlansap_set_invalid_session( |
| 4886 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4887 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4888 | wlansap_cleanup_cac_timer( |
| 4889 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4890 | } |
| 4891 | |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4892 | /* Delete peers if any for STA and P2P client modes */ |
| 4893 | if (adapter->device_mode == QDF_STA_MODE || |
| 4894 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4895 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4896 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4897 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4898 | |
| 4899 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4900 | peerMacAddr.bytes); |
| 4901 | } |
| 4902 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4903 | /* Destroy vdev which will be recreated during reinit. */ |
| 4904 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | } |
| 4906 | |
| 4907 | EXIT(); |
| 4908 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4909 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | } |
| 4911 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4912 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4913 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4914 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4915 | bool close_modules = true; |
| 4916 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 4917 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4918 | hdd_info("FTM mode, don't close the module"); |
| 4919 | return false; |
| 4920 | } |
| 4921 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4922 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4923 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 4924 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4925 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4926 | close_modules = false; |
| 4927 | break; |
| 4928 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4929 | } |
| 4930 | |
| 4931 | return close_modules; |
| 4932 | } |
| 4933 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 4934 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4935 | { |
| 4936 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4937 | return true; |
| 4938 | else |
| 4939 | return false; |
| 4940 | } |
| 4941 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4942 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 4943 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4944 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4945 | struct ieee80211_channel *channel, |
| 4946 | const u8 *bssid, const u8 *ssid, |
| 4947 | size_t ssid_len) |
| 4948 | { |
| 4949 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4950 | ssid, ssid_len, |
| 4951 | WLAN_CAPABILITY_ESS, |
| 4952 | WLAN_CAPABILITY_ESS); |
| 4953 | } |
| 4954 | #else |
| 4955 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4956 | struct ieee80211_channel *channel, |
| 4957 | const u8 *bssid, const u8 *ssid, |
| 4958 | size_t ssid_len) |
| 4959 | { |
| 4960 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4961 | ssid, ssid_len, |
| 4962 | IEEE80211_BSS_TYPE_ESS, |
| 4963 | IEEE80211_PRIVACY_ANY); |
| 4964 | } |
| 4965 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4966 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4967 | #if defined CFG80211_CONNECT_BSS || \ |
| 4968 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4969 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4970 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4971 | /** |
| 4972 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4973 | * @timeout_reason: reason for connect timeout |
| 4974 | * |
| 4975 | * This function is used to convert host timeout |
| 4976 | * reason enum to kernel specific enum. |
| 4977 | * |
| 4978 | * Return: nl timeout enum |
| 4979 | */ |
| 4980 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4981 | tSirResultCodes timeout_reason) |
| 4982 | { |
| 4983 | switch (timeout_reason) { |
| 4984 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 4985 | return NL80211_TIMEOUT_SCAN; |
| 4986 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 4987 | return NL80211_TIMEOUT_AUTH; |
| 4988 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 4989 | return NL80211_TIMEOUT_ASSOC; |
| 4990 | default: |
| 4991 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 4992 | } |
| 4993 | } |
| 4994 | |
| 4995 | /** |
| 4996 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 4997 | * @dev: network device |
| 4998 | * @bssid: bssid to which we want to associate |
| 4999 | * @timeout_reason: reason for connect timeout |
| 5000 | * |
| 5001 | * This API is used to send connection timeout reason to supplicant |
| 5002 | * |
| 5003 | * Return: void |
| 5004 | */ |
| 5005 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5006 | const u8 *bssid, |
| 5007 | tSirResultCodes timeout_reason) |
| 5008 | { |
| 5009 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5010 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5011 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5012 | |
| 5013 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5014 | nl_timeout_reason); |
| 5015 | } |
| 5016 | |
| 5017 | /** |
| 5018 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5019 | * @dev: network device |
| 5020 | * @bssid: bssid to which we want to associate |
| 5021 | * @req_ie: Request Information Element |
| 5022 | * @req_ie_len: len of the req IE |
| 5023 | * @resp_ie: Response IE |
| 5024 | * @resp_ie_len: len of ht response IE |
| 5025 | * @status: status |
| 5026 | * @gfp: Kernel Flag |
| 5027 | * @timeout_reason: reason for connect timeout |
| 5028 | * |
| 5029 | * Return: void |
| 5030 | */ |
| 5031 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5032 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5033 | size_t req_ie_len, const u8 *resp_ie, |
| 5034 | size_t resp_ie_len, int status, gfp_t gfp, |
| 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_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5042 | resp_ie, resp_ie_len, status, gfp, |
| 5043 | nl_timeout_reason); |
| 5044 | } |
| 5045 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5046 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5047 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5048 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5049 | const u8 *bssid, |
| 5050 | tSirResultCodes timeout_reason) |
| 5051 | { |
| 5052 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5053 | } |
| 5054 | #endif |
| 5055 | |
| 5056 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5057 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5058 | size_t req_ie_len, const u8 *resp_ie, |
| 5059 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5060 | tSirResultCodes timeout_reason) |
| 5061 | { |
| 5062 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5063 | resp_ie, resp_ie_len, status, gfp); |
| 5064 | } |
| 5065 | #endif |
| 5066 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5067 | /** |
| 5068 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5069 | * @dev: network device |
| 5070 | * @bssid: bssid to which we want to associate |
| 5071 | * @req_ie: Request Information Element |
| 5072 | * @req_ie_len: len of the req IE |
| 5073 | * @resp_ie: Response IE |
| 5074 | * @resp_ie_len: len of ht response IE |
| 5075 | * @status: status |
| 5076 | * @gfp: Kernel Flag |
| 5077 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5078 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5079 | * |
| 5080 | * The API is a wrapper to send connection status to supplicant |
| 5081 | * |
| 5082 | * Return: Void |
| 5083 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5084 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5085 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5086 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5087 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5088 | size_t req_ie_len, const u8 *resp_ie, |
| 5089 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5090 | bool connect_timeout, |
| 5091 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5092 | { |
| 5093 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5094 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5095 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5096 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5097 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5098 | } |
| 5099 | #else |
| 5100 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5101 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5102 | size_t req_ie_len, const u8 *resp_ie, |
| 5103 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5104 | bool connect_timeout, |
| 5105 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5106 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5107 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5108 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5109 | } |
| 5110 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5111 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5112 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5113 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5114 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5115 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5116 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5117 | /** |
| 5118 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5119 | * @fils_params: connect response to supplicant |
| 5120 | * @fils_kek: FILS kek |
| 5121 | * @fils_kek_len: FILS kek length |
| 5122 | * @pmk: FILS PMK |
| 5123 | * @pmk_len: FILS PMK length |
| 5124 | * @pmkid: PMKID |
| 5125 | * @fils_seq_num: FILS Seq number |
| 5126 | * |
| 5127 | * Return: None |
| 5128 | */ |
| 5129 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5130 | *fils_params, const uint8_t *fils_kek, |
| 5131 | size_t fils_kek_len, const uint8_t *pmk, |
| 5132 | size_t pmk_len, const uint8_t *pmkid, |
| 5133 | uint16_t fils_seq_num) |
| 5134 | { |
| 5135 | /* Increament seq number to be used for next FILS */ |
| 5136 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5137 | fils_params->update_erp_next_seq_num = true; |
| 5138 | fils_params->fils_kek = fils_kek; |
| 5139 | fils_params->fils_kek_len = fils_kek_len; |
| 5140 | fils_params->pmk = pmk; |
| 5141 | fils_params->pmk_len = pmk_len; |
| 5142 | fils_params->pmkid = pmkid; |
| 5143 | } |
| 5144 | #else |
| 5145 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5146 | *fils_params, const uint8_t |
| 5147 | *fils_kek, size_t fils_kek_len, |
| 5148 | const uint8_t *pmk, size_t pmk_len, |
| 5149 | const uint8_t *pmkid, |
| 5150 | uint16_t fils_seq_num) |
| 5151 | { } |
| 5152 | #endif |
| 5153 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5154 | void hdd_update_hlp_info(struct net_device *dev, |
| 5155 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5156 | { |
| 5157 | struct sk_buff *skb; |
| 5158 | uint16_t skb_len; |
| 5159 | struct llc_snap_hdr_t *llc_hdr; |
| 5160 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5161 | uint8_t *hlp_data; |
| 5162 | uint16_t hlp_data_len; |
| 5163 | struct fils_join_rsp_params *roam_fils_params |
| 5164 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5165 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5166 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5167 | if (!roam_fils_params) { |
| 5168 | hdd_err("FILS Roam Param NULL"); |
| 5169 | return; |
| 5170 | } |
| 5171 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5172 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5173 | hdd_err("FILS HLP Data NULL, len %d", |
| 5174 | roam_fils_params->hlp_data_len); |
| 5175 | return; |
| 5176 | } |
| 5177 | |
| 5178 | hlp_data = roam_fils_params->hlp_data; |
| 5179 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5180 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5181 | /* Calculate skb length */ |
| 5182 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5183 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5184 | if (skb == NULL) { |
| 5185 | hdd_err("HLP packet nbuf alloc fails"); |
| 5186 | return; |
| 5187 | } |
| 5188 | |
| 5189 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5190 | QDF_MAC_ADDR_SIZE); |
| 5191 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5192 | QDF_MAC_ADDR_SIZE); |
| 5193 | |
| 5194 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5195 | if (IS_SNAP(llc_hdr)) { |
| 5196 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5197 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5198 | } |
| 5199 | |
| 5200 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5201 | |
| 5202 | /* |
| 5203 | * This HLP packet is formed from HLP info encapsulated |
| 5204 | * in assoc response frame which is AEAD encrypted. |
| 5205 | * Hence, this checksum validation can be set unnecessary. |
| 5206 | * i.e. network layer need not worry about checksum. |
| 5207 | */ |
| 5208 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5209 | |
| 5210 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5211 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5212 | hdd_err("Sending HLP packet fails"); |
| 5213 | return; |
| 5214 | } |
| 5215 | hdd_debug("send HLP packet to netif successfully"); |
| 5216 | } |
| 5217 | |
| 5218 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5219 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5220 | * @dev: network device |
| 5221 | * @bssid: bssid to which we want to associate |
| 5222 | * @bss: cfg80211 bss info |
| 5223 | * @roam_info: information about connected bss |
| 5224 | * @req_ie: Request Information Element |
| 5225 | * @req_ie_len: len of the req IE |
| 5226 | * @resp_ie: Response IE |
| 5227 | * @resp_ie_len: len of ht response IE |
| 5228 | * @status: status |
| 5229 | * @gfp: allocation flags |
| 5230 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5231 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5232 | * |
| 5233 | * This API is used as wrapper to send FILS key/sequence number |
| 5234 | * params etc. to supplicant in case of FILS connection |
| 5235 | * |
| 5236 | * Return: None |
| 5237 | */ |
| 5238 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5239 | struct cfg80211_bss *bss, |
| 5240 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5241 | const u8 *req_ie, size_t req_ie_len, |
| 5242 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5243 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5244 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5245 | { |
| 5246 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5247 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5248 | struct fils_join_rsp_params *roam_fils_params = |
| 5249 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5250 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5251 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5252 | |
| 5253 | if (!roam_fils_params) { |
| 5254 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5255 | } else { |
| 5256 | fils_params.status = status; |
| 5257 | fils_params.bssid = bssid; |
| 5258 | fils_params.timeout_reason = timeout_reason; |
| 5259 | fils_params.req_ie = req_ie; |
| 5260 | fils_params.req_ie_len = req_ie_len; |
| 5261 | fils_params.resp_ie = resp_ie; |
| 5262 | fils_params.resp_ie_len = resp_ie_len; |
| 5263 | fils_params.bss = bss; |
| 5264 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5265 | roam_fils_params->kek_len, |
| 5266 | roam_fils_params->fils_pmk, |
| 5267 | roam_fils_params->fils_pmk_len, |
| 5268 | roam_fils_params->fils_pmkid, |
| 5269 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5270 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5271 | } |
| 5272 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5273 | fils_params.status, |
| 5274 | fils_params.fils_erp_next_seq_num); |
| 5275 | |
| 5276 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5277 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5278 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5279 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5280 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5281 | /* Clear all the FILS key info */ |
| 5282 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5283 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5284 | if (roam_fils_params) |
| 5285 | qdf_mem_free(roam_fils_params); |
| 5286 | roam_info->fils_join_rsp = NULL; |
| 5287 | } |
| 5288 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5289 | static inline void |
| 5290 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5291 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5292 | const u8 *req_ie, size_t req_ie_len, |
| 5293 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5294 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5295 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5296 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5297 | #endif |
| 5298 | #endif |
| 5299 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5300 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5301 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5302 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5303 | /** |
| 5304 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5305 | * supplicant. |
| 5306 | * @dev: network device |
| 5307 | * @bssid: bssid to which we want to associate |
| 5308 | * @bss: cfg80211 bss info |
| 5309 | * @roam_info: information about connected bss |
| 5310 | * @req_ie: Request Information Element |
| 5311 | * @req_ie_len: len of the req IE |
| 5312 | * @resp_ie: Response IE |
| 5313 | * @resp_ie_len: len of ht response IE |
| 5314 | * @status: status |
| 5315 | * @gfp: allocation flags |
| 5316 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5317 | * @timeout_reason: reason for connect timeout |
| 5318 | * |
| 5319 | * The API is a wrapper to send connection status to supplicant |
| 5320 | * |
| 5321 | * Return: 0 if success else failure |
| 5322 | */ |
| 5323 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5324 | const u8 *bssid, |
| 5325 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5326 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5327 | size_t req_ie_len, const u8 *resp_ie, |
| 5328 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5329 | bool connect_timeout, |
| 5330 | tSirResultCodes timeout_reason) |
| 5331 | { |
| 5332 | ENTER(); |
| 5333 | if (!roam_info || !roam_info->is_fils_connection) |
| 5334 | return -EINVAL; |
| 5335 | |
| 5336 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5337 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5338 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5339 | return 0; |
| 5340 | } |
| 5341 | #else |
| 5342 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5343 | const u8 *bssid, |
| 5344 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5345 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5346 | size_t req_ie_len, const u8 *resp_ie, |
| 5347 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5348 | bool connect_timeout, |
| 5349 | tSirResultCodes timeout_reason) |
| 5350 | { |
| 5351 | return -EINVAL; |
| 5352 | } |
| 5353 | #endif |
| 5354 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5355 | /** |
| 5356 | * hdd_connect_result() - API to send connection status to supplicant |
| 5357 | * @dev: network device |
| 5358 | * @bssid: bssid to which we want to associate |
| 5359 | * @roam_info: information about connected bss |
| 5360 | * @req_ie: Request Information Element |
| 5361 | * @req_ie_len: len of the req IE |
| 5362 | * @resp_ie: Response IE |
| 5363 | * @resp_ie_len: len of ht response IE |
| 5364 | * @status: status |
| 5365 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5366 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5367 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5368 | * |
| 5369 | * The API is a wrapper to send connection status to supplicant |
| 5370 | * and allow runtime suspend |
| 5371 | * |
| 5372 | * Return: Void |
| 5373 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5374 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5375 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5376 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5377 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5378 | bool connect_timeout, |
| 5379 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5380 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5381 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5382 | struct cfg80211_bss *bss = NULL; |
| 5383 | |
| 5384 | if (WLAN_STATUS_SUCCESS == status) { |
| 5385 | struct ieee80211_channel *chan; |
| 5386 | int freq; |
| 5387 | int chan_no = roam_info->pBssDesc->channelId; |
| 5388 | |
| 5389 | if (chan_no <= 14) |
| 5390 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5391 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5392 | else |
| 5393 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5394 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5395 | |
| 5396 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5397 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5398 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5399 | roam_info->u.pConnectedProfile->SSID.length); |
| 5400 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5401 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5402 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5403 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5404 | resp_ie_len, status, gfp, connect_timeout, |
| 5405 | timeout_reason) != 0) { |
| 5406 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5407 | req_ie_len, resp_ie, resp_ie_len, |
| 5408 | status, gfp, connect_timeout, timeout_reason); |
| 5409 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5410 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5411 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5412 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5413 | } |
| 5414 | #else |
| 5415 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5416 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5417 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5418 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5419 | bool connect_timeout, |
| 5420 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5421 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5422 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5423 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5424 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5425 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5426 | |
| 5427 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5428 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5429 | } |
| 5430 | #endif |
| 5431 | |
| 5432 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5433 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5434 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5435 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5436 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5437 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5438 | #endif |
| 5439 | eConnectionState connState; |
| 5440 | |
| 5441 | ENTER(); |
| 5442 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5443 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5444 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5445 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5446 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5447 | hdd_wmm_init(adapter); |
| 5448 | |
| 5449 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5450 | case QDF_STA_MODE: |
| 5451 | case QDF_P2P_CLIENT_MODE: |
| 5452 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5453 | |
| 5454 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5455 | ->conn_info.connState; |
| 5456 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5457 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5458 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5459 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5460 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5461 | /* Indicate disconnect event to supplicant |
| 5462 | * if associated previously |
| 5463 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5464 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5465 | eConnectionState_IbssConnected == connState || |
| 5466 | eConnectionState_NotConnected == connState || |
| 5467 | eConnectionState_IbssDisconnected == connState || |
| 5468 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5469 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5470 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5471 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5472 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5473 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5474 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5475 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5476 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5477 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5478 | |
| 5479 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5480 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5481 | adapter->dev, false, |
| 5482 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5483 | } else if (eConnectionState_Connecting == connState) { |
| 5484 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5485 | * Indicate connect failure to supplicant if we |
| 5486 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5487 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5488 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5489 | NULL, 0, NULL, 0, |
| 5490 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5491 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5492 | } |
| 5493 | |
| 5494 | hdd_register_tx_flow_control(adapter, |
| 5495 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5496 | hdd_tx_resume_cb, |
| 5497 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5498 | |
| 5499 | break; |
| 5500 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5501 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5502 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5503 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5504 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5505 | break; |
| 5506 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5507 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5508 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5509 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5510 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5511 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5512 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5513 | /* event supplicant to restart */ |
| 5514 | cfg80211_del_sta(adapter->dev, |
| 5515 | (const u8 *)&bcastMac.bytes[0], |
| 5516 | GFP_KERNEL); |
| 5517 | #endif |
| 5518 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5519 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5520 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5521 | hdd_set_mon_rx_cb(adapter->dev); |
| 5522 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5523 | adapter->mon_bandwidth); |
| 5524 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5525 | default: |
| 5526 | break; |
| 5527 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5528 | /* |
| 5529 | * Action frame registered in one adapter which will |
| 5530 | * applicable to all interfaces |
| 5531 | */ |
| 5532 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5533 | } |
| 5534 | |
| 5535 | EXIT(); |
| 5536 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5537 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5538 | } |
| 5539 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5540 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5541 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5542 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5543 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5544 | qdf_list_node_t *node; |
| 5545 | |
| 5546 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5547 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5548 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5549 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5550 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5551 | |
| 5552 | if (QDF_IS_STATUS_ERROR(status)) |
| 5553 | return status; |
| 5554 | |
| 5555 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5556 | |
| 5557 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5558 | } |
| 5559 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5560 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5561 | struct hdd_adapter *current_adapter, |
| 5562 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5563 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5564 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5565 | qdf_list_node_t *node; |
| 5566 | |
| 5567 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5568 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5569 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5570 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5571 | ¤t_adapter->node, |
| 5572 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5573 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5574 | |
| 5575 | if (QDF_IS_STATUS_ERROR(status)) |
| 5576 | return status; |
| 5577 | |
| 5578 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5579 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5580 | return status; |
| 5581 | } |
| 5582 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5583 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5584 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5585 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5586 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5587 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5588 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5589 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5590 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5591 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5592 | return status; |
| 5593 | } |
| 5594 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5595 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5596 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5597 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5598 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5599 | qdf_list_node_t *node; |
| 5600 | |
| 5601 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5602 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5603 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5604 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5605 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5606 | |
| 5607 | if (QDF_IS_STATUS_ERROR(status)) |
| 5608 | return status; |
| 5609 | |
| 5610 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5611 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | return status; |
| 5613 | } |
| 5614 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5615 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5616 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5617 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5618 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5619 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5620 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5621 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5622 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5623 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5624 | return status; |
| 5625 | } |
| 5626 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5627 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5628 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5629 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5630 | QDF_STATUS status; |
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_insert_front(&hdd_ctx->hdd_adapters, &adapter->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 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5636 | return status; |
| 5637 | } |
| 5638 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5639 | 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] | 5640 | tSirMacAddr macAddr) |
| 5641 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5642 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5643 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5644 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5645 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5646 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5647 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5648 | } |
| 5649 | |
| 5650 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5651 | } |
| 5652 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5653 | 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] | 5654 | uint32_t vdev_id) |
| 5655 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5656 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5658 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5659 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5660 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5661 | } |
| 5662 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5663 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5664 | |
| 5665 | return NULL; |
| 5666 | } |
| 5667 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5668 | /** |
| 5669 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5670 | * the sessionid |
| 5671 | * @hdd_ctx: hdd context. |
| 5672 | * @sme_session_id: sme session is for the adapter to get. |
| 5673 | * |
| 5674 | * This function is used to get the adapter with provided session id |
| 5675 | * |
| 5676 | * Return: adapter pointer if found |
| 5677 | * |
| 5678 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5679 | struct hdd_adapter * |
| 5680 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5681 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5682 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5683 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5684 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5685 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5686 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5687 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5688 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5689 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5690 | return NULL; |
| 5691 | } |
| 5692 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5693 | 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] | 5694 | const char *iface_name) |
| 5695 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5696 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5697 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5698 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5699 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5700 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5701 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5702 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5703 | return NULL; |
| 5704 | } |
| 5705 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5706 | /** |
| 5707 | * hdd_get_adapter() - to get adapter matching the mode |
| 5708 | * @hdd_ctx: hdd context |
| 5709 | * @mode: adapter mode |
| 5710 | * |
| 5711 | * This routine will return the pointer to adapter matching |
| 5712 | * with the passed mode. |
| 5713 | * |
| 5714 | * Return: pointer to adapter or null |
| 5715 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5716 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5717 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5718 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5719 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5720 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5721 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5722 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5723 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5724 | } |
| 5725 | |
| 5726 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5727 | } |
| 5728 | |
| 5729 | /** |
| 5730 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5731 | * @hdd_ctx: Pointer to the HDD context. |
| 5732 | * @mode: Device mode for which operating channel is required. |
| 5733 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5734 | * QDF_STA_MODE, |
| 5735 | * QDF_P2P_CLIENT_MODE, |
| 5736 | * QDF_SAP_MODE, |
| 5737 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5738 | * |
| 5739 | * This API returns the operating channel of the requested device mode |
| 5740 | * |
| 5741 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5742 | * not connected. |
| 5743 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5744 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5745 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5746 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5747 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5748 | uint8_t operatingChannel = 0; |
| 5749 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5750 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5751 | if (mode == adapter->device_mode) { |
| 5752 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5753 | case QDF_STA_MODE: |
| 5754 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5755 | if (hdd_conn_is_connected |
| 5756 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5757 | (adapter))) { |
| 5758 | operatingChannel = |
| 5759 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5760 | (adapter))->conn_info. |
| 5761 | operationChannel; |
| 5762 | } |
| 5763 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5764 | case QDF_SAP_MODE: |
| 5765 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5766 | /* softap connection info */ |
| 5767 | if (test_bit |
| 5768 | (SOFTAP_BSS_STARTED, |
| 5769 | &adapter->event_flags)) |
| 5770 | operatingChannel = |
| 5771 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 5772 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5773 | break; |
| 5774 | default: |
| 5775 | break; |
| 5776 | } |
| 5777 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5778 | /* Found the device of interest. break the loop */ |
| 5779 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5780 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5781 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5782 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5783 | return operatingChannel; |
| 5784 | } |
| 5785 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5786 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5787 | hdd_ctx) |
| 5788 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5789 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5790 | |
| 5791 | ENTER(); |
| 5792 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5793 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5794 | if (adapter->device_mode == QDF_STA_MODE || |
| 5795 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5796 | adapter->device_mode == QDF_IBSS_MODE || |
| 5797 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5798 | adapter->device_mode == QDF_SAP_MODE || |
| 5799 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5800 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5801 | hdd_unregister_wext(adapter->dev); |
| 5802 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5803 | } |
| 5804 | |
| 5805 | EXIT(); |
| 5806 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5807 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5808 | } |
| 5809 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5810 | 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] | 5811 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5812 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5813 | |
| 5814 | ENTER(); |
| 5815 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5816 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5817 | if (adapter->device_mode == QDF_STA_MODE || |
| 5818 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5819 | adapter->device_mode == QDF_IBSS_MODE || |
| 5820 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5821 | adapter->device_mode == QDF_SAP_MODE || |
| 5822 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5823 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5824 | adapter->session_id, INVALID_SCAN_ID, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5825 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5826 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5827 | } |
| 5828 | |
| 5829 | EXIT(); |
| 5830 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5831 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5832 | } |
| 5833 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5834 | /** |
| 5835 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5836 | * adapters |
| 5837 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5838 | * |
| 5839 | * return: QDF_STATUS_SUCCESS |
| 5840 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5841 | 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] | 5842 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5843 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5844 | int err; |
| 5845 | |
| 5846 | ENTER(); |
| 5847 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5848 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5849 | if (adapter->device_mode == QDF_STA_MODE || |
| 5850 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5851 | adapter->device_mode == QDF_IBSS_MODE || |
| 5852 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5853 | adapter->device_mode == QDF_SAP_MODE || |
| 5854 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5855 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5856 | if (err) |
| 5857 | hdd_err("Unable to stop scheduled scan"); |
| 5858 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5859 | } |
| 5860 | |
| 5861 | EXIT(); |
| 5862 | |
| 5863 | return QDF_STATUS_SUCCESS; |
| 5864 | } |
| 5865 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5866 | #ifdef WLAN_NS_OFFLOAD |
| 5867 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5868 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5869 | * @hdd_ctx: Pointer to hdd context |
| 5870 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5871 | * Unregister for IPv6 address change notifications. |
| 5872 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5873 | * Return: None |
| 5874 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5875 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5876 | { |
| 5877 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5878 | } |
| 5879 | |
| 5880 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5881 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5882 | * @hdd_ctx: Pointer to hdd context |
| 5883 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5884 | * Register for IPv6 address change notifications. |
| 5885 | * |
| 5886 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5887 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5888 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5889 | { |
| 5890 | int ret; |
| 5891 | |
| 5892 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5893 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5894 | if (ret) { |
| 5895 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5896 | goto out; |
| 5897 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5898 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5899 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5900 | out: |
| 5901 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5902 | } |
| 5903 | #else |
| 5904 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5905 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5906 | * @hdd_ctx: Pointer to hdd context |
| 5907 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5908 | * Unregister for IPv6 address change notifications. |
| 5909 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5910 | * Return: None |
| 5911 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5912 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5913 | { |
| 5914 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5915 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5916 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5917 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5918 | * @hdd_ctx: Pointer to hdd context |
| 5919 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5920 | * Register for IPv6 address change notifications. |
| 5921 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5922 | * Return: None |
| 5923 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5924 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5925 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5926 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5927 | } |
| 5928 | #endif |
| 5929 | |
| 5930 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5931 | * hdd_register_notifiers - Register netdev notifiers. |
| 5932 | * @hdd_ctx: HDD context |
| 5933 | * |
| 5934 | * Register netdev notifiers like IPv4 and IPv6. |
| 5935 | * |
| 5936 | * Return: 0 on success and errno on failure |
| 5937 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5938 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5939 | { |
| 5940 | int ret; |
| 5941 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5942 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5943 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5944 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5945 | |
| 5946 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5947 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5948 | if (ret) { |
| 5949 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5950 | goto unregister_ip6_notifier; |
| 5951 | } |
| 5952 | |
| 5953 | return 0; |
| 5954 | |
| 5955 | unregister_ip6_notifier: |
| 5956 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5957 | out: |
| 5958 | return ret; |
| 5959 | |
| 5960 | } |
| 5961 | |
| 5962 | /** |
| 5963 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5964 | * @hdd_ctx: HDD context |
| 5965 | * |
| 5966 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5967 | * |
| 5968 | * Return: None. |
| 5969 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5970 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5971 | { |
| 5972 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5973 | |
| 5974 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5975 | } |
| 5976 | |
| 5977 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5978 | * hdd_exit_netlink_services - Exit netlink services |
| 5979 | * @hdd_ctx: HDD context |
| 5980 | * |
| 5981 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5982 | * nl service. |
| 5983 | * |
| 5984 | * Return: None. |
| 5985 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5986 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5987 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5988 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 5989 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5990 | ptt_sock_deactivate_svc(); |
| 5991 | |
| 5992 | nl_srv_exit(); |
| 5993 | } |
| 5994 | |
| 5995 | /** |
| 5996 | * hdd_init_netlink_services- Init netlink services |
| 5997 | * @hdd_ctx: HDD context |
| 5998 | * |
| 5999 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6000 | * nl service. |
| 6001 | * |
| 6002 | * Return: 0 on success and errno on failure. |
| 6003 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6004 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6005 | { |
| 6006 | int ret; |
| 6007 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6008 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6009 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6010 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6011 | goto out; |
| 6012 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6013 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6014 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6015 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6016 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6017 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6018 | goto err_nl_srv; |
| 6019 | } |
| 6020 | |
| 6021 | ret = ptt_sock_activate_svc(); |
| 6022 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6023 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6024 | goto err_nl_srv; |
| 6025 | } |
| 6026 | |
| 6027 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6028 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6029 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6030 | |
| 6031 | ret = cnss_diag_activate_service(); |
| 6032 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6033 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6034 | goto err_close_cesium; |
| 6035 | } |
| 6036 | |
| 6037 | return 0; |
| 6038 | |
| 6039 | err_close_cesium: |
| 6040 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6041 | ptt_sock_deactivate_svc(); |
| 6042 | err_nl_srv: |
| 6043 | nl_srv_exit(); |
| 6044 | out: |
| 6045 | return ret; |
| 6046 | } |
| 6047 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6048 | /** |
| 6049 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6050 | * @hdd_ctx: HDD context. |
| 6051 | * |
| 6052 | * Destroy RX wakelock. |
| 6053 | * |
| 6054 | * Return: None. |
| 6055 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6056 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6057 | { |
| 6058 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6059 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6060 | |
| 6061 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6062 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6063 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6064 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6065 | * Create RX wakelock. |
| 6066 | * |
| 6067 | * Return: None. |
| 6068 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6069 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6070 | { |
| 6071 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6072 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6073 | |
| 6074 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6075 | * hdd_context_deinit() - Deinitialize HDD context |
| 6076 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6077 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6078 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6079 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6080 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6081 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6082 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6083 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6084 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6085 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6086 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6087 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6088 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6089 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6090 | hdd_sap_context_destroy(hdd_ctx); |
| 6091 | |
| 6092 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6093 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6094 | hdd_scan_context_destroy(hdd_ctx); |
| 6095 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6096 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6097 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6098 | return 0; |
| 6099 | } |
| 6100 | |
| 6101 | /** |
| 6102 | * hdd_context_destroy() - Destroy HDD context |
| 6103 | * @hdd_ctx: HDD context to be destroyed. |
| 6104 | * |
| 6105 | * Free config and HDD context as well as destroy all the resources. |
| 6106 | * |
| 6107 | * Return: None |
| 6108 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6109 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6110 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6111 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6112 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6113 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6114 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6115 | hdd_context_deinit(hdd_ctx); |
| 6116 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6117 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6118 | hdd_ctx->config = NULL; |
| 6119 | |
| 6120 | wiphy_free(hdd_ctx->wiphy); |
| 6121 | } |
| 6122 | |
| 6123 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6124 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6125 | * |
| 6126 | * This function is used to destroy bug report lock |
| 6127 | * |
| 6128 | * Return: None |
| 6129 | */ |
| 6130 | static void wlan_destroy_bug_report_lock(void) |
| 6131 | { |
| 6132 | p_cds_contextType p_cds_context; |
| 6133 | |
| 6134 | p_cds_context = cds_get_global_context(); |
| 6135 | if (!p_cds_context) { |
| 6136 | hdd_err("cds context is NULL"); |
| 6137 | return; |
| 6138 | } |
| 6139 | |
| 6140 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6141 | } |
| 6142 | |
| 6143 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6144 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6145 | * @hdd_ctx: Pointer to the HDD Context |
| 6146 | * |
| 6147 | * This is the driver exit point (invoked during rmmod) |
| 6148 | * |
| 6149 | * Return: None |
| 6150 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6151 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6152 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6153 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6154 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6155 | |
| 6156 | ENTER(); |
| 6157 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6158 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6159 | |
| 6160 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6161 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6162 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6163 | |
| 6164 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6165 | if (QDF_TIMER_STATE_RUNNING == |
| 6166 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6167 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | } |
| 6169 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6170 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6171 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6172 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6173 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6174 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6175 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6176 | hdd_ctx->last_acs_channel_list = NULL; |
| 6177 | hdd_ctx->num_of_channels = 0; |
| 6178 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6179 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6180 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6181 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6182 | driver_status = hdd_ctx->driver_status; |
| 6183 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6184 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6185 | /* |
| 6186 | * Powersave Offload Case |
| 6187 | * Disable Idle Power Save Mode |
| 6188 | */ |
| 6189 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6190 | /* clear the scan queue in all the scenarios */ |
| 6191 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6192 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6193 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6194 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6195 | /* |
| 6196 | * Cancel any outstanding scan requests. We are about to close |
| 6197 | * all of our adapters, but an adapter structure is what SME |
| 6198 | * passes back to our callback function. Hence if there |
| 6199 | * are any outstanding scan requests then there is a |
| 6200 | * race condition between when the adapter is closed and |
| 6201 | * when the callback is invoked. We try to resolve that |
| 6202 | * race condition here by canceling any outstanding scans |
| 6203 | * before we close the adapters. |
| 6204 | * Note that the scans may be cancelled in an asynchronous |
| 6205 | * manner, so ideally there needs to be some kind of |
| 6206 | * synchronization. Rather than introduce a new |
| 6207 | * synchronization here, we will utilize the fact that we are |
| 6208 | * about to Request Full Power, and since that is synchronized, |
| 6209 | * the expectation is that by the time Request Full Power has |
| 6210 | * completed, all scans will be cancelled |
| 6211 | */ |
| 6212 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6213 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 6214 | hdd_stop_all_adapters(hdd_ctx, true); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6215 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6216 | } |
| 6217 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6218 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6219 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6220 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6221 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6222 | memdump_deinit(); |
| 6223 | hdd_driver_memdump_deinit(); |
| 6224 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6225 | qdf_nbuf_deinit_replenish_timer(); |
| 6226 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6227 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6228 | hdd_info("Release wakelock for monitor mode!"); |
| 6229 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6230 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6231 | } |
| 6232 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6233 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6234 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6235 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6236 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6237 | /* |
| 6238 | * Close CDS |
| 6239 | * This frees pMac(HAL) context. There should not be any call |
| 6240 | * that requires pMac access after this. |
| 6241 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6242 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 6243 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6244 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6245 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6246 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6247 | |
| 6248 | hdd_ipa_cleanup(hdd_ctx); |
| 6249 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6250 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6251 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6252 | /* |
| 6253 | * If there is re_init failure wiphy would have already de-registered |
| 6254 | * check the wiphy status before un-registering again |
| 6255 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6256 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6257 | wiphy_unregister(wiphy); |
| 6258 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6259 | hdd_lpass_notify_stop(hdd_ctx); |
| 6260 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6261 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6262 | hdd_exit_netlink_services(hdd_ctx); |
| 6263 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6264 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6265 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6266 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6267 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6268 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6269 | if (driver_status) |
| 6270 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6271 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6272 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6273 | } |
| 6274 | |
| 6275 | void __hdd_wlan_exit(void) |
| 6276 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6277 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6278 | |
| 6279 | ENTER(); |
| 6280 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6281 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6282 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6283 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6284 | EXIT(); |
| 6285 | return; |
| 6286 | } |
| 6287 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | /* Do all the cleanup before deregistering the driver */ |
| 6289 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6290 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6291 | EXIT(); |
| 6292 | } |
| 6293 | |
| 6294 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6295 | /** |
| 6296 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6297 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6298 | * |
| 6299 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6300 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6301 | * scan information. |
| 6302 | * |
| 6303 | * Return: void |
| 6304 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6305 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6306 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6307 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6308 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6309 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6311 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6312 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6313 | hdd_ctx->last_acs_channel_list = NULL; |
| 6314 | hdd_ctx->num_of_channels = 0; |
| 6315 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6316 | |
| 6317 | if (!hdd_ctx->hHal) |
| 6318 | return; |
| 6319 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6320 | } |
| 6321 | #endif |
| 6322 | |
| 6323 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6324 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6325 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6326 | { |
| 6327 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6328 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6329 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6330 | |
| 6331 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6332 | |
| 6333 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6334 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6335 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6337 | if (!hdd_ctx->hHal) |
| 6338 | return -EINVAL; |
| 6339 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6340 | 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] | 6341 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6342 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6343 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6344 | return -EINVAL; |
| 6345 | } |
| 6346 | |
| 6347 | return 0; |
| 6348 | } |
| 6349 | #endif |
| 6350 | |
| 6351 | /** |
| 6352 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6353 | * @state: state |
| 6354 | * |
| 6355 | * This function notifies FW with modem power status |
| 6356 | * |
| 6357 | * Return: 0 if successful, error number otherwise |
| 6358 | */ |
| 6359 | int hdd_wlan_notify_modem_power_state(int state) |
| 6360 | { |
| 6361 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6362 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6363 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6364 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6365 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6367 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6368 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6369 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6370 | if (!hdd_ctx->hHal) |
| 6371 | return -EINVAL; |
| 6372 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6373 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6374 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6375 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6376 | state); |
| 6377 | return -EINVAL; |
| 6378 | } |
| 6379 | return 0; |
| 6380 | } |
| 6381 | |
| 6382 | /** |
| 6383 | * |
| 6384 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6385 | * @adapter - Pointer to the HDD |
| 6386 | * |
| 6387 | * Return: None |
| 6388 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6389 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6390 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6391 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6392 | |
| 6393 | /* |
| 6394 | * Send ready indication to the HDD. This will kick off the MAC |
| 6395 | * into a 'running' state and should kick off an initial scan. |
| 6396 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6397 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6398 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6399 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6400 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6401 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6402 | } |
| 6403 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6404 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6405 | } |
| 6406 | |
| 6407 | /* wake lock APIs for HDD */ |
| 6408 | void hdd_prevent_suspend(uint32_t reason) |
| 6409 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6410 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6411 | } |
| 6412 | |
| 6413 | void hdd_allow_suspend(uint32_t reason) |
| 6414 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6415 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6416 | } |
| 6417 | |
| 6418 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6419 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6420 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6421 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6422 | } |
| 6423 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6424 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6425 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6427 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6428 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6429 | hdd_ctx->reg.alpha2, |
| 6430 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6431 | } |
| 6432 | |
| 6433 | /** |
| 6434 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6435 | * @hdd_ctx: Pointer to the hdd context |
| 6436 | * |
| 6437 | * HDD function to know if hardware supports 5GHz |
| 6438 | * |
| 6439 | * Return: true if hardware supports 5GHz |
| 6440 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6441 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6442 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6443 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6444 | return true; |
| 6445 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6446 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6447 | return true; |
| 6448 | else |
| 6449 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | } |
| 6451 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6452 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6453 | { |
| 6454 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6455 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6456 | |
| 6457 | wiphy = hdd_ctx->wiphy; |
| 6458 | |
| 6459 | /* |
| 6460 | * The channel information in |
| 6461 | * wiphy needs to be initialized before wiphy registration |
| 6462 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6463 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6464 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6465 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6466 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | } |
| 6468 | |
| 6469 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6470 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6471 | #else |
| 6472 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6473 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6474 | WIPHY_WOWLAN_DISCONNECT | |
| 6475 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6476 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6477 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6478 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6479 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6480 | |
| 6481 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6482 | WOW_MAX_FILTERS_PER_LIST); |
| 6483 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6484 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6485 | #endif |
| 6486 | |
| 6487 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6488 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6489 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6490 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6491 | return ret_val; |
| 6492 | } |
| 6493 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6494 | if (!hdd_ctx->reg_offload) |
| 6495 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6497 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | } |
| 6499 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6500 | #ifdef MSM_PLATFORM |
| 6501 | /** |
| 6502 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6503 | * @hdd_ctx - handle to hdd context |
| 6504 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6505 | * |
| 6506 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6507 | * Stats show up in wlan driver logs. |
| 6508 | * |
| 6509 | * Returns: None |
| 6510 | */ |
| 6511 | static inline |
| 6512 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6513 | bool data_in_interval) |
| 6514 | { |
| 6515 | static u32 counter; |
| 6516 | static bool data_in_time_period; |
| 6517 | ol_txrx_pdev_handle pdev; |
| 6518 | |
| 6519 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6520 | return; |
| 6521 | |
| 6522 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6523 | if (!pdev) { |
| 6524 | hdd_err("pdev is NULL"); |
| 6525 | return; |
| 6526 | } |
| 6527 | |
| 6528 | counter++; |
| 6529 | if (data_in_interval) |
| 6530 | data_in_time_period = data_in_interval; |
| 6531 | |
| 6532 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6533 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6534 | if (data_in_time_period) { |
| 6535 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6536 | CDP_TXRX_PATH_STATS, |
| 6537 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6538 | wlan_hdd_display_netif_queue_history |
| 6539 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6540 | qdf_dp_trace_dump_stats(); |
| 6541 | } |
| 6542 | counter = 0; |
| 6543 | data_in_time_period = false; |
| 6544 | } |
| 6545 | } |
| 6546 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6547 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6548 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6549 | * @hdd_ctx - handle to hdd context |
| 6550 | * @tx_packets - transmit packet count |
| 6551 | * @rx_packets - receive packet count |
| 6552 | * |
| 6553 | * The function controls the bus bandwidth and dynamic control of |
| 6554 | * tcp delayed ack configuration |
| 6555 | * |
| 6556 | * Returns: None |
| 6557 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6558 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6559 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6560 | const uint64_t tx_packets, |
| 6561 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6563 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6564 | uint64_t temp_rx = 0; |
| 6565 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6566 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6567 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6568 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6569 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6570 | uint16_t index = 0; |
| 6571 | bool vote_level_change = false; |
| 6572 | bool rx_level_change = false; |
| 6573 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6574 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6575 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6576 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6577 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6578 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6579 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6580 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6581 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6582 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6585 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6586 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6587 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6588 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6589 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6590 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6591 | if (hdd_ctx->hbw_requested) { |
| 6592 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6593 | hdd_ctx->hbw_requested = false; |
| 6594 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6595 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6596 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6597 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6598 | if (!hdd_ctx->hbw_requested) { |
| 6599 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6600 | hdd_ctx->hbw_requested = true; |
| 6601 | } |
| 6602 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6603 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6604 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6605 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6606 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6607 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6608 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6609 | qdf_dp_trace_throttle_live_mode( |
| 6610 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6611 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6612 | /* fine-tuning parameters for RX Flows */ |
| 6613 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6614 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6615 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6616 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6617 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6618 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6619 | else |
| 6620 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6621 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6622 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6623 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6624 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6625 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6626 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6627 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6628 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6629 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6630 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6633 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 6634 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6635 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6636 | next_rx_level, temp_rx); |
| 6637 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6638 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6639 | /* Send throughput indication only if it is enabled. |
| 6640 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6641 | * to default delayed ack. Note that this will disable the |
| 6642 | * dynamic delayed ack mechanism across the system |
| 6643 | */ |
| 6644 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6645 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 6646 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 6647 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 6648 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 6649 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6650 | rx_tp_data.level = next_rx_level; |
| 6651 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6652 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 6653 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6654 | } |
| 6655 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6656 | /* fine-tuning parameters for TX Flows */ |
| 6657 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6658 | hdd_ctx->prev_tx = tx_packets; |
| 6659 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6660 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6661 | else |
| 6662 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6663 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6664 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6665 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6666 | next_tx_level, temp_tx); |
| 6667 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6668 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6669 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6670 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6671 | &next_tx_level, |
| 6672 | sizeof(next_tx_level)); |
| 6673 | } |
| 6674 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6675 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6676 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6677 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6678 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6679 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6680 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6681 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6682 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6683 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6684 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6685 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6686 | |
| 6687 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6688 | } |
| 6689 | |
| 6690 | #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] | 6691 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6692 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6693 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6694 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6695 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6696 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6697 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6698 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6699 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6700 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6701 | bool connected = false; |
| 6702 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6703 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6704 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6705 | return; |
| 6706 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 6707 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6708 | goto restart_timer; |
| 6709 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6710 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6711 | /* |
| 6712 | * Validate magic so we don't end up accessing |
| 6713 | * an invalid adapter. |
| 6714 | */ |
| 6715 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6716 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6717 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6718 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6719 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6720 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6721 | != eConnectionState_Associated) { |
| 6722 | |
| 6723 | continue; |
| 6724 | } |
| 6725 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6726 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6727 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 6728 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6729 | |
| 6730 | continue; |
| 6731 | } |
| 6732 | |
| 6733 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6734 | adapter->prev_tx_packets); |
| 6735 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6736 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6737 | |
| 6738 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6739 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6740 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6741 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6742 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6743 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6744 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6745 | &fwd_tx_packets, &fwd_rx_packets); |
| 6746 | if (ret == A_OK) { |
| 6747 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6748 | fwd_tx_packets, |
| 6749 | adapter->prev_fwd_tx_packets); |
| 6750 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6751 | fwd_tx_packets, |
| 6752 | adapter->prev_fwd_rx_packets); |
| 6753 | } |
| 6754 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6755 | |
| 6756 | total_rx += adapter->stats.rx_packets; |
| 6757 | total_tx += adapter->stats.tx_packets; |
| 6758 | |
| 6759 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6760 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6761 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6762 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6763 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6764 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6765 | connected = true; |
| 6766 | } |
| 6767 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6768 | /* add intra bss forwarded tx and rx packets */ |
| 6769 | tx_packets += fwd_tx_packets_diff; |
| 6770 | rx_packets += fwd_rx_packets_diff; |
| 6771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6772 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6773 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6774 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6775 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6776 | if (adapter) { |
| 6777 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6778 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6779 | } |
| 6780 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6781 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6782 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6783 | return; |
| 6784 | } |
| 6785 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6786 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6787 | |
| 6788 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6789 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6790 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6791 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6792 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6793 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6794 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6795 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6796 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6797 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6798 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6799 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6800 | /** |
| 6801 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6802 | * @arg: Argument of timer function |
| 6803 | * |
| 6804 | * Schedule a workqueue in this function where all the processing is done. |
| 6805 | * |
| 6806 | * Return: None. |
| 6807 | */ |
| 6808 | static void __hdd_bus_bw_cbk(void *arg) |
| 6809 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6810 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6811 | |
| 6812 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6813 | return; |
| 6814 | |
| 6815 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6816 | } |
| 6817 | |
| 6818 | /** |
| 6819 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6820 | * @arg: Argument of timer function |
| 6821 | * |
| 6822 | * Return: None. |
| 6823 | */ |
| 6824 | static void hdd_bus_bw_cbk(void *arg) |
| 6825 | { |
| 6826 | cds_ssr_protect(__func__); |
| 6827 | __hdd_bus_bw_cbk(arg); |
| 6828 | cds_ssr_unprotect(__func__); |
| 6829 | } |
| 6830 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6831 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6832 | { |
| 6833 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6834 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6835 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6836 | hdd_ctx->bus_bw_timer_running = false; |
| 6837 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6838 | qdf_timer_init(NULL, |
| 6839 | &hdd_ctx->bus_bw_timer, |
| 6840 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6841 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6842 | |
| 6843 | return 0; |
| 6844 | } |
| 6845 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6846 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6847 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6848 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6849 | hdd_reset_tcp_delack(hdd_ctx); |
| 6850 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6851 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6852 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6853 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6854 | hdd_ctx->bus_bw_timer_running = false; |
| 6855 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6856 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6857 | |
| 6858 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6859 | { |
| 6860 | if (hdd_ctx) |
| 6861 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6862 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 6863 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6864 | #endif |
| 6865 | |
| 6866 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6867 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6868 | * @hdd_ctx: hdd context |
| 6869 | * |
| 6870 | * Return: 0 for success or error code |
| 6871 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6872 | 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] | 6873 | { |
| 6874 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6875 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6876 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6877 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6878 | return -ENOMEM; |
| 6879 | } |
| 6880 | return 0; |
| 6881 | } |
| 6882 | |
| 6883 | /** |
| 6884 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6885 | * @hdd_ctx: hdd context |
| 6886 | * |
| 6887 | * Return: none |
| 6888 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6889 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6890 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6891 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6892 | return; |
| 6893 | |
| 6894 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6895 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6896 | } |
| 6897 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6898 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6899 | { |
| 6900 | switch (level) { |
| 6901 | /* initialize the wlan sub system */ |
| 6902 | case WLAN_SVC_TP_NONE: |
| 6903 | return "NONE"; |
| 6904 | case WLAN_SVC_TP_LOW: |
| 6905 | return "LOW"; |
| 6906 | case WLAN_SVC_TP_MEDIUM: |
| 6907 | return "MED"; |
| 6908 | case WLAN_SVC_TP_HIGH: |
| 6909 | return "HIGH"; |
| 6910 | default: |
| 6911 | return "INVAL"; |
| 6912 | } |
| 6913 | } |
| 6914 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6915 | |
| 6916 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6918 | * @hdd_ctx: hdd context |
| 6919 | * |
| 6920 | * Return: none |
| 6921 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6922 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6923 | { |
| 6924 | int i; |
| 6925 | |
| 6926 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6927 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6928 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6929 | 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] | 6930 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6931 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6932 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6933 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6934 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6935 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6936 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6937 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6938 | 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] | 6939 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6940 | #endif |
| 6941 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6942 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6943 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6944 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6945 | 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] | 6946 | |
| 6947 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6948 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6949 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6950 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6951 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6952 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6953 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6954 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6955 | convert_level_to_string( |
| 6956 | hdd_ctx->hdd_txrx_hist[i]. |
| 6957 | next_vote_level), |
| 6958 | convert_level_to_string( |
| 6959 | hdd_ctx->hdd_txrx_hist[i]. |
| 6960 | next_rx_level), |
| 6961 | convert_level_to_string( |
| 6962 | hdd_ctx->hdd_txrx_hist[i]. |
| 6963 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6964 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | } |
| 6966 | |
| 6967 | /** |
| 6968 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6969 | * @hdd_ctx: hdd context |
| 6970 | * |
| 6971 | * Return: none |
| 6972 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6973 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6974 | { |
| 6975 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6976 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6977 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6978 | } |
| 6979 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6980 | /* length of the netif queue log needed per adapter */ |
| 6981 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 6982 | |
| 6983 | /** |
| 6984 | * |
| 6985 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 6986 | * @hdd_ctx: hdd context |
| 6987 | * |
| 6988 | * Return: none |
| 6989 | */ |
| 6990 | static void |
| 6991 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 6992 | { |
| 6993 | int adapter_num = 0; |
| 6994 | int i; |
| 6995 | int bytes_written; |
| 6996 | u32 tbytes; |
| 6997 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6998 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
| 6999 | char comb_log_str[(ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1]; |
| 7000 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7001 | |
| 7002 | bytes_written = 0; |
| 7003 | qdf_mem_set(comb_log_str, 0, sizeof(comb_log_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7004 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7005 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7006 | curr_time = qdf_system_ticks(); |
| 7007 | total = curr_time - adapter->start_time; |
| 7008 | delta = curr_time - adapter->last_time; |
| 7009 | |
| 7010 | if (adapter->pause_map) { |
| 7011 | pause = adapter->total_pause_time + delta; |
| 7012 | unpause = adapter->total_unpause_time; |
| 7013 | } else { |
| 7014 | unpause = adapter->total_unpause_time + delta; |
| 7015 | pause = adapter->total_pause_time; |
| 7016 | } |
| 7017 | |
| 7018 | tbytes = 0; |
| 7019 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7020 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7021 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7022 | continue; |
| 7023 | tbytes += |
| 7024 | snprintf( |
| 7025 | &temp_str[tbytes], |
| 7026 | (tbytes >= sizeof(temp_str) ? |
| 7027 | 0 : sizeof(temp_str) - tbytes), |
| 7028 | "%d(%d,%d) ", |
| 7029 | i, |
| 7030 | adapter->queue_oper_stats[i]. |
| 7031 | pause_count, |
| 7032 | adapter->queue_oper_stats[i]. |
| 7033 | unpause_count); |
| 7034 | } |
| 7035 | if (tbytes >= sizeof(temp_str)) |
| 7036 | hdd_warn("log truncated"); |
| 7037 | |
| 7038 | bytes_written += snprintf(&comb_log_str[bytes_written], |
| 7039 | bytes_written >= sizeof(comb_log_str) ? 0 : |
| 7040 | sizeof(comb_log_str) - bytes_written, |
| 7041 | "[%d %d] (%d) %u/%ums %s|", |
| 7042 | adapter->session_id, adapter->device_mode, |
| 7043 | adapter->pause_map, |
| 7044 | qdf_system_ticks_to_msecs(pause), |
| 7045 | qdf_system_ticks_to_msecs(total), |
| 7046 | temp_str); |
| 7047 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7048 | adapter_num++; |
| 7049 | } |
| 7050 | |
| 7051 | /* using QDF_TRACE to avoid printing function name */ |
| 7052 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7053 | "STATS |%s", comb_log_str); |
| 7054 | |
| 7055 | if (bytes_written >= sizeof(comb_log_str)) |
| 7056 | hdd_warn("log string truncated"); |
| 7057 | } |
| 7058 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7059 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7060 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7061 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7062 | * |
| 7063 | * Return: none |
| 7064 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7065 | void |
| 7066 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7067 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7068 | { |
| 7069 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7070 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7071 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7072 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7073 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7074 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7075 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7076 | return; |
| 7077 | } |
| 7078 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7079 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7080 | hdd_debug("Netif queue operation statistics:"); |
| 7081 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7082 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7083 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7084 | curr_time = qdf_system_ticks(); |
| 7085 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7086 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7087 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7088 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7089 | unpause = adapter->total_unpause_time; |
| 7090 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7091 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7092 | pause = adapter->total_pause_time; |
| 7093 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7094 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7095 | qdf_system_ticks_to_msecs(total), |
| 7096 | qdf_system_ticks_to_msecs(pause), |
| 7097 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7098 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7099 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7100 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7101 | qdf_time_t pause_delta = 0; |
| 7102 | |
| 7103 | if (adapter->pause_map & (1 << i)) |
| 7104 | pause_delta = delta; |
| 7105 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7106 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7107 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7108 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | hdd_reason_type_to_string(i), |
| 7110 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7111 | adapter->queue_oper_stats[i].unpause_count, |
| 7112 | qdf_system_ticks_to_msecs( |
| 7113 | adapter->queue_oper_stats[i].total_pause_time + |
| 7114 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7115 | } |
| 7116 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7117 | hdd_debug("Netif queue operation history:"); |
| 7118 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7119 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7120 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7121 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7122 | |
| 7123 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7124 | /* using hdd_log to avoid printing function name */ |
| 7125 | if (adapter->queue_oper_history[i].time == 0) |
| 7126 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7127 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7128 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 7129 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7130 | adapter->queue_oper_history[i].time), |
| 7131 | hdd_action_type_to_string( |
| 7132 | adapter->queue_oper_history[i].netif_action), |
| 7133 | hdd_reason_type_to_string( |
| 7134 | adapter->queue_oper_history[i].netif_reason), |
| 7135 | adapter->queue_oper_history[i].pause_map); |
| 7136 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7137 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | } |
| 7139 | |
| 7140 | /** |
| 7141 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7142 | * @hdd_ctx: hdd context |
| 7143 | * |
| 7144 | * Return: none |
| 7145 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7146 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7147 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7148 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7149 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7150 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7151 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7153 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7154 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7155 | adapter->history_index = 0; |
| 7156 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7157 | adapter->total_pause_time = 0; |
| 7158 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7159 | } |
| 7160 | } |
| 7161 | |
| 7162 | /** |
| 7163 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7164 | * @halHandle: Hal handle |
| 7165 | * @pContext: Pointer to the context |
| 7166 | * @sessionId: Session ID |
| 7167 | * @scanId: Scan ID |
| 7168 | * @status: Status |
| 7169 | * |
| 7170 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7171 | * the scan results |
| 7172 | * |
| 7173 | * 11d scan is done during driver load and is a passive scan on all |
| 7174 | * channels supported by the device, 11d scans may find some APs on |
| 7175 | * frequencies which are forbidden to be used in the regulatory domain |
| 7176 | * the device is operating in. If these APs are notified to the supplicant |
| 7177 | * it may try to connect to these APs, thus flush out all the scan results |
| 7178 | * which are present in SME after 11d scan is done. |
| 7179 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7180 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7181 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7182 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7183 | uint8_t sessionId, uint32_t scanId, |
| 7184 | eCsrScanStatus status) |
| 7185 | { |
| 7186 | ENTER(); |
| 7187 | |
| 7188 | sme_scan_flush_result(halHandle); |
| 7189 | |
| 7190 | EXIT(); |
| 7191 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7192 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7193 | } |
| 7194 | |
| 7195 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7196 | /** |
| 7197 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7198 | * @hdd_ctx: hdd global context |
| 7199 | * |
| 7200 | * Return: none |
| 7201 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7202 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7203 | { |
| 7204 | uint8_t i; |
| 7205 | |
| 7206 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7207 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7208 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7209 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7210 | } |
| 7211 | } |
| 7212 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7213 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7214 | { |
| 7215 | } |
| 7216 | #endif |
| 7217 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7218 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7219 | /** |
| 7220 | * 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] | 7221 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7222 | * @enable: enable or disable this behaviour |
| 7223 | * |
| 7224 | * Return: int |
| 7225 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7226 | 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] | 7227 | { |
| 7228 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7229 | struct wow_pulse_mode wow_pulse_set_info; |
| 7230 | QDF_STATUS status; |
| 7231 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7232 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7233 | |
| 7234 | if (false == phddctx->config->wow_pulse_support) |
| 7235 | return 0; |
| 7236 | |
| 7237 | /* prepare the request to send to SME */ |
| 7238 | if (enable == true) { |
| 7239 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7240 | wow_pulse_set_info.wow_pulse_pin = |
| 7241 | pcfg_ini->wow_pulse_pin; |
| 7242 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7243 | pcfg_ini->wow_pulse_interval_low; |
| 7244 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7245 | pcfg_ini->wow_pulse_interval_high; |
| 7246 | } else { |
| 7247 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7248 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7249 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7250 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7251 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7252 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7253 | wow_pulse_set_info.wow_pulse_enable, |
| 7254 | wow_pulse_set_info.wow_pulse_pin, |
| 7255 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7256 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7257 | |
| 7258 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7259 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7260 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7261 | return -EIO; |
| 7262 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7263 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7264 | return 0; |
| 7265 | } |
| 7266 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7267 | 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] | 7268 | { |
| 7269 | return 0; |
| 7270 | } |
| 7271 | #endif |
| 7272 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7273 | #ifdef WLAN_FEATURE_FASTPATH |
| 7274 | /** |
| 7275 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7276 | * @hdd_cfg: hdd config |
| 7277 | * @context: lower layer context |
| 7278 | * |
| 7279 | * Return: none |
| 7280 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7281 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7282 | void *context) |
| 7283 | { |
| 7284 | if (hdd_cfg->fastpath_enable) |
| 7285 | hif_enable_fastpath(context); |
| 7286 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7287 | #endif |
| 7288 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7289 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7290 | /** |
| 7291 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7292 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7293 | * @level: thermal level |
| 7294 | * |
| 7295 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7296 | * than 0, and restore the original data path when throttle level is 0 |
| 7297 | * |
| 7298 | * Return: none |
| 7299 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7300 | 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] | 7301 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7302 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7303 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7304 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7305 | if (level > THROTTLE_LEVEL_0) |
| 7306 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7307 | else |
| 7308 | /* restore original concurrency mode */ |
| 7309 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7310 | } |
| 7311 | |
| 7312 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7313 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7314 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7315 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7316 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7317 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7318 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7319 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7320 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7321 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7322 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7323 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7324 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7325 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7326 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7327 | struct sir_pcl_list pcl; |
| 7328 | QDF_STATUS status; |
| 7329 | uint32_t i, j; |
| 7330 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7331 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7332 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7333 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7334 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7335 | if (!hdd_ctx) { |
| 7336 | hdd_err("invalid HDD context"); |
| 7337 | return INVALID_CHANNEL_ID; |
| 7338 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7339 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7340 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7341 | if (!hal_handle) { |
| 7342 | hdd_err("invalid HAL handle"); |
| 7343 | return INVALID_CHANNEL_ID; |
| 7344 | } |
| 7345 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7346 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7347 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7348 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7349 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7350 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7351 | hdd_err("Get PCL failed"); |
| 7352 | return INVALID_CHANNEL_ID; |
| 7353 | } |
| 7354 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7355 | /* |
| 7356 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7357 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7358 | * try to choose a safe channel from acs range. |
| 7359 | */ |
| 7360 | if (!pcl.pcl_len) |
| 7361 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7362 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7363 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7364 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7365 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7366 | |
| 7367 | /* PCL already takes unsafe channel into account */ |
| 7368 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7369 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7370 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7371 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7372 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7373 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7374 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7375 | return pcl.pcl_list[i]; |
| 7376 | } |
| 7377 | } |
| 7378 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7379 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7380 | |
| 7381 | /* Try for safe channel from all valid channel */ |
| 7382 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7383 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7384 | &pcl.pcl_len); |
| 7385 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7386 | hdd_err("error in getting valid channel list"); |
| 7387 | return INVALID_CHANNEL_ID; |
| 7388 | } |
| 7389 | |
| 7390 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7391 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7392 | found = false; |
| 7393 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7394 | if (pcl.pcl_list[i] == |
| 7395 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7396 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7397 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7398 | break; |
| 7399 | } |
| 7400 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7401 | |
| 7402 | if (found) |
| 7403 | continue; |
| 7404 | |
| 7405 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7406 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7407 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7408 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7409 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7410 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7411 | } |
| 7412 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7413 | |
| 7414 | return INVALID_CHANNEL_ID; |
| 7415 | } |
| 7416 | |
| 7417 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7418 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7419 | * @adapter: AP adapter |
| 7420 | * @channel: Channel |
| 7421 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7422 | * Moves the SAP interface by invoking the function which |
| 7423 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7424 | * |
| 7425 | * Return: None |
| 7426 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7427 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7428 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7429 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7430 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7431 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7432 | |
| 7433 | if (!adapter) { |
| 7434 | hdd_err("invalid adapter"); |
| 7435 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7436 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7437 | |
| 7438 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7439 | |
| 7440 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7441 | if (!hal_handle) { |
| 7442 | hdd_err("invalid HAL handle"); |
| 7443 | return; |
| 7444 | } |
| 7445 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7446 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7447 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7448 | hdd_ap_ctx->sap_config.channel = channel; |
| 7449 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7450 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7451 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7452 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7453 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7454 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7455 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7456 | hdd_ap_ctx->sap_config.channel, |
| 7457 | hdd_ap_ctx->sap_config.sec_ch, |
| 7458 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7459 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7460 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7461 | adapter->session_id, channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7462 | hdd_ap_ctx->sap_config.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7463 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7464 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7465 | 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] | 7466 | { |
| 7467 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7468 | int status; |
| 7469 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7470 | |
| 7471 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7472 | |
| 7473 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7474 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7475 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7476 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7477 | } |
| 7478 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7479 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7480 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7481 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7482 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7483 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7484 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7485 | hdd_err("failed to start external acs timer"); |
| 7486 | return -ENOSPC; |
| 7487 | } |
| 7488 | /* Update config to application */ |
| 7489 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7490 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7491 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7492 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7493 | } |
| 7494 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7495 | /** |
| 7496 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7497 | * @hdd_ctx: hdd context pointer |
| 7498 | * |
| 7499 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7500 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7501 | * sap. User space on LTE coex indication restart driver. |
| 7502 | * |
| 7503 | * Return - none |
| 7504 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7505 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7506 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7507 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7508 | uint32_t i; |
| 7509 | bool found = false; |
| 7510 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7511 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7512 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7513 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7514 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7515 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7516 | adapter->device_mode, |
| 7517 | adapter->session.ap.sap_config. |
| 7518 | acs_cfg.acs_mode); |
| 7519 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7520 | } |
| 7521 | |
| 7522 | found = false; |
| 7523 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7524 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7525 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7526 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7527 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7528 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7529 | break; |
| 7530 | } |
| 7531 | } |
| 7532 | |
| 7533 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7534 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7535 | adapter->session.ap.operating_channel); |
| 7536 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7537 | } |
| 7538 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7539 | if (hdd_ctxt->config->vendor_acs_support && |
| 7540 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7541 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7542 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7543 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7544 | } else |
| 7545 | restart_chan = |
| 7546 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7547 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7548 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7549 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7550 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7551 | /* |
| 7552 | * SAP restart due to unsafe channel. While |
| 7553 | * restarting the SAP, make sure to clear |
| 7554 | * acs_channel, channel to reset to |
| 7555 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7556 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7557 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7558 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7559 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7560 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7561 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7562 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7563 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7564 | hdd_debug("driver to start sap: %d", |
| 7565 | hdd_ctxt->config->sap_internal_restart); |
| 7566 | if (hdd_ctxt->config->sap_internal_restart) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7567 | hdd_switch_sap_channel(adapter, restart_chan); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7568 | else |
| 7569 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7570 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7571 | } |
| 7572 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7573 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7574 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7575 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7576 | * @hdd_ctx: HDD global context |
| 7577 | * |
| 7578 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7579 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7580 | * down to the lower layers. Then subscribe to subsequent channel |
| 7581 | * avoidance events. |
| 7582 | * |
| 7583 | * Return: None |
| 7584 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7585 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7586 | { |
| 7587 | uint16_t unsafe_channel_count; |
| 7588 | int index; |
| 7589 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7590 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7591 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7592 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7593 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7594 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7595 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | hdd_ctx->unsafe_channel_count); |
| 7597 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7598 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7599 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | |
| 7601 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7602 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7603 | hdd_ctx->unsafe_channel_list[index]); |
| 7604 | |
| 7605 | } |
| 7606 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7608 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7609 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7610 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7611 | { |
| 7612 | uint8_t restart_chan; |
| 7613 | |
| 7614 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7615 | if (!restart_chan) { |
| 7616 | hdd_alert("fail to restart SAP"); |
| 7617 | return; |
| 7618 | } |
| 7619 | |
| 7620 | /* SAP restart due to unsafe channel. While restarting |
| 7621 | * the SAP, make sure to clear acs_channel, channel to |
| 7622 | * reset to 0. Otherwise these settings will override |
| 7623 | * the ACS while restart. |
| 7624 | */ |
| 7625 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7626 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7627 | |
| 7628 | hdd_debug("sending coex indication"); |
| 7629 | |
| 7630 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7631 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7632 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7633 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7634 | |
| 7635 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7636 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7637 | { |
| 7638 | uint32_t size; |
| 7639 | uint16_t *unsafe_list; |
| 7640 | uint16_t chan_count; |
| 7641 | |
| 7642 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7643 | return -EINVAL; |
| 7644 | |
| 7645 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7646 | NUM_CHANNELS); |
| 7647 | if (chan_count) { |
| 7648 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7649 | unsafe_list = qdf_mem_malloc(size); |
| 7650 | if (!unsafe_list) { |
| 7651 | hdd_err("No memory for unsafe chan list size%d", |
| 7652 | size); |
| 7653 | return -ENOMEM; |
| 7654 | } |
| 7655 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7656 | } else { |
| 7657 | unsafe_list = NULL; |
| 7658 | } |
| 7659 | |
| 7660 | *local_unsafe_list = unsafe_list; |
| 7661 | *local_unsafe_list_count = chan_count; |
| 7662 | |
| 7663 | return 0; |
| 7664 | } |
| 7665 | |
| 7666 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7667 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7668 | { |
| 7669 | int i, j; |
| 7670 | |
| 7671 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7672 | return true; |
| 7673 | if (local_unsafe_list_count == 0) |
| 7674 | return false; |
| 7675 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7676 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7677 | if (local_unsafe_list[i] == |
| 7678 | hdd_ctx->unsafe_channel_list[j]) |
| 7679 | break; |
| 7680 | if (j >= local_unsafe_list_count) |
| 7681 | break; |
| 7682 | } |
| 7683 | if (i >= local_unsafe_list_count) { |
| 7684 | hdd_info("unsafe chan list same"); |
| 7685 | return false; |
| 7686 | } |
| 7687 | |
| 7688 | return true; |
| 7689 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7690 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7691 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7692 | { |
| 7693 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7694 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7695 | 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] | 7696 | { |
| 7697 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7698 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7699 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7700 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7701 | { |
| 7702 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7703 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7704 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7705 | |
| 7706 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7707 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7708 | * user space |
| 7709 | * @frame_ind: Management frame data to be informed. |
| 7710 | * |
| 7711 | * This function is used to indicate management frame to |
| 7712 | * user space |
| 7713 | * |
| 7714 | * Return: None |
| 7715 | * |
| 7716 | */ |
| 7717 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7718 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7719 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7720 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7721 | int i; |
| 7722 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7723 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7724 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7725 | |
| 7726 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7727 | return; |
| 7728 | |
| 7729 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7730 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7731 | adapter = |
| 7732 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7733 | if (adapter) |
| 7734 | break; |
| 7735 | } |
| 7736 | } else { |
| 7737 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7738 | frame_ind->sessionId); |
| 7739 | } |
| 7740 | |
| 7741 | if ((NULL != adapter) && |
| 7742 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7743 | __hdd_indicate_mgmt_frame(adapter, |
| 7744 | frame_ind->frame_len, |
| 7745 | frame_ind->frameBuf, |
| 7746 | frame_ind->frameType, |
| 7747 | frame_ind->rxChan, |
| 7748 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7749 | } |
| 7750 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7751 | void hdd_acs_response_timeout_handler(void *context) |
| 7752 | { |
| 7753 | struct hdd_external_acs_timer_context *timer_context = |
| 7754 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7755 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7756 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7757 | uint8_t reason; |
| 7758 | |
| 7759 | ENTER(); |
| 7760 | if (!timer_context) { |
| 7761 | hdd_err("invlaid timer context"); |
| 7762 | return; |
| 7763 | } |
| 7764 | adapter = timer_context->adapter; |
| 7765 | reason = timer_context->reason; |
| 7766 | |
| 7767 | |
| 7768 | if ((!adapter) || |
| 7769 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7770 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7771 | return; |
| 7772 | } |
| 7773 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7774 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7775 | return; |
| 7776 | |
| 7777 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7778 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7779 | else |
| 7780 | return; |
| 7781 | |
| 7782 | hdd_err("ACS timeout happened for %s reason %d", |
| 7783 | adapter->dev->name, reason); |
| 7784 | switch (reason) { |
| 7785 | /* SAP init case */ |
| 7786 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7787 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7788 | false); |
| 7789 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7790 | break; |
| 7791 | /* DFS detected on current channel */ |
| 7792 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7793 | wlan_sap_update_next_channel( |
| 7794 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7795 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7796 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7797 | break; |
| 7798 | /* LTE coex event on current channel */ |
| 7799 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7800 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7801 | break; |
| 7802 | default: |
| 7803 | hdd_info("invalid reason for timer invoke"); |
| 7804 | |
| 7805 | } |
| 7806 | } |
| 7807 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7808 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7809 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7810 | * @hdd_ctx: HDD context |
| 7811 | * |
| 7812 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7813 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7814 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7815 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7816 | 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] | 7817 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7818 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7819 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7820 | |
| 7821 | if (!hdd_ctx) { |
| 7822 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7823 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7824 | } |
| 7825 | |
| 7826 | cfg.scan_config = 0; |
| 7827 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7828 | 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] | 7829 | |
| 7830 | hdd_debug("Disabling all dual mac features..."); |
| 7831 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7832 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7833 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7834 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7835 | return status; |
| 7836 | } |
| 7837 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7838 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7839 | } |
| 7840 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7841 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7842 | 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] | 7843 | { |
| 7844 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7845 | QDF_STATUS status; |
| 7846 | |
| 7847 | if (!hdd_ctx) { |
| 7848 | hdd_err("HDD context is NULL"); |
| 7849 | return QDF_STATUS_E_FAILURE; |
| 7850 | } |
| 7851 | |
| 7852 | cfg.scan_config = 0; |
| 7853 | cfg.fw_mode_config = 0; |
| 7854 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7855 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7856 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7857 | &cfg.fw_mode_config, |
| 7858 | hdd_ctx->config->dual_mac_feature_disable); |
| 7859 | |
| 7860 | if (status != QDF_STATUS_SUCCESS) { |
| 7861 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7862 | status); |
| 7863 | return status; |
| 7864 | } |
| 7865 | |
| 7866 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7867 | cfg.scan_config, cfg.fw_mode_config); |
| 7868 | |
| 7869 | status = sme_soc_set_dual_mac_config(cfg); |
| 7870 | if (status != QDF_STATUS_SUCCESS) { |
| 7871 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7872 | return status; |
| 7873 | } |
| 7874 | |
| 7875 | return QDF_STATUS_SUCCESS; |
| 7876 | } |
| 7877 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7878 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7879 | * hdd_override_ini_config - Override INI config |
| 7880 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7881 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7882 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7883 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7884 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7885 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7886 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7887 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7889 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7890 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7891 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7892 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7893 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7894 | if (0 == enable_11d || 1 == enable_11d) { |
| 7895 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7896 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7897 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7898 | |
| 7899 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7900 | hdd_ctx->config->IpaConfig = 0; |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 7901 | |
| 7902 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 7903 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 7904 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 7905 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 7906 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 7907 | hdd_ctx->config->oce_sta_enabled = 0; |
| 7908 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7909 | } |
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 | /** |
| 7912 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7913 | * @hdd_ctx - HDD context |
| 7914 | * |
| 7915 | * Set trace level for each module based on INI config. |
| 7916 | * |
| 7917 | * Return: None |
| 7918 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7919 | 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] | 7920 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7921 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7922 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7923 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7924 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7925 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7926 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7927 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7928 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7929 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7930 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7931 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7932 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7933 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7934 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7935 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7936 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7937 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7938 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7939 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7940 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7941 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7942 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7943 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7944 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7945 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7946 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7947 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 7948 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 7949 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 7950 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7951 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7952 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7953 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7954 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7955 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7956 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7957 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7958 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7959 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7960 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7961 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7962 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 7963 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 7964 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 7965 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7966 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7967 | } |
| 7968 | |
| 7969 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7970 | * hdd_context_init() - Initialize HDD context |
| 7971 | * @hdd_ctx: HDD context. |
| 7972 | * |
| 7973 | * Initialize HDD context along with all the feature specific contexts. |
| 7974 | * |
| 7975 | * return: 0 on success and errno on failure. |
| 7976 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7977 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7978 | { |
| 7979 | int ret; |
| 7980 | |
| 7981 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 7982 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 7983 | |
| 7984 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 7985 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7986 | |
| 7987 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 7988 | init_completion(&hdd_ctx->ready_to_suspend); |
| 7989 | |
| 7990 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7991 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7992 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7993 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7994 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7995 | |
| 7996 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 7997 | |
| 7998 | ret = hdd_scan_context_init(hdd_ctx); |
| 7999 | if (ret) |
| 8000 | goto list_destroy; |
| 8001 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8002 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8003 | |
| 8004 | ret = hdd_sap_context_init(hdd_ctx); |
| 8005 | if (ret) |
| 8006 | goto scan_destroy; |
| 8007 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8008 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8009 | |
| 8010 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8011 | |
| 8012 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8013 | hdd_ctx->config); |
| 8014 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8015 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8016 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8017 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8018 | "monitor_mode_wakelock"); |
| 8019 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8020 | return 0; |
| 8021 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8022 | sap_destroy: |
| 8023 | hdd_sap_context_destroy(hdd_ctx); |
| 8024 | |
| 8025 | scan_destroy: |
| 8026 | hdd_scan_context_destroy(hdd_ctx); |
| 8027 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8028 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8029 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8030 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8031 | return ret; |
| 8032 | } |
| 8033 | |
| 8034 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8035 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8036 | * @hdd_ctx: pointer to hdd context |
| 8037 | * |
| 8038 | * Return: status of initialization |
| 8039 | * 0 - success |
| 8040 | * negative value - failure |
| 8041 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8042 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8043 | { |
| 8044 | int ret; |
| 8045 | |
| 8046 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8047 | return 0; |
| 8048 | |
| 8049 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8050 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8051 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8052 | return -EINVAL; |
| 8053 | } |
| 8054 | |
| 8055 | /* parse ini string probe req oui */ |
| 8056 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8057 | if (ret) { |
| 8058 | hdd_err("parsing error: disable ie whitelisting"); |
| 8059 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8060 | } |
| 8061 | |
| 8062 | return ret; |
| 8063 | } |
| 8064 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8065 | |
| 8066 | /** |
| 8067 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8068 | * @priv: pointer to hdd context |
| 8069 | * |
| 8070 | * This function is invoked when the timer waiting for the interface change |
| 8071 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8072 | * |
| 8073 | * Return: void |
| 8074 | */ |
| 8075 | static void hdd_iface_change_callback(void *priv) |
| 8076 | { |
| 8077 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8078 | int ret; |
| 8079 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8080 | |
| 8081 | if (status) |
| 8082 | return; |
| 8083 | |
| 8084 | ENTER(); |
| 8085 | hdd_debug("Interface change timer expired close the modules!"); |
| 8086 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8087 | if (ret) |
| 8088 | hdd_err("Failed to stop modules"); |
| 8089 | EXIT(); |
| 8090 | } |
| 8091 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8092 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8093 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8094 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8095 | * |
| 8096 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8097 | * wiphy allocation and then context is initialized. |
| 8098 | * |
| 8099 | * Return: HDD context on success and ERR_PTR on failure |
| 8100 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8101 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8102 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8103 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8104 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8105 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8106 | |
| 8107 | ENTER(); |
| 8108 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8109 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8110 | if (hdd_ctx == NULL) { |
| 8111 | ret = -ENOMEM; |
| 8112 | goto err_out; |
| 8113 | } |
| 8114 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8115 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8116 | hdd_iface_change_callback, |
| 8117 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8118 | |
| 8119 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8120 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8121 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8122 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8123 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8124 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8125 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8126 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8127 | ret = -ENOMEM; |
| 8128 | goto err_free_hdd_context; |
| 8129 | } |
| 8130 | |
| 8131 | /* Read and parse the qcom_cfg.ini file */ |
| 8132 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8133 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8134 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8135 | WLAN_INI_FILE); |
| 8136 | ret = -EINVAL; |
| 8137 | goto err_free_config; |
| 8138 | } |
| 8139 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8140 | ie_whitelist_attrs_init(hdd_ctx); |
| 8141 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8142 | hdd_debug("setting timer multiplier: %u", |
| 8143 | hdd_ctx->config->timer_multiplier); |
| 8144 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8145 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8146 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8147 | if (hdd_ctx->config->fhostNSOffload) |
| 8148 | hdd_ctx->ns_offload_enable = true; |
| 8149 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8150 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8151 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8152 | hdd_override_ini_config(hdd_ctx); |
| 8153 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8154 | ret = hdd_context_init(hdd_ctx); |
| 8155 | |
| 8156 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8157 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8158 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8159 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8160 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8161 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8162 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8163 | goto skip_multicast_logging; |
| 8164 | |
| 8165 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8166 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8167 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8168 | if (ret) |
| 8169 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8170 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8171 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8172 | if (ret) |
| 8173 | goto err_deinit_txrx_histogram; |
| 8174 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 8175 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 8176 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8177 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8178 | skip_multicast_logging: |
| 8179 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8180 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8181 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8182 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8183 | EXIT(); |
| 8184 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8185 | return hdd_ctx; |
| 8186 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8187 | err_deinit_txrx_histogram: |
| 8188 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8189 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8190 | err_deinit_hdd_context: |
| 8191 | hdd_context_deinit(hdd_ctx); |
| 8192 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8193 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8194 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8195 | |
| 8196 | err_free_hdd_context: |
| 8197 | wiphy_free(hdd_ctx->wiphy); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8198 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8199 | |
| 8200 | err_out: |
| 8201 | return ERR_PTR(ret); |
| 8202 | } |
| 8203 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8204 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8205 | /** |
| 8206 | * hdd_open_p2p_interface - Open P2P interface |
| 8207 | * @hdd_ctx: HDD context |
| 8208 | * @rtnl_held: True if RTNL lock held |
| 8209 | * |
| 8210 | * Open P2P interface during probe. This function called to open the P2P |
| 8211 | * interface at probe along with STA interface. |
| 8212 | * |
| 8213 | * Return: 0 on success and errno on failure |
| 8214 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8215 | 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] | 8216 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8217 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8218 | uint8_t *p2p_dev_addr; |
| 8219 | |
| 8220 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8221 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8222 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8223 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8224 | sizeof(tSirMacAddr)); |
| 8225 | |
| 8226 | /* |
| 8227 | * Generate the P2P Device Address. This consists of |
| 8228 | * the device's primary MAC address with the locally |
| 8229 | * administered bit set. |
| 8230 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8231 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8232 | } else { |
| 8233 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8234 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8235 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8236 | return -ENOSPC; |
| 8237 | } |
| 8238 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8239 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8240 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8241 | } |
| 8242 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8243 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8244 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8245 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8246 | |
| 8247 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8248 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8249 | return -ENOSPC; |
| 8250 | } |
| 8251 | |
| 8252 | return 0; |
| 8253 | } |
| 8254 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8255 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8256 | bool rtnl_held) |
| 8257 | { |
| 8258 | return 0; |
| 8259 | } |
| 8260 | #endif |
| 8261 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8262 | 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] | 8263 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8264 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8265 | int ret = 0; |
| 8266 | |
| 8267 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8268 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8269 | NET_NAME_UNKNOWN, rtnl_held); |
| 8270 | if (adapter == NULL) { |
| 8271 | hdd_err("Failed to open 802.11p interface"); |
| 8272 | ret = -ENOSPC; |
| 8273 | } |
| 8274 | |
| 8275 | return ret; |
| 8276 | } |
| 8277 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8278 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8279 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8280 | * @adapter: HDD adapter |
| 8281 | * |
| 8282 | * This function initializes the adapter for the station mode. |
| 8283 | * |
| 8284 | * Return: 0 on success or errno on failure. |
| 8285 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8286 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8287 | { |
| 8288 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8289 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8290 | |
| 8291 | ENTER_DEV(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8292 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8293 | hdd_err("session is already opened, %d", |
| 8294 | adapter->session_id); |
| 8295 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8296 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8297 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8298 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8299 | if (ret) { |
| 8300 | hdd_err("failed to create vdev: %d", ret); |
| 8301 | return ret; |
| 8302 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8303 | status = hdd_init_station_mode(adapter); |
| 8304 | |
| 8305 | if (QDF_STATUS_SUCCESS != status) { |
| 8306 | hdd_err("Error Initializing station mode: %d", status); |
| 8307 | return qdf_status_to_os_return(status); |
| 8308 | } |
| 8309 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8310 | hdd_register_tx_flow_control(adapter, |
| 8311 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8312 | hdd_tx_resume_cb, |
| 8313 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8314 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8315 | EXIT(); |
| 8316 | return 0; |
| 8317 | } |
| 8318 | |
| 8319 | /** |
| 8320 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8321 | * @adapter: HDD adapter |
| 8322 | * |
| 8323 | * This function initializes the adapter for the AP mode. |
| 8324 | * |
| 8325 | * Return: 0 on success errno on failure. |
| 8326 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8327 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8328 | { |
| 8329 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8330 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8331 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8332 | |
| 8333 | ENTER(); |
| 8334 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8335 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8336 | hdd_err("session is already opened, %d", |
| 8337 | adapter->session_id); |
| 8338 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8339 | } |
| 8340 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8341 | * In SSR case no need to create new sap context. |
| 8342 | * Otherwise create sap context first and then create |
| 8343 | * vdev as while creating the vdev, driver needs to |
| 8344 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8345 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8346 | if (adapter->session.ap.sap_context) { |
| 8347 | is_ssr = true; |
| 8348 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8349 | hdd_err("sap creation failed"); |
| 8350 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8351 | } |
| 8352 | |
| 8353 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8354 | adapter->session.ap.sap_context); |
| 8355 | if (ret) { |
| 8356 | hdd_err("failed to create vdev, status:%d", ret); |
| 8357 | hdd_sap_destroy_ctx(adapter); |
| 8358 | return ret; |
| 8359 | } |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8360 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8361 | |
| 8362 | if (QDF_STATUS_SUCCESS != status) { |
| 8363 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8364 | return qdf_status_to_os_return(status); |
| 8365 | } |
| 8366 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8367 | hdd_register_tx_flow_control(adapter, |
| 8368 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8369 | hdd_softap_tx_resume_cb, |
| 8370 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8371 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8372 | EXIT(); |
| 8373 | return 0; |
| 8374 | } |
| 8375 | |
| 8376 | /** |
| 8377 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 8378 | * @adapter: HDD adapter |
| 8379 | * |
| 8380 | * This function initializes the adapter for the FTM mode. |
| 8381 | * |
| 8382 | * Return: 0 on success or errno on failure. |
| 8383 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8384 | int hdd_start_ftm_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8385 | { |
| 8386 | QDF_STATUS qdf_status; |
| 8387 | |
| 8388 | ENTER_DEV(adapter->dev); |
| 8389 | |
| 8390 | qdf_status = hdd_init_tx_rx(adapter); |
| 8391 | |
| 8392 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 8393 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 8394 | return qdf_status_to_os_return(qdf_status); |
| 8395 | } |
| 8396 | |
| 8397 | return 0; |
| 8398 | EXIT(); |
| 8399 | } |
| 8400 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8401 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8402 | bool rtnl_held) |
| 8403 | { |
| 8404 | struct hdd_adapter *adapter; |
| 8405 | |
| 8406 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8407 | hdd_ctx->config->enableConcurrentSTA, |
| 8408 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8409 | NET_NAME_UNKNOWN, rtnl_held); |
| 8410 | |
| 8411 | if (!adapter) |
| 8412 | return -ENOSPC; |
| 8413 | |
| 8414 | return 0; |
| 8415 | } |
| 8416 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8417 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8418 | * hdd_open_interfaces - Open all required interfaces |
| 8419 | * hdd_ctx: HDD context |
| 8420 | * rtnl_held: True if RTNL lock is held |
| 8421 | * |
| 8422 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8423 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8424 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8425 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8426 | 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] | 8427 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8428 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8429 | int ret; |
| 8430 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8431 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8432 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8433 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8434 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8435 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8436 | |
| 8437 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8438 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8439 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8440 | if (!adapter) { |
| 8441 | hdd_err("open adapter failed"); |
| 8442 | return -ENOSPC; |
| 8443 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8444 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8445 | return 0; |
| 8446 | } |
| 8447 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8448 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8449 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8450 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8451 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8452 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8453 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8454 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8455 | |
| 8456 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8457 | return -ENOSPC; |
| 8458 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 8459 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 8460 | adapter->fast_roaming_allowed = true; |
| 8461 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8462 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8463 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8464 | if (ret) |
| 8465 | hdd_err("Cannot create concurrent STA interface"); |
| 8466 | } |
| 8467 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8468 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8469 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8470 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8471 | |
| 8472 | /* Open 802.11p Interface */ |
| 8473 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8474 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8475 | if (ret) |
| 8476 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8477 | } |
| 8478 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8479 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8480 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8481 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8482 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8483 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8484 | } |
| 8485 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8486 | /** |
| 8487 | * hdd_update_country_code - Update country code |
| 8488 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8489 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8490 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8491 | * |
| 8492 | * Return: 0 on success and errno on failure |
| 8493 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8494 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8495 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8496 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8497 | return 0; |
| 8498 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8499 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8500 | } |
| 8501 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8502 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8503 | /** |
| 8504 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8505 | * @cds_cfg: CDS Configuration |
| 8506 | * @hdd_ctx: Pointer to hdd context |
| 8507 | * |
| 8508 | * Return: none |
| 8509 | */ |
| 8510 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8511 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8512 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8513 | { |
| 8514 | cds_cfg->tx_flow_stop_queue_th = |
| 8515 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8516 | cds_cfg->tx_flow_start_queue_offset = |
| 8517 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8518 | } |
| 8519 | #else |
| 8520 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8521 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8522 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8523 | { |
| 8524 | } |
| 8525 | #endif |
| 8526 | |
| 8527 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8528 | /** |
| 8529 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8530 | * @cds_cfg: CDS Configuration |
| 8531 | * @hdd_ctx: Pointer to hdd context |
| 8532 | * |
| 8533 | * Return: none |
| 8534 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8535 | 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] | 8536 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8537 | { |
| 8538 | cds_cfg->ra_ratelimit_interval = |
| 8539 | hdd_ctx->config->RArateLimitInterval; |
| 8540 | cds_cfg->is_ra_ratelimit_enabled = |
| 8541 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8542 | } |
| 8543 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8544 | 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] | 8545 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8546 | { |
| 8547 | } |
| 8548 | #endif |
| 8549 | |
| 8550 | /** |
| 8551 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8552 | * @hdd_ctx: HDD Context |
| 8553 | * |
| 8554 | * Return: 0 for Success, errno on failure |
| 8555 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8556 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8557 | { |
| 8558 | struct cds_config_info *cds_cfg; |
| 8559 | |
| 8560 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8561 | if (!cds_cfg) { |
| 8562 | hdd_err("failed to allocate cds config"); |
| 8563 | return -ENOMEM; |
| 8564 | } |
| 8565 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8566 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8567 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8568 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8569 | cds_cfg->powersave_offload_enabled = |
| 8570 | hdd_ctx->config->enablePowersaveOffload; |
| 8571 | } else { |
| 8572 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8573 | PS_QPOWER_NODEEPSLEEP) || |
| 8574 | (hdd_ctx->config->enablePowersaveOffload == |
| 8575 | PS_LEGACY_NODEEPSLEEP)) |
| 8576 | cds_cfg->powersave_offload_enabled = |
| 8577 | PS_LEGACY_NODEEPSLEEP; |
| 8578 | else |
| 8579 | cds_cfg->powersave_offload_enabled = |
| 8580 | PS_LEGACY_DEEPSLEEP; |
| 8581 | hdd_info("Qpower disabled in cds config, %d", |
| 8582 | cds_cfg->powersave_offload_enabled); |
| 8583 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8584 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8585 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8586 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8587 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8588 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8589 | |
| 8590 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8591 | * ns offload and others. Currently 1st bit is used for arp |
| 8592 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8593 | */ |
| 8594 | if (hdd_ctx->config->fhostArpOffload) |
| 8595 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8596 | if (hdd_ctx->config->fhostNSOffload) |
| 8597 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8598 | |
| 8599 | /* |
| 8600 | * Copy the DFS Phyerr Filtering Offload status. |
| 8601 | * This parameter reflects the value of the |
| 8602 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8603 | */ |
| 8604 | cds_cfg->dfs_phyerr_filter_offload = |
| 8605 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8606 | if (hdd_ctx->config->ssdp) |
| 8607 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8608 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8609 | cds_cfg->force_target_assert_enabled = |
| 8610 | hdd_ctx->config->crash_inject_enabled; |
| 8611 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8612 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8613 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8614 | |
| 8615 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8616 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8617 | |
| 8618 | cds_cfg->ap_disable_intrabss_fwd = |
| 8619 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8620 | |
| 8621 | cds_cfg->dfs_pri_multiplier = |
| 8622 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8623 | cds_cfg->reorder_offload = |
| 8624 | hdd_ctx->config->reorderOffloadSupport; |
| 8625 | |
| 8626 | /* IPA micro controller data path offload resource config item */ |
| 8627 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8628 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8629 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8630 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8631 | hdd_ctx->config->IpaUcTxBufCount); |
| 8632 | hdd_ctx->config->IpaUcTxBufCount = |
| 8633 | rounddown_pow_of_two( |
| 8634 | hdd_ctx->config->IpaUcTxBufCount); |
| 8635 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8636 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8637 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8638 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8639 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8640 | hdd_ctx->config->IpaUcTxBufCount); |
| 8641 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8642 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8643 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8644 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8645 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8646 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8647 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8648 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8649 | rounddown_pow_of_two( |
| 8650 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8651 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8652 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8653 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8654 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8655 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8656 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8657 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8658 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8659 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8660 | cds_cfg->uc_tx_partition_base = |
| 8661 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8662 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8663 | |
| 8664 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8665 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8666 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8667 | cds_cfg->ce_classify_enabled = |
| 8668 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8669 | cds_cfg->bpf_packet_filter_enable = |
| 8670 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8671 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8672 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8673 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8674 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8675 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8676 | cds_cfg->max_msdus_per_rxinorderind = |
| 8677 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8678 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8679 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8680 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8681 | 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] | 8682 | cds_cfg->auto_power_save_fail_mode = |
| 8683 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8684 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8685 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8686 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8687 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8688 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8689 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8690 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8691 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8692 | cds_init_ini_config(cds_cfg); |
| 8693 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8694 | |
| 8695 | exit: |
| 8696 | qdf_mem_free(cds_cfg); |
| 8697 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8698 | } |
| 8699 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8700 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8701 | * hdd_update_user_config() - API to update user configuration |
| 8702 | * parameters to obj mgr which are used by multiple components |
| 8703 | * @hdd_ctx: HDD Context |
| 8704 | * |
| 8705 | * Return: 0 for Success, errno on failure |
| 8706 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8707 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8708 | { |
| 8709 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8710 | |
| 8711 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8712 | if (user_config == NULL) { |
| 8713 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8714 | return -ENOMEM; |
| 8715 | } |
| 8716 | |
| 8717 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8718 | user_config->dual_mac_feature_disable = |
| 8719 | hdd_ctx->config->dual_mac_feature_disable; |
| 8720 | user_config->indoor_channel_support = |
| 8721 | hdd_ctx->config->indoor_channel_support; |
| 8722 | user_config->is_11d_support_enabled = |
| 8723 | hdd_ctx->config->Is11dSupportEnabled; |
| 8724 | user_config->is_11h_support_enabled = |
| 8725 | hdd_ctx->config->Is11hSupportEnabled; |
| 8726 | user_config->optimize_chan_avoid_event = |
| 8727 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8728 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8729 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8730 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8731 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8732 | |
| 8733 | qdf_mem_free(user_config); |
| 8734 | return 0; |
| 8735 | } |
| 8736 | |
| 8737 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8738 | * hdd_init_thermal_info - Initialize thermal level |
| 8739 | * @hdd_ctx: HDD context |
| 8740 | * |
| 8741 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8742 | * which would be called when a configured thermal threshold is hit. |
| 8743 | * |
| 8744 | * Return: 0 on success and errno on failure |
| 8745 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8746 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8747 | { |
| 8748 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8749 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8750 | |
| 8751 | thermal_param.smeThermalMgmtEnabled = |
| 8752 | hdd_ctx->config->thermalMitigationEnable; |
| 8753 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8754 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8755 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8756 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8757 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8758 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8759 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8760 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8761 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8762 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8763 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8764 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8765 | hdd_ctx->config->thermalTempMinLevel0; |
| 8766 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8767 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8768 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8769 | hdd_ctx->config->thermalTempMinLevel1; |
| 8770 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8771 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8772 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8773 | hdd_ctx->config->thermalTempMinLevel2; |
| 8774 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8775 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8776 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8777 | hdd_ctx->config->thermalTempMinLevel3; |
| 8778 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8779 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8780 | |
| 8781 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8782 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8783 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8784 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8785 | |
| 8786 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8787 | hdd_set_thermal_level_cb); |
| 8788 | |
| 8789 | return 0; |
| 8790 | |
| 8791 | } |
| 8792 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8793 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8794 | /** |
| 8795 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8796 | * |
| 8797 | * Hold RTNL lock |
| 8798 | * |
| 8799 | * Return: True if held and false otherwise |
| 8800 | */ |
| 8801 | static inline bool hdd_hold_rtnl_lock(void) |
| 8802 | { |
| 8803 | rtnl_lock(); |
| 8804 | return true; |
| 8805 | } |
| 8806 | |
| 8807 | /** |
| 8808 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8809 | * |
| 8810 | * Release RTNL lock |
| 8811 | * |
| 8812 | * Return: None |
| 8813 | */ |
| 8814 | static inline void hdd_release_rtnl_lock(void) |
| 8815 | { |
| 8816 | rtnl_unlock(); |
| 8817 | } |
| 8818 | #else |
| 8819 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8820 | static inline void hdd_release_rtnl_lock(void) { } |
| 8821 | #endif |
| 8822 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8823 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8824 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8825 | /* MAX iwpriv command support */ |
| 8826 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8827 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8828 | #define MAX_PKTLOG_SIZE 16 |
| 8829 | |
| 8830 | /** |
| 8831 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8832 | * @hdd_ctx: hdd context |
| 8833 | * @set_value2: pktlog buffer size value |
| 8834 | * |
| 8835 | * |
| 8836 | * Return: 0 for success or error. |
| 8837 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8838 | 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] | 8839 | { |
| 8840 | struct sir_wifi_start_log start_log = { 0 }; |
| 8841 | QDF_STATUS status; |
| 8842 | |
| 8843 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8844 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8845 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8846 | start_log.user_triggered = 1; |
| 8847 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8848 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8849 | |
| 8850 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8851 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8852 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8853 | EXIT(); |
| 8854 | return -EINVAL; |
| 8855 | } |
| 8856 | |
| 8857 | return 0; |
| 8858 | } |
| 8859 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8860 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8861 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8862 | * @hdd_ctx: hdd context |
| 8863 | * |
| 8864 | * Return: 0 for success or error. |
| 8865 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8866 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8867 | { |
| 8868 | struct sir_wifi_start_log start_log; |
| 8869 | QDF_STATUS status; |
| 8870 | |
| 8871 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8872 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8873 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8874 | start_log.user_triggered = 1; |
| 8875 | start_log.size = 0; |
| 8876 | start_log.is_pktlog_buff_clear = true; |
| 8877 | |
| 8878 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8879 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8880 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8881 | EXIT(); |
| 8882 | return -EINVAL; |
| 8883 | } |
| 8884 | |
| 8885 | return 0; |
| 8886 | } |
| 8887 | |
| 8888 | |
| 8889 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8890 | * hdd_process_pktlog_command() - process pktlog command |
| 8891 | * @hdd_ctx: hdd context |
| 8892 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8893 | * @set_value2: pktlog buffer size value |
| 8894 | * |
| 8895 | * This function process pktlog command. |
| 8896 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8897 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8898 | * |
| 8899 | * Return: 0 for success or error. |
| 8900 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8901 | 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] | 8902 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8903 | { |
| 8904 | int ret; |
| 8905 | bool enable; |
| 8906 | uint8_t user_triggered = 0; |
| 8907 | |
| 8908 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8909 | if (0 != ret) |
| 8910 | return ret; |
| 8911 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8912 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8913 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8914 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8915 | hdd_err("invalid pktlog value %d", set_value); |
| 8916 | return -EINVAL; |
| 8917 | } |
| 8918 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8919 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8920 | if (set_value2 <= 0) { |
| 8921 | hdd_err("invalid pktlog size %d", set_value2); |
| 8922 | return -EINVAL; |
| 8923 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8924 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8925 | return -EINVAL; |
| 8926 | } |
| 8927 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8928 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8929 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8930 | } |
| 8931 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8932 | /* |
| 8933 | * set_value = 0 then disable packetlog |
| 8934 | * set_value = 1 enable packetlog forcefully |
| 8935 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8936 | * enable packetlog with AUTO type. |
| 8937 | */ |
| 8938 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8939 | true : false; |
| 8940 | |
| 8941 | if (1 == set_value) { |
| 8942 | enable = true; |
| 8943 | user_triggered = 1; |
| 8944 | } |
| 8945 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8946 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8947 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 8948 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8949 | /** |
| 8950 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8951 | * @hdd_ctx: HDD context |
| 8952 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8953 | * @user_triggered: triggered through iwpriv |
| 8954 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8955 | * |
| 8956 | * Return: 0 on success; error number otherwise |
| 8957 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8958 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8959 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8960 | { |
| 8961 | struct sir_wifi_start_log start_log; |
| 8962 | QDF_STATUS status; |
| 8963 | |
| 8964 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8965 | start_log.verbose_level = |
| 8966 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8967 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8968 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8969 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8970 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8971 | /* |
| 8972 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8973 | * commands. Host uses this flag to decide whether to send pktlog |
| 8974 | * disable command to fw without sending pktlog enable command |
| 8975 | * previously. For eg, If vendor sends pktlog disable command without |
| 8976 | * sending pktlog enable command, then host discards the packet |
| 8977 | * but for iwpriv command, host will send it to fw. |
| 8978 | */ |
| 8979 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8980 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8981 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8982 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8983 | EXIT(); |
| 8984 | return -EINVAL; |
| 8985 | } |
| 8986 | |
| 8987 | return 0; |
| 8988 | } |
| 8989 | #endif /* REMOVE_PKT_LOG */ |
| 8990 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8991 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8992 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 8993 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 8994 | * @dev: Device Pointer |
| 8995 | * @num: Number of Valid Mac address |
| 8996 | * |
| 8997 | * Return: Pointer to MAC address buffer |
| 8998 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 8999 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9000 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9001 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9002 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9003 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9004 | |
| 9005 | /** |
| 9006 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9007 | * @hdd_ctx: HDD Context |
| 9008 | * @num: Number of random mac addresses needed |
| 9009 | * |
| 9010 | * Generate random addresses using bit manipulation on the base mac address |
| 9011 | * |
| 9012 | * Return: None |
| 9013 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9014 | 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] | 9015 | { |
| 9016 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9017 | uint32_t iter; |
| 9018 | struct hdd_config *ini = hdd_ctx->config; |
| 9019 | uint8_t *buf = NULL; |
| 9020 | uint8_t macaddr_b3, tmp_br3; |
| 9021 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9022 | |
| 9023 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9024 | buf = ini->intfMacAddr[iter].bytes; |
| 9025 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9026 | macaddr_b3 = buf[3]; |
| 9027 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9028 | INTF_MACADDR_MASK; |
| 9029 | macaddr_b3 += tmp_br3; |
| 9030 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9031 | buf[0] |= 0x02; |
| 9032 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9033 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9034 | } |
| 9035 | } |
| 9036 | |
| 9037 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9038 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9039 | * @hdd_ctx: HDD Context |
| 9040 | * |
| 9041 | * API to get mac addresses from platform driver and update the driver |
| 9042 | * structures and configure FW with the base mac address. |
| 9043 | * Return: int |
| 9044 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9045 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9046 | { |
| 9047 | uint32_t no_of_mac_addr, iter; |
| 9048 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9049 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9050 | uint8_t *addr, *buf; |
| 9051 | struct device *dev = hdd_ctx->parent_dev; |
| 9052 | struct hdd_config *ini = hdd_ctx->config; |
| 9053 | tSirMacAddr mac_addr; |
| 9054 | QDF_STATUS status; |
| 9055 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9056 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9057 | |
| 9058 | if (no_of_mac_addr == 0 || !addr) { |
| 9059 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9060 | return -EINVAL; |
| 9061 | } |
| 9062 | |
| 9063 | if (no_of_mac_addr > max_mac_addr) |
| 9064 | no_of_mac_addr = max_mac_addr; |
| 9065 | |
| 9066 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9067 | |
| 9068 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9069 | buf = ini->intfMacAddr[iter].bytes; |
| 9070 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9071 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9072 | } |
| 9073 | |
| 9074 | status = sme_set_custom_mac_addr(mac_addr); |
| 9075 | |
| 9076 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9077 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9078 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9079 | if (no_of_mac_addr < max_mac_addr) |
| 9080 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9081 | no_of_mac_addr); |
| 9082 | return 0; |
| 9083 | } |
| 9084 | |
| 9085 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9086 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9087 | * @hdd_ctx: HDD Context |
| 9088 | * |
| 9089 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9090 | * will generate its own MAC and update it to FW. |
| 9091 | * |
| 9092 | * Return: 0 for success |
| 9093 | * Non-zero error code for failure |
| 9094 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9095 | 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] | 9096 | { |
| 9097 | tSirMacAddr customMacAddr; |
| 9098 | QDF_STATUS status; |
| 9099 | |
| 9100 | qdf_mem_copy(&customMacAddr, |
| 9101 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9102 | sizeof(tSirMacAddr)); |
| 9103 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9104 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9105 | return -EAGAIN; |
| 9106 | return 0; |
| 9107 | } |
| 9108 | |
| 9109 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9110 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9111 | * @hdd_ctx: HDD Context |
| 9112 | * |
| 9113 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9114 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9115 | * wlan_mac.bin to update HW MAC addresses. |
| 9116 | * |
| 9117 | * Return: None |
| 9118 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9119 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9120 | { |
| 9121 | QDF_STATUS status; |
| 9122 | int ret; |
| 9123 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9124 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9125 | if (ret == 0) |
| 9126 | return; |
| 9127 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9128 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9129 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9130 | |
| 9131 | status = hdd_update_mac_config(hdd_ctx); |
| 9132 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9133 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9134 | return; |
| 9135 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9136 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9137 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9138 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9139 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9140 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9141 | if (ret != 0) { |
| 9142 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9143 | QDF_ASSERT(ret); |
| 9144 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9145 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9146 | } |
| 9147 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9148 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9149 | { |
| 9150 | int vdev_id = 0; |
| 9151 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9152 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9153 | int vpdev = PDEV_CMD; |
| 9154 | int ret; |
| 9155 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9156 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9157 | if (ret) |
| 9158 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9159 | |
| 9160 | return ret; |
| 9161 | } |
| 9162 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9163 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9164 | { |
| 9165 | int vdev_id = 0; |
| 9166 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9167 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9168 | int vpdev = PDEV_CMD; |
| 9169 | int ret; |
| 9170 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9171 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9172 | if (ret) |
| 9173 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9174 | ret); |
| 9175 | |
| 9176 | return ret; |
| 9177 | } |
| 9178 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9179 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9180 | { |
| 9181 | int vdev_id = 0; |
| 9182 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9183 | int value = hdd_ctx->config->ani_enabled; |
| 9184 | int vpdev = PDEV_CMD; |
| 9185 | int ret; |
| 9186 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9187 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9188 | if (ret) |
| 9189 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9190 | |
| 9191 | return ret; |
| 9192 | } |
| 9193 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9194 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9195 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9196 | * @hdd_ctx: HDD context |
| 9197 | * |
| 9198 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9199 | * |
| 9200 | * Return: 0 on success and errno on failure. |
| 9201 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9202 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9203 | { |
| 9204 | int ret; |
| 9205 | QDF_STATUS status; |
| 9206 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9207 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9208 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9209 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9210 | /* |
| 9211 | * Set 802.11p config |
| 9212 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9213 | * parameter is set in CSR when we init the channel list. This should |
| 9214 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9215 | * domain. |
| 9216 | */ |
| 9217 | hdd_set_dot11p_config(hdd_ctx); |
| 9218 | |
| 9219 | /* |
| 9220 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9221 | * The cfg download must occur before we update the SME config |
| 9222 | * since the SME config operation must access the cfg database |
| 9223 | */ |
| 9224 | status = hdd_set_sme_config(hdd_ctx); |
| 9225 | |
| 9226 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9227 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9228 | ret = qdf_status_to_os_return(status); |
| 9229 | goto out; |
| 9230 | } |
| 9231 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9232 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9233 | if (QDF_STATUS_SUCCESS != status) { |
| 9234 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9235 | ret = qdf_status_to_os_return(status); |
| 9236 | goto out; |
| 9237 | } |
| 9238 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9239 | 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] | 9240 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9241 | PDEV_CMD); |
| 9242 | if (0 != ret) { |
| 9243 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9244 | goto out; |
| 9245 | } |
| 9246 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9247 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9248 | if (ret) |
| 9249 | goto out; |
| 9250 | |
| 9251 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9252 | if (ret) |
| 9253 | goto out; |
| 9254 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9255 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9256 | if (ret) |
| 9257 | goto out; |
| 9258 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9259 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9260 | hdd_ctx->config->arp_ac_category, |
| 9261 | PDEV_CMD); |
| 9262 | if (0 != ret) { |
| 9263 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9264 | hdd_ctx->config->arp_ac_category, ret); |
| 9265 | goto out; |
| 9266 | } |
| 9267 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9268 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9269 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9270 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9271 | ret = qdf_status_to_os_return(status); |
| 9272 | goto out; |
| 9273 | } |
| 9274 | |
| 9275 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9276 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9277 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9278 | ret = -EINVAL; |
| 9279 | goto out; |
| 9280 | } |
| 9281 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9282 | /* |
| 9283 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9284 | * Remove this once self sta is added as part of session open. |
| 9285 | */ |
| 9286 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9287 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9288 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9289 | |
| 9290 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9291 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9292 | hal_status, hal_status); |
| 9293 | ret = -EINVAL; |
| 9294 | goto out; |
| 9295 | } |
| 9296 | |
| 9297 | hdd_init_channel_avoidance(hdd_ctx); |
| 9298 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9299 | /* update enable sap mandatory chan list */ |
| 9300 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9301 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9302 | out: |
| 9303 | return ret; |
| 9304 | } |
| 9305 | |
| 9306 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9307 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9308 | * @context_ptr - hdd context pointer |
| 9309 | * @event_ptr - event structure pointer |
| 9310 | * |
| 9311 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9312 | * event back to supplicant to notify the stop reason. |
| 9313 | * |
| 9314 | * Return: None |
| 9315 | */ |
| 9316 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9317 | void *event_ptr) |
| 9318 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9319 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9320 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9321 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9322 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9323 | |
| 9324 | ENTER(); |
| 9325 | |
| 9326 | if (hdd_ctx == NULL) { |
| 9327 | hdd_err("Invalid HDD context pointer"); |
| 9328 | return; |
| 9329 | } |
| 9330 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9331 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9332 | if (!adapter) { |
| 9333 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9334 | evt->vdev_id); |
| 9335 | return; |
| 9336 | } |
| 9337 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9338 | vendor_event = |
| 9339 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9340 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9341 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9342 | GFP_KERNEL); |
| 9343 | |
| 9344 | if (!vendor_event) { |
| 9345 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9346 | return; |
| 9347 | } |
| 9348 | |
| 9349 | if (nla_put_u32(vendor_event, |
| 9350 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9351 | evt->reason_code)) { |
| 9352 | hdd_err("nla put failed"); |
| 9353 | kfree_skb(vendor_event); |
| 9354 | return; |
| 9355 | } |
| 9356 | |
| 9357 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9358 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9359 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9360 | } |
| 9361 | |
| 9362 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9363 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9364 | * @hdd_ctx: HDD context |
| 9365 | * |
| 9366 | * This function sends the adaptive dwell time config configuration to the |
| 9367 | * firmware via WMA |
| 9368 | * |
| 9369 | * Return: 0 - success, < 0 - failure |
| 9370 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9371 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9372 | { |
| 9373 | QDF_STATUS status; |
| 9374 | struct adaptive_dwelltime_params dwelltime_params; |
| 9375 | |
| 9376 | dwelltime_params.is_enabled = |
| 9377 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9378 | dwelltime_params.dwelltime_mode = |
| 9379 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9380 | dwelltime_params.lpf_weight = |
| 9381 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9382 | dwelltime_params.passive_mon_intval = |
| 9383 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9384 | dwelltime_params.wifi_act_threshold = |
| 9385 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9386 | |
| 9387 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9388 | &dwelltime_params); |
| 9389 | |
| 9390 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9391 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9392 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9393 | return -EAGAIN; |
| 9394 | } |
| 9395 | return 0; |
| 9396 | } |
| 9397 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9398 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9399 | { |
| 9400 | QDF_STATUS status; |
| 9401 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9402 | uint32_t i = 0; |
| 9403 | uint8_t count = 0, numentries = 0; |
| 9404 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9405 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9406 | |
| 9407 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9408 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9409 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9410 | return -EINVAL; |
| 9411 | |
| 9412 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9413 | dbs_scan_config, &numentries, |
| 9414 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9415 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9416 | |
| 9417 | hdd_info("numentries %hu", numentries); |
| 9418 | if (!numentries) { |
| 9419 | hdd_info("Donot send scan_selection_config"); |
| 9420 | return 0; |
| 9421 | } |
| 9422 | |
| 9423 | /* hdd_set_fw_log_params */ |
| 9424 | dbs_scan_params.num_clients = 0; |
| 9425 | while (count < (numentries - 2)) { |
| 9426 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9427 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9428 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9429 | dbs_scan_config[count + 2]; |
| 9430 | dbs_scan_params.num_clients++; |
| 9431 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9432 | dbs_scan_params.module_id[i], |
| 9433 | dbs_scan_params.num_dbs_scans[i], |
| 9434 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9435 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9436 | i++; |
| 9437 | } |
| 9438 | |
| 9439 | dbs_scan_params.pdev_id = 0; |
| 9440 | |
| 9441 | hdd_debug("clients:%d pdev:%d", |
| 9442 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9443 | |
| 9444 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9445 | &dbs_scan_params); |
| 9446 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9447 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9448 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9449 | return -EAGAIN; |
| 9450 | } |
| 9451 | return 0; |
| 9452 | } |
| 9453 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9454 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9455 | /** |
| 9456 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9457 | * @hdd_ctx: HDD context |
| 9458 | * |
| 9459 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9460 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9461 | * |
| 9462 | * Return: 0 on success and errno on failure. |
| 9463 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9464 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9465 | { |
| 9466 | QDF_STATUS status; |
| 9467 | |
| 9468 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9469 | return 0; |
| 9470 | |
| 9471 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9472 | wlan_hdd_auto_shutdown_cb); |
| 9473 | if (status != QDF_STATUS_SUCCESS) |
| 9474 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9475 | status); |
| 9476 | |
| 9477 | return qdf_status_to_os_return(status); |
| 9478 | } |
| 9479 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9480 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9481 | { |
| 9482 | return 0; |
| 9483 | } |
| 9484 | #endif |
| 9485 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9486 | 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] | 9487 | { |
| 9488 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9489 | |
| 9490 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9491 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9492 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9493 | if (status != QDF_STATUS_SUCCESS) |
| 9494 | hdd_err("Failed to disable dual mac features"); |
| 9495 | break; |
| 9496 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9497 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9498 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9499 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9500 | if (status != QDF_STATUS_SUCCESS) |
| 9501 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9502 | break; |
| 9503 | default: |
| 9504 | break; |
| 9505 | } |
| 9506 | |
| 9507 | return status; |
| 9508 | } |
| 9509 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9510 | /** |
| 9511 | * hdd_features_init() - Init features |
| 9512 | * @hdd_ctx: HDD context |
| 9513 | * @adapter: Primary adapter context |
| 9514 | * |
| 9515 | * Initialize features and their feature context after WLAN firmware is up. |
| 9516 | * |
| 9517 | * Return: 0 on success and errno on failure. |
| 9518 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9519 | 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] | 9520 | { |
| 9521 | tSirTxPowerLimit hddtxlimit; |
| 9522 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9523 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9524 | int ret; |
| 9525 | |
| 9526 | ENTER(); |
| 9527 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9528 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9529 | if (ret) { |
| 9530 | hdd_err("Failed to update country code: %d", ret); |
| 9531 | goto out; |
| 9532 | } |
| 9533 | |
| 9534 | /* FW capabilities received, Set the Dot11 mode */ |
| 9535 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9536 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9537 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9538 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9539 | |
| 9540 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9541 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9542 | else |
| 9543 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9544 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9545 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9546 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9547 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9548 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9549 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9550 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9551 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9552 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9553 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9554 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9555 | if (hdd_lro_init(hdd_ctx)) |
| 9556 | hdd_err("Unable to initialize LRO in fw"); |
| 9557 | |
| 9558 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9559 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9560 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9561 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9562 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9563 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9564 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9565 | if (ret) { |
| 9566 | hdd_err("Error while initializing thermal information"); |
| 9567 | goto deregister_frames; |
| 9568 | } |
| 9569 | |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9570 | if (cds_is_packet_log_enabled()) |
| 9571 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9572 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9573 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9574 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9575 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9576 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9577 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9578 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9579 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9580 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9581 | ret = hdd_register_cb(hdd_ctx); |
| 9582 | if (ret) { |
| 9583 | hdd_err("Failed to register HDD callbacks!"); |
| 9584 | goto deregister_frames; |
| 9585 | } |
| 9586 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9587 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9588 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9589 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9590 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9591 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9592 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9593 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9594 | status = sme_enable_disable_chanavoidind_event( |
| 9595 | hdd_ctx->hHal, 0); |
| 9596 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9597 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9598 | goto deregister_cb; |
| 9599 | } |
| 9600 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9601 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9602 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9603 | band_pref_params.rssi_boost_threshold_5g = |
| 9604 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9605 | band_pref_params.rssi_boost_factor_5g = |
| 9606 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9607 | band_pref_params.max_rssi_boost_5g = |
| 9608 | hdd_ctx->config->max_rssi_boost_5g; |
| 9609 | band_pref_params.rssi_penalize_threshold_5g = |
| 9610 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9611 | band_pref_params.rssi_penalize_factor_5g = |
| 9612 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9613 | band_pref_params.max_rssi_penalize_5g = |
| 9614 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9615 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9616 | } |
| 9617 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9618 | /* register P2P Listen Offload event callback */ |
| 9619 | if (wma_is_p2p_lo_capable()) |
| 9620 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9621 | wlan_hdd_p2p_lo_event_callback); |
| 9622 | |
| 9623 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9624 | |
| 9625 | if (ret) |
| 9626 | goto deregister_cb; |
| 9627 | |
| 9628 | EXIT(); |
| 9629 | return 0; |
| 9630 | |
| 9631 | deregister_cb: |
| 9632 | hdd_deregister_cb(hdd_ctx); |
| 9633 | deregister_frames: |
| 9634 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9635 | out: |
| 9636 | return -EINVAL; |
| 9637 | |
| 9638 | } |
| 9639 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9640 | /** |
| 9641 | * hdd_features_deinit() - Deinit features |
| 9642 | * @hdd_ctx: HDD context |
| 9643 | * |
| 9644 | * De-Initialize features and their feature context. |
| 9645 | * |
| 9646 | * Return: none. |
| 9647 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9648 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9649 | { |
| 9650 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9651 | } |
| 9652 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9653 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9654 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9655 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9656 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9657 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9658 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9659 | 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] | 9660 | { |
| 9661 | QDF_STATUS status; |
| 9662 | |
| 9663 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9664 | wlan_cfg80211_inform_bss_frame, |
| 9665 | SCAN_CB_TYPE_INFORM_BCN); |
| 9666 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9667 | hdd_err("failed with status code %08d [x%08x]", |
| 9668 | status, status); |
| 9669 | return status; |
| 9670 | } |
| 9671 | |
| 9672 | return QDF_STATUS_SUCCESS; |
| 9673 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9674 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9675 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9676 | * hdd_configure_cds() - Configure cds modules |
| 9677 | * @hdd_ctx: HDD context |
| 9678 | * @adapter: Primary adapter context |
| 9679 | * |
| 9680 | * Enable Cds modules after WLAN firmware is up. |
| 9681 | * |
| 9682 | * Return: 0 on success and errno on failure. |
| 9683 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9684 | 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] | 9685 | { |
| 9686 | int ret; |
| 9687 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9688 | int set_value; |
| 9689 | uint32_t num_abg_tx_chains = 0; |
| 9690 | uint32_t num_11b_tx_chains = 0; |
| 9691 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9692 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9693 | |
| 9694 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9695 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9696 | hdd_ctx->config->sifs_burst_duration; |
| 9697 | |
| 9698 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9699 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9700 | set_value, PDEV_CMD); |
| 9701 | } |
| 9702 | |
| 9703 | if (hdd_ctx->config->is_force_1x1) |
| 9704 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9705 | 1, PDEV_CMD); |
| 9706 | /* set chip power save failure detected callback */ |
| 9707 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9708 | hdd_chip_pwr_save_fail_detected_cb); |
| 9709 | |
| 9710 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9711 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9712 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9713 | set_value, PDEV_CMD); |
| 9714 | } |
| 9715 | |
| 9716 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9717 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9718 | sme_cli_set_command(0, |
| 9719 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9720 | set_value, PDEV_CMD); |
| 9721 | } |
| 9722 | |
| 9723 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9724 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9725 | sme_cli_set_command(0, |
| 9726 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9727 | set_value, PDEV_CMD); |
| 9728 | } |
| 9729 | |
| 9730 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9731 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9732 | if (!hdd_ctx->config->enable2x2) { |
| 9733 | if (num_11b_tx_chains > 1) |
| 9734 | num_11b_tx_chains = 1; |
| 9735 | if (num_11ag_tx_chains > 1) |
| 9736 | num_11ag_tx_chains = 1; |
| 9737 | } |
| 9738 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9739 | num_11b_tx_chains); |
| 9740 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9741 | num_11ag_tx_chains); |
| 9742 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9743 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9744 | |
| 9745 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9746 | if (ret) { |
| 9747 | hdd_err("Failed to pre-configure cds"); |
| 9748 | goto out; |
| 9749 | } |
| 9750 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9751 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9752 | * IPA module before configuring them to FW. Sequence required as crash |
| 9753 | * observed otherwise. |
| 9754 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9755 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9756 | hdd_err("Failed to setup pipes"); |
| 9757 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9758 | } |
| 9759 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9760 | /* |
| 9761 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9762 | * else |
| 9763 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9764 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9765 | |
| 9766 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9767 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9768 | goto out; |
| 9769 | } |
| 9770 | |
| 9771 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9772 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9773 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9774 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9775 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9776 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9777 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9778 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9779 | goto cds_disable; |
| 9780 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9781 | |
| 9782 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9783 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9784 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9785 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9786 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9787 | 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] | 9788 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9789 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9790 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9791 | goto cds_disable; |
| 9792 | } |
| 9793 | |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9794 | if (hdd_enable_egap(hdd_ctx)) |
| 9795 | hdd_debug("enhance green ap is not enabled"); |
| 9796 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9797 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9798 | hdd_debug("Failed to set wow pulse"); |
| 9799 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9800 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9801 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9802 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9803 | |
| 9804 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9805 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9806 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9807 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9808 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9809 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9810 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9811 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9812 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9813 | out: |
| 9814 | return -EINVAL; |
| 9815 | } |
| 9816 | |
| 9817 | /** |
| 9818 | * hdd_deconfigure_cds() -De-Configure cds |
| 9819 | * @hdd_ctx: HDD context |
| 9820 | * |
| 9821 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9822 | * |
| 9823 | * Return: 0 on success and errno on failure. |
| 9824 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9825 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9826 | { |
| 9827 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9828 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9829 | |
| 9830 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9831 | |
| 9832 | /* De-init features */ |
| 9833 | hdd_features_deinit(hdd_ctx); |
| 9834 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9835 | /* De-register the SME callbacks */ |
| 9836 | hdd_deregister_cb(hdd_ctx); |
| 9837 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9838 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9839 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9840 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9841 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9842 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9843 | } |
| 9844 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9845 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9846 | hdd_err("Failed to disconnect pipes"); |
| 9847 | ret = -EINVAL; |
| 9848 | } |
| 9849 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9850 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9851 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9852 | } |
| 9853 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9854 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9855 | static void hdd_deregister_policy_manager_callback( |
| 9856 | struct wlan_objmgr_psoc *psoc) |
| 9857 | { |
| 9858 | if (QDF_STATUS_SUCCESS != |
| 9859 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9860 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9861 | } |
| 9862 | } |
| 9863 | #else |
| 9864 | static void hdd_deregister_policy_manager_callback( |
| 9865 | struct wlan_objmgr_psoc *psoc) |
| 9866 | { |
| 9867 | } |
| 9868 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9869 | |
| 9870 | /** |
| 9871 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9872 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9873 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9874 | * |
| 9875 | * This function maintains the driver state machine it will be invoked from |
| 9876 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9877 | * shall perform the stopping/closing of the modules. |
| 9878 | * |
| 9879 | * Return: 0 for success; non-zero for failure |
| 9880 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9881 | 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] | 9882 | { |
| 9883 | void *hif_ctx; |
| 9884 | qdf_device_t qdf_ctx; |
| 9885 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9886 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 9887 | bool is_recovery_stop = cds_is_driver_recovering(); |
| 9888 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9889 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9890 | |
| 9891 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9892 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 9893 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9894 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9895 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 9896 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9897 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9898 | if (!qdf_ctx) { |
| 9899 | hdd_err("QDF device context NULL"); |
| 9900 | return -EINVAL; |
| 9901 | } |
| 9902 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9903 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 9904 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9905 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9906 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9907 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9908 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9909 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9910 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9911 | |
| 9912 | cds_print_external_threads(); |
| 9913 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9914 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9915 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 9916 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 9917 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9918 | hdd_prevent_suspend_timeout( |
| 9919 | hdd_ctx->config->iface_change_wait_time, |
| 9920 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9921 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9922 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9923 | return 0; |
| 9924 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9925 | } |
| 9926 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9927 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 9928 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 9929 | /* free user wowl patterns */ |
| 9930 | hdd_free_user_wowl_ptrns(); |
| 9931 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9932 | switch (hdd_ctx->driver_status) { |
| 9933 | case DRIVER_MODULES_UNINITIALIZED: |
| 9934 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9935 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9936 | case DRIVER_MODULES_CLOSED: |
| 9937 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9938 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9939 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9940 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 9941 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 9942 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9943 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9944 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9945 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9946 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9947 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9948 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9949 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9950 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9951 | hdd_info("Wlan transitioned (now OPENED)"); |
| 9952 | |
| 9953 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9954 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9955 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9956 | break; |
| 9957 | default: |
| 9958 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 9959 | hdd_ctx->driver_status); |
| 9960 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9961 | ret = -EINVAL; |
| 9962 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9963 | } |
| 9964 | |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9965 | hdd_debug("Closing CDS modules!"); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 9966 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9967 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9968 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 9969 | qdf_status); |
| 9970 | ret = -EINVAL; |
| 9971 | QDF_ASSERT(0); |
| 9972 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 9973 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame^] | 9974 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 9975 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 9976 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 9977 | if (ret) { |
| 9978 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 9979 | QDF_ASSERT(0); |
| 9980 | } |
| 9981 | |
| 9982 | /* |
| 9983 | * Reset total mac phy during module stop such that during |
| 9984 | * next module start same psoc is used to populate new service |
| 9985 | * ready data |
| 9986 | */ |
| 9987 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
| 9988 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 9989 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 9990 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9991 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 9992 | ret = -EINVAL; |
| 9993 | QDF_ASSERT(0); |
| 9994 | } |
| 9995 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 9996 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9997 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9998 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9999 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10000 | QDF_ASSERT(0); |
| 10001 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10002 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10003 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10004 | if (!hif_ctx) { |
| 10005 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10006 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10007 | } |
| 10008 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10009 | if (hdd_ctx->target_hw_name) { |
| 10010 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10011 | hdd_ctx->target_hw_name = NULL; |
| 10012 | } |
| 10013 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10014 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10015 | |
| 10016 | ol_cds_free(); |
| 10017 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10018 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10019 | ret = pld_power_off(qdf_ctx->dev); |
| 10020 | if (ret) |
| 10021 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10022 | ret); |
| 10023 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10024 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10025 | /* many adapter resources are not freed by design in SSR case */ |
| 10026 | if (!is_recovery_stop) |
| 10027 | hdd_check_for_leaks(); |
| 10028 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
| 10029 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10030 | /* Once the firmware sequence is completed reset this flag */ |
| 10031 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10032 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10033 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10034 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10035 | done: |
| 10036 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10037 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10038 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10039 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10040 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10041 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10042 | EXIT(); |
| 10043 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10044 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10045 | } |
| 10046 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10047 | |
| 10048 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10049 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10050 | * @buf: buffer pointer |
| 10051 | * @size: size of buffer to be filled |
| 10052 | * |
| 10053 | * This function is used to dump state information of hdd layer |
| 10054 | * |
| 10055 | * Return: None |
| 10056 | */ |
| 10057 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10058 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10059 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10060 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10061 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10062 | uint16_t len = 0; |
| 10063 | char *buf = *buf_ptr; |
| 10064 | |
| 10065 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10066 | if (!hdd_ctx) { |
| 10067 | hdd_err("Failed to get hdd context "); |
| 10068 | return; |
| 10069 | } |
| 10070 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10071 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10072 | |
| 10073 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10074 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10075 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10076 | "\n is_scheduler_suspended %d", |
| 10077 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10078 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10079 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10080 | if (adapter->dev) |
| 10081 | len += scnprintf(buf + len, *size - len, |
| 10082 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10083 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10084 | "\n device_mode: %d", adapter->device_mode); |
| 10085 | switch (adapter->device_mode) { |
| 10086 | case QDF_STA_MODE: |
| 10087 | case QDF_P2P_CLIENT_MODE: |
| 10088 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10089 | len += scnprintf(buf + len, *size - len, |
| 10090 | "\n connState: %d", |
| 10091 | hdd_sta_ctx->conn_info.connState); |
| 10092 | break; |
| 10093 | |
| 10094 | default: |
| 10095 | break; |
| 10096 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10097 | } |
| 10098 | |
| 10099 | *size -= len; |
| 10100 | *buf_ptr += len; |
| 10101 | } |
| 10102 | |
| 10103 | /** |
| 10104 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10105 | * to print hdd state information |
| 10106 | * |
| 10107 | * Return: None |
| 10108 | */ |
| 10109 | static void hdd_register_debug_callback(void) |
| 10110 | { |
| 10111 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10112 | } |
| 10113 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10114 | /* |
| 10115 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10116 | * |
| 10117 | * This function is used to create bug report lock |
| 10118 | * |
| 10119 | * Return: None |
| 10120 | */ |
| 10121 | static void wlan_init_bug_report_lock(void) |
| 10122 | { |
| 10123 | p_cds_contextType p_cds_context; |
| 10124 | |
| 10125 | p_cds_context = cds_get_global_context(); |
| 10126 | if (!p_cds_context) { |
| 10127 | hdd_err("cds context is NULL"); |
| 10128 | return; |
| 10129 | } |
| 10130 | |
| 10131 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10132 | } |
| 10133 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10134 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10135 | { |
| 10136 | |
| 10137 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10138 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10139 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10140 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10141 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10142 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10143 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10144 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10145 | |
| 10146 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10147 | &num_entries, sizeof(config_params)); |
| 10148 | |
| 10149 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10150 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10151 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10152 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10153 | else if (bw_compute_interval > 1000) { |
| 10154 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10155 | thresh_time_limit = 1; |
| 10156 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10157 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10158 | |
| 10159 | switch (num_entries) { |
| 10160 | case 4: |
| 10161 | proto_bitmap = config_params[3]; |
| 10162 | case 3: |
| 10163 | verbosity = config_params[2]; |
| 10164 | case 2: |
| 10165 | thresh = config_params[1]; |
| 10166 | case 1: |
| 10167 | live_mode = config_params[0]; |
| 10168 | default: |
| 10169 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 10170 | live_mode, thresh, thresh_time_limit, |
| 10171 | verbosity, proto_bitmap); |
| 10172 | }; |
| 10173 | |
| 10174 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10175 | verbosity, proto_bitmap); |
| 10176 | |
| 10177 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10178 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10179 | * hdd_wlan_startup() - HDD init function |
| 10180 | * @dev: Pointer to the underlying device |
| 10181 | * |
| 10182 | * This is the driver startup code executed once a WLAN device has been detected |
| 10183 | * |
| 10184 | * Return: 0 for success, < 0 for failure |
| 10185 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10186 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10187 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10188 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10189 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10190 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10191 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10192 | |
| 10193 | ENTER(); |
| 10194 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10195 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10196 | |
| 10197 | if (IS_ERR(hdd_ctx)) |
| 10198 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10199 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10200 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10201 | DEFAULT_PSOC_ID); |
| 10202 | if (ret) { |
| 10203 | hdd_err("Psoc creation fails!"); |
| 10204 | QDF_BUG(0); |
| 10205 | goto err_hdd_free_context; |
| 10206 | } |
| 10207 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10208 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10209 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10210 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10211 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10212 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10213 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 10214 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10215 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10216 | memdump_init(); |
| 10217 | hdd_driver_memdump_init(); |
| 10218 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10219 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10220 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10221 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10222 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10223 | } |
| 10224 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10225 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10226 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10227 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10228 | |
| 10229 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10230 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10231 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10232 | } |
| 10233 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10234 | ret = hdd_wiphy_init(hdd_ctx); |
| 10235 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10236 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10237 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10238 | } |
| 10239 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10240 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10241 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10242 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10243 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10244 | goto err_wiphy_unregister; |
| 10245 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 10246 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10247 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10248 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10249 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10250 | ret = hdd_register_notifiers(hdd_ctx); |
| 10251 | if (ret) |
| 10252 | goto err_ipa_cleanup; |
| 10253 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10254 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10255 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10256 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10257 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10258 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10259 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10260 | } |
| 10261 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10262 | hdd_release_rtnl_lock(); |
| 10263 | rtnl_held = false; |
| 10264 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10265 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10266 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10267 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10268 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10269 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10270 | hdd_skip_acs_scan_timer_handler, |
| 10271 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10272 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10273 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10274 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10275 | #endif |
| 10276 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10277 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10278 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10279 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10280 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10281 | if (hdd_ctx->rps) |
| 10282 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10283 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 10284 | status = wlansap_global_init(); |
| 10285 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10286 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10287 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10288 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10289 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10290 | else |
| 10291 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10292 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10293 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10294 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10295 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10296 | hdd_prevent_suspend_timeout( |
| 10297 | hdd_ctx->config->iface_change_wait_time, |
| 10298 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10299 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10300 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10301 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10302 | goto success; |
| 10303 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10304 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10305 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10306 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10307 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10308 | if (rtnl_held) |
| 10309 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10310 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10311 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10312 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10313 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10314 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10315 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10316 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10317 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10318 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10319 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10320 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10321 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10322 | err_memdump_deinit: |
| 10323 | hdd_driver_memdump_deinit(); |
| 10324 | memdump_deinit(); |
| 10325 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 10326 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10327 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10328 | hdd_exit_netlink_services(hdd_ctx); |
| 10329 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10330 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10331 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10332 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10333 | if (cds_is_fw_down()) |
| 10334 | hdd_err("Not setting the complete event as fw is down"); |
| 10335 | else |
| 10336 | hdd_start_complete(ret); |
| 10337 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10338 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10339 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10340 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10341 | |
| 10342 | success: |
| 10343 | EXIT(); |
| 10344 | return 0; |
| 10345 | } |
| 10346 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10347 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10348 | * hdd_wlan_update_target_info() - update target type info |
| 10349 | * @hdd_ctx: HDD context |
| 10350 | * @context: hif context |
| 10351 | * |
| 10352 | * Update target info received from firmware in hdd context |
| 10353 | * Return:None |
| 10354 | */ |
| 10355 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10356 | 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] | 10357 | { |
| 10358 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10359 | |
| 10360 | if (!tgt_info) { |
| 10361 | hdd_err("Target info is Null"); |
| 10362 | return; |
| 10363 | } |
| 10364 | |
| 10365 | hdd_ctx->target_type = tgt_info->target_type; |
| 10366 | } |
| 10367 | |
| 10368 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10369 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10370 | * received from the firmware |
| 10371 | * @data: pointer to adapter. |
| 10372 | * @rsp: pointer to data received from FW. |
| 10373 | * |
| 10374 | * This is called when wlan driver received response event for |
| 10375 | * get arp stats to firmware. |
| 10376 | * |
| 10377 | * Return: None |
| 10378 | */ |
| 10379 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10380 | { |
| 10381 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10382 | struct hdd_nud_stats_context *context; |
| 10383 | int status; |
| 10384 | struct hdd_adapter *adapter = NULL; |
| 10385 | |
| 10386 | ENTER(); |
| 10387 | |
| 10388 | if (!rsp) { |
| 10389 | hdd_err("data is null"); |
| 10390 | return; |
| 10391 | } |
| 10392 | |
| 10393 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10394 | if (0 != status) |
| 10395 | return; |
| 10396 | |
| 10397 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10398 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10399 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10400 | return; |
| 10401 | } |
| 10402 | |
| 10403 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10404 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10405 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10406 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10407 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10408 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10409 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10410 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10411 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10412 | rsp->ba_session_establishment_status); |
| 10413 | |
| 10414 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10415 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10416 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10417 | adapter->dad |= rsp->dad_detected; |
| 10418 | adapter->con_status = rsp->connect_status; |
| 10419 | |
| 10420 | spin_lock(&hdd_context_lock); |
| 10421 | context = &hdd_ctx->nud_stats_context; |
| 10422 | complete(&context->response_event); |
| 10423 | spin_unlock(&hdd_context_lock); |
| 10424 | |
| 10425 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10426 | } |
| 10427 | |
| 10428 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10429 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10430 | * @hdd_ctx: HDD context |
| 10431 | * |
| 10432 | * Register the HDD callbacks to CDS/SME. |
| 10433 | * |
| 10434 | * Return: 0 for success or Error code for failure |
| 10435 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10436 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10437 | { |
| 10438 | QDF_STATUS status; |
| 10439 | int ret = 0; |
| 10440 | |
| 10441 | ENTER(); |
| 10442 | |
| 10443 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10444 | |
| 10445 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10446 | hdd_send_oem_data_rsp_msg); |
| 10447 | |
| 10448 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 10449 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 10450 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10451 | hdd_err("Failed to register memdump callback"); |
| 10452 | ret = -EINVAL; |
| 10453 | return ret; |
| 10454 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10455 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10456 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10457 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10458 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10459 | wlan_hdd_cfg80211_nan_callback); |
| 10460 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10461 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10462 | |
| 10463 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10464 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10465 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10466 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10467 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10468 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10469 | hdd_rssi_threshold_breached); |
| 10470 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10471 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10472 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10473 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10474 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10475 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10476 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10477 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10478 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10479 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10480 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10481 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10482 | hdd_lost_link_info_cb); |
| 10483 | /* print error and not block the startup process */ |
| 10484 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10485 | hdd_err("set lost link info callback failed"); |
| 10486 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10487 | ret = hdd_register_data_stall_detect_cb(); |
| 10488 | if (ret) { |
| 10489 | hdd_err("Register data stall detect detect callback failed."); |
| 10490 | return ret; |
| 10491 | } |
| 10492 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10493 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10494 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10495 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10496 | hdd_set_connection_in_progress, |
| 10497 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10498 | |
| 10499 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10500 | hdd_update_cca_info_cb); |
| 10501 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10502 | hdd_err("set congestion callback failed"); |
| 10503 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10504 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10505 | hdd_bt_activity_cb); |
| 10506 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10507 | hdd_err("set bt activity info callback failed"); |
| 10508 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10509 | EXIT(); |
| 10510 | |
| 10511 | return ret; |
| 10512 | } |
| 10513 | |
| 10514 | /** |
| 10515 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10516 | * @hdd_ctx: HDD context |
| 10517 | * |
| 10518 | * De-Register the HDD callbacks to CDS/SME. |
| 10519 | * |
| 10520 | * Return: void |
| 10521 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10522 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10523 | { |
| 10524 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10525 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10526 | |
| 10527 | ENTER(); |
| 10528 | |
| 10529 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10530 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10531 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10532 | status); |
| 10533 | |
| 10534 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10535 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10536 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10537 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10538 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10539 | |
| 10540 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10541 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10542 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10543 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10544 | status); |
| 10545 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 10546 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10547 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 10548 | status); |
| 10549 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10550 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10551 | if (ret) |
| 10552 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10553 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10554 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10555 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10556 | |
| 10557 | EXIT(); |
| 10558 | } |
| 10559 | |
| 10560 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10561 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10562 | * @adapter: Pointer to the HDD |
| 10563 | * @enable: bool value |
| 10564 | * |
| 10565 | * This to take counter measure to handle deauth req from HDD |
| 10566 | * |
| 10567 | * Return: None |
| 10568 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10569 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10570 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10571 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10572 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10573 | |
| 10574 | ENTER(); |
| 10575 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10576 | /* Ignore request to deauth bcmc station */ |
| 10577 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10578 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10579 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10580 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10581 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10582 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10583 | |
| 10584 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10585 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10586 | } |
| 10587 | |
| 10588 | /** |
| 10589 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10590 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10591 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10592 | * |
| 10593 | * This to take counter measure to handle deauth req from HDD |
| 10594 | * |
| 10595 | * Return: None |
| 10596 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10597 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10598 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10599 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10600 | ENTER(); |
| 10601 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10602 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10603 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10604 | return; |
| 10605 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10606 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10607 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10608 | } |
| 10609 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10610 | /** |
| 10611 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10612 | * @hdd_ctx: HDD Context |
| 10613 | * |
| 10614 | * API to find if there is any STA or P2P-Client is connected |
| 10615 | * |
| 10616 | * Return: true if connected; false otherwise |
| 10617 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10618 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10619 | { |
| 10620 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10621 | } |
| 10622 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10623 | /** |
| 10624 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10625 | * @adapter: HDD adapter pointer |
| 10626 | * |
| 10627 | * This function loop through each adapter and disable roaming on each STA |
| 10628 | * device mode except the input adapter. |
| 10629 | * |
| 10630 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10631 | * disable. |
| 10632 | * |
| 10633 | * Return: None |
| 10634 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10635 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10636 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10637 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10638 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10639 | |
| 10640 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10641 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10642 | QDF_STA_MODE == adapter->device_mode && |
| 10643 | policy_mgr_is_sta_active_connection_exists( |
| 10644 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10645 | hdd_debug("Connect received on STA session Id(%d)", |
| 10646 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10647 | /* |
| 10648 | * Loop through adapter and disable roaming for each STA device |
| 10649 | * mode except the input adapter. |
| 10650 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10651 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10652 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10653 | adapter->session_id != adapterIdx->session_id) { |
| 10654 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10655 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10656 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10657 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10658 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10659 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10660 | } |
| 10661 | } |
| 10662 | } |
| 10663 | |
| 10664 | /** |
| 10665 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10666 | * @adapter: HDD adapter pointer |
| 10667 | * |
| 10668 | * This function loop through each adapter and enable roaming on each STA |
| 10669 | * device mode except the input adapter. |
| 10670 | * Note: On the input adapter no need to enable roaming because link got |
| 10671 | * disconnected on this. |
| 10672 | * |
| 10673 | * Return: None |
| 10674 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10675 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10676 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10677 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10678 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10679 | |
| 10680 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10681 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10682 | QDF_STA_MODE == adapter->device_mode && |
| 10683 | policy_mgr_is_sta_active_connection_exists( |
| 10684 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10685 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10686 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10687 | /* |
| 10688 | * Loop through adapter and enable roaming for each STA device |
| 10689 | * mode except the input adapter. |
| 10690 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10691 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10692 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10693 | adapter->session_id != adapterIdx->session_id) { |
| 10694 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10695 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10696 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10697 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10698 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10699 | REASON_CONNECT); |
| 10700 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10701 | } |
| 10702 | } |
| 10703 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10704 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10705 | /** |
| 10706 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10707 | * @skb: sk buffer pointer |
| 10708 | * |
| 10709 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10710 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10711 | * |
| 10712 | * Return: None |
| 10713 | */ |
| 10714 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10715 | { |
| 10716 | #ifdef CNSS_GENL |
| 10717 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10718 | #else |
| 10719 | nl_srv_bcast(skb); |
| 10720 | #endif |
| 10721 | } |
| 10722 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10723 | 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] | 10724 | { |
| 10725 | struct sk_buff *skb; |
| 10726 | struct nlmsghdr *nlh; |
| 10727 | tAniMsgHdr *ani_hdr; |
| 10728 | void *nl_data = NULL; |
| 10729 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10730 | struct radio_index_tlv *radio_info; |
| 10731 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10732 | |
| 10733 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10734 | flags = GFP_ATOMIC; |
| 10735 | |
| 10736 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10737 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10738 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10739 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10740 | |
| 10741 | nlh = (struct nlmsghdr *)skb->data; |
| 10742 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10743 | nlh->nlmsg_flags = 0; |
| 10744 | nlh->nlmsg_seq = 0; |
| 10745 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10746 | |
| 10747 | ani_hdr = NLMSG_DATA(nlh); |
| 10748 | ani_hdr->type = type; |
| 10749 | |
| 10750 | switch (type) { |
| 10751 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10752 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10753 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10754 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10755 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10756 | ani_hdr->length = 0; |
| 10757 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10758 | break; |
| 10759 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10760 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10761 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10762 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10763 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10764 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10765 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10766 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10767 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 10768 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10769 | ani_hdr->length = len; |
| 10770 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10771 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10772 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10773 | break; |
| 10774 | |
| 10775 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10776 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10777 | type); |
| 10778 | kfree_skb(skb); |
| 10779 | return; |
| 10780 | } |
| 10781 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10782 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10783 | * Add radio index at the end of the svc event in TLV format |
| 10784 | * to maintain the backward compatibility with userspace |
| 10785 | * applications. |
| 10786 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10787 | |
| 10788 | tlv_len = 0; |
| 10789 | |
| 10790 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10791 | < WLAN_NL_MAX_PAYLOAD) { |
| 10792 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10793 | sizeof(*ani_hdr) + len); |
| 10794 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10795 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10796 | radio_info->radio = radio; |
| 10797 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10798 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10799 | "Added radio index tlv - radio index %d", |
| 10800 | radio_info->radio); |
| 10801 | } |
| 10802 | |
| 10803 | nlh->nlmsg_len += tlv_len; |
| 10804 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10805 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10806 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10807 | } |
| 10808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10809 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10810 | void wlan_hdd_auto_shutdown_cb(void) |
| 10811 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10812 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10813 | |
| 10814 | if (!hdd_ctx) |
| 10815 | return; |
| 10816 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10817 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10818 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10819 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10820 | } |
| 10821 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10822 | 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] | 10823 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10824 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10825 | bool ap_connected = false, sta_connected = false; |
| 10826 | tHalHandle hal_handle; |
| 10827 | |
| 10828 | hal_handle = hdd_ctx->hHal; |
| 10829 | if (hal_handle == NULL) |
| 10830 | return; |
| 10831 | |
| 10832 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10833 | return; |
| 10834 | |
| 10835 | if (enable == false) { |
| 10836 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10837 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10838 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10839 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10840 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10841 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10842 | return; |
| 10843 | } |
| 10844 | |
| 10845 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10846 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 10847 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10848 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10849 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10850 | conn_info.connState == |
| 10851 | eConnectionState_Associated) { |
| 10852 | sta_connected = true; |
| 10853 | break; |
| 10854 | } |
| 10855 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10856 | |
| 10857 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10858 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10859 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10860 | ap_connected = true; |
| 10861 | break; |
| 10862 | } |
| 10863 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10864 | } |
| 10865 | } |
| 10866 | |
| 10867 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10868 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10869 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10870 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10871 | |
| 10872 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10873 | hdd_ctx->config->WlanAutoShutdown) |
| 10874 | != QDF_STATUS_SUCCESS) |
| 10875 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10876 | else |
| 10877 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10878 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10879 | } |
| 10880 | #endif |
| 10881 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10882 | struct hdd_adapter * |
| 10883 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 10884 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10885 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10886 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10887 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10888 | |
| 10889 | con_sap_adapter = NULL; |
| 10890 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10891 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10892 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 10893 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10894 | adapter != this_sap_adapter) { |
| 10895 | if (check_start_bss) { |
| 10896 | if (test_bit(SOFTAP_BSS_STARTED, |
| 10897 | &adapter->event_flags)) { |
| 10898 | con_sap_adapter = adapter; |
| 10899 | break; |
| 10900 | } |
| 10901 | } else { |
| 10902 | con_sap_adapter = adapter; |
| 10903 | break; |
| 10904 | } |
| 10905 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10906 | } |
| 10907 | |
| 10908 | return con_sap_adapter; |
| 10909 | } |
| 10910 | |
| 10911 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10912 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10913 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10914 | return adapter->device_mode == QDF_STA_MODE || |
| 10915 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10916 | } |
| 10917 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10918 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10919 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10920 | return adapter->device_mode == QDF_SAP_MODE || |
| 10921 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 10922 | } |
| 10923 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10924 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10925 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10926 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10927 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10928 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10929 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10930 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10931 | conn_info.connState == eConnectionState_Associated) { |
| 10932 | return true; |
| 10933 | } |
| 10934 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10935 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10936 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10937 | return true; |
| 10938 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10939 | } |
| 10940 | |
| 10941 | return false; |
| 10942 | } |
| 10943 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10944 | 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] | 10945 | { |
| 10946 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10947 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10948 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10949 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10950 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10951 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10952 | return is_running; |
| 10953 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10954 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10955 | 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] | 10956 | { |
| 10957 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10958 | hdd_ctx->bus_bw_timer_running = true; |
| 10959 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 10960 | hdd_ctx->config->busBandwidthComputeInterval); |
| 10961 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10962 | } |
| 10963 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10964 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10965 | { |
| 10966 | ENTER(); |
| 10967 | |
| 10968 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10969 | hdd_debug("Bandwidth compute timer already started"); |
| 10970 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10971 | } |
| 10972 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10973 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10974 | |
| 10975 | EXIT(); |
| 10976 | } |
| 10977 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10978 | 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] | 10979 | { |
| 10980 | ENTER(); |
| 10981 | |
| 10982 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10983 | hdd_debug("Bandwidth compute timer already started"); |
| 10984 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 10985 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10986 | |
| 10987 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 10988 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 10989 | |
| 10990 | EXIT(); |
| 10991 | } |
| 10992 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10993 | 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] | 10994 | { |
| 10995 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 10996 | |
| 10997 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10998 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 10999 | hdd_ctx->bus_bw_timer_running = false; |
| 11000 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11001 | |
| 11002 | hdd_reset_tcp_delack(hdd_ctx); |
| 11003 | } |
| 11004 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11005 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11006 | { |
| 11007 | ENTER(); |
| 11008 | |
| 11009 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11010 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11011 | return; |
| 11012 | } |
| 11013 | |
| 11014 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11015 | |
| 11016 | EXIT(); |
| 11017 | } |
| 11018 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11019 | 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] | 11020 | { |
| 11021 | ENTER(); |
| 11022 | |
| 11023 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11024 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11025 | return; |
| 11026 | } |
| 11027 | |
| 11028 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11029 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11030 | |
| 11031 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11032 | } |
| 11033 | #endif |
| 11034 | |
| 11035 | /** |
| 11036 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11037 | * and sta's operating channel. |
| 11038 | * @sta_adapter: Describe the first argument to foobar. |
| 11039 | * @ap_adapter: Describe the second argument to foobar. |
| 11040 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11041 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11042 | * set this flag to true else false. |
| 11043 | * |
| 11044 | * This function checks the sap's operating channel and sta's operating channel. |
| 11045 | * if both are same then it will return false else it will restart the sap in |
| 11046 | * sta's channel and return true. |
| 11047 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11048 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11049 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11050 | QDF_STATUS |
| 11051 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11052 | struct hdd_adapter *ap_adapter, |
| 11053 | tCsrRoamProfile *roam_profile, |
| 11054 | tScanResultHandle *scan_cache, |
| 11055 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11056 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11057 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11058 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11059 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11060 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11061 | *concurrent_chnl_same = true; |
| 11062 | |
| 11063 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11064 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11065 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11066 | scan_cache, |
| 11067 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11068 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11069 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11070 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11071 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11072 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11073 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11074 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11075 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11076 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11077 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11078 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11079 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11080 | } |
| 11081 | } |
| 11082 | } else { |
| 11083 | /* |
| 11084 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11085 | * failed so we have to stop the SAP to avoid any channel |
| 11086 | * discrepancy between SAP's channel and STA's channel. |
| 11087 | * Return the status as failure so caller function could know |
| 11088 | * that scan look up is failed. |
| 11089 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11090 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11091 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11092 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11093 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11094 | } |
| 11095 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11096 | /** |
| 11097 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11098 | * @ap_adapter: SAP adapter |
| 11099 | * |
| 11100 | * This function will process the stopping of sap adapter. |
| 11101 | * |
| 11102 | * Return: None |
| 11103 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11104 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11105 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11106 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11107 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11108 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11109 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11110 | |
| 11111 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11112 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11113 | return; |
| 11114 | } |
| 11115 | |
| 11116 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11117 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11118 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11119 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11120 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11121 | mutex_lock(&hdd_ctx->sap_lock); |
| 11122 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11123 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11124 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11125 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11126 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11127 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11128 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11129 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11130 | qdf_stop_bss_event, |
| 11131 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11132 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11133 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11134 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11135 | return; |
| 11136 | } |
| 11137 | } |
| 11138 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11139 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11140 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11141 | ap_adapter->session_id); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11142 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11143 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11144 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11145 | } |
| 11146 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11147 | } |
| 11148 | |
| 11149 | /** |
| 11150 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11151 | * @ap_adapter: SAP adapter |
| 11152 | * |
| 11153 | * This function will process the starting of sap adapter. |
| 11154 | * |
| 11155 | * Return: None |
| 11156 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11157 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11158 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11159 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11160 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11161 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11162 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11163 | tsap_Config_t *sap_config; |
| 11164 | |
| 11165 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11166 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11167 | return; |
| 11168 | } |
| 11169 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11170 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11171 | hdd_err("SoftAp role has not been enabled"); |
| 11172 | return; |
| 11173 | } |
| 11174 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11175 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11176 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11177 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11178 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11180 | mutex_lock(&hdd_ctx->sap_lock); |
| 11181 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11182 | goto end; |
| 11183 | |
| 11184 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11185 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11186 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 11187 | goto end; |
| 11188 | } |
| 11189 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11190 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11191 | 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] | 11192 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11193 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11194 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11195 | goto end; |
| 11196 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11197 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11198 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11199 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11200 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11201 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11202 | goto end; |
| 11203 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11204 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 11206 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11207 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11208 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11209 | ap_adapter->session_id); |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11210 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11211 | |
| 11212 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11213 | end: |
| 11214 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11215 | /* SAP context and beacon cleanup will happen during driver unload |
| 11216 | * in hdd_stop_adapter |
| 11217 | */ |
| 11218 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11219 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11220 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | |
| 11222 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11223 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11224 | * mac scan config |
| 11225 | * @status: Status of set antenna mode |
| 11226 | * |
| 11227 | * Callback on setting the dual mac configuration |
| 11228 | * |
| 11229 | * Return: None |
| 11230 | */ |
| 11231 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11232 | enum set_antenna_mode_status status) |
| 11233 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11234 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11235 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11236 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11237 | |
| 11238 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11239 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11240 | return; |
| 11241 | |
| 11242 | /* Signal the completion of set dual mac config */ |
| 11243 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11244 | } |
| 11245 | |
| 11246 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11247 | * hdd_get_fw_version() - Get FW version |
| 11248 | * @hdd_ctx: pointer to HDD context. |
| 11249 | * @major_spid: FW version - major spid. |
| 11250 | * @minor_spid: FW version - minor spid |
| 11251 | * @ssid: FW version - ssid |
| 11252 | * @crmid: FW version - crmid |
| 11253 | * |
| 11254 | * This function is called to get the firmware build version stored |
| 11255 | * as part of the HDD context |
| 11256 | * |
| 11257 | * Return: None |
| 11258 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11259 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11260 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11261 | uint32_t *siid, uint32_t *crmid) |
| 11262 | { |
| 11263 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11264 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11265 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11266 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11267 | } |
| 11268 | |
| 11269 | #ifdef QCA_CONFIG_SMP |
| 11270 | /** |
| 11271 | * wlan_hdd_get_cpu() - get cpu_index |
| 11272 | * |
| 11273 | * Return: cpu_index |
| 11274 | */ |
| 11275 | int wlan_hdd_get_cpu(void) |
| 11276 | { |
| 11277 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11278 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11279 | put_cpu(); |
| 11280 | return cpu_index; |
| 11281 | } |
| 11282 | #endif |
| 11283 | |
| 11284 | /** |
| 11285 | * hdd_get_fwpath() - get framework path |
| 11286 | * |
| 11287 | * This function is used to get the string written by |
| 11288 | * userspace to start the wlan driver |
| 11289 | * |
| 11290 | * Return: string |
| 11291 | */ |
| 11292 | const char *hdd_get_fwpath(void) |
| 11293 | { |
| 11294 | return fwpath.string; |
| 11295 | } |
| 11296 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11297 | static int hdd_qdf_print_init(void) |
| 11298 | { |
| 11299 | int qdf_print_idx; |
| 11300 | QDF_STATUS status; |
| 11301 | |
| 11302 | status = qdf_print_setup(); |
| 11303 | if (status != QDF_STATUS_SUCCESS) { |
| 11304 | pr_err("qdf_print_setup failed\n"); |
| 11305 | return -EINVAL; |
| 11306 | } |
| 11307 | |
| 11308 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11309 | |
| 11310 | if (qdf_print_idx < 0) { |
| 11311 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11312 | qdf_print_idx); |
| 11313 | return -EINVAL; |
| 11314 | } |
| 11315 | |
| 11316 | qdf_set_pidx(qdf_print_idx); |
| 11317 | |
| 11318 | return 0; |
| 11319 | } |
| 11320 | |
| 11321 | static void hdd_qdf_print_deinit(void) |
| 11322 | { |
| 11323 | int qdf_print_idx; |
| 11324 | |
| 11325 | qdf_print_idx = qdf_get_pidx(); |
| 11326 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11327 | } |
| 11328 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11329 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11330 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11331 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11332 | * This function initilizes CDS global context with the help of cds_init. This |
| 11333 | * has to be the first function called after probe to get a valid global |
| 11334 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11335 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11336 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11337 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11338 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11339 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11340 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11341 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11342 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11343 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11344 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11345 | hdd_err("Failed to allocate CDS context"); |
| 11346 | ret = -ENOMEM; |
| 11347 | goto err_out; |
| 11348 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11349 | |
| 11350 | wlan_init_bug_report_lock(); |
| 11351 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11352 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11353 | wlan_logging_sock_init_svc(); |
| 11354 | #endif |
| 11355 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11356 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11357 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11358 | QDF_TIMER_TYPE_SW); |
| 11359 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11360 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11361 | hdd_qdf_print_init(); |
| 11362 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11363 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11364 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11365 | err_out: |
| 11366 | return ret; |
| 11367 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11368 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11369 | /** |
| 11370 | * hdd_deinit() - Deinitialize Driver |
| 11371 | * |
| 11372 | * This function frees CDS global context with the help of cds_deinit. This |
| 11373 | * has to be the last function call in remove callback to free the global |
| 11374 | * context. |
| 11375 | */ |
| 11376 | void hdd_deinit(void) |
| 11377 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11378 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11379 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11380 | wlan_destroy_bug_report_lock(); |
| 11381 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11382 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11383 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11384 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11385 | wlan_logging_sock_deinit_svc(); |
| 11386 | #endif |
| 11387 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11388 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11389 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11390 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11391 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11392 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11393 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11394 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11395 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11396 | struct file *file) |
| 11397 | { |
| 11398 | return 0; |
| 11399 | } |
| 11400 | |
| 11401 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11402 | const char __user *user_buf, |
| 11403 | size_t count, |
| 11404 | loff_t *f_pos) |
| 11405 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11406 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11407 | static const char wlan_off_str[] = "OFF"; |
| 11408 | static const char wlan_on_str[] = "ON"; |
| 11409 | int ret; |
| 11410 | unsigned long rc; |
| 11411 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11412 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11413 | pr_err("Failed to read buffer\n"); |
| 11414 | return -EINVAL; |
| 11415 | } |
| 11416 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11417 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11418 | pr_debug("Wifi turning off from UI\n"); |
| 11419 | goto exit; |
| 11420 | } |
| 11421 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11422 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11423 | pr_err("Invalid value received from framework"); |
| 11424 | goto exit; |
| 11425 | } |
| 11426 | |
| 11427 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11428 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11429 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11430 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11431 | if (!rc) { |
| 11432 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11433 | ret = -EINVAL; |
| 11434 | hdd_start_complete(ret); |
| 11435 | return ret; |
| 11436 | } |
| 11437 | |
| 11438 | hdd_start_complete(0); |
| 11439 | } |
| 11440 | |
| 11441 | exit: |
| 11442 | return count; |
| 11443 | } |
| 11444 | |
| 11445 | |
| 11446 | const struct file_operations wlan_hdd_state_fops = { |
| 11447 | .owner = THIS_MODULE, |
| 11448 | .open = wlan_hdd_state_ctrl_param_open, |
| 11449 | .write = wlan_hdd_state_ctrl_param_write, |
| 11450 | }; |
| 11451 | |
| 11452 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11453 | { |
| 11454 | unsigned int wlan_hdd_state_major = 0; |
| 11455 | int ret; |
| 11456 | struct device *dev; |
| 11457 | |
| 11458 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11459 | |
| 11460 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11461 | if (ret) { |
| 11462 | pr_err("Failed to register qcwlanstate"); |
| 11463 | goto dev_alloc_err; |
| 11464 | } |
| 11465 | wlan_hdd_state_major = MAJOR(device); |
| 11466 | |
| 11467 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11468 | if (IS_ERR(class)) { |
| 11469 | pr_err("wlan_hdd_state class_create error"); |
| 11470 | goto class_err; |
| 11471 | } |
| 11472 | |
| 11473 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11474 | if (IS_ERR(dev)) { |
| 11475 | pr_err("wlan_hdd_statedevice_create error"); |
| 11476 | goto err_class_destroy; |
| 11477 | } |
| 11478 | |
| 11479 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11480 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11481 | if (ret) { |
| 11482 | pr_err("Failed to add cdev error"); |
| 11483 | goto cdev_add_err; |
| 11484 | } |
| 11485 | |
| 11486 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11487 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11488 | |
| 11489 | return 0; |
| 11490 | |
| 11491 | cdev_add_err: |
| 11492 | device_destroy(class, device); |
| 11493 | err_class_destroy: |
| 11494 | class_destroy(class); |
| 11495 | class_err: |
| 11496 | unregister_chrdev_region(device, dev_num); |
| 11497 | dev_alloc_err: |
| 11498 | return -ENODEV; |
| 11499 | } |
| 11500 | |
| 11501 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11502 | { |
| 11503 | cdev_del(&wlan_hdd_state_cdev); |
| 11504 | device_destroy(class, device); |
| 11505 | class_destroy(class); |
| 11506 | unregister_chrdev_region(device, dev_num); |
| 11507 | |
| 11508 | pr_info("Device node unregistered"); |
| 11509 | } |
| 11510 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11511 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11512 | * component_init - API to init cld component's |
| 11513 | * |
| 11514 | * Return: None |
| 11515 | */ |
| 11516 | static void component_init(void) |
| 11517 | { |
| 11518 | pmo_init(); |
| 11519 | } |
| 11520 | |
| 11521 | /** |
| 11522 | * component_deinit - API to deinit cld component's |
| 11523 | * |
| 11524 | * Return: None |
| 11525 | */ |
| 11526 | static void component_deinit(void) |
| 11527 | { |
| 11528 | pmo_deinit(); |
| 11529 | } |
| 11530 | |
| 11531 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11532 | * __hdd_module_init - Module init helper |
| 11533 | * |
| 11534 | * Module init helper function used by both module and static driver. |
| 11535 | * |
| 11536 | * Return: 0 for success, errno on failure |
| 11537 | */ |
| 11538 | static int __hdd_module_init(void) |
| 11539 | { |
| 11540 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11541 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11542 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11543 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11544 | g_wlan_driver_version, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11545 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11546 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11547 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11548 | if (ret) { |
| 11549 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11550 | goto err_dev_state; |
| 11551 | } |
| 11552 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11553 | pld_init(); |
| 11554 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11555 | ret = hdd_init(); |
| 11556 | if (ret) { |
| 11557 | pr_err("hdd_init failed %x\n", ret); |
| 11558 | goto err_hdd_init; |
| 11559 | } |
| 11560 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11561 | dispatcher_init(); |
| 11562 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11563 | /* Ensure to call post objmgr init */ |
| 11564 | component_init(); |
| 11565 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11566 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11567 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11568 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11569 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11570 | ret = wlan_hdd_register_driver(); |
| 11571 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11572 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11573 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11574 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11575 | } |
| 11576 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11577 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11578 | |
| 11579 | return 0; |
| 11580 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11581 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11582 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11583 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11584 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11585 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11586 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11587 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11588 | wlan_hdd_state_ctrl_param_destroy(); |
| 11589 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11590 | return ret; |
| 11591 | } |
| 11592 | |
| 11593 | /** |
| 11594 | * __hdd_module_exit - Module exit helper |
| 11595 | * |
| 11596 | * Module exit helper function used by both module and static driver. |
| 11597 | */ |
| 11598 | static void __hdd_module_exit(void) |
| 11599 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11600 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11601 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11602 | QWLAN_VERSIONSTR); |
| 11603 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11604 | hdd_wait_for_recovery_completion(); |
| 11605 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11606 | wlan_hdd_unregister_driver(); |
| 11607 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11608 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11609 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11610 | /* Ensure to call prior to objmgr deinit */ |
| 11611 | component_deinit(); |
| 11612 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11613 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11614 | |
| 11615 | hdd_sysfs_destroy_version_interface(); |
| 11616 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11617 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11618 | pld_deinit(); |
| 11619 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11620 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11621 | } |
| 11622 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11623 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11624 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11625 | * wlan_boot_cb() - Wlan boot callback |
| 11626 | * @kobj: object whose directory we're creating the link in. |
| 11627 | * @attr: attribute the user is interacting with |
| 11628 | * @buff: the buffer containing the user data |
| 11629 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11630 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11631 | * This callback is invoked when the fs is ready to start the |
| 11632 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11633 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11634 | * 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] | 11635 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11636 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11637 | struct kobj_attribute *attr, |
| 11638 | const char *buf, |
| 11639 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11640 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11641 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11642 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11643 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11644 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11645 | } |
| 11646 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11647 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11648 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11649 | return -EIO; |
| 11650 | } |
| 11651 | |
| 11652 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11653 | |
| 11654 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11655 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11656 | |
| 11657 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11658 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11659 | * |
| 11660 | * Return: None |
| 11661 | * |
| 11662 | */ |
| 11663 | static void hdd_sysfs_cleanup(void) |
| 11664 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11665 | /* remove from group */ |
| 11666 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11667 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11668 | wlan_loader->attr_group); |
| 11669 | |
| 11670 | /* unlink the object from parent */ |
| 11671 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11672 | |
| 11673 | /* free the object */ |
| 11674 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11675 | |
| 11676 | kfree(wlan_loader->attr_group); |
| 11677 | kfree(wlan_loader); |
| 11678 | |
| 11679 | wlan_loader = NULL; |
| 11680 | } |
| 11681 | |
| 11682 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11683 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11684 | * ready |
| 11685 | * |
| 11686 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11687 | * when the filesystem is ready. |
| 11688 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11689 | * QDF API cannot be used here since this function is called even before |
| 11690 | * initializing WLAN driver. |
| 11691 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11692 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11693 | */ |
| 11694 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11695 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11696 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11697 | |
| 11698 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11699 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11700 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11701 | |
| 11702 | wlan_loader->boot_wlan_obj = NULL; |
| 11703 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11704 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11705 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11706 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11707 | |
| 11708 | wlan_loader->loaded_state = 0; |
| 11709 | wlan_loader->attr_group->attrs = attrs; |
| 11710 | |
| 11711 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11712 | kernel_kobj); |
| 11713 | if (!wlan_loader->boot_wlan_obj) { |
| 11714 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11715 | goto error_return; |
| 11716 | } |
| 11717 | |
| 11718 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11719 | wlan_loader->attr_group); |
| 11720 | if (ret) { |
| 11721 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11722 | goto error_return; |
| 11723 | } |
| 11724 | |
| 11725 | return 0; |
| 11726 | |
| 11727 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11728 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11729 | |
| 11730 | return ret; |
| 11731 | } |
| 11732 | |
| 11733 | /** |
| 11734 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11735 | * |
| 11736 | * Return: 0 on success or errno on failure |
| 11737 | */ |
| 11738 | static int wlan_deinit_sysfs(void) |
| 11739 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11740 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11741 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11742 | return -EINVAL; |
| 11743 | } |
| 11744 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11745 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11746 | return 0; |
| 11747 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11748 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11749 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11750 | |
| 11751 | #ifdef MODULE |
| 11752 | /** |
| 11753 | * __hdd_module_init - Module init helper |
| 11754 | * |
| 11755 | * Module init helper function used by both module and static driver. |
| 11756 | * |
| 11757 | * Return: 0 for success, errno on failure |
| 11758 | */ |
| 11759 | static int hdd_module_init(void) |
| 11760 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11761 | if (__hdd_module_init()) { |
| 11762 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11763 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11764 | } |
| 11765 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11766 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11767 | } |
| 11768 | #else |
| 11769 | static int __init hdd_module_init(void) |
| 11770 | { |
| 11771 | int ret = -EINVAL; |
| 11772 | |
| 11773 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11774 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11775 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11776 | |
| 11777 | return ret; |
| 11778 | } |
| 11779 | #endif |
| 11780 | |
| 11781 | |
| 11782 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11783 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11784 | * hdd_module_exit() - Exit function |
| 11785 | * |
| 11786 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11787 | * |
| 11788 | * Return: None |
| 11789 | */ |
| 11790 | static void __exit hdd_module_exit(void) |
| 11791 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11792 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11793 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11794 | #else |
| 11795 | static void __exit hdd_module_exit(void) |
| 11796 | { |
| 11797 | __hdd_module_exit(); |
| 11798 | wlan_deinit_sysfs(); |
| 11799 | } |
| 11800 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11801 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11802 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11803 | { |
| 11804 | return param_set_copystring(kmessage, kp); |
| 11805 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11806 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11807 | /** |
| 11808 | * is_con_mode_valid() check con mode is valid or not |
| 11809 | * @mode: global con mode |
| 11810 | * |
| 11811 | * Return: TRUE on success FALSE on failure |
| 11812 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11813 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11814 | { |
| 11815 | switch (mode) { |
| 11816 | case QDF_GLOBAL_MONITOR_MODE: |
| 11817 | case QDF_GLOBAL_FTM_MODE: |
| 11818 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11819 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11820 | return true; |
| 11821 | default: |
| 11822 | return false; |
| 11823 | } |
| 11824 | } |
| 11825 | |
| 11826 | /** |
| 11827 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11828 | * @mode: global con mode |
| 11829 | * |
| 11830 | * Return: adapter mode |
| 11831 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11832 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11833 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11834 | { |
| 11835 | |
| 11836 | switch (mode) { |
| 11837 | case QDF_GLOBAL_MISSION_MODE: |
| 11838 | return QDF_STA_MODE; |
| 11839 | case QDF_GLOBAL_MONITOR_MODE: |
| 11840 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11841 | case QDF_GLOBAL_EPPING_MODE: |
| 11842 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11843 | case QDF_GLOBAL_FTM_MODE: |
| 11844 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11845 | case QDF_GLOBAL_QVIT_MODE: |
| 11846 | return QDF_QVIT_MODE; |
| 11847 | default: |
| 11848 | return QDF_MAX_NO_OF_MODE; |
| 11849 | } |
| 11850 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11851 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11852 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11853 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11854 | { |
| 11855 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11856 | return; |
| 11857 | |
| 11858 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11859 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 11860 | hdd_info("Release wakelock for monitor mode!"); |
| 11861 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 11862 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 11863 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11864 | case QDF_GLOBAL_FTM_MODE: |
| 11865 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11866 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
| 11867 | |
| 11868 | /* re-use the existing session */ |
| 11869 | hdd_stop_all_adapters(hdd_ctx, false); |
| 11870 | break; |
| 11871 | default: |
| 11872 | break; |
| 11873 | } |
| 11874 | } |
| 11875 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11876 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11877 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11878 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 11879 | int driver_status; |
| 11880 | |
| 11881 | driver_status = hdd_ctx->driver_status; |
| 11882 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11883 | switch (curr_mode) { |
| 11884 | case QDF_GLOBAL_MISSION_MODE: |
| 11885 | case QDF_GLOBAL_MONITOR_MODE: |
| 11886 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11887 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 11888 | hdd_close_all_adapters(hdd_ctx, false); |
| 11889 | break; |
| 11890 | case QDF_GLOBAL_EPPING_MODE: |
| 11891 | epping_disable(); |
| 11892 | epping_close(); |
| 11893 | break; |
| 11894 | default: |
| 11895 | return; |
| 11896 | } |
| 11897 | } |
| 11898 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11899 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11900 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11901 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11902 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11903 | int ret = 0; |
| 11904 | bool rtnl_held; |
| 11905 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11906 | QDF_STATUS status; |
| 11907 | |
| 11908 | if (!qdf_dev) { |
| 11909 | hdd_err("qdf device context is Null return!"); |
| 11910 | return -EINVAL; |
| 11911 | } |
| 11912 | |
| 11913 | rtnl_held = hdd_hold_rtnl_lock(); |
| 11914 | switch (mode) { |
| 11915 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11916 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11917 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11918 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11919 | break; |
| 11920 | case QDF_GLOBAL_FTM_MODE: |
| 11921 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11922 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11923 | NET_NAME_UNKNOWN, rtnl_held); |
| 11924 | if (adapter == NULL) |
| 11925 | ret = -EINVAL; |
| 11926 | break; |
| 11927 | case QDF_GLOBAL_MONITOR_MODE: |
| 11928 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11929 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11930 | NET_NAME_UNKNOWN, rtnl_held); |
| 11931 | if (adapter == NULL) |
| 11932 | ret = -EINVAL; |
| 11933 | break; |
| 11934 | case QDF_GLOBAL_EPPING_MODE: |
| 11935 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11936 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11937 | hdd_err("Failed to open in eeping mode: %d", status); |
| 11938 | ret = -EINVAL; |
| 11939 | break; |
| 11940 | } |
| 11941 | ret = epping_enable(qdf_dev->dev); |
| 11942 | if (ret) { |
| 11943 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 11944 | epping_close(); |
| 11945 | } |
| 11946 | break; |
| 11947 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11948 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11949 | ret = -ENOTSUPP; |
| 11950 | break; |
| 11951 | } |
| 11952 | hdd_release_rtnl_lock(); |
| 11953 | rtnl_held = false; |
| 11954 | return ret; |
| 11955 | } |
| 11956 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11957 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11958 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11959 | * @kmessage: con mode name on which driver to be bring up |
| 11960 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11961 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11962 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11963 | * This function is invoked when user updates con mode using sys entry, |
| 11964 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11965 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11966 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11967 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11968 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11969 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11970 | { |
| 11971 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11972 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11973 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11974 | enum QDF_OPMODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11975 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 11976 | hdd_info("con_mode handler: %s", kmessage); |
| 11977 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11978 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 11979 | if (ret) |
| 11980 | return ret; |
| 11981 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11982 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11983 | |
| 11984 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11985 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11986 | if (!(is_con_mode_valid(con_mode))) { |
| 11987 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11988 | ret = -EINVAL; |
| 11989 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11990 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11991 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11992 | curr_mode = hdd_get_conparam(); |
| 11993 | if (curr_mode == con_mode) { |
| 11994 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 11995 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11996 | ret = 0; |
| 11997 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11998 | } |
| 11999 | |
Sourav Mohapatra | 3bc5e98 | 2017-11-24 15:53:49 +0530 | [diff] [blame] | 12000 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12001 | hdd_warn("Waiting for monitor mode: External threads are active"); |
| 12002 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12003 | /* ensure adapters are stopped */ |
| 12004 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12005 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12006 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12007 | if (ret) { |
| 12008 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12009 | goto reset_flags; |
| 12010 | } |
| 12011 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12012 | /* Cleanup present mode before switching to new mode */ |
| 12013 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12014 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12015 | hdd_set_conparam(con_mode); |
| 12016 | |
| 12017 | /* Register for new con_mode & then kick_start modules again */ |
| 12018 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 12019 | if (ret) { |
| 12020 | hdd_err("Failed to register for new mode"); |
| 12021 | goto reset_flags; |
| 12022 | } |
| 12023 | |
| 12024 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 12025 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12026 | hdd_err("invalid adapter"); |
| 12027 | ret = -EINVAL; |
| 12028 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12029 | } |
| 12030 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12031 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12032 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12033 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12034 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12035 | } |
| 12036 | |
| 12037 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12038 | if (ret) { |
| 12039 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12040 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12041 | } |
| 12042 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12043 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12044 | con_mode == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12045 | if (hdd_start_adapter(adapter)) { |
| 12046 | hdd_err("Failed to start %s adapter", kmessage); |
| 12047 | ret = -EINVAL; |
| 12048 | goto reset_flags; |
| 12049 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12050 | } |
| 12051 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12052 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 12053 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12054 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12055 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12056 | } |
| 12057 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12058 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12059 | ret = 0; |
| 12060 | |
| 12061 | reset_flags: |
| 12062 | cds_set_load_in_progress(false); |
| 12063 | return ret; |
| 12064 | } |
| 12065 | |
| 12066 | |
| 12067 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12068 | { |
| 12069 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12070 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12071 | |
| 12072 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12073 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12074 | if (ret) |
| 12075 | return ret; |
| 12076 | |
| 12077 | cds_ssr_protect(__func__); |
| 12078 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12079 | cds_ssr_unprotect(__func__); |
| 12080 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12081 | return ret; |
| 12082 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12083 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12084 | static int con_mode_handler_ftm(const char *kmessage, |
| 12085 | struct kernel_param *kp) |
| 12086 | { |
| 12087 | int ret; |
| 12088 | |
| 12089 | ret = param_set_int(kmessage, kp); |
| 12090 | |
| 12091 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12092 | pr_err("Only FTM mode supported!"); |
| 12093 | return -ENOTSUPP; |
| 12094 | } |
| 12095 | |
| 12096 | hdd_set_conparam(con_mode_ftm); |
| 12097 | con_mode = con_mode_ftm; |
| 12098 | |
| 12099 | return ret; |
| 12100 | } |
| 12101 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12102 | static int con_mode_handler_monitor(const char *kmessage, |
| 12103 | struct kernel_param *kp) |
| 12104 | { |
| 12105 | int ret; |
| 12106 | |
| 12107 | ret = param_set_int(kmessage, kp); |
| 12108 | |
| 12109 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12110 | pr_err("Only Monitor mode supported!"); |
| 12111 | return -ENOTSUPP; |
| 12112 | } |
| 12113 | |
| 12114 | hdd_set_conparam(con_mode_monitor); |
| 12115 | con_mode = con_mode_monitor; |
| 12116 | |
| 12117 | return ret; |
| 12118 | } |
| 12119 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12120 | /** |
| 12121 | * hdd_get_conparam() - driver exit point |
| 12122 | * |
| 12123 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12124 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12125 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12126 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12127 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12128 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12129 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12130 | } |
| 12131 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12132 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12133 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12134 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12135 | } |
| 12136 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12137 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12138 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12139 | * @hdd_ctx: HDD context |
| 12140 | * |
| 12141 | * Cleans up the pre cac interface, if it exists |
| 12142 | * |
| 12143 | * Return: None |
| 12144 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12145 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12146 | { |
| 12147 | uint8_t session_id; |
| 12148 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12149 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12150 | |
| 12151 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12152 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12153 | hdd_err("failed to get pre cac vdev id"); |
| 12154 | return; |
| 12155 | } |
| 12156 | |
| 12157 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12158 | if (!precac_adapter) { |
| 12159 | hdd_err("invalid pre cac adapater"); |
| 12160 | return; |
| 12161 | } |
| 12162 | |
| 12163 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12164 | wlan_hdd_sap_pre_cac_failure, |
| 12165 | (void *)precac_adapter); |
| 12166 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12167 | |
| 12168 | } |
| 12169 | |
| 12170 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12171 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12172 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12173 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12174 | * Return: void |
| 12175 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12176 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12177 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12178 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12179 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12180 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12181 | if (!ol_ctx) |
| 12182 | return; |
| 12183 | |
| 12184 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12185 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12186 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12187 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12188 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12189 | |
| 12190 | ol_init_ini_config(ol_ctx, &cfg); |
| 12191 | } |
| 12192 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12193 | #ifdef FEATURE_RUNTIME_PM |
| 12194 | /** |
| 12195 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12196 | * @hdd_ctx: hdd context |
| 12197 | * @cfg: pointer to the configuration memory being populated |
| 12198 | * |
| 12199 | * Return: void |
| 12200 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12201 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12202 | struct hif_config_info *cfg) |
| 12203 | { |
| 12204 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12205 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12206 | } |
| 12207 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12208 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12209 | struct hif_config_info *cfg) |
| 12210 | { |
| 12211 | } |
| 12212 | #endif |
| 12213 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12214 | /** |
| 12215 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12216 | * @hdd_ctx: HDD Context |
| 12217 | * |
| 12218 | * Return: void |
| 12219 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12220 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12221 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12222 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12223 | struct hif_config_info cfg; |
| 12224 | |
| 12225 | if (!scn) |
| 12226 | return; |
| 12227 | |
| 12228 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12229 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12230 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12231 | |
| 12232 | if (hdd_ctx->config->prevent_link_down) |
| 12233 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12234 | } |
| 12235 | |
| 12236 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12237 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12238 | * datapath |
| 12239 | * @hdd_ctx: HDD Context |
| 12240 | * |
| 12241 | * Return: 0 for success/errno for failure |
| 12242 | */ |
| 12243 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12244 | { |
| 12245 | struct cdp_config_params params; |
| 12246 | QDF_STATUS status; |
| 12247 | |
| 12248 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12249 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12250 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12251 | params.tx_flow_stop_queue_threshold = |
| 12252 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12253 | params.tx_flow_start_queue_offset = |
| 12254 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12255 | #endif |
| 12256 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12257 | params.napi_enable = hdd_ctx->napi_enable; |
| 12258 | params.tcp_udp_checksumoffload = |
| 12259 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12260 | |
| 12261 | status = cdp_update_config_parameters( |
| 12262 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12263 | ¶ms); |
| 12264 | if (status) { |
| 12265 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 12266 | "%s: Failed to attach config parameters", __func__); |
| 12267 | return status; |
| 12268 | } |
| 12269 | |
| 12270 | return 0; |
| 12271 | } |
| 12272 | |
| 12273 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12274 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12275 | * @hdd_ctx: HDD Context |
| 12276 | * |
| 12277 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12278 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12279 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12280 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12281 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12282 | int ret; |
| 12283 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12284 | hdd_update_ol_config(hdd_ctx); |
| 12285 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12286 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12287 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12288 | else |
| 12289 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12290 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12291 | |
| 12292 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12293 | } |
| 12294 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12295 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12296 | /** |
| 12297 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12298 | * @psoc_cfg: pmo psoc Configuration |
| 12299 | * @hdd_ctx: Pointer to hdd context |
| 12300 | * |
| 12301 | * Return: none |
| 12302 | */ |
| 12303 | static inline void hdd_ra_populate_pmo_config( |
| 12304 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12305 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12306 | { |
| 12307 | psoc_cfg->ra_ratelimit_interval = |
| 12308 | hdd_ctx->config->RArateLimitInterval; |
| 12309 | psoc_cfg->ra_ratelimit_enable = |
| 12310 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12311 | } |
| 12312 | #else |
| 12313 | static inline void hdd_ra_populate_pmo_config( |
| 12314 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12315 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12316 | { |
| 12317 | } |
| 12318 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12319 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12320 | /** |
| 12321 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12322 | * @hdd_ctx: HDD context |
| 12323 | * |
| 12324 | * Return: void |
| 12325 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12326 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12327 | { |
| 12328 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12329 | struct pmo_psoc_cfg psoc_cfg; |
| 12330 | QDF_STATUS status; |
| 12331 | |
| 12332 | /* |
| 12333 | * Value of hdd_ctx->wowEnable can be, |
| 12334 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12335 | * 1 - Enable magic pattern match on all interfaces. |
| 12336 | * 2 - Enable pattern byte match on all interfaces. |
| 12337 | * 3 - Enable both magic patter and pattern byte match on |
| 12338 | * all interfaces. |
| 12339 | */ |
| 12340 | psoc_cfg.magic_ptrn_enable = |
| 12341 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12342 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12343 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12344 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12345 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12346 | psoc_cfg.bpf_enable = |
| 12347 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12348 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12349 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12350 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12351 | if (hdd_ctx->config->fhostNSOffload) |
| 12352 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12353 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12354 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12355 | psoc_cfg.active_mode_offload = |
| 12356 | hdd_ctx->config->active_mode_offload; |
| 12357 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12358 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12359 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12360 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12361 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12362 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12363 | psoc_cfg.power_save_mode = |
| 12364 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12365 | psoc_cfg.auto_power_save_fail_mode = |
| 12366 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12367 | |
| 12368 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12369 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12370 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Rajeev Kumar | d1a7ac4 | 2017-11-08 14:54:22 -0800 | [diff] [blame] | 12371 | status = ucfg_pmo_update_psoc_config(psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12372 | if (status != QDF_STATUS_SUCCESS) { |
| 12373 | hdd_err("failed pmo psoc configuration"); |
| 12374 | return -EINVAL; |
| 12375 | } |
| 12376 | |
| 12377 | return 0; |
| 12378 | } |
| 12379 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12380 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12381 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12382 | struct hdd_config *cfg) |
| 12383 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12384 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12385 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12386 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12387 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12388 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12389 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12390 | pno_cfg->channel_prediction_full_scan = |
| 12391 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12392 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12393 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12394 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12395 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12396 | } |
| 12397 | #else |
| 12398 | static inline void |
| 12399 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12400 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12401 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12402 | } |
| 12403 | #endif |
| 12404 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12405 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12406 | struct hdd_config *cfg) |
| 12407 | { |
| 12408 | uint8_t i = 0; |
| 12409 | |
| 12410 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12411 | if (!ie_whitelist->white_list) |
| 12412 | return; |
| 12413 | |
| 12414 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12415 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12416 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12417 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12418 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12419 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12420 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12421 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12422 | |
| 12423 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12424 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12425 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12426 | } |
| 12427 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12428 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12429 | { |
| 12430 | uint8_t i, score; |
| 12431 | |
| 12432 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12433 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12434 | if (score > MAX_INDEX_SCORE) |
| 12435 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12436 | MAX_INDEX_SCORE, i); |
| 12437 | } |
| 12438 | |
| 12439 | return per_index_score; |
| 12440 | } |
| 12441 | |
| 12442 | /** |
| 12443 | * hdd_update_score_config - API to update candidate scoring related params |
| 12444 | * configuration parameters |
| 12445 | * @score_config: score config to update |
| 12446 | * @cfg: config params |
| 12447 | * |
| 12448 | * Return: 0 if success else err |
| 12449 | */ |
| 12450 | static void hdd_update_score_config( |
| 12451 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12452 | { |
| 12453 | int total_weight; |
| 12454 | |
| 12455 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12456 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12457 | score_config->weight_cfg.vht_caps_weightage = |
| 12458 | cfg->vht_caps_weightage; |
| 12459 | score_config->weight_cfg.he_caps_weightage = |
| 12460 | cfg->he_caps_weightage; |
| 12461 | score_config->weight_cfg.chan_width_weightage = |
| 12462 | cfg->chan_width_weightage; |
| 12463 | score_config->weight_cfg.chan_band_weightage = |
| 12464 | cfg->chan_band_weightage; |
| 12465 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12466 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12467 | cfg->beamforming_cap_weightage; |
| 12468 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12469 | score_config->weight_cfg.channel_congestion_weightage = |
| 12470 | cfg->channel_congestion_weightage; |
| 12471 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12472 | |
| 12473 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12474 | score_config->weight_cfg.ht_caps_weightage + |
| 12475 | score_config->weight_cfg.vht_caps_weightage + |
| 12476 | score_config->weight_cfg.he_caps_weightage + |
| 12477 | score_config->weight_cfg.chan_width_weightage + |
| 12478 | score_config->weight_cfg.chan_band_weightage + |
| 12479 | score_config->weight_cfg.nss_weightage + |
| 12480 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12481 | score_config->weight_cfg.pcl_weightage + |
| 12482 | score_config->weight_cfg.channel_congestion_weightage + |
| 12483 | score_config->weight_cfg.oce_wan_weightage; |
| 12484 | |
| 12485 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12486 | hdd_err("total weight is greater than %d fallback to default values", |
| 12487 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12488 | |
| 12489 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12490 | score_config->weight_cfg.ht_caps_weightage = |
| 12491 | HT_CAPABILITY_WEIGHTAGE; |
| 12492 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12493 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12494 | score_config->weight_cfg.chan_width_weightage = |
| 12495 | CHAN_WIDTH_WEIGHTAGE; |
| 12496 | score_config->weight_cfg.chan_band_weightage = |
| 12497 | CHAN_BAND_WEIGHTAGE; |
| 12498 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12499 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12500 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12501 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12502 | score_config->weight_cfg.channel_congestion_weightage = |
| 12503 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12504 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12505 | } |
| 12506 | |
| 12507 | score_config->bandwidth_weight_per_index = |
| 12508 | hdd_limit_max_per_index_score( |
| 12509 | cfg->bandwidth_weight_per_index); |
| 12510 | score_config->nss_weight_per_index = |
| 12511 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12512 | score_config->band_weight_per_index = |
| 12513 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12514 | |
| 12515 | score_config->rssi_score.best_rssi_threshold = |
| 12516 | cfg->best_rssi_threshold; |
| 12517 | score_config->rssi_score.good_rssi_threshold = |
| 12518 | cfg->good_rssi_threshold; |
| 12519 | score_config->rssi_score.bad_rssi_threshold = |
| 12520 | cfg->bad_rssi_threshold; |
| 12521 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12522 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12523 | score_config->rssi_score.good_rssi_bucket_size = |
| 12524 | cfg->good_rssi_bucket_size; |
| 12525 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12526 | cfg->bad_rssi_bucket_size; |
| 12527 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12528 | cfg->rssi_pref_5g_rssi_thresh; |
| 12529 | |
| 12530 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12531 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12532 | hdd_limit_max_per_index_score( |
| 12533 | cfg->esp_qbss_score_slots3_to_0); |
| 12534 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12535 | hdd_limit_max_per_index_score( |
| 12536 | cfg->esp_qbss_score_slots7_to_4); |
| 12537 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12538 | hdd_limit_max_per_index_score( |
| 12539 | cfg->esp_qbss_score_slots11_to_8); |
| 12540 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12541 | hdd_limit_max_per_index_score( |
| 12542 | cfg->esp_qbss_score_slots15_to_12); |
| 12543 | |
| 12544 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12545 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12546 | hdd_limit_max_per_index_score( |
| 12547 | cfg->oce_wan_score_slots3_to_0); |
| 12548 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12549 | hdd_limit_max_per_index_score( |
| 12550 | cfg->oce_wan_score_slots7_to_4); |
| 12551 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12552 | hdd_limit_max_per_index_score( |
| 12553 | cfg->oce_wan_score_slots11_to_8); |
| 12554 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12555 | hdd_limit_max_per_index_score( |
| 12556 | cfg->oce_wan_score_slots15_to_12); |
| 12557 | |
| 12558 | |
| 12559 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12560 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12561 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12562 | |
| 12563 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12564 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12565 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12566 | score_config->he_cap = 1; |
| 12567 | |
| 12568 | if (score_config->he_cap || |
| 12569 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12570 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12571 | score_config->vht_cap = 1; |
| 12572 | |
| 12573 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12574 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12575 | score_config->ht_cap = 1; |
| 12576 | |
| 12577 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12578 | score_config->vht_24G_cap = 1; |
| 12579 | |
| 12580 | if (cfg->enableTxBF) |
| 12581 | score_config->beamformee_cap = 1; |
| 12582 | |
| 12583 | } |
| 12584 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12585 | /** |
| 12586 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12587 | * @hdd_ctx: HDD context |
| 12588 | * |
| 12589 | * Return: 0 if success else err |
| 12590 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12591 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12592 | { |
| 12593 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12594 | struct scan_user_cfg scan_cfg; |
| 12595 | struct hdd_config *cfg = hdd_ctx->config; |
| 12596 | QDF_STATUS status; |
| 12597 | |
| 12598 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12599 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12600 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12601 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12602 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12603 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12604 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12605 | /* convert to ms */ |
| 12606 | scan_cfg.scan_cache_aging_time = |
| 12607 | cfg->scanAgingTimeout * 1000; |
| 12608 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12609 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12610 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12611 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12612 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12613 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12614 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12615 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12616 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12617 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12618 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12619 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12620 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12621 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12622 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12623 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12624 | if (status != QDF_STATUS_SUCCESS) { |
| 12625 | hdd_err("failed pmo psoc configuration"); |
| 12626 | return -EINVAL; |
| 12627 | } |
| 12628 | |
| 12629 | return 0; |
| 12630 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12631 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12632 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12633 | { |
| 12634 | int ret; |
| 12635 | |
| 12636 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12637 | if (ret) |
| 12638 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12639 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12640 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12641 | if (ret) |
| 12642 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12643 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12644 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12645 | if (ret) |
| 12646 | return ret; |
| 12647 | |
| 12648 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12649 | |
| 12650 | return ret; |
| 12651 | } |
| 12652 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12653 | /** |
| 12654 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12655 | * @mode : cfg80211 DFS mode |
| 12656 | * |
| 12657 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12658 | */ |
| 12659 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12660 | { |
| 12661 | switch (mode) { |
| 12662 | case DFS_MODE_ENABLE: |
| 12663 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12664 | case DFS_MODE_DISABLE: |
| 12665 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12666 | case DFS_MODE_DEPRIORITIZE: |
| 12667 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12668 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12669 | hdd_debug("ACS dfs mode is NONE"); |
| 12670 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12671 | } |
| 12672 | } |
| 12673 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12674 | /** |
| 12675 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12676 | * @hddctx: pointer to hdd context |
| 12677 | * @set_value: enable/disable |
| 12678 | * |
| 12679 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12680 | * Host(even though it is duplicate). When Host send vendor command |
| 12681 | * disable,FW doesn't perform any action. Whenever any change in |
| 12682 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12683 | * |
| 12684 | * return - 0 on success, appropriate error values on failure. |
| 12685 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12686 | 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] | 12687 | { |
| 12688 | QDF_STATUS status; |
| 12689 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12690 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12691 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12692 | |
| 12693 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12694 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12695 | return -EINVAL; |
| 12696 | } |
| 12697 | |
| 12698 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12699 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12700 | hdd_err("Failed to send chan avoid command to SME"); |
| 12701 | return -EINVAL; |
| 12702 | } |
| 12703 | return 0; |
| 12704 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12705 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12706 | /** |
| 12707 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12708 | * @value: value to set |
| 12709 | * |
| 12710 | * This function will set the passed value to roaming in progress flag. |
| 12711 | * |
| 12712 | * Return: None |
| 12713 | */ |
| 12714 | void hdd_set_roaming_in_progress(bool value) |
| 12715 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12716 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12717 | |
| 12718 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12719 | if (!hdd_ctx) { |
| 12720 | hdd_err("HDD context is NULL"); |
| 12721 | return; |
| 12722 | } |
| 12723 | |
| 12724 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12725 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12726 | } |
| 12727 | |
| 12728 | /** |
| 12729 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12730 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12731 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12732 | * 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] | 12733 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12734 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12735 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12736 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12737 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12738 | |
| 12739 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12740 | if (!hdd_ctx) { |
| 12741 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12742 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12743 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12744 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12745 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12746 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12747 | hdd_ctx->roaming_in_progress); |
| 12748 | |
| 12749 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12750 | } |
| 12751 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12752 | /** |
| 12753 | * hdd_is_connection_in_progress() - check if connection is in |
| 12754 | * progress |
| 12755 | * @session_id: session id |
| 12756 | * @reason: scan reject reason |
| 12757 | * |
| 12758 | * Go through each adapter and check if Connection is in progress |
| 12759 | * |
| 12760 | * Return: true if connection is in progress else false |
| 12761 | */ |
| 12762 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12763 | enum scan_reject_states *reason) |
| 12764 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12765 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12766 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12767 | uint8_t sta_id = 0; |
| 12768 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12769 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12770 | |
| 12771 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12772 | if (!hdd_ctx) { |
| 12773 | hdd_err("HDD context is NULL"); |
| 12774 | return false; |
| 12775 | } |
| 12776 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12777 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12778 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12779 | hdd_device_mode_to_string(adapter->device_mode), |
| 12780 | adapter->device_mode); |
| 12781 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12782 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12783 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12784 | && (eConnectionState_Connecting == |
| 12785 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12786 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12787 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12788 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12789 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12790 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12791 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12792 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12793 | } |
| 12794 | return true; |
| 12795 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12796 | /* |
| 12797 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12798 | * hdd_is_roaming_in_progress is for LFR3 |
| 12799 | */ |
| 12800 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12801 | sme_neighbor_middle_of_roaming( |
| 12802 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12803 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12804 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12805 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12806 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12807 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12808 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12809 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12810 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12811 | } |
| 12812 | return true; |
| 12813 | } |
| 12814 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12815 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12816 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12817 | hdd_sta_ctx = |
| 12818 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12819 | if ((eConnectionState_Associated == |
| 12820 | hdd_sta_ctx->conn_info.connState) |
| 12821 | && (false == |
| 12822 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12823 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 12824 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12825 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12826 | " is in middle of WPS/EAPOL exchange.", |
| 12827 | MAC_ADDR_ARRAY(sta_mac)); |
| 12828 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12829 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12830 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12831 | } |
| 12832 | return true; |
| 12833 | } |
| 12834 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12835 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12836 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12837 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12838 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12839 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12840 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12841 | continue; |
| 12842 | |
| 12843 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12844 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 12845 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12846 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12847 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12848 | MAC_ADDR_ARRAY(sta_mac)); |
| 12849 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12850 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12851 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12852 | } |
| 12853 | return true; |
| 12854 | } |
| 12855 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12856 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12857 | return true; |
| 12858 | } |
| 12859 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12860 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12861 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12862 | return false; |
| 12863 | } |
| 12864 | |
| 12865 | /** |
| 12866 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12867 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12868 | * |
| 12869 | * Return: None |
| 12870 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12871 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12872 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12873 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12874 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12875 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12876 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12877 | tsap_Config_t *sap_config; |
| 12878 | void *sap_ctx; |
| 12879 | |
| 12880 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 12881 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12882 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12883 | |
| 12884 | mutex_lock(&hdd_ctx->sap_lock); |
| 12885 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 12886 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12887 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 12888 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 12889 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 12890 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12891 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12892 | qdf_stop_bss_event, |
| 12893 | SME_CMD_TIMEOUT_VALUE); |
| 12894 | |
| 12895 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12896 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12897 | goto end; |
| 12898 | } |
| 12899 | } |
| 12900 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12901 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12902 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12903 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12904 | |
| 12905 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12906 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12907 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12908 | eUPDATE_IE_ALL); |
| 12909 | goto end; |
| 12910 | } |
| 12911 | |
| 12912 | qdf_event_reset(&hostapd_state->qdf_event); |
| 12913 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 12914 | sap_config, |
| 12915 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12916 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12917 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12918 | eUPDATE_IE_ALL); |
| 12919 | goto end; |
| 12920 | } |
| 12921 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12922 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12923 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12924 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12925 | SME_CMD_TIMEOUT_VALUE); |
| 12926 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12927 | eUPDATE_IE_ALL); |
| 12928 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12929 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12930 | goto end; |
| 12931 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12932 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12933 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 12934 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12935 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12936 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12937 | ap_adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12938 | } |
| 12939 | end: |
| 12940 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12941 | } |
| 12942 | |
| 12943 | /** |
| 12944 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 12945 | * with non dfs acs |
| 12946 | * |
| 12947 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 12948 | * |
| 12949 | * Return: None |
| 12950 | */ |
| 12951 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 12952 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12953 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12954 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12955 | cds_context_type *cds_ctx; |
| 12956 | |
| 12957 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12958 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12959 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12960 | return; |
| 12961 | } |
| 12962 | |
| 12963 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 12964 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12965 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12966 | return; |
| 12967 | } |
| 12968 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12969 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 12970 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12971 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12972 | return; |
| 12973 | } |
| 12974 | |
| 12975 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 12976 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 12977 | &ap_adapter->event_flags) && |
| 12978 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12979 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12980 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12981 | 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] | 12982 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12983 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12984 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12985 | acs_cfg.acs_mode = true; |
| 12986 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12987 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12988 | } |
| 12989 | } |
| 12990 | |
| 12991 | /** |
| 12992 | * hdd_set_connection_in_progress() - to set the connection in |
| 12993 | * progress flag |
| 12994 | * @value: value to set |
| 12995 | * |
| 12996 | * This function will set the passed value to connection in progress flag. |
| 12997 | * If value is previously being set to true then no need to set it again. |
| 12998 | * |
| 12999 | * Return: true if value is being set correctly and false otherwise. |
| 13000 | */ |
| 13001 | bool hdd_set_connection_in_progress(bool value) |
| 13002 | { |
| 13003 | bool status = true; |
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 | |
| 13006 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13007 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13008 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13009 | return false; |
| 13010 | } |
| 13011 | |
| 13012 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13013 | /* |
| 13014 | * if the value is set to true previously and if someone is |
| 13015 | * trying to make it true again then it could be some race |
| 13016 | * condition being triggered. Avoid this situation by returning |
| 13017 | * false |
| 13018 | */ |
| 13019 | if (hdd_ctx->connection_in_progress && value) |
| 13020 | status = false; |
| 13021 | else |
| 13022 | hdd_ctx->connection_in_progress = value; |
| 13023 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13024 | return status; |
| 13025 | } |
| 13026 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13027 | 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] | 13028 | { |
| 13029 | if (!adapter) { |
| 13030 | hdd_err("Invalid adapter"); |
| 13031 | return -EINVAL; |
| 13032 | } |
| 13033 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13034 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13035 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13036 | set_value, VDEV_CMD); |
| 13037 | return 0; |
| 13038 | |
| 13039 | } |
| 13040 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13041 | 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] | 13042 | { |
| 13043 | if (!adapter) { |
| 13044 | hdd_err("Invalid adapter"); |
| 13045 | return -EINVAL; |
| 13046 | } |
| 13047 | |
| 13048 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13049 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13050 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13051 | set_value, VDEV_CMD); |
| 13052 | return 0; |
| 13053 | } |
| 13054 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13055 | 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] | 13056 | *psoc, uint8_t vdev_id) |
| 13057 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13058 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13059 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13060 | |
| 13061 | /* |
| 13062 | * Currently PSOC is not being used. But this logic will |
| 13063 | * change once we have the converged implementation of |
| 13064 | * HDD context per PSOC in place. This would break if |
| 13065 | * multiple vdev objects reuse the vdev id. |
| 13066 | */ |
| 13067 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13068 | if (!adapter) |
| 13069 | hdd_err("Get adapter by vdev id failed"); |
| 13070 | |
| 13071 | return adapter; |
| 13072 | } |
| 13073 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13074 | 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] | 13075 | int8_t *rssi, int8_t *snr) |
| 13076 | { |
| 13077 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 13078 | struct hdd_wext_state *wext_state = |
| 13079 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13080 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 13081 | |
| 13082 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 13083 | profile, bssid, rssi, snr); |
| 13084 | if (QDF_STATUS_SUCCESS != status) { |
| 13085 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13086 | return -EINVAL; |
| 13087 | } |
| 13088 | |
| 13089 | return 0; |
| 13090 | } |
| 13091 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13092 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13093 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13094 | * @adapter - HDD adapter |
| 13095 | * @tos - type of service |
| 13096 | * @status - status of the traffic |
| 13097 | * |
| 13098 | * Return: 0 on success and non zero value on failure |
| 13099 | */ |
| 13100 | |
| 13101 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13102 | bool is_tos_active) |
| 13103 | { |
| 13104 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13105 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13106 | uint32_t max_off_chan_time = 0; |
| 13107 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13108 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13109 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13110 | |
| 13111 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13112 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13113 | |
| 13114 | if (ret < 0) { |
| 13115 | hdd_err("failed to set limit off chan params"); |
| 13116 | return ret; |
| 13117 | } |
| 13118 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13119 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13120 | |
| 13121 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13122 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13123 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13124 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13125 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13126 | if (adapter->active_ac) { |
| 13127 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13128 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13129 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13130 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13131 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13132 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13133 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13134 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13135 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13136 | PM_LATENCY); |
| 13137 | } else { |
| 13138 | /*ignore this command if only BE/BK is active */ |
| 13139 | is_tos_active = false; |
| 13140 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13141 | hdd_ctx->config->conc_system_pref); |
| 13142 | } |
| 13143 | } else { |
| 13144 | /* No active tos */ |
| 13145 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13146 | hdd_ctx->config->conc_system_pref); |
| 13147 | } |
| 13148 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13149 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13150 | is_tos_active, max_off_chan_time, |
| 13151 | hdd_ctx->config->nRestTimeConc, true); |
| 13152 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13153 | hdd_err("failed to set limit off chan params"); |
| 13154 | ret = -EINVAL; |
| 13155 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13156 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13157 | return ret; |
| 13158 | } |
| 13159 | |
| 13160 | /** |
| 13161 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13162 | * @adapter - HDD adapter |
| 13163 | * |
| 13164 | * Return: 0 on success and non zero value on failure |
| 13165 | */ |
| 13166 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13167 | { |
| 13168 | struct hdd_context *hdd_ctx; |
| 13169 | int ret; |
| 13170 | QDF_STATUS status; |
| 13171 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13172 | |
| 13173 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13174 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13175 | if (ret < 0) |
| 13176 | return ret; |
| 13177 | |
| 13178 | /* set the system preferece to default */ |
| 13179 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13180 | hdd_ctx->config->conc_system_pref); |
| 13181 | |
| 13182 | /* clear the bitmap */ |
| 13183 | adapter->active_ac = 0; |
| 13184 | |
| 13185 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13186 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13187 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13188 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13189 | false, 0, 0, false); |
| 13190 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13191 | hdd_err("failed to reset limit off chan params"); |
| 13192 | ret = -EINVAL; |
| 13193 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13194 | |
| 13195 | return ret; |
| 13196 | } |
| 13197 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13198 | /** |
| 13199 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13200 | * @drv_op: Enum indicating driver op |
| 13201 | * |
| 13202 | * Return: none |
| 13203 | */ |
| 13204 | void hdd_start_driver_ops_timer(int drv_op) |
| 13205 | { |
| 13206 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13207 | switch (drv_op) { |
| 13208 | case eHDD_DRV_OP_PROBE: |
| 13209 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13210 | break; |
| 13211 | case eHDD_DRV_OP_REMOVE: |
| 13212 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13213 | break; |
| 13214 | case eHDD_DRV_OP_SHUTDOWN: |
| 13215 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13216 | break; |
| 13217 | case eHDD_DRV_OP_REINIT: |
| 13218 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13219 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13220 | case eHDD_DRV_OP_IFF_UP: |
| 13221 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13222 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13223 | } |
| 13224 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13225 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13226 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13227 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13228 | } |
| 13229 | |
| 13230 | /** |
| 13231 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13232 | * |
| 13233 | * Return: none |
| 13234 | */ |
| 13235 | void hdd_stop_driver_ops_timer(void) |
| 13236 | { |
| 13237 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13238 | } |
| 13239 | |
| 13240 | /** |
| 13241 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13242 | * inactivity timer |
| 13243 | * |
| 13244 | * Return: None |
| 13245 | */ |
| 13246 | void hdd_drv_ops_inactivity_handler(void) |
| 13247 | { |
| 13248 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13249 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13250 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13251 | if (hdd_drv_ops_task) { |
| 13252 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13253 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13254 | } else { |
| 13255 | hdd_err("hdd_drv_ops_task is null"); |
| 13256 | } |
| 13257 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13258 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13259 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13260 | sizeof("shutdown"))) |
| 13261 | QDF_BUG(0); |
| 13262 | |
| 13263 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13264 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13265 | else |
| 13266 | QDF_BUG(0); |
| 13267 | } |
| 13268 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13269 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13270 | { |
| 13271 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13272 | |
| 13273 | if (!hdd_ctx) |
| 13274 | return; |
| 13275 | |
| 13276 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13277 | } |
| 13278 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13279 | /** |
| 13280 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13281 | * @struct hdd_context *hdd_ctx |
| 13282 | * @struct hdd_adapter *padapter |
| 13283 | * @bool enble |
| 13284 | * |
| 13285 | * Return: none |
| 13286 | */ |
| 13287 | void hdd_set_rx_mode_rps(bool enable) |
| 13288 | { |
| 13289 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13290 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13291 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13292 | |
| 13293 | if (adapter && hdd_ctx && |
| 13294 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13295 | if (enable && !cds_cfg->rps_enabled) |
| 13296 | hdd_send_rps_ind(adapter); |
| 13297 | else if (!enable && cds_cfg->rps_enabled) |
| 13298 | hdd_send_rps_disable_ind(adapter); |
| 13299 | } |
| 13300 | } |
| 13301 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13302 | /* Register the module init/exit functions */ |
| 13303 | module_init(hdd_module_init); |
| 13304 | module_exit(hdd_module_exit); |
| 13305 | |
| 13306 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13307 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13308 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13310 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13311 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13312 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13313 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13314 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13315 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13316 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13317 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13318 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13319 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13320 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13321 | |
| 13322 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13323 | |
| 13324 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13325 | |
| 13326 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |