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 | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2351 | /** |
| 2352 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2353 | * |
| 2354 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2355 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2356 | * |
| 2357 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2358 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2359 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2360 | * fixed. |
| 2361 | * |
| 2362 | * Return: None |
| 2363 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2364 | static void hdd_check_for_leaks(void) |
| 2365 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2366 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2367 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2368 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2369 | } |
| 2370 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2371 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2372 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2373 | * @hdd_ctx: HDD context |
| 2374 | * @adapter: HDD adapter |
| 2375 | * @reinit: flag to indicate from SSR or normal path |
| 2376 | * |
| 2377 | * This function maintains the driver state machine it will be invoked from |
| 2378 | * startup, reinit and change interface. Depending on the driver state shall |
| 2379 | * perform the opening of the modules. |
| 2380 | * |
| 2381 | * Return: 0 for success; non-zero for failure |
| 2382 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2383 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2384 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2385 | bool reinit) |
| 2386 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2387 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2388 | qdf_device_t qdf_dev; |
| 2389 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2390 | bool unint = false; |
| 2391 | void *hif_ctx; |
| 2392 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2393 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2394 | |
| 2395 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2396 | if (!qdf_dev) { |
| 2397 | hdd_err("QDF Device Context is Invalid return"); |
| 2398 | return -EINVAL; |
| 2399 | } |
| 2400 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2401 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 2402 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2403 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2404 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2405 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2406 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2407 | hdd_info("Driver modules already Enabled"); |
| 2408 | EXIT(); |
| 2409 | return 0; |
| 2410 | } |
| 2411 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2412 | hdd_ctx->start_modules_in_progress = true; |
| 2413 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2414 | switch (hdd_ctx->driver_status) { |
| 2415 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2416 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2417 | unint = true; |
| 2418 | /* Fall through dont add break here */ |
| 2419 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2420 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2421 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2422 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
| 2423 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2424 | if (!reinit && !unint) { |
| 2425 | ret = pld_power_on(qdf_dev->dev); |
| 2426 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2427 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2428 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2429 | goto release_lock; |
| 2430 | } |
| 2431 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2432 | |
| 2433 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2434 | hdd_ctx->config->enable_fw_log); |
| 2435 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2436 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2437 | qdf_dev->bus_type, |
| 2438 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2439 | HIF_ENABLE_TYPE_PROBE); |
| 2440 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2441 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2442 | goto power_down; |
| 2443 | } |
| 2444 | |
| 2445 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2446 | if (!hif_ctx) { |
| 2447 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2448 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2449 | goto power_down; |
| 2450 | } |
| 2451 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2452 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2453 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2454 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2455 | status); |
| 2456 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2457 | goto hif_close; |
| 2458 | } |
| 2459 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2460 | ret = hdd_update_config(hdd_ctx); |
| 2461 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2462 | hdd_err("Failed to update configuration; errno: %d", |
| 2463 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2464 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2465 | } |
| 2466 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2467 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2468 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2469 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2470 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2471 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2472 | ret = qdf_status_to_os_return(status); |
| 2473 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2474 | } |
| 2475 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2476 | /* initalize components configurations after psoc open */ |
| 2477 | ret = hdd_update_components_config(hdd_ctx); |
| 2478 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2479 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2480 | ret); |
| 2481 | goto close; |
| 2482 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2483 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2484 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2485 | hdd_err("Failed to Open cds post open; status: %d", |
| 2486 | status); |
| 2487 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2488 | goto close; |
| 2489 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2490 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2491 | /* |
| 2492 | * NAN compoenet requires certian operations like, open adapter, |
| 2493 | * close adapter, etc. to be initiated by HDD, for those |
| 2494 | * register HDD callbacks with UMAC's NAN componenet. |
| 2495 | */ |
| 2496 | hdd_nan_register_callbacks(hdd_ctx); |
| 2497 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2498 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2499 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2500 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2501 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2502 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2503 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2504 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2505 | } |
| 2506 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2507 | hdd_register_policy_manager_callback( |
| 2508 | hdd_ctx->hdd_psoc); |
| 2509 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2510 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2511 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2512 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2513 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2514 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2515 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2516 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2517 | sme_register_ftm_msg_processor(hdd_ctx->hHal, |
| 2518 | hdd_ftm_mc_process_msg); |
| 2519 | break; |
| 2520 | } |
| 2521 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2522 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2523 | break; |
| 2524 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2525 | |
| 2526 | if (reinit) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2527 | ret = hdd_ipa_uc_ssr_reinit(hdd_ctx); |
| 2528 | if (ret) { |
| 2529 | hdd_err("HDD IPA UC reinit failed; errno: %d", |
| 2530 | ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2531 | goto post_disable; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 2532 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2533 | } |
| 2534 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2535 | /* Fall through dont add break here */ |
| 2536 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2537 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2538 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2539 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2540 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2541 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2542 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2543 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2544 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2545 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2546 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2547 | break; |
| 2548 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2549 | |
| 2550 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2551 | if (ret) { |
| 2552 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2553 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2554 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2555 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2556 | hdd_enable_power_management(); |
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 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2559 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2560 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2561 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2562 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2563 | default: |
| 2564 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2565 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2566 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2567 | goto release_lock; |
| 2568 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2569 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2570 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2571 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2572 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2573 | EXIT(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2574 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2575 | return 0; |
| 2576 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2577 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2578 | cds_post_disable(); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2579 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2580 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2581 | cds_txrx_free: |
| 2582 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2583 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2584 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2585 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2586 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2587 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2588 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2589 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2590 | deinit_config: |
| 2591 | cds_deinit_ini_config(); |
| 2592 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2593 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2594 | ol_cds_free(); |
| 2595 | |
| 2596 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2597 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2598 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2599 | power_down: |
| 2600 | if (!reinit && !unint) |
| 2601 | pld_power_off(qdf_dev->dev); |
| 2602 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2603 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2604 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2605 | |
| 2606 | /* many adapter resources are not freed by design in SSR case */ |
| 2607 | if (!reinit) |
| 2608 | hdd_check_for_leaks(); |
| 2609 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
| 2610 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2611 | EXIT(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2612 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2613 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2614 | } |
| 2615 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2616 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2617 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2618 | { |
| 2619 | int ret = os_if_wifi_pos_register_nl(); |
| 2620 | |
| 2621 | if (ret) |
| 2622 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2623 | |
| 2624 | return ret; |
| 2625 | } |
| 2626 | |
| 2627 | static int hdd_deactivate_wifi_pos(void) |
| 2628 | { |
| 2629 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2630 | |
| 2631 | if (ret) |
| 2632 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2633 | |
| 2634 | return ret; |
| 2635 | } |
| 2636 | |
| 2637 | /** |
| 2638 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2639 | * @hdd_ctx: hdd context |
| 2640 | * |
| 2641 | * Return: status of operation |
| 2642 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2643 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2644 | { |
| 2645 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2646 | struct hdd_config *cfg = hdd_ctx->config; |
| 2647 | |
| 2648 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2649 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2650 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2651 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2652 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2653 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2654 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2655 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2656 | } |
| 2657 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2658 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2659 | { |
| 2660 | return oem_activate_service(hdd_ctx); |
| 2661 | } |
| 2662 | |
| 2663 | static int hdd_deactivate_wifi_pos(void) |
| 2664 | { |
| 2665 | return 0; |
| 2666 | } |
| 2667 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2668 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2669 | { |
| 2670 | } |
| 2671 | #endif |
| 2672 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2673 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2674 | * __hdd_open() - HDD Open function |
| 2675 | * @dev: Pointer to net_device structure |
| 2676 | * |
| 2677 | * This is called in response to ifconfig up |
| 2678 | * |
| 2679 | * Return: 0 for success; non-zero for failure |
| 2680 | */ |
| 2681 | static int __hdd_open(struct net_device *dev) |
| 2682 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2683 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2684 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2685 | int ret; |
| 2686 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2687 | ENTER_DEV(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2688 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2689 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2690 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2691 | /* Nothing to be done if device is unloading */ |
| 2692 | if (cds_is_driver_unloading()) { |
| 2693 | hdd_err("Driver is unloading can not open the hdd"); |
| 2694 | return -EBUSY; |
| 2695 | } |
| 2696 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2697 | if (cds_is_driver_recovering()) { |
| 2698 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2699 | return -EBUSY; |
| 2700 | } |
| 2701 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2702 | mutex_lock(&hdd_init_deinit_lock); |
| 2703 | |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2704 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2705 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2706 | /* |
| 2707 | * This scenario can be hit in cases where in the wlan driver after |
| 2708 | * registering the netdevices and there is a failure in driver |
| 2709 | * initialization. So return error gracefully because the netdevices |
| 2710 | * will be de-registered as part of the load failure. |
| 2711 | */ |
| 2712 | |
| 2713 | if (!cds_is_driver_loaded()) { |
| 2714 | hdd_err("Failed to start the wlan driver!!"); |
| 2715 | ret = -EIO; |
| 2716 | goto err_hdd_hdd_init_deinit_lock; |
| 2717 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2718 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2719 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2720 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2721 | if (ret) { |
| 2722 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2723 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2724 | } |
| 2725 | |
| 2726 | |
| 2727 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2728 | ret = hdd_start_adapter(adapter); |
| 2729 | if (ret) { |
| 2730 | hdd_err("Failed to start adapter :%d", |
| 2731 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2732 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2733 | } |
| 2734 | } |
| 2735 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2736 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2737 | 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] | 2738 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2739 | /* Enable TX queues only when we are connected */ |
| 2740 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2741 | WLAN_START_ALL_NETIF_QUEUE, |
| 2742 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2743 | } |
| 2744 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2745 | /* Enable carrier and transmit queues for NDI */ |
| 2746 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2747 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2748 | wlan_hdd_netif_queue_control(adapter, |
| 2749 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2750 | WLAN_CONTROL_PATH); |
| 2751 | } |
| 2752 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2753 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2754 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2755 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2756 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2757 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2758 | return ret; |
| 2759 | } |
| 2760 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2761 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2762 | /** |
| 2763 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 2764 | * @dev: Pointer to net_device structure |
| 2765 | * |
| 2766 | * This is called in response to ifconfig up |
| 2767 | * |
| 2768 | * Return: 0 for success; non-zero for failure |
| 2769 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2770 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2771 | { |
| 2772 | int ret; |
| 2773 | |
| 2774 | cds_ssr_protect(__func__); |
| 2775 | ret = __hdd_open(dev); |
| 2776 | cds_ssr_unprotect(__func__); |
| 2777 | |
| 2778 | return ret; |
| 2779 | } |
| 2780 | |
| 2781 | /** |
| 2782 | * __hdd_stop() - HDD stop function |
| 2783 | * @dev: Pointer to net_device structure |
| 2784 | * |
| 2785 | * This is called in response to ifconfig down |
| 2786 | * |
| 2787 | * Return: 0 for success; non-zero for failure |
| 2788 | */ |
| 2789 | static int __hdd_stop(struct net_device *dev) |
| 2790 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2791 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2792 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2793 | int ret; |
| 2794 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2795 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2796 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2797 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2798 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2799 | |
| 2800 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 2801 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2802 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2803 | |
| 2804 | /* Nothing to be done if the interface is not opened */ |
| 2805 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2806 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2807 | return -ENODEV; |
| 2808 | } |
| 2809 | |
| 2810 | /* Make sure the interface is marked as closed */ |
| 2811 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2812 | |
| 2813 | hdd_debug("Disabling Auto Power save timer"); |
| 2814 | sme_ps_disable_auto_ps_timer( |
| 2815 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2816 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 2817 | |
| 2818 | /* |
| 2819 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 2820 | * be called on that interface |
| 2821 | */ |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 2822 | hdd_notice("Disabling queues, adapter device mode: %s(%d)", |
| 2823 | hdd_device_mode_to_string(adapter->device_mode), |
| 2824 | adapter->device_mode); |
| 2825 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 2826 | wlan_hdd_netif_queue_control(adapter, |
| 2827 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 2828 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2829 | |
| 2830 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2831 | * NAN data interface is different in some sense. The traffic on NDI is |
| 2832 | * bursty in nature and depends on the need to transfer. The service |
| 2833 | * layer may down the interface after the usage and up again when |
| 2834 | * required. In some sense, the NDI is expected to be available |
| 2835 | * (like SAP) iface until NDI delete request is issued by the service |
| 2836 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 2837 | * interface (NDI). |
| 2838 | */ |
| 2839 | if (WLAN_HDD_IS_NDI(adapter)) |
| 2840 | return 0; |
| 2841 | |
Tushnim Bhattacharyya | 8629489 | 2017-10-25 16:29:11 -0700 | [diff] [blame] | 2842 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->hdd_psoc); |
| 2843 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2844 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2845 | * The interface is marked as down for outside world (aka kernel) |
| 2846 | * But the driver is pretty much alive inside. The driver needs to |
| 2847 | * tear down the existing connection on the netdev (session) |
| 2848 | * cleanup the data pipes and wait until the control plane is stabilized |
| 2849 | * for this interface. The call also needs to wait until the above |
| 2850 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2851 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2852 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 2853 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2854 | hdd_stop_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2855 | |
| 2856 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 2857 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 2858 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2859 | |
| 2860 | /* |
| 2861 | * Find if any iface is up. If any iface is up then can't put device to |
| 2862 | * sleep/power save mode |
| 2863 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 2864 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2865 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2866 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 2867 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 2868 | hdd_prevent_suspend_timeout( |
| 2869 | hdd_ctx->config->iface_change_wait_time, |
| 2870 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2871 | } |
| 2872 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2873 | EXIT(); |
| 2874 | return 0; |
| 2875 | } |
| 2876 | |
| 2877 | /** |
| 2878 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 2879 | * @dev: pointer to net_device structure |
| 2880 | * |
| 2881 | * This is called in response to ifconfig down |
| 2882 | * |
| 2883 | * Return: 0 for success and error number for failure |
| 2884 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2885 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2886 | { |
| 2887 | int ret; |
| 2888 | |
| 2889 | cds_ssr_protect(__func__); |
| 2890 | ret = __hdd_stop(dev); |
| 2891 | cds_ssr_unprotect(__func__); |
| 2892 | |
| 2893 | return ret; |
| 2894 | } |
| 2895 | |
| 2896 | /** |
| 2897 | * __hdd_uninit() - HDD uninit function |
| 2898 | * @dev: Pointer to net_device structure |
| 2899 | * |
| 2900 | * This is called during the netdev unregister to uninitialize all data |
| 2901 | * associated with the device |
| 2902 | * |
| 2903 | * Return: None |
| 2904 | */ |
| 2905 | static void __hdd_uninit(struct net_device *dev) |
| 2906 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2907 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2908 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2909 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 2910 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2911 | |
| 2912 | do { |
| 2913 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2914 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2915 | break; |
| 2916 | } |
| 2917 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2918 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 2919 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2920 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2921 | break; |
| 2922 | } |
| 2923 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2924 | if (dev != adapter->dev) |
| 2925 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2926 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 2927 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2928 | |
| 2929 | /* after uninit our adapter structure will no longer be valid */ |
| 2930 | adapter->dev = NULL; |
| 2931 | adapter->magic = 0; |
| 2932 | } while (0); |
| 2933 | |
| 2934 | EXIT(); |
| 2935 | } |
| 2936 | |
| 2937 | /** |
| 2938 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 2939 | * @dev: pointer to net_device structure |
| 2940 | * |
| 2941 | * This is called during the netdev unregister to uninitialize all data |
| 2942 | * associated with the device |
| 2943 | * |
| 2944 | * Return: none |
| 2945 | */ |
| 2946 | static void hdd_uninit(struct net_device *dev) |
| 2947 | { |
| 2948 | cds_ssr_protect(__func__); |
| 2949 | __hdd_uninit(dev); |
| 2950 | cds_ssr_unprotect(__func__); |
| 2951 | } |
| 2952 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2953 | static int hdd_open_cesium_nl_sock(void) |
| 2954 | { |
| 2955 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2956 | struct netlink_kernel_cfg cfg = { |
| 2957 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 2958 | .input = NULL |
| 2959 | }; |
| 2960 | #endif |
| 2961 | int ret = 0; |
| 2962 | |
| 2963 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 2964 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2965 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 2966 | THIS_MODULE, |
| 2967 | #endif |
| 2968 | &cfg); |
| 2969 | #else |
| 2970 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 2971 | WLAN_NLINK_MCAST_GRP_ID, |
| 2972 | NULL, NULL, THIS_MODULE); |
| 2973 | #endif |
| 2974 | |
| 2975 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 2976 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 2977 | ret = -ECONNREFUSED; |
| 2978 | } |
| 2979 | |
| 2980 | return ret; |
| 2981 | } |
| 2982 | |
| 2983 | static void hdd_close_cesium_nl_sock(void) |
| 2984 | { |
| 2985 | if (NULL != cesium_nl_srv_sock) { |
| 2986 | netlink_kernel_release(cesium_nl_srv_sock); |
| 2987 | cesium_nl_srv_sock = NULL; |
| 2988 | } |
| 2989 | } |
| 2990 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2991 | /** |
| 2992 | * __hdd_set_mac_address() - set the user specified mac address |
| 2993 | * @dev: Pointer to the net device. |
| 2994 | * @addr: Pointer to the sockaddr. |
| 2995 | * |
| 2996 | * This function sets the user specified mac address using |
| 2997 | * the command ifconfig wlanX hw ether <mac adress>. |
| 2998 | * |
| 2999 | * Return: 0 for success, non zero for failure |
| 3000 | */ |
| 3001 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3002 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3003 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3004 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3005 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3006 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | int ret; |
| 3008 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3009 | ENTER_DEV(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3010 | |
| 3011 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3012 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3013 | if (0 != ret) |
| 3014 | return ret; |
| 3015 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3016 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3017 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3018 | |
| 3019 | EXIT(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3020 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3021 | } |
| 3022 | |
| 3023 | /** |
| 3024 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3025 | * function from SSR |
| 3026 | * @dev: pointer to net_device structure |
| 3027 | * @addr: Pointer to the sockaddr |
| 3028 | * |
| 3029 | * This function sets the user specified mac address using |
| 3030 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3031 | * |
| 3032 | * Return: 0 for success. |
| 3033 | */ |
| 3034 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3035 | { |
| 3036 | int ret; |
| 3037 | |
| 3038 | cds_ssr_protect(__func__); |
| 3039 | ret = __hdd_set_mac_address(dev, addr); |
| 3040 | cds_ssr_unprotect(__func__); |
| 3041 | |
| 3042 | return ret; |
| 3043 | } |
| 3044 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3045 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3046 | { |
| 3047 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3048 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3049 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3050 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3051 | break; |
| 3052 | } |
| 3053 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3054 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | return NULL; |
| 3056 | |
| 3057 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3058 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3059 | } |
| 3060 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3061 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3062 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | { |
| 3064 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3065 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3066 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3067 | if (!memcmp(releaseAddr, |
| 3068 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3069 | 6)) { |
| 3070 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3071 | break; |
| 3072 | } |
| 3073 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3074 | } |
| 3075 | |
| 3076 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3077 | /** |
| 3078 | * __hdd_set_multicast_list() - set the multicast address list |
| 3079 | * @dev: Pointer to the WLAN device. |
| 3080 | * @skb: Pointer to OS packet (sk_buff). |
| 3081 | * |
| 3082 | * This funciton sets the multicast address list. |
| 3083 | * |
| 3084 | * Return: None |
| 3085 | */ |
| 3086 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3087 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3088 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3089 | int i = 0, status; |
| 3090 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3091 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3092 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3093 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3094 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3095 | |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 3096 | ENTER_DEV(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3097 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3098 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3099 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3100 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3101 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3102 | goto out; |
| 3103 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3104 | status = hdd_validate_adapter(adapter); |
| 3105 | if (status) |
| 3106 | goto out; |
| 3107 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3108 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3109 | hdd_err("%s: Driver module is closed", __func__); |
| 3110 | return; |
| 3111 | } |
| 3112 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3113 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3114 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3115 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3116 | goto out; |
| 3117 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3118 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3119 | /* Delete already configured multicast address list */ |
| 3120 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3121 | hdd_info("clear previously configured MC address list"); |
| 3122 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3123 | pmo_mc_list_change_notify); |
| 3124 | } |
| 3125 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3126 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3127 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3128 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3129 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3130 | } else { |
| 3131 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3132 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3133 | 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] | 3134 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3135 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3136 | pmo_mc_list_change_notify); |
| 3137 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3138 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3139 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3140 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3141 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3142 | if (i == mc_count) |
| 3143 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3144 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3145 | 0, ETH_ALEN); |
| 3146 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3147 | ha->addr, ETH_ALEN); |
| 3148 | hdd_info("mlist[%d] = %pM", i, |
| 3149 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | i++; |
| 3151 | } |
| 3152 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3153 | |
| 3154 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3155 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3156 | mc_list_request->count = mc_count; |
| 3157 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3158 | if (status == 0) { |
| 3159 | hdd_enable_mc_addr_filtering(adapter, |
| 3160 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3161 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3162 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3163 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3164 | out: |
| 3165 | if (mc_list_request) |
| 3166 | qdf_mem_free(mc_list_request); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3167 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3168 | } |
| 3169 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3170 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3171 | /** |
| 3172 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3173 | * @dev: pointer to net_device |
| 3174 | * |
| 3175 | * Return: none |
| 3176 | */ |
| 3177 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3178 | { |
| 3179 | cds_ssr_protect(__func__); |
| 3180 | __hdd_set_multicast_list(dev); |
| 3181 | cds_ssr_unprotect(__func__); |
| 3182 | } |
| 3183 | #endif |
| 3184 | |
| 3185 | /** |
| 3186 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3187 | * @dev: Pointer to the WLAN device. |
| 3188 | * @skb: Pointer to OS packet (sk_buff). |
| 3189 | * |
| 3190 | * This function is registered with the Linux OS for network |
| 3191 | * core to decide which queue to use first. |
| 3192 | * |
| 3193 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3194 | */ |
| 3195 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3196 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3197 | , void *accel_priv |
| 3198 | #endif |
| 3199 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3200 | , select_queue_fallback_t fallback |
| 3201 | #endif |
| 3202 | ) |
| 3203 | { |
| 3204 | return hdd_wmm_select_queue(dev, skb); |
| 3205 | } |
| 3206 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3207 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | .ndo_open = hdd_open, |
| 3209 | .ndo_stop = hdd_stop, |
| 3210 | .ndo_uninit = hdd_uninit, |
| 3211 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3212 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3213 | .ndo_get_stats = hdd_get_stats, |
| 3214 | .ndo_do_ioctl = hdd_ioctl, |
| 3215 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3216 | .ndo_select_queue = hdd_select_queue, |
| 3217 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3218 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3219 | #endif |
| 3220 | }; |
| 3221 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3222 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3223 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3224 | .ndo_open = hdd_mon_open, |
| 3225 | .ndo_stop = hdd_stop, |
| 3226 | .ndo_get_stats = hdd_get_stats, |
| 3227 | }; |
| 3228 | |
| 3229 | /** |
| 3230 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3231 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3232 | * Return: None |
| 3233 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3234 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3235 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3236 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3237 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3238 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3239 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3240 | } |
| 3241 | |
| 3242 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3243 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3244 | * @hdd_ctx: global hdd context |
| 3245 | * @macAddr: mac address to assign to the interface |
| 3246 | * @name: User-visible name of the interface |
| 3247 | * |
| 3248 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3249 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3250 | * |
| 3251 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3252 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3253 | 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] | 3254 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3255 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3256 | const char *name) |
| 3257 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3258 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3259 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3260 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3261 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3262 | /* |
| 3263 | * cfg80211 initialization and registration.... |
| 3264 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3265 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3266 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3267 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3268 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3269 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3270 | hdd_mon_mode_ether_setup : ether_setup), |
| 3271 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3272 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3273 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3274 | |
| 3275 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3276 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3277 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3278 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3279 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3280 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3281 | sizeof(sta_ctx->conn_info.staId), |
| 3282 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3283 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3284 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3285 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3286 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3288 | qdf_status = qdf_event_create( |
| 3289 | &adapter->qdf_session_open_event); |
| 3290 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3291 | hdd_err("Session open QDF event init failed!"); |
| 3292 | free_netdev(adapter->dev); |
| 3293 | return NULL; |
| 3294 | } |
| 3295 | |
| 3296 | qdf_status = qdf_event_create( |
| 3297 | &adapter->qdf_session_close_event); |
| 3298 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3299 | hdd_err("Session close QDF event init failed!"); |
| 3300 | free_netdev(adapter->dev); |
| 3301 | return NULL; |
| 3302 | } |
| 3303 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3304 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3305 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3306 | init_completion(&adapter->linkup_event_var); |
| 3307 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3308 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3309 | init_completion(&adapter->sta_authorized_event); |
| 3310 | init_completion(&adapter->offchannel_tx_event); |
| 3311 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3312 | init_completion(&adapter->ibss_peer_info_comp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3313 | init_completion(&adapter->change_country_code); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3314 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3315 | |
| 3316 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3317 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3318 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3319 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3320 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3321 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3323 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3325 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3326 | |
| 3327 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3328 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3329 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3330 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3331 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3332 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3333 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | hdd_set_station_ops(adapter->dev); |
| 3335 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3336 | hdd_dev_setup_destructor(dev); |
| 3337 | dev->ieee80211_ptr = &adapter->wdev; |
| 3338 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3340 | adapter->wdev.netdev = dev; |
| 3341 | /* set dev's parent to underlying device */ |
| 3342 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3343 | hdd_wmm_init(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3344 | hdd_adapter_runtime_suspend_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3345 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3346 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3347 | } |
| 3348 | |
| 3349 | return adapter; |
| 3350 | } |
| 3351 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3352 | 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] | 3353 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3354 | struct net_device *dev = adapter->dev; |
| 3355 | int ret; |
| 3356 | |
| 3357 | ENTER(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3358 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3359 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3360 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3361 | |
| 3362 | ret = dev_alloc_name(dev, dev->name); |
| 3363 | if (ret < 0) { |
| 3364 | hdd_err( |
| 3365 | "unable to get dev name: %s, 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 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3370 | |
| 3371 | ret = register_netdevice(dev); |
| 3372 | if (ret) { |
| 3373 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3374 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3375 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3376 | } |
| 3377 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3378 | ret = register_netdev(dev); |
| 3379 | if (ret) { |
| 3380 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3381 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3382 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | } |
| 3384 | } |
| 3385 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3386 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3387 | EXIT(); |
| 3388 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3389 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3390 | } |
| 3391 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3392 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3393 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3394 | struct hdd_adapter *adapter; |
| 3395 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3397 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3398 | if (!hdd_ctx) { |
| 3399 | hdd_err("Invalid HDD_CTX"); |
| 3400 | return QDF_STATUS_E_FAILURE; |
| 3401 | } |
| 3402 | |
| 3403 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3404 | if (NULL == adapter) { |
| 3405 | hdd_err("NULL adapter"); |
| 3406 | return QDF_STATUS_E_INVAL; |
| 3407 | } |
| 3408 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3409 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3410 | hdd_debug("session %d opened", adapter->session_id); |
| 3411 | |
| 3412 | return QDF_STATUS_SUCCESS; |
| 3413 | } |
| 3414 | |
| 3415 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3416 | { |
| 3417 | struct hdd_adapter *adapter; |
| 3418 | struct hdd_context *hdd_ctx; |
| 3419 | |
| 3420 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3421 | if (!hdd_ctx) { |
| 3422 | hdd_err("Invalid HDD_CTX"); |
| 3423 | return QDF_STATUS_E_FAILURE; |
| 3424 | } |
| 3425 | |
| 3426 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3427 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3428 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3429 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | } |
| 3431 | |
| 3432 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3433 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3434 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3435 | } |
| 3436 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3437 | /* |
| 3438 | * For NAN Data interface, the close session results in the final |
| 3439 | * indication to the userspace |
| 3440 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3441 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3442 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3443 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3445 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3446 | /* |
| 3447 | * We can be blocked while waiting for scheduled work to be |
| 3448 | * flushed, and the adapter structure can potentially be freed, in |
| 3449 | * which case the magic will have been reset. So make sure the |
| 3450 | * magic is still good, and hence the adapter structure is still |
| 3451 | * valid, before signaling completion |
| 3452 | */ |
| 3453 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3454 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3455 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3456 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3457 | } |
| 3458 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3459 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3460 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3461 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3463 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3464 | if (QDF_IS_STATUS_ERROR(status)) |
| 3465 | return qdf_status_to_os_return(status); |
| 3466 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3467 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3468 | if (QDF_IS_STATUS_ERROR(status)) |
| 3469 | return qdf_status_to_os_return(status); |
| 3470 | |
| 3471 | if (wma_capability_enhanced_mcast_filter()) |
| 3472 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3473 | else |
| 3474 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3475 | |
| 3476 | return qdf_status_to_os_return(status); |
| 3477 | } |
| 3478 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3479 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3480 | { |
| 3481 | QDF_STATUS status; |
| 3482 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3483 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3484 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3485 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3486 | vdev_id = adapter->session_id; |
| 3487 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3488 | |
| 3489 | /* vdev created sanity check */ |
| 3490 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3491 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3492 | return -EINVAL; |
| 3493 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3494 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3495 | /* |
| 3496 | * In SSR case, there is no need to destroy vdev in firmware since |
| 3497 | * it has already asserted. vdev can be released directly. |
| 3498 | */ |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3499 | if (cds_is_driver_recovering()) { |
| 3500 | hdd_debug("SSR: silently release the vdev for session-id: %d", |
| 3501 | adapter->session_id); |
| 3502 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3503 | goto release_vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3504 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3505 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3506 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3507 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3508 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3509 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3510 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3511 | hdd_err("failed to close sme session: %d", status); |
| 3512 | return qdf_status_to_os_return(status); |
| 3513 | } |
| 3514 | |
| 3515 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3516 | status = qdf_wait_for_event_completion( |
| 3517 | &adapter->qdf_session_close_event, |
| 3518 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3519 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3520 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3521 | hdd_ndp_session_end_handler(adapter); |
| 3522 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3523 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3524 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3525 | hdd_err("timed out waiting for close sme session: %u", status); |
| 3526 | return -ETIMEDOUT; |
| 3527 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3528 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
| 3529 | return -EINVAL; |
| 3530 | } else { |
| 3531 | hdd_err("Failed to close sme session (%u)", status); |
| 3532 | return -EINVAL; |
| 3533 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3534 | } |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3535 | release_vdev: |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3536 | /* do vdev logical destroy via objmgr */ |
| 3537 | errno = hdd_objmgr_destroy_vdev(adapter); |
| 3538 | if (errno) { |
| 3539 | hdd_err("failed to destroy objmgr vdev: %d", errno); |
| 3540 | return errno; |
| 3541 | } |
| 3542 | |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 3543 | /* now that sme session is closed, allow physical vdev destroy */ |
| 3544 | errno = hdd_objmgr_release_vdev(adapter); |
| 3545 | if (errno) { |
| 3546 | hdd_err("failed to release objmgr vdev: %d", errno); |
| 3547 | return errno; |
| 3548 | } |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3549 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3550 | |
| 3551 | return 0; |
| 3552 | } |
| 3553 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3554 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3555 | struct sme_session_params *session_param, |
| 3556 | csr_roam_completeCallback callback, |
| 3557 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3558 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3559 | uint32_t type; |
| 3560 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3561 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3562 | |
| 3563 | /* determine vdev (sub)type */ |
| 3564 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3565 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3566 | hdd_err("failed to get vdev type: %d", status); |
| 3567 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3568 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3569 | session_param->sme_session_id = adapter->session_id; |
| 3570 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3571 | session_param->type_of_persona = type; |
| 3572 | session_param->subtype_of_persona = sub_type; |
| 3573 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3574 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3575 | session_param->callback = callback; |
| 3576 | session_param->callback_ctx = callback_ctx; |
| 3577 | |
| 3578 | return 0; |
| 3579 | } |
| 3580 | |
| 3581 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3582 | csr_roam_completeCallback callback, void *ctx) |
| 3583 | { |
| 3584 | QDF_STATUS status; |
| 3585 | int errno; |
| 3586 | struct hdd_context *hdd_ctx; |
| 3587 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3588 | |
| 3589 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3590 | |
| 3591 | /* do vdev create via objmgr */ |
| 3592 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3593 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3594 | if (errno) { |
| 3595 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3596 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3598 | |
| 3599 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3600 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3601 | if (QDF_STATUS_SUCCESS != status) { |
| 3602 | hdd_err("failed to reinit session open event"); |
| 3603 | return -EINVAL; |
| 3604 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3605 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3606 | callback, ctx); |
| 3607 | if (errno) { |
| 3608 | hdd_err("failed to populating SME params"); |
| 3609 | goto objmgr_vdev_destroy_procedure; |
| 3610 | } |
| 3611 | |
| 3612 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3613 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3614 | hdd_err("failed to open sme session: %d", status); |
| 3615 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3616 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3617 | } |
| 3618 | |
| 3619 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3620 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3621 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3622 | if (QDF_STATUS_SUCCESS != status) { |
| 3623 | if (adapter->qdf_session_open_event.force_set) { |
| 3624 | /* |
| 3625 | * SSR/PDR has caused shutdown, which has forcefully |
| 3626 | * set the event. Return without the closing session. |
| 3627 | */ |
| 3628 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3629 | hdd_err("Session open event forcefully set"); |
| 3630 | return -EINVAL; |
| 3631 | } else { |
| 3632 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3633 | hdd_err("Session failed to open within timeout period"); |
| 3634 | else |
| 3635 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3636 | status); |
| 3637 | errno = -ETIMEDOUT; |
| 3638 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3639 | goto hdd_vdev_destroy_procedure; |
| 3640 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3641 | } |
| 3642 | |
| 3643 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3644 | errno = hdd_vdev_ready(adapter); |
| 3645 | if (errno) { |
| 3646 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3647 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3648 | } |
| 3649 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3650 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3651 | |
| 3652 | return 0; |
| 3653 | |
| 3654 | /* |
| 3655 | * Due to legacy constraints, we need to destroy in the same order as |
| 3656 | * create. So, split error handling into 2 cases to accommodate. |
| 3657 | */ |
| 3658 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3659 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3660 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3661 | |
| 3662 | return errno; |
| 3663 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3664 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3665 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3666 | |
| 3667 | return errno; |
| 3668 | } |
| 3669 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3670 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3671 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3672 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3673 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3674 | QDF_STATUS status; |
| 3675 | int ret_val; |
| 3676 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3677 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3678 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3679 | 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] | 3680 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3681 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | /* Register wireless extensions */ |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3683 | status = hdd_register_wext(adapter->dev); |
| 3684 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3685 | hdd_err("failed to register wireless extensions: %d", status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3686 | goto error_register_wext; |
| 3687 | } |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3688 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3690 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3691 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3692 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3693 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3694 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3695 | adapter->fast_roaming_allowed); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3696 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3697 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | hdd_ctx->config->OperatingChannel; |
| 3699 | |
| 3700 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3701 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3702 | |
| 3703 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3704 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3705 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3706 | status, status); |
| 3707 | goto error_init_txrx; |
| 3708 | } |
| 3709 | |
| 3710 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3711 | |
| 3712 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3713 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3714 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | status, status); |
| 3716 | goto error_wmm_init; |
| 3717 | } |
| 3718 | |
| 3719 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3720 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3721 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3722 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3723 | hdd_ctx->config->enableSifsBurst, |
| 3724 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3725 | if (ret_val) |
| 3726 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3728 | /* |
| 3729 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 3730 | * during that time, then as part of SSR init, do not enable |
| 3731 | * the LRO again. Keep the LRO state same as before SSR. |
| 3732 | */ |
| 3733 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 3734 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 3735 | |
| 3736 | /* rcpi info initialization */ |
| 3737 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 3738 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3739 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3741 | error_wmm_init: |
| 3742 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3743 | hdd_deinit_tx_rx(adapter); |
| 3744 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3745 | hdd_unregister_wext(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3746 | error_register_wext: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3747 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3749 | return status; |
| 3750 | } |
| 3751 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3752 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3753 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3754 | * @hdd_ctx: global hdd context |
| 3755 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3756 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 3757 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3758 | * |
| 3759 | * This function De-initializes the STA/P2P/OCB adapter. |
| 3760 | * |
| 3761 | * Return: None. |
| 3762 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3763 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3764 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3765 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3766 | { |
| 3767 | ENTER_DEV(adapter->dev); |
| 3768 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 3769 | if (adapter->dev) { |
| 3770 | if (rtnl_held) |
| 3771 | adapter->dev->wireless_handlers = NULL; |
| 3772 | else { |
| 3773 | rtnl_lock(); |
| 3774 | adapter->dev->wireless_handlers = NULL; |
| 3775 | rtnl_unlock(); |
| 3776 | } |
| 3777 | } |
| 3778 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3779 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 3780 | hdd_deinit_tx_rx(adapter); |
| 3781 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3782 | } |
| 3783 | |
| 3784 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 3785 | hdd_wmm_adapter_close(adapter); |
| 3786 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3787 | } |
| 3788 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3789 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3790 | EXIT(); |
| 3791 | } |
| 3792 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3793 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 3794 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3795 | bool rtnl_held) |
| 3796 | { |
| 3797 | ENTER(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 3798 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3800 | case QDF_STA_MODE: |
| 3801 | case QDF_P2P_CLIENT_MODE: |
| 3802 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3803 | case QDF_IBSS_MODE: |
| 3804 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3805 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3806 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3807 | break; |
| 3808 | } |
| 3809 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 3810 | case QDF_SAP_MODE: |
| 3811 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3812 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3813 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3814 | break; |
| 3815 | } |
| 3816 | |
| 3817 | default: |
| 3818 | break; |
| 3819 | } |
| 3820 | |
| 3821 | EXIT(); |
| 3822 | } |
| 3823 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3824 | 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] | 3825 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3826 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3827 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3828 | |
| 3829 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3830 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3831 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 3832 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3833 | return; |
| 3834 | } |
| 3835 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 3836 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 3837 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 3838 | hdd_adapter_runtime_suspend_deinit(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 3839 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3840 | /* |
| 3841 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 3842 | * the driver is almost closed and cannot handle either control |
| 3843 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3844 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 3845 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3846 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 3847 | * the interface is closed and restricts any operations on that |
| 3848 | */ |
| 3849 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3850 | |
| 3851 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3852 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3853 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3854 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3855 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3856 | /* |
| 3857 | * Note that the adapter is no longer valid at this point |
| 3858 | * since the memory has been reclaimed |
| 3859 | */ |
| 3860 | } |
| 3861 | } |
| 3862 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3863 | 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] | 3864 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3865 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3866 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3867 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3868 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 3869 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 3870 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3871 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3872 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3873 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 3874 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3875 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3876 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3877 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3878 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 3879 | /** |
| 3880 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 3881 | * @hdd_ctx: HDD Context |
| 3882 | * @adapter: HDD Adapter |
| 3883 | * |
| 3884 | * This function set the FW Debug log level based on the INI. |
| 3885 | * |
| 3886 | * Return: None |
| 3887 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3888 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3889 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3890 | { |
| 3891 | uint8_t count = 0, numentries = 0, |
| 3892 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 3893 | uint32_t value = 0; |
| 3894 | int ret; |
| 3895 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3896 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 3897 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3898 | 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] | 3899 | return; |
| 3900 | } |
| 3901 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3902 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3903 | hdd_ctx->fw_log_settings.dl_type = |
| 3904 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3905 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3906 | WMI_DBGLOG_TYPE, |
| 3907 | hdd_ctx->config->enableFwLogType, |
| 3908 | DBG_CMD); |
| 3909 | if (ret != 0) |
| 3910 | hdd_err("Failed to enable FW log type ret %d", |
| 3911 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3912 | |
| 3913 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3914 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3915 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3916 | WMI_DBGLOG_LOG_LEVEL, |
| 3917 | hdd_ctx->config->enableFwLogLevel, |
| 3918 | DBG_CMD); |
| 3919 | if (ret != 0) |
| 3920 | hdd_err("Failed to enable FW log level ret %d", |
| 3921 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3922 | |
| 3923 | hdd_string_to_u8_array( |
| 3924 | hdd_ctx->config->enableFwModuleLogLevel, |
| 3925 | moduleloglevel, |
| 3926 | &numentries, |
| 3927 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 3928 | |
| 3929 | while (count < numentries) { |
| 3930 | /* |
| 3931 | * FW module log level input string looks like |
| 3932 | * below: |
| 3933 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 3934 | * <Log Level>,... |
| 3935 | * For example: |
| 3936 | * gFwDebugModuleLoglevel= |
| 3937 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 3938 | * Above input string means : |
| 3939 | * For FW module ID 1 enable log level 0 |
| 3940 | * For FW module ID 2 enable log level 1 |
| 3941 | * For FW module ID 3 enable log level 2 |
| 3942 | * For FW module ID 4 enable log level 3 |
| 3943 | * For FW module ID 5 enable log level 4 |
| 3944 | * For FW module ID 6 enable log level 5 |
| 3945 | * For FW module ID 7 enable log level 6 |
| 3946 | */ |
| 3947 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 3948 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 3949 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 3950 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 3951 | moduleloglevel[count], |
| 3952 | moduleloglevel[count + 1]); |
| 3953 | return; |
| 3954 | } |
| 3955 | |
| 3956 | value = moduleloglevel[count] << 16; |
| 3957 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3958 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3959 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 3960 | value, DBG_CMD); |
| 3961 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3962 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 3963 | value, ret); |
| 3964 | |
| 3965 | count += 2; |
| 3966 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3967 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3968 | } |
| 3969 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3970 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3971 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 3972 | { |
| 3973 | } |
| 3974 | |
| 3975 | #endif |
| 3976 | |
| 3977 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 3978 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 3979 | * @adapter: HDD adapter |
| 3980 | * |
| 3981 | * Return: 0 on success or errno on failure |
| 3982 | */ |
| 3983 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 3984 | { |
| 3985 | int ret_val; |
| 3986 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3987 | |
| 3988 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 3989 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 3990 | hdd_ctx->config->txchainmask1x1, |
| 3991 | hdd_ctx->config->rxchainmask1x1); |
| 3992 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 3993 | hdd_ctx->config->dual_mac_feature_disable, |
| 3994 | hdd_ctx->config->tx_chain_mask_2g, |
| 3995 | hdd_ctx->config->rx_chain_mask_2g); |
| 3996 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 3997 | hdd_ctx->config->tx_chain_mask_5g, |
| 3998 | hdd_ctx->config->rx_chain_mask_5g); |
| 3999 | |
| 4000 | if (hdd_ctx->config->enable2x2) { |
| 4001 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4002 | return 0; |
| 4003 | } |
| 4004 | |
| 4005 | if (hdd_ctx->config->txchainmask1x1) { |
| 4006 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4007 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4008 | hdd_ctx->config->txchainmask1x1, |
| 4009 | PDEV_CMD); |
| 4010 | if (ret_val) |
| 4011 | goto error; |
| 4012 | } |
| 4013 | |
| 4014 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4015 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4016 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4017 | hdd_ctx->config->rxchainmask1x1, |
| 4018 | PDEV_CMD); |
| 4019 | if (ret_val) |
| 4020 | goto error; |
| 4021 | } |
| 4022 | |
| 4023 | if (hdd_ctx->lte_coex_ant_share) { |
| 4024 | hdd_info("lte ant sharing enabled. skip per band chain mask"); |
| 4025 | return 0; |
| 4026 | } |
| 4027 | |
| 4028 | if (hdd_ctx->config->txchainmask1x1 || |
| 4029 | hdd_ctx->config->rxchainmask1x1) { |
| 4030 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4031 | return 0; |
| 4032 | } |
| 4033 | |
| 4034 | if (!hdd_ctx->config->dual_mac_feature_disable) { |
| 4035 | hdd_info("DBS enabled. skip per band chain mask"); |
| 4036 | return 0; |
| 4037 | } |
| 4038 | |
| 4039 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4040 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4041 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4042 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4043 | if (0 != ret_val) |
| 4044 | goto error; |
| 4045 | } |
| 4046 | |
| 4047 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4048 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4049 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4050 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4051 | if (0 != ret_val) |
| 4052 | goto error; |
| 4053 | } |
| 4054 | |
| 4055 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4056 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4057 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4058 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4059 | if (0 != ret_val) |
| 4060 | goto error; |
| 4061 | } |
| 4062 | |
| 4063 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4064 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4065 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4066 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4067 | if (0 != ret_val) |
| 4068 | goto error; |
| 4069 | } |
| 4070 | |
| 4071 | return 0; |
| 4072 | |
| 4073 | error: |
| 4074 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4075 | return -EINVAL; |
| 4076 | } |
| 4077 | |
| 4078 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4079 | * hdd_set_fw_params() - Set parameters to firmware |
| 4080 | * @adapter: HDD adapter |
| 4081 | * |
| 4082 | * This function Sets various parameters to fw once the |
| 4083 | * adapter is started. |
| 4084 | * |
| 4085 | * Return: 0 on success or errno on failure |
| 4086 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4087 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4088 | { |
| 4089 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4090 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4091 | |
| 4092 | ENTER_DEV(adapter->dev); |
| 4093 | |
| 4094 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4095 | if (!hdd_ctx) |
| 4096 | return -EINVAL; |
| 4097 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4098 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4099 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4100 | return 0; |
| 4101 | } |
| 4102 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4103 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4104 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4105 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4106 | if (ret) { |
| 4107 | hdd_err("Failed to set LPRx"); |
| 4108 | goto error; |
| 4109 | } |
| 4110 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4111 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4112 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4113 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4114 | hdd_ctx->config->upper_brssi_thresh); |
| 4115 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4116 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4117 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4118 | hdd_ctx->config->lower_brssi_thresh); |
| 4119 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4120 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4121 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4122 | hdd_ctx->config->enable_dtim_1chrx); |
| 4123 | } |
| 4124 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4125 | if (hdd_ctx->config->enable2x2) { |
| 4126 | hdd_debug("configuring 2x2 mode fw params"); |
| 4127 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4128 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4129 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4130 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4131 | PDEV_CMD); |
| 4132 | if (ret) { |
| 4133 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4134 | ret); |
| 4135 | goto error; |
| 4136 | } |
| 4137 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4138 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4139 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4140 | hdd_debug("configuring 1x1 mode fw params"); |
| 4141 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4142 | /* |
| 4143 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4144 | * we are passing two value |
| 4145 | * as param_id << 29 | param_value. |
| 4146 | * Below param_value = 0(disable) |
| 4147 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4148 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4149 | WMI_STA_SMPS_PARAM_CMDID, |
| 4150 | HDD_DTIM_1CHAIN_RX_ID << |
| 4151 | HDD_SMPS_PARAM_VALUE_S, |
| 4152 | VDEV_CMD); |
| 4153 | if (ret) { |
| 4154 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4155 | goto error; |
| 4156 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4157 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4158 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4159 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4160 | |
| 4161 | if (hdd_configure_chain_mask(adapter)) |
| 4162 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4163 | } |
| 4164 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4165 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4166 | WMI_PDEV_PARAM_HYST_EN, |
| 4167 | hdd_ctx->config->enableMemDeepSleep, |
| 4168 | PDEV_CMD); |
| 4169 | if (ret) { |
| 4170 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4171 | goto error; |
| 4172 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4173 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4174 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4175 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4176 | hdd_ctx->config->rts_profile, |
| 4177 | VDEV_CMD); |
| 4178 | if (ret) { |
| 4179 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4180 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4181 | } |
| 4182 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4183 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4184 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4185 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4186 | GEN_VDEV_PARAM_AMSDU, |
| 4187 | hdd_ctx->config->max_amsdu_num, |
| 4188 | GEN_CMD); |
| 4189 | if (ret != 0) { |
| 4190 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4191 | goto error; |
| 4192 | } |
| 4193 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4194 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4195 | EXIT(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4196 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4197 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4198 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4199 | error: |
| 4200 | return -EINVAL; |
| 4201 | } |
| 4202 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4203 | /** |
| 4204 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4205 | * @hdd_ctx: global hdd context |
| 4206 | * @session_type: type of the interface to be created |
| 4207 | * @iface_name: User-visible name of the interface |
| 4208 | * @macAddr: MAC address to assign to the interface |
| 4209 | * @name_assign_type: the name of assign type of the netdev |
| 4210 | * @rtnl_held: the rtnl lock hold flag |
| 4211 | * |
| 4212 | * This function open and setup the hdd adpater according to the device |
| 4213 | * type request, assign the name, the mac address assigned, and then prepared |
| 4214 | * the hdd related parameters, queue, lock and ready to start. |
| 4215 | * |
| 4216 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4217 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4218 | 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] | 4219 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4220 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4221 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4222 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4223 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4224 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4225 | |
| 4226 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4227 | /* |
| 4228 | * Max limit reached on the number of vdevs configured by the |
| 4229 | * host. Return error |
| 4230 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4231 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4232 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4233 | return NULL; |
| 4234 | } |
| 4235 | |
| 4236 | if (macAddr == NULL) { |
| 4237 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4238 | 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] | 4239 | return NULL; |
| 4240 | } |
| 4241 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4242 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4243 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4244 | " already exists", |
| 4245 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4246 | return NULL; |
| 4247 | } |
| 4248 | |
| 4249 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4250 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4251 | /* Reset locally administered bit if the device mode is STA */ |
| 4252 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4253 | hdd_info("locally administered bit reset in sta mode: " |
| 4254 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4255 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4256 | case QDF_P2P_CLIENT_MODE: |
| 4257 | case QDF_P2P_DEVICE_MODE: |
| 4258 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4259 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4260 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4261 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4262 | name_assign_type, |
| 4263 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | |
| 4265 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4266 | hdd_err("failed to allocate adapter for session %d", |
| 4267 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4268 | return NULL; |
| 4269 | } |
| 4270 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4271 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4272 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4273 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4274 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4275 | else if (QDF_MONITOR_MODE == session_type) |
| 4276 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4277 | else |
| 4278 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4279 | |
| 4280 | adapter->device_mode = session_type; |
| 4281 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4282 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4283 | /* |
| 4284 | * Workqueue which gets scheduled in IPv4 notification |
| 4285 | * callback |
| 4286 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4287 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4289 | |
| 4290 | #ifdef WLAN_NS_OFFLOAD |
| 4291 | /* |
| 4292 | * Workqueue which gets scheduled in IPv6 |
| 4293 | * notification callback. |
| 4294 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4295 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4296 | hdd_ipv6_notifier_work_queue); |
| 4297 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4298 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4299 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4300 | goto err_deinit_adapter_runtime_pm; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4301 | |
| 4302 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4303 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4305 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4306 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4307 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4308 | /* Initialize NAN Data Interface */ |
| 4309 | if (QDF_NDI_MODE == session_type) { |
| 4310 | status = hdd_init_nan_data_mode(adapter); |
| 4311 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4312 | goto err_deinit_adapter_runtime_pm; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4313 | } |
| 4314 | |
| 4315 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4316 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4317 | case QDF_P2P_GO_MODE: |
| 4318 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4319 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4320 | name_assign_type, |
| 4321 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4322 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4323 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4324 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4325 | return NULL; |
| 4326 | } |
| 4327 | |
| 4328 | adapter->wdev.iftype = |
| 4329 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4330 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4331 | NL80211_IFTYPE_P2P_GO; |
| 4332 | adapter->device_mode = session_type; |
| 4333 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4334 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4335 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4336 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4337 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4338 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4339 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4340 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4341 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4342 | |
| 4343 | /* |
| 4344 | * Workqueue which gets scheduled in IPv4 notification |
| 4345 | * callback |
| 4346 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4347 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4348 | hdd_ipv4_notifier_work_queue); |
| 4349 | |
| 4350 | #ifdef WLAN_NS_OFFLOAD |
| 4351 | /* |
| 4352 | * Workqueue which gets scheduled in IPv6 |
| 4353 | * notification callback. |
| 4354 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4355 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4356 | hdd_ipv6_notifier_work_queue); |
| 4357 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4358 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4359 | case QDF_FTM_MODE: |
| 4360 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4361 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4362 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4363 | if (NULL == adapter) { |
| 4364 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4365 | return NULL; |
| 4366 | } |
| 4367 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4368 | adapter->device_mode = session_type; |
| 4369 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4370 | if (QDF_STATUS_SUCCESS != status) |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4371 | goto err_deinit_adapter_runtime_pm; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4372 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4373 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4374 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4375 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4376 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4377 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4378 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4379 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4380 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4381 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4382 | return NULL; |
| 4383 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4384 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4385 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4386 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4387 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4388 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4389 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4390 | } |
| 4391 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4392 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4393 | if (NULL != adapter) { |
| 4394 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4395 | adapter = NULL; |
| 4396 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4397 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4398 | return NULL; |
| 4399 | } |
| 4400 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4401 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4402 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4403 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4404 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4405 | /* Adapter successfully added. Increment the vdev count */ |
| 4406 | hdd_ctx->current_intf_count++; |
| 4407 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4408 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | hdd_ctx->current_intf_count); |
| 4410 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4411 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4412 | } |
| 4413 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4414 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4415 | hdd_err("Interface %s wow debug_fs init failed", |
| 4416 | netdev_name(adapter->dev)); |
| 4417 | |
| 4418 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4419 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4420 | |
| 4421 | return adapter; |
| 4422 | |
Yue Ma | 9e89e83 | 2017-11-14 11:40:23 -0800 | [diff] [blame] | 4423 | err_deinit_adapter_runtime_pm: |
| 4424 | /* |
| 4425 | * For certain error cases that hdd_alloc_station_adapter() |
| 4426 | * is used to allocate the adapter. |
| 4427 | */ |
| 4428 | hdd_adapter_runtime_suspend_deinit(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4429 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4430 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4431 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4432 | |
| 4433 | return NULL; |
| 4434 | } |
| 4435 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4436 | 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] | 4437 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4438 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4439 | /* |
| 4440 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4441 | * |
| 4442 | * The reason is to fix one race condition between |
| 4443 | * bus bandwidth work and cleaning up an adapter. |
| 4444 | * Under some conditions, it is possible for the bus bandwidth |
| 4445 | * work to access a particularly destroyed adapter, leading to |
| 4446 | * use-after-free. |
| 4447 | */ |
| 4448 | hdd_debug("wait for bus bw work to flush"); |
| 4449 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4450 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4451 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4452 | /* cleanup adapter */ |
| 4453 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4454 | adapter->device_mode); |
| 4455 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4456 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4457 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4458 | /* conditionally restart the bw timer */ |
| 4459 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4460 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4461 | /* Adapter removed. Decrement vdev count */ |
| 4462 | if (hdd_ctx->current_intf_count != 0) |
| 4463 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4464 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4465 | /* Fw will take care incase of concurrency */ |
| 4466 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4467 | } |
| 4468 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4469 | /** |
| 4470 | * hdd_close_all_adapters - Close all open adapters |
| 4471 | * @hdd_ctx: Hdd context |
| 4472 | * rtnl_held: True if RTNL lock held |
| 4473 | * |
| 4474 | * Close all open adapters. |
| 4475 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4476 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4477 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4478 | 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] | 4479 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4480 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4481 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4482 | |
| 4483 | ENTER(); |
| 4484 | |
| 4485 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4486 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4487 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4488 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4489 | adapter->mac_addr.bytes); |
| 4490 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4491 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4492 | /* Adapter removed. Decrement vdev count */ |
| 4493 | if (hdd_ctx->current_intf_count != 0) |
| 4494 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4496 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4497 | |
| 4498 | EXIT(); |
| 4499 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4500 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4501 | } |
| 4502 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4503 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4504 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4505 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4506 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4507 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4508 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4509 | case QDF_STA_MODE: |
| 4510 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4511 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4512 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4513 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4514 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | break; |
| 4516 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4517 | case QDF_SAP_MODE: |
| 4518 | case QDF_P2P_GO_MODE: |
| 4519 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4520 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4521 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4522 | break; |
| 4523 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4524 | case QDF_FTM_MODE: |
| 4525 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4526 | default: |
| 4527 | /* |
| 4528 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4529 | * for these kind of devices |
| 4530 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4531 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4532 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4533 | return; |
| 4534 | } |
| 4535 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4536 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4537 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4538 | updateIE.ieBufferlength = 0; |
| 4539 | updateIE.pAdditionIEBuffer = NULL; |
| 4540 | updateIE.append = true; |
| 4541 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4542 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4543 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4544 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4545 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4546 | } |
| 4547 | } |
| 4548 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4549 | 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] | 4550 | const bool bCloseSession) |
| 4551 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4552 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 4553 | struct hdd_wext_state *pWextState = |
| 4554 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4555 | union iwreq_data wrqu; |
| 4556 | tSirUpdateIE updateIE; |
| 4557 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4558 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4559 | |
| 4560 | ENTER(); |
| 4561 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4562 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4563 | wlan_hdd_netif_queue_control(adapter, |
| 4564 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4565 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4566 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4567 | case QDF_STA_MODE: |
| 4568 | case QDF_P2P_CLIENT_MODE: |
| 4569 | case QDF_IBSS_MODE: |
| 4570 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4571 | case QDF_NDI_MODE: |
| 4572 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4573 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4574 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4575 | hdd_is_connecting( |
| 4576 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4577 | INIT_COMPLETION(adapter->disconnect_comp_var); |
| 4578 | /* |
| 4579 | * For NDI do not use pWextState from sta_ctx, if needed |
| 4580 | * extract from ndi_ctx. |
| 4581 | */ |
| 4582 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4583 | qdf_ret_status = sme_roam_disconnect( |
| 4584 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4585 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4586 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
| 4587 | else if (pWextState->roamProfile.BSSType == |
| 4588 | eCSR_BSS_TYPE_START_IBSS) |
| 4589 | qdf_ret_status = sme_roam_disconnect( |
| 4590 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4591 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4592 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4593 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4594 | qdf_ret_status = |
| 4595 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4596 | hdd_debug("Send disconnected event to userspace"); |
| 4597 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4598 | adapter->dev, true, |
| 4599 | WLAN_REASON_UNSPECIFIED); |
| 4600 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4601 | else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4602 | qdf_ret_status = sme_roam_disconnect( |
| 4603 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4604 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4605 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4606 | /* success implies disconnect command got |
| 4607 | * queued up successfully |
| 4608 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4609 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4610 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4611 | rc = wait_for_completion_timeout( |
| 4612 | &adapter->disconnect_comp_var, |
| 4613 | msecs_to_jiffies |
| 4614 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4615 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4616 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4617 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4618 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4619 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4620 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4621 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4622 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4623 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4624 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4625 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4626 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4627 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4628 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4629 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4630 | |
| 4631 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4632 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4633 | #endif |
| 4634 | |
| 4635 | hdd_deregister_tx_flow_control(adapter); |
| 4636 | |
| 4637 | #ifdef WLAN_NS_OFFLOAD |
| 4638 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4639 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4640 | #endif |
| 4641 | #endif |
| 4642 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4643 | if (adapter->device_mode == QDF_STA_MODE) |
| 4644 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4645 | adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4646 | /* |
| 4647 | * It is possible that the caller of this function does not |
| 4648 | * wish to close the session |
| 4649 | */ |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4650 | if (true == bCloseSession) { |
| 4651 | if (0 != wlan_hdd_try_disconnect(adapter)) { |
| 4652 | hdd_err("Error: Can't disconnect adapter"); |
| 4653 | return QDF_STATUS_E_FAILURE; |
| 4654 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4655 | hdd_debug("Destroying adapter: %d", |
| 4656 | adapter->session_id); |
Dustin Brown | 0d2eeae | 2017-03-24 15:21:32 -0700 | [diff] [blame] | 4657 | hdd_vdev_destroy(adapter); |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4658 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4659 | break; |
| 4660 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4661 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 4662 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4663 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4664 | sap_config = &adapter->session.ap.sap_config; |
| 4665 | if (sap_config) |
| 4666 | wlansap_reset_sap_config_add_ie(sap_config, |
| 4667 | eUPDATE_IE_ALL); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 4668 | hdd_ipa_flush(hdd_ctx); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4669 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4670 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4671 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 4672 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 4673 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 4674 | cds_flush_delayed_work( |
| 4675 | &adapter->acs_pending_work); |
| 4676 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 4677 | } |
| 4678 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 4679 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4680 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4681 | /* Any softap specific cleanup here... */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 4682 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4683 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4684 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4685 | |
| 4686 | hdd_deregister_tx_flow_control(adapter); |
| 4687 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 4688 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4689 | mutex_lock(&hdd_ctx->sap_lock); |
| 4690 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4691 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4692 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4693 | |
| 4694 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4695 | status = wlansap_stop_bss( |
| 4696 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4697 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4698 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 4699 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4700 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4701 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4702 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4703 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 4704 | qdf_wait_for_event_completion( |
| 4705 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 4706 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4707 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 4708 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4709 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 4710 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4711 | } |
| 4712 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4713 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4714 | } |
| 4715 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4716 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 4717 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4718 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4719 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4720 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4721 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4722 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | updateIE.ieBufferlength = 0; |
| 4724 | updateIE.pAdditionIEBuffer = NULL; |
| 4725 | updateIE.append = false; |
| 4726 | updateIE.notify = false; |
| 4727 | /* Probe bcn reset */ |
| 4728 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4729 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4730 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4731 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4732 | } |
| 4733 | /* Assoc resp reset */ |
| 4734 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 4735 | &updateIE, |
| 4736 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4737 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4738 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4739 | } |
| 4740 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 4741 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4742 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4743 | qdf_mem_free(adapter->session.ap.beacon); |
| 4744 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 4745 | /* |
| 4746 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 4747 | */ |
| 4748 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 4749 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 4750 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4751 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4752 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4753 | #endif |
| 4754 | |
| 4755 | #ifdef WLAN_NS_OFFLOAD |
| 4756 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4757 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4758 | #endif |
| 4759 | #endif |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4760 | if (true == bCloseSession) { |
| 4761 | hdd_debug("Destroying adapter: %d", |
| 4762 | adapter->session_id); |
| 4763 | hdd_vdev_destroy(adapter); |
| 4764 | } |
| 4765 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4767 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 4768 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 4769 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 4770 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4771 | break; |
| 4772 | default: |
| 4773 | break; |
| 4774 | } |
| 4775 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4776 | if (adapter->scan_info.default_scan_ies) { |
| 4777 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 4778 | adapter->scan_info.default_scan_ies = NULL; |
| 4779 | } |
| 4780 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4781 | EXIT(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 4782 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4783 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4784 | } |
| 4785 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4786 | /** |
| 4787 | * hdd_deinit_all_adapters - deinit all adapters |
| 4788 | * @hdd_ctx: HDD context |
| 4789 | * @rtnl_held: True if RTNL lock held |
| 4790 | * |
| 4791 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4792 | 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] | 4793 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4794 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4795 | |
| 4796 | ENTER(); |
| 4797 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4798 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4799 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 4800 | |
| 4801 | EXIT(); |
| 4802 | } |
| 4803 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4804 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx, |
| 4805 | bool close_session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4806 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4807 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | |
| 4809 | ENTER(); |
| 4810 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4811 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4812 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4813 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 4814 | hdd_stop_adapter(hdd_ctx, adapter, close_session); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4815 | |
| 4816 | EXIT(); |
| 4817 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4818 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | } |
| 4820 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4821 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 4822 | struct hdd_adapter *adapter) |
| 4823 | { |
| 4824 | switch (adapter->device_mode) { |
| 4825 | case QDF_STA_MODE: |
| 4826 | case QDF_P2P_CLIENT_MODE: |
| 4827 | case QDF_IBSS_MODE: |
| 4828 | case QDF_P2P_DEVICE_MODE: |
| 4829 | case QDF_NDI_MODE: |
| 4830 | wlan_hdd_scan_abort(adapter); |
| 4831 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4832 | if (adapter->device_mode == QDF_STA_MODE) |
| 4833 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4834 | adapter->dev); |
| 4835 | break; |
| 4836 | case QDF_P2P_GO_MODE: |
| 4837 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 4838 | break; |
| 4839 | case QDF_SAP_MODE: |
| 4840 | wlan_hdd_undo_acs(adapter); |
| 4841 | break; |
| 4842 | default: |
| 4843 | break; |
| 4844 | } |
| 4845 | } |
| 4846 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4847 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4848 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4849 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4850 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4851 | struct qdf_mac_addr peerMacAddr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4852 | |
| 4853 | ENTER(); |
| 4854 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 4855 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 4856 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4857 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4858 | hdd_notice("Disabling queues for adapter type: %d", |
| 4859 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4860 | |
| 4861 | if ((adapter->device_mode == QDF_STA_MODE) || |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4862 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4863 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 4864 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 4865 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4866 | if (hdd_ctx->config->sap_internal_restart && |
| 4867 | adapter->device_mode == QDF_SAP_MODE) { |
| 4868 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4869 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4870 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4871 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4872 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4873 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4874 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 4875 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 4876 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4877 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4878 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 4879 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4880 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 4881 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4882 | adapter->session.station.hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | |
| 4884 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4885 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4886 | adapter->device_mode, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4888 | hdd_wmm_adapter_close(adapter); |
| 4889 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4890 | } |
| 4891 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 4892 | if (adapter->device_mode == QDF_STA_MODE) |
| 4893 | hdd_clear_fils_connection_info(adapter); |
| 4894 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4895 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 4896 | /* |
| 4897 | * If adapter is SAP, set session ID to invalid |
| 4898 | * since SAP session will be cleanup during SSR. |
| 4899 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 4900 | wlansap_set_invalid_session( |
| 4901 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4902 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 4903 | wlansap_cleanup_cac_timer( |
| 4904 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 4905 | } |
| 4906 | |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4907 | /* Delete peers if any for STA and P2P client modes */ |
| 4908 | if (adapter->device_mode == QDF_STA_MODE || |
| 4909 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4910 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4911 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4912 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 4913 | |
| 4914 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 4915 | peerMacAddr.bytes); |
| 4916 | } |
| 4917 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4918 | /* Destroy vdev which will be recreated during reinit. */ |
| 4919 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | } |
| 4921 | |
| 4922 | EXIT(); |
| 4923 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4924 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4925 | } |
| 4926 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4927 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4928 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4929 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4930 | bool close_modules = true; |
| 4931 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 4932 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 4933 | hdd_info("FTM mode, don't close the module"); |
| 4934 | return false; |
| 4935 | } |
| 4936 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4937 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4938 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 4939 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4940 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4941 | close_modules = false; |
| 4942 | break; |
| 4943 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 4944 | } |
| 4945 | |
| 4946 | return close_modules; |
| 4947 | } |
| 4948 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 4949 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4950 | { |
| 4951 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 4952 | return true; |
| 4953 | else |
| 4954 | return false; |
| 4955 | } |
| 4956 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4957 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 4958 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4959 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4960 | struct ieee80211_channel *channel, |
| 4961 | const u8 *bssid, const u8 *ssid, |
| 4962 | size_t ssid_len) |
| 4963 | { |
| 4964 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4965 | ssid, ssid_len, |
| 4966 | WLAN_CAPABILITY_ESS, |
| 4967 | WLAN_CAPABILITY_ESS); |
| 4968 | } |
| 4969 | #else |
| 4970 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 4971 | struct ieee80211_channel *channel, |
| 4972 | const u8 *bssid, const u8 *ssid, |
| 4973 | size_t ssid_len) |
| 4974 | { |
| 4975 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 4976 | ssid, ssid_len, |
| 4977 | IEEE80211_BSS_TYPE_ESS, |
| 4978 | IEEE80211_PRIVACY_ANY); |
| 4979 | } |
| 4980 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 4981 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4982 | #if defined CFG80211_CONNECT_BSS || \ |
| 4983 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4984 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 4985 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 4986 | /** |
| 4987 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 4988 | * @timeout_reason: reason for connect timeout |
| 4989 | * |
| 4990 | * This function is used to convert host timeout |
| 4991 | * reason enum to kernel specific enum. |
| 4992 | * |
| 4993 | * Return: nl timeout enum |
| 4994 | */ |
| 4995 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 4996 | tSirResultCodes timeout_reason) |
| 4997 | { |
| 4998 | switch (timeout_reason) { |
| 4999 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5000 | return NL80211_TIMEOUT_SCAN; |
| 5001 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5002 | return NL80211_TIMEOUT_AUTH; |
| 5003 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5004 | return NL80211_TIMEOUT_ASSOC; |
| 5005 | default: |
| 5006 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5007 | } |
| 5008 | } |
| 5009 | |
| 5010 | /** |
| 5011 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5012 | * @dev: network device |
| 5013 | * @bssid: bssid to which we want to associate |
| 5014 | * @timeout_reason: reason for connect timeout |
| 5015 | * |
| 5016 | * This API is used to send connection timeout reason to supplicant |
| 5017 | * |
| 5018 | * Return: void |
| 5019 | */ |
| 5020 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5021 | const u8 *bssid, |
| 5022 | tSirResultCodes timeout_reason) |
| 5023 | { |
| 5024 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5025 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5026 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5027 | |
| 5028 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5029 | nl_timeout_reason); |
| 5030 | } |
| 5031 | |
| 5032 | /** |
| 5033 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5034 | * @dev: network device |
| 5035 | * @bssid: bssid to which we want to associate |
| 5036 | * @req_ie: Request Information Element |
| 5037 | * @req_ie_len: len of the req IE |
| 5038 | * @resp_ie: Response IE |
| 5039 | * @resp_ie_len: len of ht response IE |
| 5040 | * @status: status |
| 5041 | * @gfp: Kernel Flag |
| 5042 | * @timeout_reason: reason for connect timeout |
| 5043 | * |
| 5044 | * Return: void |
| 5045 | */ |
| 5046 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5047 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5048 | size_t req_ie_len, const u8 *resp_ie, |
| 5049 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5050 | tSirResultCodes timeout_reason) |
| 5051 | { |
| 5052 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5053 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5054 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5055 | |
| 5056 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5057 | resp_ie, resp_ie_len, status, gfp, |
| 5058 | nl_timeout_reason); |
| 5059 | } |
| 5060 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5061 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5062 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5063 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5064 | const u8 *bssid, |
| 5065 | tSirResultCodes timeout_reason) |
| 5066 | { |
| 5067 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5068 | } |
| 5069 | #endif |
| 5070 | |
| 5071 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5072 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5073 | size_t req_ie_len, const u8 *resp_ie, |
| 5074 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5075 | tSirResultCodes timeout_reason) |
| 5076 | { |
| 5077 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5078 | resp_ie, resp_ie_len, status, gfp); |
| 5079 | } |
| 5080 | #endif |
| 5081 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5082 | /** |
| 5083 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5084 | * @dev: network device |
| 5085 | * @bssid: bssid to which we want to associate |
| 5086 | * @req_ie: Request Information Element |
| 5087 | * @req_ie_len: len of the req IE |
| 5088 | * @resp_ie: Response IE |
| 5089 | * @resp_ie_len: len of ht response IE |
| 5090 | * @status: status |
| 5091 | * @gfp: Kernel Flag |
| 5092 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5093 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5094 | * |
| 5095 | * The API is a wrapper to send connection status to supplicant |
| 5096 | * |
| 5097 | * Return: Void |
| 5098 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5099 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5100 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5101 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5102 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5103 | size_t req_ie_len, const u8 *resp_ie, |
| 5104 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5105 | bool connect_timeout, |
| 5106 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5107 | { |
| 5108 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5109 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5110 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5111 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5112 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5113 | } |
| 5114 | #else |
| 5115 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5116 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5117 | size_t req_ie_len, const u8 *resp_ie, |
| 5118 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5119 | bool connect_timeout, |
| 5120 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5121 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5122 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5123 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5124 | } |
| 5125 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5126 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5127 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5128 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5129 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5130 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5131 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5132 | /** |
| 5133 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5134 | * @fils_params: connect response to supplicant |
| 5135 | * @fils_kek: FILS kek |
| 5136 | * @fils_kek_len: FILS kek length |
| 5137 | * @pmk: FILS PMK |
| 5138 | * @pmk_len: FILS PMK length |
| 5139 | * @pmkid: PMKID |
| 5140 | * @fils_seq_num: FILS Seq number |
| 5141 | * |
| 5142 | * Return: None |
| 5143 | */ |
| 5144 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5145 | *fils_params, const uint8_t *fils_kek, |
| 5146 | size_t fils_kek_len, const uint8_t *pmk, |
| 5147 | size_t pmk_len, const uint8_t *pmkid, |
| 5148 | uint16_t fils_seq_num) |
| 5149 | { |
| 5150 | /* Increament seq number to be used for next FILS */ |
| 5151 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5152 | fils_params->update_erp_next_seq_num = true; |
| 5153 | fils_params->fils_kek = fils_kek; |
| 5154 | fils_params->fils_kek_len = fils_kek_len; |
| 5155 | fils_params->pmk = pmk; |
| 5156 | fils_params->pmk_len = pmk_len; |
| 5157 | fils_params->pmkid = pmkid; |
| 5158 | } |
| 5159 | #else |
| 5160 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5161 | *fils_params, const uint8_t |
| 5162 | *fils_kek, size_t fils_kek_len, |
| 5163 | const uint8_t *pmk, size_t pmk_len, |
| 5164 | const uint8_t *pmkid, |
| 5165 | uint16_t fils_seq_num) |
| 5166 | { } |
| 5167 | #endif |
| 5168 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5169 | void hdd_update_hlp_info(struct net_device *dev, |
| 5170 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5171 | { |
| 5172 | struct sk_buff *skb; |
| 5173 | uint16_t skb_len; |
| 5174 | struct llc_snap_hdr_t *llc_hdr; |
| 5175 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5176 | uint8_t *hlp_data; |
| 5177 | uint16_t hlp_data_len; |
| 5178 | struct fils_join_rsp_params *roam_fils_params |
| 5179 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5180 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5181 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5182 | if (!roam_fils_params) { |
| 5183 | hdd_err("FILS Roam Param NULL"); |
| 5184 | return; |
| 5185 | } |
| 5186 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5187 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5188 | hdd_err("FILS HLP Data NULL, len %d", |
| 5189 | roam_fils_params->hlp_data_len); |
| 5190 | return; |
| 5191 | } |
| 5192 | |
| 5193 | hlp_data = roam_fils_params->hlp_data; |
| 5194 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5195 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5196 | /* Calculate skb length */ |
| 5197 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5198 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5199 | if (skb == NULL) { |
| 5200 | hdd_err("HLP packet nbuf alloc fails"); |
| 5201 | return; |
| 5202 | } |
| 5203 | |
| 5204 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5205 | QDF_MAC_ADDR_SIZE); |
| 5206 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5207 | QDF_MAC_ADDR_SIZE); |
| 5208 | |
| 5209 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5210 | if (IS_SNAP(llc_hdr)) { |
| 5211 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5212 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5213 | } |
| 5214 | |
| 5215 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5216 | |
| 5217 | /* |
| 5218 | * This HLP packet is formed from HLP info encapsulated |
| 5219 | * in assoc response frame which is AEAD encrypted. |
| 5220 | * Hence, this checksum validation can be set unnecessary. |
| 5221 | * i.e. network layer need not worry about checksum. |
| 5222 | */ |
| 5223 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5224 | |
| 5225 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5226 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5227 | hdd_err("Sending HLP packet fails"); |
| 5228 | return; |
| 5229 | } |
| 5230 | hdd_debug("send HLP packet to netif successfully"); |
| 5231 | } |
| 5232 | |
| 5233 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5234 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5235 | * @dev: network device |
| 5236 | * @bssid: bssid to which we want to associate |
| 5237 | * @bss: cfg80211 bss info |
| 5238 | * @roam_info: information about connected bss |
| 5239 | * @req_ie: Request Information Element |
| 5240 | * @req_ie_len: len of the req IE |
| 5241 | * @resp_ie: Response IE |
| 5242 | * @resp_ie_len: len of ht response IE |
| 5243 | * @status: status |
| 5244 | * @gfp: allocation flags |
| 5245 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5246 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5247 | * |
| 5248 | * This API is used as wrapper to send FILS key/sequence number |
| 5249 | * params etc. to supplicant in case of FILS connection |
| 5250 | * |
| 5251 | * Return: None |
| 5252 | */ |
| 5253 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5254 | struct cfg80211_bss *bss, |
| 5255 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5256 | const u8 *req_ie, size_t req_ie_len, |
| 5257 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5258 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5259 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5260 | { |
| 5261 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5262 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5263 | struct fils_join_rsp_params *roam_fils_params = |
| 5264 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5265 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5266 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5267 | |
| 5268 | if (!roam_fils_params) { |
| 5269 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5270 | } else { |
| 5271 | fils_params.status = status; |
| 5272 | fils_params.bssid = bssid; |
| 5273 | fils_params.timeout_reason = timeout_reason; |
| 5274 | fils_params.req_ie = req_ie; |
| 5275 | fils_params.req_ie_len = req_ie_len; |
| 5276 | fils_params.resp_ie = resp_ie; |
| 5277 | fils_params.resp_ie_len = resp_ie_len; |
| 5278 | fils_params.bss = bss; |
| 5279 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5280 | roam_fils_params->kek_len, |
| 5281 | roam_fils_params->fils_pmk, |
| 5282 | roam_fils_params->fils_pmk_len, |
| 5283 | roam_fils_params->fils_pmkid, |
| 5284 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5285 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5286 | } |
| 5287 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5288 | fils_params.status, |
| 5289 | fils_params.fils_erp_next_seq_num); |
| 5290 | |
| 5291 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5292 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5293 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5294 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5295 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5296 | /* Clear all the FILS key info */ |
| 5297 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5298 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5299 | if (roam_fils_params) |
| 5300 | qdf_mem_free(roam_fils_params); |
| 5301 | roam_info->fils_join_rsp = NULL; |
| 5302 | } |
| 5303 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5304 | static inline void |
| 5305 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5306 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5307 | const u8 *req_ie, size_t req_ie_len, |
| 5308 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5309 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5310 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5311 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5312 | #endif |
| 5313 | #endif |
| 5314 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5315 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5316 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5317 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5318 | /** |
| 5319 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5320 | * supplicant. |
| 5321 | * @dev: network device |
| 5322 | * @bssid: bssid to which we want to associate |
| 5323 | * @bss: cfg80211 bss info |
| 5324 | * @roam_info: information about connected bss |
| 5325 | * @req_ie: Request Information Element |
| 5326 | * @req_ie_len: len of the req IE |
| 5327 | * @resp_ie: Response IE |
| 5328 | * @resp_ie_len: len of ht response IE |
| 5329 | * @status: status |
| 5330 | * @gfp: allocation flags |
| 5331 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5332 | * @timeout_reason: reason for connect timeout |
| 5333 | * |
| 5334 | * The API is a wrapper to send connection status to supplicant |
| 5335 | * |
| 5336 | * Return: 0 if success else failure |
| 5337 | */ |
| 5338 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5339 | const u8 *bssid, |
| 5340 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5341 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5342 | size_t req_ie_len, const u8 *resp_ie, |
| 5343 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5344 | bool connect_timeout, |
| 5345 | tSirResultCodes timeout_reason) |
| 5346 | { |
| 5347 | ENTER(); |
| 5348 | if (!roam_info || !roam_info->is_fils_connection) |
| 5349 | return -EINVAL; |
| 5350 | |
| 5351 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5352 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5353 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5354 | return 0; |
| 5355 | } |
| 5356 | #else |
| 5357 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5358 | const u8 *bssid, |
| 5359 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5360 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5361 | size_t req_ie_len, const u8 *resp_ie, |
| 5362 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5363 | bool connect_timeout, |
| 5364 | tSirResultCodes timeout_reason) |
| 5365 | { |
| 5366 | return -EINVAL; |
| 5367 | } |
| 5368 | #endif |
| 5369 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5370 | /** |
| 5371 | * hdd_connect_result() - API to send connection status to supplicant |
| 5372 | * @dev: network device |
| 5373 | * @bssid: bssid to which we want to associate |
| 5374 | * @roam_info: information about connected bss |
| 5375 | * @req_ie: Request Information Element |
| 5376 | * @req_ie_len: len of the req IE |
| 5377 | * @resp_ie: Response IE |
| 5378 | * @resp_ie_len: len of ht response IE |
| 5379 | * @status: status |
| 5380 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5381 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5382 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5383 | * |
| 5384 | * The API is a wrapper to send connection status to supplicant |
| 5385 | * and allow runtime suspend |
| 5386 | * |
| 5387 | * Return: Void |
| 5388 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5389 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5390 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5391 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5392 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5393 | bool connect_timeout, |
| 5394 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5395 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5396 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5397 | struct cfg80211_bss *bss = NULL; |
| 5398 | |
| 5399 | if (WLAN_STATUS_SUCCESS == status) { |
| 5400 | struct ieee80211_channel *chan; |
| 5401 | int freq; |
| 5402 | int chan_no = roam_info->pBssDesc->channelId; |
| 5403 | |
| 5404 | if (chan_no <= 14) |
| 5405 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5406 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5407 | else |
| 5408 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5409 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5410 | |
| 5411 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5412 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5413 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5414 | roam_info->u.pConnectedProfile->SSID.length); |
| 5415 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5416 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5417 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5418 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5419 | resp_ie_len, status, gfp, connect_timeout, |
| 5420 | timeout_reason) != 0) { |
| 5421 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5422 | req_ie_len, resp_ie, resp_ie_len, |
| 5423 | status, gfp, connect_timeout, timeout_reason); |
| 5424 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5425 | |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5426 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5427 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5428 | } |
| 5429 | #else |
| 5430 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5431 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5432 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5433 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5434 | bool connect_timeout, |
| 5435 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5436 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5437 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5438 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5439 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5440 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5441 | |
| 5442 | qdf_runtime_pm_allow_suspend(&padapter->connect_rpm_ctx.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5443 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5444 | } |
| 5445 | #endif |
| 5446 | |
| 5447 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5448 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5449 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5450 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5451 | #ifndef MSM_PLATFORM |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5452 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BROADCAST_INITIALIZER; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5453 | #endif |
| 5454 | eConnectionState connState; |
| 5455 | |
| 5456 | ENTER(); |
| 5457 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5458 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5459 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5460 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5461 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5462 | hdd_wmm_init(adapter); |
| 5463 | |
| 5464 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5465 | case QDF_STA_MODE: |
| 5466 | case QDF_P2P_CLIENT_MODE: |
| 5467 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5468 | |
| 5469 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5470 | ->conn_info.connState; |
| 5471 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5472 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5473 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5474 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5475 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5476 | /* Indicate disconnect event to supplicant |
| 5477 | * if associated previously |
| 5478 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5479 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5480 | eConnectionState_IbssConnected == connState || |
| 5481 | eConnectionState_NotConnected == connState || |
| 5482 | eConnectionState_IbssDisconnected == connState || |
| 5483 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5484 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5485 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5486 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5487 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5488 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5489 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5490 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5491 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5492 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5493 | |
| 5494 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5495 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5496 | adapter->dev, false, |
| 5497 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5498 | } else if (eConnectionState_Connecting == connState) { |
| 5499 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5500 | * Indicate connect failure to supplicant if we |
| 5501 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5502 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5503 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5504 | NULL, 0, NULL, 0, |
| 5505 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5506 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5507 | } |
| 5508 | |
| 5509 | hdd_register_tx_flow_control(adapter, |
| 5510 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5511 | hdd_tx_resume_cb, |
| 5512 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5513 | |
| 5514 | break; |
| 5515 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5516 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5517 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5518 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5519 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5520 | break; |
| 5521 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5522 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5523 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5524 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5525 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5526 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5527 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5528 | /* event supplicant to restart */ |
| 5529 | cfg80211_del_sta(adapter->dev, |
| 5530 | (const u8 *)&bcastMac.bytes[0], |
| 5531 | GFP_KERNEL); |
| 5532 | #endif |
| 5533 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5534 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5535 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5536 | hdd_set_mon_rx_cb(adapter->dev); |
| 5537 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5538 | adapter->mon_bandwidth); |
| 5539 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5540 | default: |
| 5541 | break; |
| 5542 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5543 | /* |
| 5544 | * Action frame registered in one adapter which will |
| 5545 | * applicable to all interfaces |
| 5546 | */ |
| 5547 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5548 | } |
| 5549 | |
| 5550 | EXIT(); |
| 5551 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5552 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5553 | } |
| 5554 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5555 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5556 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5557 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5558 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5559 | qdf_list_node_t *node; |
| 5560 | |
| 5561 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5562 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5563 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5564 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5565 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5566 | |
| 5567 | if (QDF_IS_STATUS_ERROR(status)) |
| 5568 | return status; |
| 5569 | |
| 5570 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5571 | |
| 5572 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5573 | } |
| 5574 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5575 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5576 | struct hdd_adapter *current_adapter, |
| 5577 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5578 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5579 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5580 | qdf_list_node_t *node; |
| 5581 | |
| 5582 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5583 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5584 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 5585 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5586 | ¤t_adapter->node, |
| 5587 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5588 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5589 | |
| 5590 | if (QDF_IS_STATUS_ERROR(status)) |
| 5591 | return status; |
| 5592 | |
| 5593 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5594 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5595 | return status; |
| 5596 | } |
| 5597 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5598 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5599 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5600 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5601 | QDF_STATUS status; |
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_node(&hdd_ctx->hdd_adapters, &adapter->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 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5607 | return status; |
| 5608 | } |
| 5609 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5610 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5611 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5612 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5613 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5614 | qdf_list_node_t *node; |
| 5615 | |
| 5616 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5617 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5618 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5619 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5620 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5621 | |
| 5622 | if (QDF_IS_STATUS_ERROR(status)) |
| 5623 | return status; |
| 5624 | |
| 5625 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 5626 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5627 | return status; |
| 5628 | } |
| 5629 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5630 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5631 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5632 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5633 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5634 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5635 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5636 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5637 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5638 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5639 | return status; |
| 5640 | } |
| 5641 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5642 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5643 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5644 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5645 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5646 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5647 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5648 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5649 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5650 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5651 | return status; |
| 5652 | } |
| 5653 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5654 | 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] | 5655 | tSirMacAddr macAddr) |
| 5656 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5657 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5658 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5659 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5660 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 5661 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5662 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5663 | } |
| 5664 | |
| 5665 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5666 | } |
| 5667 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5668 | 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] | 5669 | uint32_t vdev_id) |
| 5670 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5671 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5672 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5673 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5674 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5675 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5676 | } |
| 5677 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5678 | hdd_err("vdev_id %d does not exist with host", vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5679 | |
| 5680 | return NULL; |
| 5681 | } |
| 5682 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5683 | /** |
| 5684 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 5685 | * the sessionid |
| 5686 | * @hdd_ctx: hdd context. |
| 5687 | * @sme_session_id: sme session is for the adapter to get. |
| 5688 | * |
| 5689 | * This function is used to get the adapter with provided session id |
| 5690 | * |
| 5691 | * Return: adapter pointer if found |
| 5692 | * |
| 5693 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 5694 | struct hdd_adapter * |
| 5695 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 5696 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5697 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5698 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5699 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5700 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5701 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5702 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5703 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5704 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 5705 | return NULL; |
| 5706 | } |
| 5707 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5708 | 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] | 5709 | const char *iface_name) |
| 5710 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5711 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5712 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5713 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5714 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5715 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5716 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5717 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 5718 | return NULL; |
| 5719 | } |
| 5720 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5721 | /** |
| 5722 | * hdd_get_adapter() - to get adapter matching the mode |
| 5723 | * @hdd_ctx: hdd context |
| 5724 | * @mode: adapter mode |
| 5725 | * |
| 5726 | * This routine will return the pointer to adapter matching |
| 5727 | * with the passed mode. |
| 5728 | * |
| 5729 | * Return: pointer to adapter or null |
| 5730 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5731 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5732 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5733 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5734 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5735 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5736 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5737 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5738 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5739 | } |
| 5740 | |
| 5741 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5742 | } |
| 5743 | |
| 5744 | /** |
| 5745 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 5746 | * @hdd_ctx: Pointer to the HDD context. |
| 5747 | * @mode: Device mode for which operating channel is required. |
| 5748 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5749 | * QDF_STA_MODE, |
| 5750 | * QDF_P2P_CLIENT_MODE, |
| 5751 | * QDF_SAP_MODE, |
| 5752 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5753 | * |
| 5754 | * This API returns the operating channel of the requested device mode |
| 5755 | * |
| 5756 | * Return: channel number. "0" id the requested device is not found OR it is |
| 5757 | * not connected. |
| 5758 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5759 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 5760 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5761 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5762 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5763 | uint8_t operatingChannel = 0; |
| 5764 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5765 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5766 | if (mode == adapter->device_mode) { |
| 5767 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5768 | case QDF_STA_MODE: |
| 5769 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5770 | if (hdd_conn_is_connected |
| 5771 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5772 | (adapter))) { |
| 5773 | operatingChannel = |
| 5774 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 5775 | (adapter))->conn_info. |
| 5776 | operationChannel; |
| 5777 | } |
| 5778 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5779 | case QDF_SAP_MODE: |
| 5780 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5781 | /* softap connection info */ |
| 5782 | if (test_bit |
| 5783 | (SOFTAP_BSS_STARTED, |
| 5784 | &adapter->event_flags)) |
| 5785 | operatingChannel = |
| 5786 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 5787 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5788 | break; |
| 5789 | default: |
| 5790 | break; |
| 5791 | } |
| 5792 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5793 | /* Found the device of interest. break the loop */ |
| 5794 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5795 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5796 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5797 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5798 | return operatingChannel; |
| 5799 | } |
| 5800 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5801 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5802 | hdd_ctx) |
| 5803 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5804 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5805 | |
| 5806 | ENTER(); |
| 5807 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5808 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5809 | if (adapter->device_mode == QDF_STA_MODE || |
| 5810 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5811 | adapter->device_mode == QDF_IBSS_MODE || |
| 5812 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5813 | adapter->device_mode == QDF_SAP_MODE || |
| 5814 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5815 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5816 | hdd_unregister_wext(adapter->dev); |
| 5817 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5818 | } |
| 5819 | |
| 5820 | EXIT(); |
| 5821 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5822 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5823 | } |
| 5824 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5825 | 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] | 5826 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5827 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5828 | |
| 5829 | ENTER(); |
| 5830 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5831 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5832 | if (adapter->device_mode == QDF_STA_MODE || |
| 5833 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5834 | adapter->device_mode == QDF_IBSS_MODE || |
| 5835 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5836 | adapter->device_mode == QDF_SAP_MODE || |
| 5837 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5838 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5839 | adapter->session_id, INVALID_SCAN_ID, |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 5840 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5841 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5842 | } |
| 5843 | |
| 5844 | EXIT(); |
| 5845 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5846 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5847 | } |
| 5848 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5849 | /** |
| 5850 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 5851 | * adapters |
| 5852 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 5853 | * |
| 5854 | * return: QDF_STATUS_SUCCESS |
| 5855 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5856 | 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] | 5857 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5858 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5859 | int err; |
| 5860 | |
| 5861 | ENTER(); |
| 5862 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5863 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5864 | if (adapter->device_mode == QDF_STA_MODE || |
| 5865 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 5866 | adapter->device_mode == QDF_IBSS_MODE || |
| 5867 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 5868 | adapter->device_mode == QDF_SAP_MODE || |
| 5869 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5870 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 5871 | if (err) |
| 5872 | hdd_err("Unable to stop scheduled scan"); |
| 5873 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 5874 | } |
| 5875 | |
| 5876 | EXIT(); |
| 5877 | |
| 5878 | return QDF_STATUS_SUCCESS; |
| 5879 | } |
| 5880 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5881 | #ifdef WLAN_NS_OFFLOAD |
| 5882 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5883 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5884 | * @hdd_ctx: Pointer to hdd context |
| 5885 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5886 | * Unregister for IPv6 address change notifications. |
| 5887 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5888 | * Return: None |
| 5889 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5890 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5891 | { |
| 5892 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5893 | } |
| 5894 | |
| 5895 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5896 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5897 | * @hdd_ctx: Pointer to hdd context |
| 5898 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5899 | * Register for IPv6 address change notifications. |
| 5900 | * |
| 5901 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5902 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5903 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5904 | { |
| 5905 | int ret; |
| 5906 | |
| 5907 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 5908 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5909 | if (ret) { |
| 5910 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 5911 | goto out; |
| 5912 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5913 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5914 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5915 | out: |
| 5916 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5917 | } |
| 5918 | #else |
| 5919 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5920 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5921 | * @hdd_ctx: Pointer to hdd context |
| 5922 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5923 | * Unregister for IPv6 address change notifications. |
| 5924 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5925 | * Return: None |
| 5926 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5927 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5928 | { |
| 5929 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5930 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5931 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5932 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5933 | * @hdd_ctx: Pointer to hdd context |
| 5934 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5935 | * Register for IPv6 address change notifications. |
| 5936 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5937 | * Return: None |
| 5938 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5939 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5941 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5942 | } |
| 5943 | #endif |
| 5944 | |
| 5945 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5946 | * hdd_register_notifiers - Register netdev notifiers. |
| 5947 | * @hdd_ctx: HDD context |
| 5948 | * |
| 5949 | * Register netdev notifiers like IPv4 and IPv6. |
| 5950 | * |
| 5951 | * Return: 0 on success and errno on failure |
| 5952 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5953 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5954 | { |
| 5955 | int ret; |
| 5956 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5957 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 5958 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 5959 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5960 | |
| 5961 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 5962 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 5963 | if (ret) { |
| 5964 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 5965 | goto unregister_ip6_notifier; |
| 5966 | } |
| 5967 | |
| 5968 | return 0; |
| 5969 | |
| 5970 | unregister_ip6_notifier: |
| 5971 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5972 | out: |
| 5973 | return ret; |
| 5974 | |
| 5975 | } |
| 5976 | |
| 5977 | /** |
| 5978 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 5979 | * @hdd_ctx: HDD context |
| 5980 | * |
| 5981 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 5982 | * |
| 5983 | * Return: None. |
| 5984 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5985 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5986 | { |
| 5987 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 5988 | |
| 5989 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 5990 | } |
| 5991 | |
| 5992 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 5993 | * hdd_exit_netlink_services - Exit netlink services |
| 5994 | * @hdd_ctx: HDD context |
| 5995 | * |
| 5996 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 5997 | * nl service. |
| 5998 | * |
| 5999 | * Return: None. |
| 6000 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6001 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6002 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6003 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6004 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6005 | ptt_sock_deactivate_svc(); |
| 6006 | |
| 6007 | nl_srv_exit(); |
| 6008 | } |
| 6009 | |
| 6010 | /** |
| 6011 | * hdd_init_netlink_services- Init netlink services |
| 6012 | * @hdd_ctx: HDD context |
| 6013 | * |
| 6014 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6015 | * nl service. |
| 6016 | * |
| 6017 | * Return: 0 on success and errno on failure. |
| 6018 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6019 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6020 | { |
| 6021 | int ret; |
| 6022 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6023 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6024 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6025 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6026 | goto out; |
| 6027 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6028 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6029 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6030 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6031 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6032 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6033 | goto err_nl_srv; |
| 6034 | } |
| 6035 | |
| 6036 | ret = ptt_sock_activate_svc(); |
| 6037 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6038 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6039 | goto err_nl_srv; |
| 6040 | } |
| 6041 | |
| 6042 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6043 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6044 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6045 | |
| 6046 | ret = cnss_diag_activate_service(); |
| 6047 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6048 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6049 | goto err_close_cesium; |
| 6050 | } |
| 6051 | |
| 6052 | return 0; |
| 6053 | |
| 6054 | err_close_cesium: |
| 6055 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6056 | ptt_sock_deactivate_svc(); |
| 6057 | err_nl_srv: |
| 6058 | nl_srv_exit(); |
| 6059 | out: |
| 6060 | return ret; |
| 6061 | } |
| 6062 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6063 | /** |
| 6064 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6065 | * @hdd_ctx: HDD context. |
| 6066 | * |
| 6067 | * Destroy RX wakelock. |
| 6068 | * |
| 6069 | * Return: None. |
| 6070 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6071 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6072 | { |
| 6073 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6074 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6075 | |
| 6076 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6077 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6078 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6079 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6080 | * Create RX wakelock. |
| 6081 | * |
| 6082 | * Return: None. |
| 6083 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6084 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6085 | { |
| 6086 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6087 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6088 | |
| 6089 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6090 | * hdd_context_deinit() - Deinitialize HDD context |
| 6091 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6092 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6093 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6094 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6095 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6096 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6097 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6098 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6099 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6100 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6101 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6102 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6103 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6104 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6105 | hdd_sap_context_destroy(hdd_ctx); |
| 6106 | |
| 6107 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6108 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6109 | hdd_scan_context_destroy(hdd_ctx); |
| 6110 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6111 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6112 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6113 | return 0; |
| 6114 | } |
| 6115 | |
| 6116 | /** |
| 6117 | * hdd_context_destroy() - Destroy HDD context |
| 6118 | * @hdd_ctx: HDD context to be destroyed. |
| 6119 | * |
| 6120 | * Free config and HDD context as well as destroy all the resources. |
| 6121 | * |
| 6122 | * Return: None |
| 6123 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6124 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6125 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6126 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6127 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6128 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6129 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6130 | hdd_context_deinit(hdd_ctx); |
| 6131 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6132 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6133 | hdd_ctx->config = NULL; |
| 6134 | |
| 6135 | wiphy_free(hdd_ctx->wiphy); |
| 6136 | } |
| 6137 | |
| 6138 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6139 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6140 | * |
| 6141 | * This function is used to destroy bug report lock |
| 6142 | * |
| 6143 | * Return: None |
| 6144 | */ |
| 6145 | static void wlan_destroy_bug_report_lock(void) |
| 6146 | { |
| 6147 | p_cds_contextType p_cds_context; |
| 6148 | |
| 6149 | p_cds_context = cds_get_global_context(); |
| 6150 | if (!p_cds_context) { |
| 6151 | hdd_err("cds context is NULL"); |
| 6152 | return; |
| 6153 | } |
| 6154 | |
| 6155 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6156 | } |
| 6157 | |
| 6158 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6159 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6160 | * @hdd_ctx: Pointer to the HDD Context |
| 6161 | * |
| 6162 | * This is the driver exit point (invoked during rmmod) |
| 6163 | * |
| 6164 | * Return: None |
| 6165 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6166 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6167 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6169 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6170 | |
| 6171 | ENTER(); |
| 6172 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 6173 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6174 | |
| 6175 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6176 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6177 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6178 | |
| 6179 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6180 | if (QDF_TIMER_STATE_RUNNING == |
| 6181 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6182 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6183 | } |
| 6184 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6185 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6186 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6187 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6188 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6189 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6190 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6191 | hdd_ctx->last_acs_channel_list = NULL; |
| 6192 | hdd_ctx->num_of_channels = 0; |
| 6193 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6194 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6196 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6197 | driver_status = hdd_ctx->driver_status; |
| 6198 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6199 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6200 | /* |
| 6201 | * Powersave Offload Case |
| 6202 | * Disable Idle Power Save Mode |
| 6203 | */ |
| 6204 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6205 | /* clear the scan queue in all the scenarios */ |
| 6206 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6207 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6208 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6209 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6210 | /* |
| 6211 | * Cancel any outstanding scan requests. We are about to close |
| 6212 | * all of our adapters, but an adapter structure is what SME |
| 6213 | * passes back to our callback function. Hence if there |
| 6214 | * are any outstanding scan requests then there is a |
| 6215 | * race condition between when the adapter is closed and |
| 6216 | * when the callback is invoked. We try to resolve that |
| 6217 | * race condition here by canceling any outstanding scans |
| 6218 | * before we close the adapters. |
| 6219 | * Note that the scans may be cancelled in an asynchronous |
| 6220 | * manner, so ideally there needs to be some kind of |
| 6221 | * synchronization. Rather than introduce a new |
| 6222 | * synchronization here, we will utilize the fact that we are |
| 6223 | * about to Request Full Power, and since that is synchronized, |
| 6224 | * the expectation is that by the time Request Full Power has |
| 6225 | * completed, all scans will be cancelled |
| 6226 | */ |
| 6227 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6228 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 6229 | hdd_stop_all_adapters(hdd_ctx, true); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6230 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6231 | } |
| 6232 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6233 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6234 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6235 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6236 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6237 | memdump_deinit(); |
| 6238 | hdd_driver_memdump_deinit(); |
| 6239 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6240 | qdf_nbuf_deinit_replenish_timer(); |
| 6241 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6242 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6243 | hdd_info("Release wakelock for monitor mode!"); |
| 6244 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6245 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6246 | } |
| 6247 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6248 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6249 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6250 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6251 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | /* |
| 6253 | * Close CDS |
| 6254 | * This frees pMac(HAL) context. There should not be any call |
| 6255 | * that requires pMac access after this. |
| 6256 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6257 | |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 6258 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6259 | hdd_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6260 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 6261 | hdd_close_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6262 | |
| 6263 | hdd_ipa_cleanup(hdd_ctx); |
| 6264 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6265 | wlansap_global_deinit(); |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 6266 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6267 | /* |
| 6268 | * If there is re_init failure wiphy would have already de-registered |
| 6269 | * check the wiphy status before un-registering again |
| 6270 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6271 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6272 | wiphy_unregister(wiphy); |
| 6273 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6274 | hdd_lpass_notify_stop(hdd_ctx); |
| 6275 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6276 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6277 | hdd_exit_netlink_services(hdd_ctx); |
| 6278 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6279 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6280 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6281 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6282 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6283 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6284 | if (driver_status) |
| 6285 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6286 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6287 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | } |
| 6289 | |
| 6290 | void __hdd_wlan_exit(void) |
| 6291 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6292 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6293 | |
| 6294 | ENTER(); |
| 6295 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6296 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6297 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6298 | hdd_err("Invalid HDD Context"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6299 | EXIT(); |
| 6300 | return; |
| 6301 | } |
| 6302 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6303 | /* Do all the cleanup before deregistering the driver */ |
| 6304 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6305 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6306 | EXIT(); |
| 6307 | } |
| 6308 | |
| 6309 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6310 | /** |
| 6311 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6312 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6313 | * |
| 6314 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6315 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6316 | * scan information. |
| 6317 | * |
| 6318 | * Return: void |
| 6319 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6320 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6321 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6322 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6323 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6324 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6325 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6326 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6327 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6328 | hdd_ctx->last_acs_channel_list = NULL; |
| 6329 | hdd_ctx->num_of_channels = 0; |
| 6330 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | |
| 6332 | if (!hdd_ctx->hHal) |
| 6333 | return; |
| 6334 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6335 | } |
| 6336 | #endif |
| 6337 | |
| 6338 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6339 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6340 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | { |
| 6342 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6343 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6344 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | |
| 6346 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6347 | |
| 6348 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6349 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6350 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6352 | if (!hdd_ctx->hHal) |
| 6353 | return -EINVAL; |
| 6354 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6355 | 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] | 6356 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6357 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6358 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | return -EINVAL; |
| 6360 | } |
| 6361 | |
| 6362 | return 0; |
| 6363 | } |
| 6364 | #endif |
| 6365 | |
| 6366 | /** |
| 6367 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6368 | * @state: state |
| 6369 | * |
| 6370 | * This function notifies FW with modem power status |
| 6371 | * |
| 6372 | * Return: 0 if successful, error number otherwise |
| 6373 | */ |
| 6374 | int hdd_wlan_notify_modem_power_state(int state) |
| 6375 | { |
| 6376 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6377 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6378 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6379 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6380 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6381 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6382 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6383 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6384 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6385 | if (!hdd_ctx->hHal) |
| 6386 | return -EINVAL; |
| 6387 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6388 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6389 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6390 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6391 | state); |
| 6392 | return -EINVAL; |
| 6393 | } |
| 6394 | return 0; |
| 6395 | } |
| 6396 | |
| 6397 | /** |
| 6398 | * |
| 6399 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6400 | * @adapter - Pointer to the HDD |
| 6401 | * |
| 6402 | * Return: None |
| 6403 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6404 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6405 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6406 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6407 | |
| 6408 | /* |
| 6409 | * Send ready indication to the HDD. This will kick off the MAC |
| 6410 | * into a 'running' state and should kick off an initial scan. |
| 6411 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6412 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6413 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6414 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6415 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6416 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6417 | } |
| 6418 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6419 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6420 | } |
| 6421 | |
| 6422 | /* wake lock APIs for HDD */ |
| 6423 | void hdd_prevent_suspend(uint32_t reason) |
| 6424 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6425 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | } |
| 6427 | |
| 6428 | void hdd_allow_suspend(uint32_t reason) |
| 6429 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6430 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6431 | } |
| 6432 | |
| 6433 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6434 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6435 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6436 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6437 | } |
| 6438 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6439 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6440 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6441 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6442 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6443 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6444 | hdd_ctx->reg.alpha2, |
| 6445 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6446 | } |
| 6447 | |
| 6448 | /** |
| 6449 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6450 | * @hdd_ctx: Pointer to the hdd context |
| 6451 | * |
| 6452 | * HDD function to know if hardware supports 5GHz |
| 6453 | * |
| 6454 | * Return: true if hardware supports 5GHz |
| 6455 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6456 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6457 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6458 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6459 | return true; |
| 6460 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6461 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6462 | return true; |
| 6463 | else |
| 6464 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6465 | } |
| 6466 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6467 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6468 | { |
| 6469 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6470 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6471 | |
| 6472 | wiphy = hdd_ctx->wiphy; |
| 6473 | |
| 6474 | /* |
| 6475 | * The channel information in |
| 6476 | * wiphy needs to be initialized before wiphy registration |
| 6477 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6478 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6479 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6480 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6481 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | } |
| 6483 | |
| 6484 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6485 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6486 | #else |
| 6487 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6488 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6489 | WIPHY_WOWLAN_DISCONNECT | |
| 6490 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6491 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6492 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6493 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6494 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6495 | |
| 6496 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6497 | WOW_MAX_FILTERS_PER_LIST); |
| 6498 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6499 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6500 | #endif |
| 6501 | |
| 6502 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6503 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6504 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6505 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6506 | return ret_val; |
| 6507 | } |
| 6508 | |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6509 | if (!hdd_ctx->reg_offload) |
| 6510 | hdd_program_country_code(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6511 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6512 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6513 | } |
| 6514 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6515 | #ifdef MSM_PLATFORM |
| 6516 | /** |
| 6517 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6518 | * @hdd_ctx - handle to hdd context |
| 6519 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6520 | * |
| 6521 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 6522 | * Stats show up in wlan driver logs. |
| 6523 | * |
| 6524 | * Returns: None |
| 6525 | */ |
| 6526 | static inline |
| 6527 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 6528 | bool data_in_interval) |
| 6529 | { |
| 6530 | static u32 counter; |
| 6531 | static bool data_in_time_period; |
| 6532 | ol_txrx_pdev_handle pdev; |
| 6533 | |
| 6534 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 6535 | return; |
| 6536 | |
| 6537 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 6538 | if (!pdev) { |
| 6539 | hdd_err("pdev is NULL"); |
| 6540 | return; |
| 6541 | } |
| 6542 | |
| 6543 | counter++; |
| 6544 | if (data_in_interval) |
| 6545 | data_in_time_period = data_in_interval; |
| 6546 | |
| 6547 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 6548 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 6549 | if (data_in_time_period) { |
| 6550 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 6551 | CDP_TXRX_PATH_STATS, |
| 6552 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6553 | wlan_hdd_display_netif_queue_history |
| 6554 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 6555 | qdf_dp_trace_dump_stats(); |
| 6556 | } |
| 6557 | counter = 0; |
| 6558 | data_in_time_period = false; |
| 6559 | } |
| 6560 | } |
| 6561 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6562 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6563 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6564 | * @hdd_ctx - handle to hdd context |
| 6565 | * @tx_packets - transmit packet count |
| 6566 | * @rx_packets - receive packet count |
| 6567 | * |
| 6568 | * The function controls the bus bandwidth and dynamic control of |
| 6569 | * tcp delayed ack configuration |
| 6570 | * |
| 6571 | * Returns: None |
| 6572 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6573 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6574 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 6575 | const uint64_t tx_packets, |
| 6576 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6577 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6578 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6579 | uint64_t temp_rx = 0; |
| 6580 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6581 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6582 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6583 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6584 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6585 | uint16_t index = 0; |
| 6586 | bool vote_level_change = false; |
| 6587 | bool rx_level_change = false; |
| 6588 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6589 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6590 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6591 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6592 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6593 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6594 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6595 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 6596 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6597 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6598 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6599 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6600 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 6601 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6603 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6604 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6605 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6606 | if (hdd_ctx->hbw_requested) { |
| 6607 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 6608 | hdd_ctx->hbw_requested = false; |
| 6609 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6610 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6611 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6612 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 6613 | if (!hdd_ctx->hbw_requested) { |
| 6614 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 6615 | hdd_ctx->hbw_requested = true; |
| 6616 | } |
| 6617 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 6618 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6619 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6620 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 6621 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6622 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6623 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 6624 | qdf_dp_trace_throttle_live_mode( |
| 6625 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 6626 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6627 | /* fine-tuning parameters for RX Flows */ |
| 6628 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 6629 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6630 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 6631 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 6632 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 6633 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 6634 | else |
| 6635 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 6636 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 6637 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 6638 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 6639 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 6640 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 6641 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6642 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6643 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 6644 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 6645 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6647 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6648 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 6649 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6650 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6651 | next_rx_level, temp_rx); |
| 6652 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6653 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 6654 | /* Send throughput indication only if it is enabled. |
| 6655 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 6656 | * to default delayed ack. Note that this will disable the |
| 6657 | * dynamic delayed ack mechanism across the system |
| 6658 | */ |
| 6659 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6660 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 6661 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 6662 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 6663 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 6664 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 6665 | rx_tp_data.level = next_rx_level; |
| 6666 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6667 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 6668 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | } |
| 6670 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6671 | /* fine-tuning parameters for TX Flows */ |
| 6672 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 6673 | hdd_ctx->prev_tx = tx_packets; |
| 6674 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 6675 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 6676 | else |
| 6677 | next_tx_level = WLAN_SVC_TP_LOW; |
| 6678 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6679 | if (hdd_ctx->cur_tx_level != next_tx_level) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6680 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 6681 | next_tx_level, temp_tx); |
| 6682 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6683 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 6684 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 6685 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 6686 | &next_tx_level, |
| 6687 | sizeof(next_tx_level)); |
| 6688 | } |
| 6689 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6690 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6691 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 6692 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 6693 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 6694 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 6695 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 6696 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 6697 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 6698 | hdd_ctx->hdd_txrx_hist_idx++; |
| 6699 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 6700 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6701 | |
| 6702 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6703 | } |
| 6704 | |
| 6705 | #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] | 6706 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6707 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6708 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6709 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6710 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6711 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 6712 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 6713 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6714 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6715 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6716 | bool connected = false; |
| 6717 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 6718 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6719 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6720 | return; |
| 6721 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 6722 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6723 | goto restart_timer; |
| 6724 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6725 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 6726 | /* |
| 6727 | * Validate magic so we don't end up accessing |
| 6728 | * an invalid adapter. |
| 6729 | */ |
| 6730 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 6731 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6732 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6733 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6734 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6735 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 6736 | != eConnectionState_Associated) { |
| 6737 | |
| 6738 | continue; |
| 6739 | } |
| 6740 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6741 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 6742 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 6743 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6744 | |
| 6745 | continue; |
| 6746 | } |
| 6747 | |
| 6748 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 6749 | adapter->prev_tx_packets); |
| 6750 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 6751 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6752 | |
| 6753 | if (adapter->device_mode == QDF_SAP_MODE || |
| 6754 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 6755 | adapter->device_mode == QDF_IBSS_MODE) { |
| 6756 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 6757 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 6758 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6759 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6760 | &fwd_tx_packets, &fwd_rx_packets); |
| 6761 | if (ret == A_OK) { |
| 6762 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 6763 | fwd_tx_packets, |
| 6764 | adapter->prev_fwd_tx_packets); |
| 6765 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 6766 | fwd_tx_packets, |
| 6767 | adapter->prev_fwd_rx_packets); |
| 6768 | } |
| 6769 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6770 | |
| 6771 | total_rx += adapter->stats.rx_packets; |
| 6772 | total_tx += adapter->stats.tx_packets; |
| 6773 | |
| 6774 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 6775 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 6776 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6777 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 6778 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6779 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 6780 | connected = true; |
| 6781 | } |
| 6782 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 6783 | /* add intra bss forwarded tx and rx packets */ |
| 6784 | tx_packets += fwd_tx_packets_diff; |
| 6785 | rx_packets += fwd_rx_packets_diff; |
| 6786 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6787 | hdd_ipa_uc_stat_query(hdd_ctx, &ipa_tx_packets, &ipa_rx_packets); |
| 6788 | tx_packets += (uint64_t)ipa_tx_packets; |
| 6789 | rx_packets += (uint64_t)ipa_rx_packets; |
| 6790 | |
Yun Park | 2aa880c | 2017-08-22 10:58:10 -0700 | [diff] [blame] | 6791 | if (adapter) { |
| 6792 | adapter->stats.tx_packets += ipa_tx_packets; |
| 6793 | adapter->stats.rx_packets += ipa_rx_packets; |
| 6794 | } |
| 6795 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6796 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6797 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6798 | return; |
| 6799 | } |
| 6800 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 6801 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6802 | |
| 6803 | hdd_ipa_set_perf_level(hdd_ctx, tx_packets, rx_packets); |
| 6804 | hdd_ipa_uc_stat_request(adapter, 2); |
| 6805 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 6806 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6807 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6808 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 6809 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 6810 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6811 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6812 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6813 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6814 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6815 | /** |
| 6816 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 6817 | * @arg: Argument of timer function |
| 6818 | * |
| 6819 | * Schedule a workqueue in this function where all the processing is done. |
| 6820 | * |
| 6821 | * Return: None. |
| 6822 | */ |
| 6823 | static void __hdd_bus_bw_cbk(void *arg) |
| 6824 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6825 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6826 | |
| 6827 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 6828 | return; |
| 6829 | |
| 6830 | schedule_work(&hdd_ctx->bus_bw_work); |
| 6831 | } |
| 6832 | |
| 6833 | /** |
| 6834 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 6835 | * @arg: Argument of timer function |
| 6836 | * |
| 6837 | * Return: None. |
| 6838 | */ |
| 6839 | static void hdd_bus_bw_cbk(void *arg) |
| 6840 | { |
| 6841 | cds_ssr_protect(__func__); |
| 6842 | __hdd_bus_bw_cbk(arg); |
| 6843 | cds_ssr_unprotect(__func__); |
| 6844 | } |
| 6845 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6846 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6847 | { |
| 6848 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6849 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 6850 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6851 | hdd_ctx->bus_bw_timer_running = false; |
| 6852 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6853 | qdf_timer_init(NULL, |
| 6854 | &hdd_ctx->bus_bw_timer, |
| 6855 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 6856 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6857 | |
| 6858 | return 0; |
| 6859 | } |
| 6860 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6861 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6862 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6863 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6864 | hdd_reset_tcp_delack(hdd_ctx); |
| 6865 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6866 | hdd_debug("wait for bus bw work to flush"); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 6867 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6868 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 6869 | hdd_ctx->bus_bw_timer_running = false; |
| 6870 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6871 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 6872 | |
| 6873 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 6874 | { |
| 6875 | if (hdd_ctx) |
| 6876 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 6877 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 6878 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6879 | #endif |
| 6880 | |
| 6881 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6882 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 6883 | * @hdd_ctx: hdd context |
| 6884 | * |
| 6885 | * Return: 0 for success or error code |
| 6886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6887 | 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] | 6888 | { |
| 6889 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 6890 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 6891 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6892 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6893 | return -ENOMEM; |
| 6894 | } |
| 6895 | return 0; |
| 6896 | } |
| 6897 | |
| 6898 | /** |
| 6899 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 6900 | * @hdd_ctx: hdd context |
| 6901 | * |
| 6902 | * Return: none |
| 6903 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6904 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6905 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6906 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 6907 | return; |
| 6908 | |
| 6909 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 6910 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6911 | } |
| 6912 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6913 | static uint8_t *convert_level_to_string(uint32_t level) |
| 6914 | { |
| 6915 | switch (level) { |
| 6916 | /* initialize the wlan sub system */ |
| 6917 | case WLAN_SVC_TP_NONE: |
| 6918 | return "NONE"; |
| 6919 | case WLAN_SVC_TP_LOW: |
| 6920 | return "LOW"; |
| 6921 | case WLAN_SVC_TP_MEDIUM: |
| 6922 | return "MED"; |
| 6923 | case WLAN_SVC_TP_HIGH: |
| 6924 | return "HIGH"; |
| 6925 | default: |
| 6926 | return "INVAL"; |
| 6927 | } |
| 6928 | } |
| 6929 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6930 | |
| 6931 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6932 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 6933 | * @hdd_ctx: hdd context |
| 6934 | * |
| 6935 | * Return: none |
| 6936 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6937 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6938 | { |
| 6939 | int i; |
| 6940 | |
| 6941 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6942 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6943 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6944 | 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] | 6945 | hdd_ctx->config->busBandwidthHighThreshold, |
| 6946 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 6947 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6948 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6949 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6950 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 6952 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6953 | 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] | 6954 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6955 | #endif |
| 6956 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6957 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 6958 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 6959 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6960 | 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] | 6961 | |
| 6962 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6963 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6964 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 6965 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 6966 | "[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 6967 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6968 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 6969 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 6970 | convert_level_to_string( |
| 6971 | hdd_ctx->hdd_txrx_hist[i]. |
| 6972 | next_vote_level), |
| 6973 | convert_level_to_string( |
| 6974 | hdd_ctx->hdd_txrx_hist[i]. |
| 6975 | next_rx_level), |
| 6976 | convert_level_to_string( |
| 6977 | hdd_ctx->hdd_txrx_hist[i]. |
| 6978 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6979 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | } |
| 6981 | |
| 6982 | /** |
| 6983 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 6984 | * @hdd_ctx: hdd context |
| 6985 | * |
| 6986 | * Return: none |
| 6987 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6988 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6989 | { |
| 6990 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 6991 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 6992 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | } |
| 6994 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6995 | /* length of the netif queue log needed per adapter */ |
| 6996 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 6997 | |
| 6998 | /** |
| 6999 | * |
| 7000 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7001 | * @hdd_ctx: hdd context |
| 7002 | * |
| 7003 | * Return: none |
| 7004 | */ |
| 7005 | static void |
| 7006 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7007 | { |
| 7008 | int adapter_num = 0; |
| 7009 | int i; |
| 7010 | int bytes_written; |
| 7011 | u32 tbytes; |
| 7012 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7013 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
| 7014 | char comb_log_str[(ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1]; |
| 7015 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7016 | |
| 7017 | bytes_written = 0; |
| 7018 | qdf_mem_set(comb_log_str, 0, sizeof(comb_log_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7019 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7020 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7021 | curr_time = qdf_system_ticks(); |
| 7022 | total = curr_time - adapter->start_time; |
| 7023 | delta = curr_time - adapter->last_time; |
| 7024 | |
| 7025 | if (adapter->pause_map) { |
| 7026 | pause = adapter->total_pause_time + delta; |
| 7027 | unpause = adapter->total_unpause_time; |
| 7028 | } else { |
| 7029 | unpause = adapter->total_unpause_time + delta; |
| 7030 | pause = adapter->total_pause_time; |
| 7031 | } |
| 7032 | |
| 7033 | tbytes = 0; |
| 7034 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7035 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7036 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7037 | continue; |
| 7038 | tbytes += |
| 7039 | snprintf( |
| 7040 | &temp_str[tbytes], |
| 7041 | (tbytes >= sizeof(temp_str) ? |
| 7042 | 0 : sizeof(temp_str) - tbytes), |
| 7043 | "%d(%d,%d) ", |
| 7044 | i, |
| 7045 | adapter->queue_oper_stats[i]. |
| 7046 | pause_count, |
| 7047 | adapter->queue_oper_stats[i]. |
| 7048 | unpause_count); |
| 7049 | } |
| 7050 | if (tbytes >= sizeof(temp_str)) |
| 7051 | hdd_warn("log truncated"); |
| 7052 | |
| 7053 | bytes_written += snprintf(&comb_log_str[bytes_written], |
| 7054 | bytes_written >= sizeof(comb_log_str) ? 0 : |
| 7055 | sizeof(comb_log_str) - bytes_written, |
| 7056 | "[%d %d] (%d) %u/%ums %s|", |
| 7057 | adapter->session_id, adapter->device_mode, |
| 7058 | adapter->pause_map, |
| 7059 | qdf_system_ticks_to_msecs(pause), |
| 7060 | qdf_system_ticks_to_msecs(total), |
| 7061 | temp_str); |
| 7062 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7063 | adapter_num++; |
| 7064 | } |
| 7065 | |
| 7066 | /* using QDF_TRACE to avoid printing function name */ |
| 7067 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7068 | "STATS |%s", comb_log_str); |
| 7069 | |
| 7070 | if (bytes_written >= sizeof(comb_log_str)) |
| 7071 | hdd_warn("log string truncated"); |
| 7072 | } |
| 7073 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7074 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7075 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7076 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7077 | * |
| 7078 | * Return: none |
| 7079 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7080 | void |
| 7081 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7082 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7083 | { |
| 7084 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7085 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7086 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7087 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7088 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7089 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7090 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7091 | return; |
| 7092 | } |
| 7093 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7094 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7095 | hdd_debug("Netif queue operation statistics:"); |
| 7096 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7097 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7098 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7099 | curr_time = qdf_system_ticks(); |
| 7100 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7101 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7102 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7103 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7104 | unpause = adapter->total_unpause_time; |
| 7105 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7106 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7107 | pause = adapter->total_pause_time; |
| 7108 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7109 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7110 | qdf_system_ticks_to_msecs(total), |
| 7111 | qdf_system_ticks_to_msecs(pause), |
| 7112 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7113 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7114 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7115 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7116 | qdf_time_t pause_delta = 0; |
| 7117 | |
| 7118 | if (adapter->pause_map & (1 << i)) |
| 7119 | pause_delta = delta; |
| 7120 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7121 | /* using hdd_log to avoid printing function name */ |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7122 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7123 | "%s: %d: %d: %ums", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | hdd_reason_type_to_string(i), |
| 7125 | adapter->queue_oper_stats[i].pause_count, |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7126 | adapter->queue_oper_stats[i].unpause_count, |
| 7127 | qdf_system_ticks_to_msecs( |
| 7128 | adapter->queue_oper_stats[i].total_pause_time + |
| 7129 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7130 | } |
| 7131 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7132 | hdd_debug("Netif queue operation history:"); |
| 7133 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7134 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7135 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7136 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7137 | |
| 7138 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7139 | /* using hdd_log to avoid printing function name */ |
| 7140 | if (adapter->queue_oper_history[i].time == 0) |
| 7141 | continue; |
Houston Hoffman | 0022711 | 2017-08-14 23:58:18 -0700 | [diff] [blame] | 7142 | hdd_log(QDF_TRACE_LEVEL_DEBUG, |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7143 | "%d: %u: %s: %s: %x", |
Anurag Chouhan | 50220ce | 2016-02-18 20:11:33 +0530 | [diff] [blame] | 7144 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7145 | adapter->queue_oper_history[i].time), |
| 7146 | hdd_action_type_to_string( |
| 7147 | adapter->queue_oper_history[i].netif_action), |
| 7148 | hdd_reason_type_to_string( |
| 7149 | adapter->queue_oper_history[i].netif_reason), |
| 7150 | adapter->queue_oper_history[i].pause_map); |
| 7151 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7153 | } |
| 7154 | |
| 7155 | /** |
| 7156 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7157 | * @hdd_ctx: hdd context |
| 7158 | * |
| 7159 | * Return: none |
| 7160 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7161 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7162 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7163 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7164 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7165 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7166 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7168 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7169 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7170 | adapter->history_index = 0; |
| 7171 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7172 | adapter->total_pause_time = 0; |
| 7173 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7174 | } |
| 7175 | } |
| 7176 | |
| 7177 | /** |
| 7178 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7179 | * @halHandle: Hal handle |
| 7180 | * @pContext: Pointer to the context |
| 7181 | * @sessionId: Session ID |
| 7182 | * @scanId: Scan ID |
| 7183 | * @status: Status |
| 7184 | * |
| 7185 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7186 | * the scan results |
| 7187 | * |
| 7188 | * 11d scan is done during driver load and is a passive scan on all |
| 7189 | * channels supported by the device, 11d scans may find some APs on |
| 7190 | * frequencies which are forbidden to be used in the regulatory domain |
| 7191 | * the device is operating in. If these APs are notified to the supplicant |
| 7192 | * it may try to connect to these APs, thus flush out all the scan results |
| 7193 | * which are present in SME after 11d scan is done. |
| 7194 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7195 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7196 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7197 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7198 | uint8_t sessionId, uint32_t scanId, |
| 7199 | eCsrScanStatus status) |
| 7200 | { |
| 7201 | ENTER(); |
| 7202 | |
| 7203 | sme_scan_flush_result(halHandle); |
| 7204 | |
| 7205 | EXIT(); |
| 7206 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7207 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7208 | } |
| 7209 | |
| 7210 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7211 | /** |
| 7212 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7213 | * @hdd_ctx: hdd global context |
| 7214 | * |
| 7215 | * Return: none |
| 7216 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7217 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7218 | { |
| 7219 | uint8_t i; |
| 7220 | |
| 7221 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7222 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7223 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7224 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7225 | } |
| 7226 | } |
| 7227 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7228 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7229 | { |
| 7230 | } |
| 7231 | #endif |
| 7232 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7233 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7234 | /** |
| 7235 | * 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] | 7236 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7237 | * @enable: enable or disable this behaviour |
| 7238 | * |
| 7239 | * Return: int |
| 7240 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7241 | 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] | 7242 | { |
| 7243 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7244 | struct wow_pulse_mode wow_pulse_set_info; |
| 7245 | QDF_STATUS status; |
| 7246 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7247 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7248 | |
| 7249 | if (false == phddctx->config->wow_pulse_support) |
| 7250 | return 0; |
| 7251 | |
| 7252 | /* prepare the request to send to SME */ |
| 7253 | if (enable == true) { |
| 7254 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7255 | wow_pulse_set_info.wow_pulse_pin = |
| 7256 | pcfg_ini->wow_pulse_pin; |
| 7257 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7258 | pcfg_ini->wow_pulse_interval_low; |
| 7259 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7260 | pcfg_ini->wow_pulse_interval_high; |
| 7261 | } else { |
| 7262 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7263 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7264 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7265 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7266 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7267 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7268 | wow_pulse_set_info.wow_pulse_enable, |
| 7269 | wow_pulse_set_info.wow_pulse_pin, |
| 7270 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7271 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7272 | |
| 7273 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7274 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7275 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7276 | return -EIO; |
| 7277 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7278 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7279 | return 0; |
| 7280 | } |
| 7281 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7282 | 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] | 7283 | { |
| 7284 | return 0; |
| 7285 | } |
| 7286 | #endif |
| 7287 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7288 | #ifdef WLAN_FEATURE_FASTPATH |
| 7289 | /** |
| 7290 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7291 | * @hdd_cfg: hdd config |
| 7292 | * @context: lower layer context |
| 7293 | * |
| 7294 | * Return: none |
| 7295 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7296 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7297 | void *context) |
| 7298 | { |
| 7299 | if (hdd_cfg->fastpath_enable) |
| 7300 | hif_enable_fastpath(context); |
| 7301 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7302 | #endif |
| 7303 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7304 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7305 | /** |
| 7306 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7307 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7308 | * @level: thermal level |
| 7309 | * |
| 7310 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7311 | * than 0, and restore the original data path when throttle level is 0 |
| 7312 | * |
| 7313 | * Return: none |
| 7314 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7315 | 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] | 7316 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7317 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7318 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7319 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7320 | if (level > THROTTLE_LEVEL_0) |
| 7321 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, true); |
| 7322 | else |
| 7323 | /* restore original concurrency mode */ |
| 7324 | hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode); |
| 7325 | } |
| 7326 | |
| 7327 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7328 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7329 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7330 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7331 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7332 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7333 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7334 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7335 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7336 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7337 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7338 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7339 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7340 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7341 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7342 | struct sir_pcl_list pcl; |
| 7343 | QDF_STATUS status; |
| 7344 | uint32_t i, j; |
| 7345 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7346 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7347 | bool found = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7348 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7349 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7350 | if (!hdd_ctx) { |
| 7351 | hdd_err("invalid HDD context"); |
| 7352 | return INVALID_CHANNEL_ID; |
| 7353 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7354 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7355 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7356 | if (!hal_handle) { |
| 7357 | hdd_err("invalid HAL handle"); |
| 7358 | return INVALID_CHANNEL_ID; |
| 7359 | } |
| 7360 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7361 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7362 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7363 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7364 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7365 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7366 | hdd_err("Get PCL failed"); |
| 7367 | return INVALID_CHANNEL_ID; |
| 7368 | } |
| 7369 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7370 | /* |
| 7371 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7372 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7373 | * try to choose a safe channel from acs range. |
| 7374 | */ |
| 7375 | if (!pcl.pcl_len) |
| 7376 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7377 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7378 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7379 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7380 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7381 | |
| 7382 | /* PCL already takes unsafe channel into account */ |
| 7383 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7384 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7385 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7386 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7387 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7388 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7389 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7390 | return pcl.pcl_list[i]; |
| 7391 | } |
| 7392 | } |
| 7393 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7394 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7395 | |
| 7396 | /* Try for safe channel from all valid channel */ |
| 7397 | pcl.pcl_len = MAX_NUM_CHAN; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7398 | status = sme_get_cfg_valid_channels(pcl.pcl_list, |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7399 | &pcl.pcl_len); |
| 7400 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7401 | hdd_err("error in getting valid channel list"); |
| 7402 | return INVALID_CHANNEL_ID; |
| 7403 | } |
| 7404 | |
| 7405 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7406 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7407 | found = false; |
| 7408 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7409 | if (pcl.pcl_list[i] == |
| 7410 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7411 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7412 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7413 | break; |
| 7414 | } |
| 7415 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7416 | |
| 7417 | if (found) |
| 7418 | continue; |
| 7419 | |
| 7420 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7421 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7422 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7423 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7424 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7425 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7426 | } |
| 7427 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7428 | |
| 7429 | return INVALID_CHANNEL_ID; |
| 7430 | } |
| 7431 | |
| 7432 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7433 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7434 | * @adapter: AP adapter |
| 7435 | * @channel: Channel |
| 7436 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7437 | * Moves the SAP interface by invoking the function which |
| 7438 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7439 | * |
| 7440 | * Return: None |
| 7441 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7442 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7443 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7444 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7445 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7446 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7447 | |
| 7448 | if (!adapter) { |
| 7449 | hdd_err("invalid adapter"); |
| 7450 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7451 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7452 | |
| 7453 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7454 | |
| 7455 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7456 | if (!hal_handle) { |
| 7457 | hdd_err("invalid HAL handle"); |
| 7458 | return; |
| 7459 | } |
| 7460 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7461 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7462 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7463 | hdd_ap_ctx->sap_config.channel = channel; |
| 7464 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7465 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7466 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7467 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7468 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7469 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7470 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7471 | hdd_ap_ctx->sap_config.channel, |
| 7472 | hdd_ap_ctx->sap_config.sec_ch, |
| 7473 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7474 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7475 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7476 | adapter->session_id, channel, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7477 | hdd_ap_ctx->sap_config.ch_width_orig); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7478 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7479 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7480 | 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] | 7481 | { |
| 7482 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7483 | int status; |
| 7484 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7485 | |
| 7486 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7487 | |
| 7488 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7489 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7490 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7491 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7492 | } |
| 7493 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7494 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7495 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7496 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7497 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7498 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7499 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7500 | hdd_err("failed to start external acs timer"); |
| 7501 | return -ENOSPC; |
| 7502 | } |
| 7503 | /* Update config to application */ |
| 7504 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7505 | hdd_notice("Updated ACS config to nl with reason %d", reason); |
| 7506 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7507 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7508 | } |
| 7509 | |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7510 | /** |
| 7511 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7512 | * @hdd_ctx: hdd context pointer |
| 7513 | * |
| 7514 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 7515 | * and if ACS is enabled, driver will ask userspace to restart the |
| 7516 | * sap. User space on LTE coex indication restart driver. |
| 7517 | * |
| 7518 | * Return - none |
| 7519 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7520 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7521 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7522 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7523 | uint32_t i; |
| 7524 | bool found = false; |
| 7525 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7526 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7527 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 7528 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 7529 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7530 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7531 | adapter->device_mode, |
| 7532 | adapter->session.ap.sap_config. |
| 7533 | acs_cfg.acs_mode); |
| 7534 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7535 | } |
| 7536 | |
| 7537 | found = false; |
| 7538 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7539 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7540 | hdd_ctxt->unsafe_channel_list[i]) { |
| 7541 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7542 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7543 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7544 | break; |
| 7545 | } |
| 7546 | } |
| 7547 | |
| 7548 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7549 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7550 | adapter->session.ap.operating_channel); |
| 7551 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7552 | } |
| 7553 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7554 | if (hdd_ctxt->config->vendor_acs_support && |
| 7555 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7556 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7557 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7558 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7559 | } else |
| 7560 | restart_chan = |
| 7561 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7562 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7563 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7564 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7565 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7566 | /* |
| 7567 | * SAP restart due to unsafe channel. While |
| 7568 | * restarting the SAP, make sure to clear |
| 7569 | * acs_channel, channel to reset to |
| 7570 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7571 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 7572 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7573 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7574 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 7575 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7576 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7577 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 7578 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7579 | hdd_debug("driver to start sap: %d", |
| 7580 | hdd_ctxt->config->sap_internal_restart); |
| 7581 | if (hdd_ctxt->config->sap_internal_restart) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7582 | hdd_switch_sap_channel(adapter, restart_chan); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 7583 | else |
| 7584 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7585 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7586 | } |
| 7587 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7588 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7589 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7590 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 7591 | * @hdd_ctx: HDD global context |
| 7592 | * |
| 7593 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7594 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7595 | * down to the lower layers. Then subscribe to subsequent channel |
| 7596 | * avoidance events. |
| 7597 | * |
| 7598 | * Return: None |
| 7599 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7600 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7601 | { |
| 7602 | uint16_t unsafe_channel_count; |
| 7603 | int index; |
| 7604 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7605 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 7606 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7608 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7609 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7610 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7611 | hdd_ctx->unsafe_channel_count); |
| 7612 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7613 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 7614 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7615 | |
| 7616 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7617 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7618 | hdd_ctx->unsafe_channel_list[index]); |
| 7619 | |
| 7620 | } |
| 7621 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7622 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7623 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7624 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7625 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7626 | { |
| 7627 | uint8_t restart_chan; |
| 7628 | |
| 7629 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 7630 | if (!restart_chan) { |
| 7631 | hdd_alert("fail to restart SAP"); |
| 7632 | return; |
| 7633 | } |
| 7634 | |
| 7635 | /* SAP restart due to unsafe channel. While restarting |
| 7636 | * the SAP, make sure to clear acs_channel, channel to |
| 7637 | * reset to 0. Otherwise these settings will override |
| 7638 | * the ACS while restart. |
| 7639 | */ |
| 7640 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7641 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7642 | |
| 7643 | hdd_debug("sending coex indication"); |
| 7644 | |
| 7645 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7646 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
| 7647 | hdd_switch_sap_channel(adapter, restart_chan); |
| 7648 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 7649 | |
| 7650 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 7651 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 7652 | { |
| 7653 | uint32_t size; |
| 7654 | uint16_t *unsafe_list; |
| 7655 | uint16_t chan_count; |
| 7656 | |
| 7657 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 7658 | return -EINVAL; |
| 7659 | |
| 7660 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 7661 | NUM_CHANNELS); |
| 7662 | if (chan_count) { |
| 7663 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 7664 | unsafe_list = qdf_mem_malloc(size); |
| 7665 | if (!unsafe_list) { |
| 7666 | hdd_err("No memory for unsafe chan list size%d", |
| 7667 | size); |
| 7668 | return -ENOMEM; |
| 7669 | } |
| 7670 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 7671 | } else { |
| 7672 | unsafe_list = NULL; |
| 7673 | } |
| 7674 | |
| 7675 | *local_unsafe_list = unsafe_list; |
| 7676 | *local_unsafe_list_count = chan_count; |
| 7677 | |
| 7678 | return 0; |
| 7679 | } |
| 7680 | |
| 7681 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 7682 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 7683 | { |
| 7684 | int i, j; |
| 7685 | |
| 7686 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 7687 | return true; |
| 7688 | if (local_unsafe_list_count == 0) |
| 7689 | return false; |
| 7690 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 7691 | for (j = 0; j < local_unsafe_list_count; j++) |
| 7692 | if (local_unsafe_list[i] == |
| 7693 | hdd_ctx->unsafe_channel_list[j]) |
| 7694 | break; |
| 7695 | if (j >= local_unsafe_list_count) |
| 7696 | break; |
| 7697 | } |
| 7698 | if (i >= local_unsafe_list_count) { |
| 7699 | hdd_info("unsafe chan list same"); |
| 7700 | return false; |
| 7701 | } |
| 7702 | |
| 7703 | return true; |
| 7704 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7705 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7706 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7707 | { |
| 7708 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7709 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7710 | 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] | 7711 | { |
| 7712 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7713 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7714 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7715 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 7716 | { |
| 7717 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 7718 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7719 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7720 | |
| 7721 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7722 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 7723 | * user space |
| 7724 | * @frame_ind: Management frame data to be informed. |
| 7725 | * |
| 7726 | * This function is used to indicate management frame to |
| 7727 | * user space |
| 7728 | * |
| 7729 | * Return: None |
| 7730 | * |
| 7731 | */ |
| 7732 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 7733 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7734 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7735 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7736 | int i; |
| 7737 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7738 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7739 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7740 | |
| 7741 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 7742 | return; |
| 7743 | |
| 7744 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 7745 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 7746 | adapter = |
| 7747 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 7748 | if (adapter) |
| 7749 | break; |
| 7750 | } |
| 7751 | } else { |
| 7752 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 7753 | frame_ind->sessionId); |
| 7754 | } |
| 7755 | |
| 7756 | if ((NULL != adapter) && |
| 7757 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 7758 | __hdd_indicate_mgmt_frame(adapter, |
| 7759 | frame_ind->frame_len, |
| 7760 | frame_ind->frameBuf, |
| 7761 | frame_ind->frameType, |
| 7762 | frame_ind->rxChan, |
| 7763 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7764 | } |
| 7765 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7766 | void hdd_acs_response_timeout_handler(void *context) |
| 7767 | { |
| 7768 | struct hdd_external_acs_timer_context *timer_context = |
| 7769 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7770 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7771 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7772 | uint8_t reason; |
| 7773 | |
| 7774 | ENTER(); |
| 7775 | if (!timer_context) { |
| 7776 | hdd_err("invlaid timer context"); |
| 7777 | return; |
| 7778 | } |
| 7779 | adapter = timer_context->adapter; |
| 7780 | reason = timer_context->reason; |
| 7781 | |
| 7782 | |
| 7783 | if ((!adapter) || |
| 7784 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 7785 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 7786 | return; |
| 7787 | } |
| 7788 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7789 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7790 | return; |
| 7791 | |
| 7792 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 7793 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7794 | else |
| 7795 | return; |
| 7796 | |
| 7797 | hdd_err("ACS timeout happened for %s reason %d", |
| 7798 | adapter->dev->name, reason); |
| 7799 | switch (reason) { |
| 7800 | /* SAP init case */ |
| 7801 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 7802 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 7803 | false); |
| 7804 | wlan_hdd_cfg80211_start_acs(adapter); |
| 7805 | break; |
| 7806 | /* DFS detected on current channel */ |
| 7807 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 7808 | wlan_sap_update_next_channel( |
| 7809 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 7810 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7811 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7812 | break; |
| 7813 | /* LTE coex event on current channel */ |
| 7814 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 7815 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 7816 | break; |
| 7817 | default: |
| 7818 | hdd_info("invalid reason for timer invoke"); |
| 7819 | |
| 7820 | } |
| 7821 | } |
| 7822 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 7823 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7824 | * wlan_hdd_disable_all_dual_mac_features() - Disable dual mac features |
| 7825 | * @hdd_ctx: HDD context |
| 7826 | * |
| 7827 | * Disables all the dual mac features like DBS, Agile DFS etc. |
| 7828 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7829 | * Return: QDF_STATUS_SUCCESS on success |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7830 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7831 | 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] | 7832 | { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7833 | struct policy_mgr_dual_mac_config cfg = {0}; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7834 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7835 | |
| 7836 | if (!hdd_ctx) { |
| 7837 | hdd_err("HDD context is NULL"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7838 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7839 | } |
| 7840 | |
| 7841 | cfg.scan_config = 0; |
| 7842 | cfg.fw_mode_config = 0; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7843 | 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] | 7844 | |
| 7845 | hdd_debug("Disabling all dual mac features..."); |
| 7846 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7847 | status = sme_soc_set_dual_mac_config(cfg); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7848 | if (status != QDF_STATUS_SUCCESS) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7849 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7850 | return status; |
| 7851 | } |
| 7852 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7853 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7854 | } |
| 7855 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 7856 | static QDF_STATUS |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7857 | 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] | 7858 | { |
| 7859 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 7860 | QDF_STATUS status; |
| 7861 | |
| 7862 | if (!hdd_ctx) { |
| 7863 | hdd_err("HDD context is NULL"); |
| 7864 | return QDF_STATUS_E_FAILURE; |
| 7865 | } |
| 7866 | |
| 7867 | cfg.scan_config = 0; |
| 7868 | cfg.fw_mode_config = 0; |
| 7869 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 7870 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 7871 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 7872 | &cfg.fw_mode_config, |
| 7873 | hdd_ctx->config->dual_mac_feature_disable); |
| 7874 | |
| 7875 | if (status != QDF_STATUS_SUCCESS) { |
| 7876 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 7877 | status); |
| 7878 | return status; |
| 7879 | } |
| 7880 | |
| 7881 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 7882 | cfg.scan_config, cfg.fw_mode_config); |
| 7883 | |
| 7884 | status = sme_soc_set_dual_mac_config(cfg); |
| 7885 | if (status != QDF_STATUS_SUCCESS) { |
| 7886 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 7887 | return status; |
| 7888 | } |
| 7889 | |
| 7890 | return QDF_STATUS_SUCCESS; |
| 7891 | } |
| 7892 | |
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 | * hdd_override_ini_config - Override INI config |
| 7895 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7896 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7897 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7898 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7899 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7900 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7901 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7902 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7903 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7904 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 7905 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7906 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7907 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7908 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7909 | if (0 == enable_11d || 1 == enable_11d) { |
| 7910 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7911 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7912 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 7913 | |
| 7914 | if (!hdd_ipa_is_present(hdd_ctx)) |
| 7915 | hdd_ctx->config->IpaConfig = 0; |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 7916 | |
| 7917 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 7918 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 7919 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 7920 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 7921 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 7922 | hdd_ctx->config->oce_sta_enabled = 0; |
| 7923 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7924 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7925 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7926 | /** |
| 7927 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 7928 | * @hdd_ctx - HDD context |
| 7929 | * |
| 7930 | * Set trace level for each module based on INI config. |
| 7931 | * |
| 7932 | * Return: None |
| 7933 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7934 | 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] | 7935 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7936 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 7937 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 7938 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 7939 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 7940 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 7941 | hdd_ctx->config->qdf_trace_enable_sme); |
| 7942 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 7943 | hdd_ctx->config->qdf_trace_enable_pe); |
| 7944 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 7945 | hdd_ctx->config->qdf_trace_enable_wma); |
| 7946 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 7947 | hdd_ctx->config->qdf_trace_enable_sys); |
| 7948 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 7949 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 7950 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 7951 | hdd_ctx->config->qdf_trace_enable_sap); |
| 7952 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 7953 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 7954 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 7955 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 7956 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 7957 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 7958 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 7959 | hdd_ctx->config->qdf_trace_enable_epping); |
| 7960 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 7961 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 7962 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 7963 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 7964 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 7965 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7966 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 7967 | hdd_ctx->config->qdf_trace_enable_htc); |
| 7968 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 7969 | hdd_ctx->config->qdf_trace_enable_hif); |
| 7970 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 7971 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 7972 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 7973 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 7974 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 7975 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 7976 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 7977 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 7978 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 7979 | hdd_ctx->config->qdf_trace_enable_regulatory); |
| 7980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7981 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7982 | } |
| 7983 | |
| 7984 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7985 | * hdd_context_init() - Initialize HDD context |
| 7986 | * @hdd_ctx: HDD context. |
| 7987 | * |
| 7988 | * Initialize HDD context along with all the feature specific contexts. |
| 7989 | * |
| 7990 | * return: 0 on success and errno on failure. |
| 7991 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7992 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7993 | { |
| 7994 | int ret; |
| 7995 | |
| 7996 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 7997 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 7998 | |
| 7999 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8000 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8001 | |
| 8002 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8003 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8004 | |
| 8005 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8006 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8007 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8008 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8009 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8010 | |
| 8011 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8012 | |
| 8013 | ret = hdd_scan_context_init(hdd_ctx); |
| 8014 | if (ret) |
| 8015 | goto list_destroy; |
| 8016 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8017 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8018 | |
| 8019 | ret = hdd_sap_context_init(hdd_ctx); |
| 8020 | if (ret) |
| 8021 | goto scan_destroy; |
| 8022 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8023 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8024 | |
| 8025 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8026 | |
| 8027 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8028 | hdd_ctx->config); |
| 8029 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8030 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8031 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8032 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8033 | "monitor_mode_wakelock"); |
| 8034 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8035 | return 0; |
| 8036 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8037 | sap_destroy: |
| 8038 | hdd_sap_context_destroy(hdd_ctx); |
| 8039 | |
| 8040 | scan_destroy: |
| 8041 | hdd_scan_context_destroy(hdd_ctx); |
| 8042 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8043 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8044 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8045 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8046 | return ret; |
| 8047 | } |
| 8048 | |
| 8049 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8050 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8051 | * @hdd_ctx: pointer to hdd context |
| 8052 | * |
| 8053 | * Return: status of initialization |
| 8054 | * 0 - success |
| 8055 | * negative value - failure |
| 8056 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8057 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8058 | { |
| 8059 | int ret; |
| 8060 | |
| 8061 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8062 | return 0; |
| 8063 | |
| 8064 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8065 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8066 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8067 | return -EINVAL; |
| 8068 | } |
| 8069 | |
| 8070 | /* parse ini string probe req oui */ |
| 8071 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8072 | if (ret) { |
| 8073 | hdd_err("parsing error: disable ie whitelisting"); |
| 8074 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8075 | } |
| 8076 | |
| 8077 | return ret; |
| 8078 | } |
| 8079 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8080 | |
| 8081 | /** |
| 8082 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8083 | * @priv: pointer to hdd context |
| 8084 | * |
| 8085 | * This function is invoked when the timer waiting for the interface change |
| 8086 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8087 | * |
| 8088 | * Return: void |
| 8089 | */ |
| 8090 | static void hdd_iface_change_callback(void *priv) |
| 8091 | { |
| 8092 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8093 | int ret; |
| 8094 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8095 | |
| 8096 | if (status) |
| 8097 | return; |
| 8098 | |
| 8099 | ENTER(); |
| 8100 | hdd_debug("Interface change timer expired close the modules!"); |
| 8101 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8102 | if (ret) |
| 8103 | hdd_err("Failed to stop modules"); |
| 8104 | EXIT(); |
| 8105 | } |
| 8106 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8107 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8108 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8109 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8110 | * |
| 8111 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8112 | * wiphy allocation and then context is initialized. |
| 8113 | * |
| 8114 | * Return: HDD context on success and ERR_PTR on failure |
| 8115 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8116 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8117 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8118 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8119 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8120 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8121 | |
| 8122 | ENTER(); |
| 8123 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8124 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8125 | if (hdd_ctx == NULL) { |
| 8126 | ret = -ENOMEM; |
| 8127 | goto err_out; |
| 8128 | } |
| 8129 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8130 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8131 | hdd_iface_change_callback, |
| 8132 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8133 | |
| 8134 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8135 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8136 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8137 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8138 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8139 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8140 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8141 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8142 | ret = -ENOMEM; |
| 8143 | goto err_free_hdd_context; |
| 8144 | } |
| 8145 | |
| 8146 | /* Read and parse the qcom_cfg.ini file */ |
| 8147 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8148 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8149 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8150 | WLAN_INI_FILE); |
| 8151 | ret = -EINVAL; |
| 8152 | goto err_free_config; |
| 8153 | } |
| 8154 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8155 | ie_whitelist_attrs_init(hdd_ctx); |
| 8156 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8157 | hdd_debug("setting timer multiplier: %u", |
| 8158 | hdd_ctx->config->timer_multiplier); |
| 8159 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8160 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8161 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8162 | if (hdd_ctx->config->fhostNSOffload) |
| 8163 | hdd_ctx->ns_offload_enable = true; |
| 8164 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8165 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8166 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8167 | hdd_override_ini_config(hdd_ctx); |
| 8168 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8169 | ret = hdd_context_init(hdd_ctx); |
| 8170 | |
| 8171 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8172 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8173 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8174 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8175 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8176 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8177 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8178 | goto skip_multicast_logging; |
| 8179 | |
| 8180 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8181 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8182 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8183 | if (ret) |
| 8184 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8185 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8186 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8187 | if (ret) |
| 8188 | goto err_deinit_txrx_histogram; |
| 8189 | |
Dustin Brown | 7b3dea2 | 2017-07-10 13:02:47 -0700 | [diff] [blame] | 8190 | wlan_logging_set_log_to_console(hdd_ctx->config->wlanLoggingToConsole); |
| 8191 | wlan_logging_set_active(hdd_ctx->config->wlanLoggingEnable); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8192 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8193 | skip_multicast_logging: |
| 8194 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8195 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8196 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8197 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8198 | EXIT(); |
| 8199 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8200 | return hdd_ctx; |
| 8201 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8202 | err_deinit_txrx_histogram: |
| 8203 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8204 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8205 | err_deinit_hdd_context: |
| 8206 | hdd_context_deinit(hdd_ctx); |
| 8207 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8208 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8209 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8210 | |
| 8211 | err_free_hdd_context: |
| 8212 | wiphy_free(hdd_ctx->wiphy); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8213 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8214 | |
| 8215 | err_out: |
| 8216 | return ERR_PTR(ret); |
| 8217 | } |
| 8218 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8219 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8220 | /** |
| 8221 | * hdd_open_p2p_interface - Open P2P interface |
| 8222 | * @hdd_ctx: HDD context |
| 8223 | * @rtnl_held: True if RTNL lock held |
| 8224 | * |
| 8225 | * Open P2P interface during probe. This function called to open the P2P |
| 8226 | * interface at probe along with STA interface. |
| 8227 | * |
| 8228 | * Return: 0 on success and errno on failure |
| 8229 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8230 | 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] | 8231 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8232 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8233 | uint8_t *p2p_dev_addr; |
| 8234 | |
| 8235 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8236 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8237 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8238 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8239 | sizeof(tSirMacAddr)); |
| 8240 | |
| 8241 | /* |
| 8242 | * Generate the P2P Device Address. This consists of |
| 8243 | * the device's primary MAC address with the locally |
| 8244 | * administered bit set. |
| 8245 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8246 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8247 | } else { |
| 8248 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8249 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8250 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8251 | return -ENOSPC; |
| 8252 | } |
| 8253 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8254 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8255 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8256 | } |
| 8257 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8258 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8259 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8260 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8261 | |
| 8262 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8263 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8264 | return -ENOSPC; |
| 8265 | } |
| 8266 | |
| 8267 | return 0; |
| 8268 | } |
| 8269 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8270 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8271 | bool rtnl_held) |
| 8272 | { |
| 8273 | return 0; |
| 8274 | } |
| 8275 | #endif |
| 8276 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8277 | 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] | 8278 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8279 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8280 | int ret = 0; |
| 8281 | |
| 8282 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8283 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8284 | NET_NAME_UNKNOWN, rtnl_held); |
| 8285 | if (adapter == NULL) { |
| 8286 | hdd_err("Failed to open 802.11p interface"); |
| 8287 | ret = -ENOSPC; |
| 8288 | } |
| 8289 | |
| 8290 | return ret; |
| 8291 | } |
| 8292 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8293 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8294 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8295 | * @adapter: HDD adapter |
| 8296 | * |
| 8297 | * This function initializes the adapter for the station mode. |
| 8298 | * |
| 8299 | * Return: 0 on success or errno on failure. |
| 8300 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8301 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8302 | { |
| 8303 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8304 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8305 | |
| 8306 | ENTER_DEV(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8307 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8308 | hdd_err("session is already opened, %d", |
| 8309 | adapter->session_id); |
| 8310 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8311 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8312 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8313 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8314 | if (ret) { |
| 8315 | hdd_err("failed to create vdev: %d", ret); |
| 8316 | return ret; |
| 8317 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8318 | status = hdd_init_station_mode(adapter); |
| 8319 | |
| 8320 | if (QDF_STATUS_SUCCESS != status) { |
| 8321 | hdd_err("Error Initializing station mode: %d", status); |
| 8322 | return qdf_status_to_os_return(status); |
| 8323 | } |
| 8324 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8325 | hdd_register_tx_flow_control(adapter, |
| 8326 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8327 | hdd_tx_resume_cb, |
| 8328 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8329 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8330 | EXIT(); |
| 8331 | return 0; |
| 8332 | } |
| 8333 | |
| 8334 | /** |
| 8335 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8336 | * @adapter: HDD adapter |
| 8337 | * |
| 8338 | * This function initializes the adapter for the AP mode. |
| 8339 | * |
| 8340 | * Return: 0 on success errno on failure. |
| 8341 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8342 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8343 | { |
| 8344 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8345 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8346 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8347 | |
| 8348 | ENTER(); |
| 8349 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8350 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8351 | hdd_err("session is already opened, %d", |
| 8352 | adapter->session_id); |
| 8353 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8354 | } |
| 8355 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8356 | * In SSR case no need to create new sap context. |
| 8357 | * Otherwise create sap context first and then create |
| 8358 | * vdev as while creating the vdev, driver needs to |
| 8359 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8360 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8361 | if (adapter->session.ap.sap_context) { |
| 8362 | is_ssr = true; |
| 8363 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8364 | hdd_err("sap creation failed"); |
| 8365 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8366 | } |
| 8367 | |
| 8368 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8369 | adapter->session.ap.sap_context); |
| 8370 | if (ret) { |
| 8371 | hdd_err("failed to create vdev, status:%d", ret); |
| 8372 | hdd_sap_destroy_ctx(adapter); |
| 8373 | return ret; |
| 8374 | } |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8375 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8376 | |
| 8377 | if (QDF_STATUS_SUCCESS != status) { |
| 8378 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8379 | return qdf_status_to_os_return(status); |
| 8380 | } |
| 8381 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8382 | hdd_register_tx_flow_control(adapter, |
| 8383 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8384 | hdd_softap_tx_resume_cb, |
| 8385 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8386 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8387 | EXIT(); |
| 8388 | return 0; |
| 8389 | } |
| 8390 | |
| 8391 | /** |
| 8392 | * hdd_start_ftm_adapter()- Start FTM adapter |
| 8393 | * @adapter: HDD adapter |
| 8394 | * |
| 8395 | * This function initializes the adapter for the FTM mode. |
| 8396 | * |
| 8397 | * Return: 0 on success or errno on failure. |
| 8398 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8399 | int hdd_start_ftm_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8400 | { |
| 8401 | QDF_STATUS qdf_status; |
| 8402 | |
| 8403 | ENTER_DEV(adapter->dev); |
| 8404 | |
| 8405 | qdf_status = hdd_init_tx_rx(adapter); |
| 8406 | |
| 8407 | if (QDF_STATUS_SUCCESS != qdf_status) { |
| 8408 | hdd_err("Failed to start FTM adapter: %d", qdf_status); |
| 8409 | return qdf_status_to_os_return(qdf_status); |
| 8410 | } |
| 8411 | |
| 8412 | return 0; |
| 8413 | EXIT(); |
| 8414 | } |
| 8415 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8416 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8417 | bool rtnl_held) |
| 8418 | { |
| 8419 | struct hdd_adapter *adapter; |
| 8420 | |
| 8421 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8422 | hdd_ctx->config->enableConcurrentSTA, |
| 8423 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8424 | NET_NAME_UNKNOWN, rtnl_held); |
| 8425 | |
| 8426 | if (!adapter) |
| 8427 | return -ENOSPC; |
| 8428 | |
| 8429 | return 0; |
| 8430 | } |
| 8431 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8432 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8433 | * hdd_open_interfaces - Open all required interfaces |
| 8434 | * hdd_ctx: HDD context |
| 8435 | * rtnl_held: True if RTNL lock is held |
| 8436 | * |
| 8437 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8438 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8439 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8440 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8441 | 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] | 8442 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8443 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8444 | int ret; |
| 8445 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8446 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8447 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8448 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8449 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8450 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8451 | |
| 8452 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8453 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8454 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8455 | if (!adapter) { |
| 8456 | hdd_err("open adapter failed"); |
| 8457 | return -ENOSPC; |
| 8458 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8459 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8460 | return 0; |
| 8461 | } |
| 8462 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8463 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8464 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8465 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8466 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8467 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8468 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8469 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8470 | |
| 8471 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8472 | return -ENOSPC; |
| 8473 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 8474 | /* fast roaming is allowed only on first STA, i.e. wlan adapter */ |
| 8475 | adapter->fast_roaming_allowed = true; |
| 8476 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8477 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8478 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8479 | if (ret) |
| 8480 | hdd_err("Cannot create concurrent STA interface"); |
| 8481 | } |
| 8482 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8483 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8484 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8485 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8486 | |
| 8487 | /* Open 802.11p Interface */ |
| 8488 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8489 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8490 | if (ret) |
| 8491 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8492 | } |
| 8493 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8494 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8495 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8496 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8497 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8498 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8499 | } |
| 8500 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8501 | /** |
| 8502 | * hdd_update_country_code - Update country code |
| 8503 | * @hdd_ctx: HDD context |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8504 | * |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8505 | * Update country code based on module parameter country_code |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8506 | * |
| 8507 | * Return: 0 on success and errno on failure |
| 8508 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8509 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8510 | { |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8511 | if (!country_code) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8512 | return 0; |
| 8513 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 8514 | return hdd_reg_set_country(hdd_ctx, country_code); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8515 | } |
| 8516 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8517 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8518 | /** |
| 8519 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8520 | * @cds_cfg: CDS Configuration |
| 8521 | * @hdd_ctx: Pointer to hdd context |
| 8522 | * |
| 8523 | * Return: none |
| 8524 | */ |
| 8525 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8526 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8527 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8528 | { |
| 8529 | cds_cfg->tx_flow_stop_queue_th = |
| 8530 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8531 | cds_cfg->tx_flow_start_queue_offset = |
| 8532 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8533 | } |
| 8534 | #else |
| 8535 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8536 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8537 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8538 | { |
| 8539 | } |
| 8540 | #endif |
| 8541 | |
| 8542 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8543 | /** |
| 8544 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8545 | * @cds_cfg: CDS Configuration |
| 8546 | * @hdd_ctx: Pointer to hdd context |
| 8547 | * |
| 8548 | * Return: none |
| 8549 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8550 | 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] | 8551 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8552 | { |
| 8553 | cds_cfg->ra_ratelimit_interval = |
| 8554 | hdd_ctx->config->RArateLimitInterval; |
| 8555 | cds_cfg->is_ra_ratelimit_enabled = |
| 8556 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8557 | } |
| 8558 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8559 | 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] | 8560 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8561 | { |
| 8562 | } |
| 8563 | #endif |
| 8564 | |
| 8565 | /** |
| 8566 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8567 | * @hdd_ctx: HDD Context |
| 8568 | * |
| 8569 | * Return: 0 for Success, errno on failure |
| 8570 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8571 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8572 | { |
| 8573 | struct cds_config_info *cds_cfg; |
| 8574 | |
| 8575 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8576 | if (!cds_cfg) { |
| 8577 | hdd_err("failed to allocate cds config"); |
| 8578 | return -ENOMEM; |
| 8579 | } |
| 8580 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8581 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8582 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8583 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8584 | cds_cfg->powersave_offload_enabled = |
| 8585 | hdd_ctx->config->enablePowersaveOffload; |
| 8586 | } else { |
| 8587 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 8588 | PS_QPOWER_NODEEPSLEEP) || |
| 8589 | (hdd_ctx->config->enablePowersaveOffload == |
| 8590 | PS_LEGACY_NODEEPSLEEP)) |
| 8591 | cds_cfg->powersave_offload_enabled = |
| 8592 | PS_LEGACY_NODEEPSLEEP; |
| 8593 | else |
| 8594 | cds_cfg->powersave_offload_enabled = |
| 8595 | PS_LEGACY_DEEPSLEEP; |
| 8596 | hdd_info("Qpower disabled in cds config, %d", |
| 8597 | cds_cfg->powersave_offload_enabled); |
| 8598 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8599 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 8600 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 8601 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 8602 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
| 8603 | cds_cfg->max_wow_filters = hdd_ctx->config->maxWoWFilters; |
| 8604 | |
| 8605 | /* Here ol_ini_info is used to store ini status of arp offload |
| 8606 | * ns offload and others. Currently 1st bit is used for arp |
| 8607 | * off load and 2nd bit for ns offload currently, rest bits are unused |
| 8608 | */ |
| 8609 | if (hdd_ctx->config->fhostArpOffload) |
| 8610 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x1; |
| 8611 | if (hdd_ctx->config->fhostNSOffload) |
| 8612 | cds_cfg->ol_ini_info = cds_cfg->ol_ini_info | 0x2; |
| 8613 | |
| 8614 | /* |
| 8615 | * Copy the DFS Phyerr Filtering Offload status. |
| 8616 | * This parameter reflects the value of the |
| 8617 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 8618 | */ |
| 8619 | cds_cfg->dfs_phyerr_filter_offload = |
| 8620 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 8621 | if (hdd_ctx->config->ssdp) |
| 8622 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 8623 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 8624 | cds_cfg->force_target_assert_enabled = |
| 8625 | hdd_ctx->config->crash_inject_enabled; |
| 8626 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8627 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 8628 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 8629 | |
| 8630 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 8631 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 8632 | |
| 8633 | cds_cfg->ap_disable_intrabss_fwd = |
| 8634 | hdd_ctx->config->apDisableIntraBssFwd; |
| 8635 | |
| 8636 | cds_cfg->dfs_pri_multiplier = |
| 8637 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 8638 | cds_cfg->reorder_offload = |
| 8639 | hdd_ctx->config->reorderOffloadSupport; |
| 8640 | |
| 8641 | /* IPA micro controller data path offload resource config item */ |
| 8642 | cds_cfg->uc_offload_enabled = hdd_ipa_uc_is_enabled(hdd_ctx); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8643 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 8644 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8645 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8646 | hdd_ctx->config->IpaUcTxBufCount); |
| 8647 | hdd_ctx->config->IpaUcTxBufCount = |
| 8648 | rounddown_pow_of_two( |
| 8649 | hdd_ctx->config->IpaUcTxBufCount); |
| 8650 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 8651 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8652 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8653 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8654 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8655 | hdd_ctx->config->IpaUcTxBufCount); |
| 8656 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8657 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 8658 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8659 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 8660 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8661 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8662 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8663 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 8664 | rounddown_pow_of_two( |
| 8665 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8666 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 8667 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8668 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8669 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8670 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8671 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 8672 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8673 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 8674 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8675 | cds_cfg->uc_tx_partition_base = |
| 8676 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 8677 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 8678 | |
| 8679 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 8680 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 8681 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8682 | cds_cfg->ce_classify_enabled = |
| 8683 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 8684 | cds_cfg->bpf_packet_filter_enable = |
| 8685 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8686 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 8687 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 8688 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 8689 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 8690 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 8691 | cds_cfg->max_msdus_per_rxinorderind = |
| 8692 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 8693 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 8694 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 8695 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 8696 | 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] | 8697 | cds_cfg->auto_power_save_fail_mode = |
| 8698 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8699 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8700 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 8701 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 8702 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8703 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 8704 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 8705 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 8706 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8707 | cds_init_ini_config(cds_cfg); |
| 8708 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 8709 | |
| 8710 | exit: |
| 8711 | qdf_mem_free(cds_cfg); |
| 8712 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8713 | } |
| 8714 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8715 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8716 | * hdd_update_user_config() - API to update user configuration |
| 8717 | * parameters to obj mgr which are used by multiple components |
| 8718 | * @hdd_ctx: HDD Context |
| 8719 | * |
| 8720 | * Return: 0 for Success, errno on failure |
| 8721 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8722 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8723 | { |
| 8724 | struct wlan_objmgr_psoc_user_config *user_config; |
| 8725 | |
| 8726 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 8727 | if (user_config == NULL) { |
| 8728 | hdd_alert("Failed to alloc memory for user_config!"); |
| 8729 | return -ENOMEM; |
| 8730 | } |
| 8731 | |
| 8732 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 8733 | user_config->dual_mac_feature_disable = |
| 8734 | hdd_ctx->config->dual_mac_feature_disable; |
| 8735 | user_config->indoor_channel_support = |
| 8736 | hdd_ctx->config->indoor_channel_support; |
| 8737 | user_config->is_11d_support_enabled = |
| 8738 | hdd_ctx->config->Is11dSupportEnabled; |
| 8739 | user_config->is_11h_support_enabled = |
| 8740 | hdd_ctx->config->Is11hSupportEnabled; |
| 8741 | user_config->optimize_chan_avoid_event = |
| 8742 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 8743 | user_config->skip_dfs_chnl_in_p2p_search = |
| 8744 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 8745 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 8746 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 8747 | |
| 8748 | qdf_mem_free(user_config); |
| 8749 | return 0; |
| 8750 | } |
| 8751 | |
| 8752 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8753 | * hdd_init_thermal_info - Initialize thermal level |
| 8754 | * @hdd_ctx: HDD context |
| 8755 | * |
| 8756 | * Initialize thermal level at SME layer and set the thermal level callback |
| 8757 | * which would be called when a configured thermal threshold is hit. |
| 8758 | * |
| 8759 | * Return: 0 on success and errno on failure |
| 8760 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8761 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8762 | { |
| 8763 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8764 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8765 | |
| 8766 | thermal_param.smeThermalMgmtEnabled = |
| 8767 | hdd_ctx->config->thermalMitigationEnable; |
| 8768 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 8769 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 8770 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 8771 | hdd_ctx->config->throttle_dutycycle_level0; |
| 8772 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 8773 | hdd_ctx->config->throttle_dutycycle_level1; |
| 8774 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 8775 | hdd_ctx->config->throttle_dutycycle_level2; |
| 8776 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 8777 | hdd_ctx->config->throttle_dutycycle_level3; |
| 8778 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8779 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 8780 | hdd_ctx->config->thermalTempMinLevel0; |
| 8781 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 8782 | hdd_ctx->config->thermalTempMaxLevel0; |
| 8783 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 8784 | hdd_ctx->config->thermalTempMinLevel1; |
| 8785 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 8786 | hdd_ctx->config->thermalTempMaxLevel1; |
| 8787 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 8788 | hdd_ctx->config->thermalTempMinLevel2; |
| 8789 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 8790 | hdd_ctx->config->thermalTempMaxLevel2; |
| 8791 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 8792 | hdd_ctx->config->thermalTempMinLevel3; |
| 8793 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 8794 | hdd_ctx->config->thermalTempMaxLevel3; |
| 8795 | |
| 8796 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 8797 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8798 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 8799 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8800 | |
| 8801 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 8802 | hdd_set_thermal_level_cb); |
| 8803 | |
| 8804 | return 0; |
| 8805 | |
| 8806 | } |
| 8807 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8808 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 8809 | /** |
| 8810 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 8811 | * |
| 8812 | * Hold RTNL lock |
| 8813 | * |
| 8814 | * Return: True if held and false otherwise |
| 8815 | */ |
| 8816 | static inline bool hdd_hold_rtnl_lock(void) |
| 8817 | { |
| 8818 | rtnl_lock(); |
| 8819 | return true; |
| 8820 | } |
| 8821 | |
| 8822 | /** |
| 8823 | * hdd_release_rtnl_lock - Release RTNL lock |
| 8824 | * |
| 8825 | * Release RTNL lock |
| 8826 | * |
| 8827 | * Return: None |
| 8828 | */ |
| 8829 | static inline void hdd_release_rtnl_lock(void) |
| 8830 | { |
| 8831 | rtnl_unlock(); |
| 8832 | } |
| 8833 | #else |
| 8834 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 8835 | static inline void hdd_release_rtnl_lock(void) { } |
| 8836 | #endif |
| 8837 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8838 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8839 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8840 | /* MAX iwpriv command support */ |
| 8841 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8842 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8843 | #define MAX_PKTLOG_SIZE 16 |
| 8844 | |
| 8845 | /** |
| 8846 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 8847 | * @hdd_ctx: hdd context |
| 8848 | * @set_value2: pktlog buffer size value |
| 8849 | * |
| 8850 | * |
| 8851 | * Return: 0 for success or error. |
| 8852 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8853 | 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] | 8854 | { |
| 8855 | struct sir_wifi_start_log start_log = { 0 }; |
| 8856 | QDF_STATUS status; |
| 8857 | |
| 8858 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8859 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8860 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8861 | start_log.user_triggered = 1; |
| 8862 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8863 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8864 | |
| 8865 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8866 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8867 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8868 | EXIT(); |
| 8869 | return -EINVAL; |
| 8870 | } |
| 8871 | |
| 8872 | return 0; |
| 8873 | } |
| 8874 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8875 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8876 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 8877 | * @hdd_ctx: hdd context |
| 8878 | * |
| 8879 | * Return: 0 for success or error. |
| 8880 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8881 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8882 | { |
| 8883 | struct sir_wifi_start_log start_log; |
| 8884 | QDF_STATUS status; |
| 8885 | |
| 8886 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8887 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 8888 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8889 | start_log.user_triggered = 1; |
| 8890 | start_log.size = 0; |
| 8891 | start_log.is_pktlog_buff_clear = true; |
| 8892 | |
| 8893 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8894 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8895 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8896 | EXIT(); |
| 8897 | return -EINVAL; |
| 8898 | } |
| 8899 | |
| 8900 | return 0; |
| 8901 | } |
| 8902 | |
| 8903 | |
| 8904 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8905 | * hdd_process_pktlog_command() - process pktlog command |
| 8906 | * @hdd_ctx: hdd context |
| 8907 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8908 | * @set_value2: pktlog buffer size value |
| 8909 | * |
| 8910 | * This function process pktlog command. |
| 8911 | * set_value2 only matters when set_value is 3 (set buff size) |
| 8912 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8913 | * |
| 8914 | * Return: 0 for success or error. |
| 8915 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8916 | 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] | 8917 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8918 | { |
| 8919 | int ret; |
| 8920 | bool enable; |
| 8921 | uint8_t user_triggered = 0; |
| 8922 | |
| 8923 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 8924 | if (0 != ret) |
| 8925 | return ret; |
| 8926 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8927 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8928 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8929 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8930 | hdd_err("invalid pktlog value %d", set_value); |
| 8931 | return -EINVAL; |
| 8932 | } |
| 8933 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8934 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 8935 | if (set_value2 <= 0) { |
| 8936 | hdd_err("invalid pktlog size %d", set_value2); |
| 8937 | return -EINVAL; |
| 8938 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 8939 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 8940 | return -EINVAL; |
| 8941 | } |
| 8942 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8943 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 8944 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8945 | } |
| 8946 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8947 | /* |
| 8948 | * set_value = 0 then disable packetlog |
| 8949 | * set_value = 1 enable packetlog forcefully |
| 8950 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 8951 | * enable packetlog with AUTO type. |
| 8952 | */ |
| 8953 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 8954 | true : false; |
| 8955 | |
| 8956 | if (1 == set_value) { |
| 8957 | enable = true; |
| 8958 | user_triggered = 1; |
| 8959 | } |
| 8960 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8961 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8962 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 8963 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8964 | /** |
| 8965 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 8966 | * @hdd_ctx: HDD context |
| 8967 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8968 | * @user_triggered: triggered through iwpriv |
| 8969 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8970 | * |
| 8971 | * Return: 0 on success; error number otherwise |
| 8972 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8973 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8974 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8975 | { |
| 8976 | struct sir_wifi_start_log start_log; |
| 8977 | QDF_STATUS status; |
| 8978 | |
| 8979 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 8980 | start_log.verbose_level = |
| 8981 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 8982 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 8983 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 8984 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 8985 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 8986 | /* |
| 8987 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 8988 | * commands. Host uses this flag to decide whether to send pktlog |
| 8989 | * disable command to fw without sending pktlog enable command |
| 8990 | * previously. For eg, If vendor sends pktlog disable command without |
| 8991 | * sending pktlog enable command, then host discards the packet |
| 8992 | * but for iwpriv command, host will send it to fw. |
| 8993 | */ |
| 8994 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 8995 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 8996 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 8997 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
| 8998 | EXIT(); |
| 8999 | return -EINVAL; |
| 9000 | } |
| 9001 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame^] | 9002 | if (enable == true) |
| 9003 | hdd_ctx->is_pktlog_enabled = 1; |
| 9004 | else |
| 9005 | hdd_ctx->is_pktlog_enabled = 0; |
| 9006 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9007 | return 0; |
| 9008 | } |
| 9009 | #endif /* REMOVE_PKT_LOG */ |
| 9010 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9011 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9012 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9013 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9014 | * @dev: Device Pointer |
| 9015 | * @num: Number of Valid Mac address |
| 9016 | * |
| 9017 | * Return: Pointer to MAC address buffer |
| 9018 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9019 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9020 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9021 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9022 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9023 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9024 | |
| 9025 | /** |
| 9026 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9027 | * @hdd_ctx: HDD Context |
| 9028 | * @num: Number of random mac addresses needed |
| 9029 | * |
| 9030 | * Generate random addresses using bit manipulation on the base mac address |
| 9031 | * |
| 9032 | * Return: None |
| 9033 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9034 | 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] | 9035 | { |
| 9036 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9037 | uint32_t iter; |
| 9038 | struct hdd_config *ini = hdd_ctx->config; |
| 9039 | uint8_t *buf = NULL; |
| 9040 | uint8_t macaddr_b3, tmp_br3; |
| 9041 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9042 | |
| 9043 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9044 | buf = ini->intfMacAddr[iter].bytes; |
| 9045 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9046 | macaddr_b3 = buf[3]; |
| 9047 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9048 | INTF_MACADDR_MASK; |
| 9049 | macaddr_b3 += tmp_br3; |
| 9050 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9051 | buf[0] |= 0x02; |
| 9052 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9053 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9054 | } |
| 9055 | } |
| 9056 | |
| 9057 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9058 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9059 | * @hdd_ctx: HDD Context |
| 9060 | * |
| 9061 | * API to get mac addresses from platform driver and update the driver |
| 9062 | * structures and configure FW with the base mac address. |
| 9063 | * Return: int |
| 9064 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9065 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9066 | { |
| 9067 | uint32_t no_of_mac_addr, iter; |
| 9068 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9069 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9070 | uint8_t *addr, *buf; |
| 9071 | struct device *dev = hdd_ctx->parent_dev; |
| 9072 | struct hdd_config *ini = hdd_ctx->config; |
| 9073 | tSirMacAddr mac_addr; |
| 9074 | QDF_STATUS status; |
| 9075 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9076 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9077 | |
| 9078 | if (no_of_mac_addr == 0 || !addr) { |
| 9079 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9080 | return -EINVAL; |
| 9081 | } |
| 9082 | |
| 9083 | if (no_of_mac_addr > max_mac_addr) |
| 9084 | no_of_mac_addr = max_mac_addr; |
| 9085 | |
| 9086 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9087 | |
| 9088 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9089 | buf = ini->intfMacAddr[iter].bytes; |
| 9090 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9091 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9092 | } |
| 9093 | |
| 9094 | status = sme_set_custom_mac_addr(mac_addr); |
| 9095 | |
| 9096 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9097 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9098 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9099 | if (no_of_mac_addr < max_mac_addr) |
| 9100 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9101 | no_of_mac_addr); |
| 9102 | return 0; |
| 9103 | } |
| 9104 | |
| 9105 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9106 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9107 | * @hdd_ctx: HDD Context |
| 9108 | * |
| 9109 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9110 | * will generate its own MAC and update it to FW. |
| 9111 | * |
| 9112 | * Return: 0 for success |
| 9113 | * Non-zero error code for failure |
| 9114 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9115 | 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] | 9116 | { |
| 9117 | tSirMacAddr customMacAddr; |
| 9118 | QDF_STATUS status; |
| 9119 | |
| 9120 | qdf_mem_copy(&customMacAddr, |
| 9121 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9122 | sizeof(tSirMacAddr)); |
| 9123 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9124 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9125 | return -EAGAIN; |
| 9126 | return 0; |
| 9127 | } |
| 9128 | |
| 9129 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9130 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9131 | * @hdd_ctx: HDD Context |
| 9132 | * |
| 9133 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9134 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9135 | * wlan_mac.bin to update HW MAC addresses. |
| 9136 | * |
| 9137 | * Return: None |
| 9138 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9139 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9140 | { |
| 9141 | QDF_STATUS status; |
| 9142 | int ret; |
| 9143 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9144 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9145 | if (ret == 0) |
| 9146 | return; |
| 9147 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9148 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9149 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9150 | |
| 9151 | status = hdd_update_mac_config(hdd_ctx); |
| 9152 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9153 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9154 | return; |
| 9155 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9156 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9157 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9158 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9159 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9160 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9161 | if (ret != 0) { |
| 9162 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9163 | QDF_ASSERT(ret); |
| 9164 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9165 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9166 | } |
| 9167 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9168 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9169 | { |
| 9170 | int vdev_id = 0; |
| 9171 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9172 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9173 | int vpdev = PDEV_CMD; |
| 9174 | int ret; |
| 9175 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9176 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9177 | if (ret) |
| 9178 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9179 | |
| 9180 | return ret; |
| 9181 | } |
| 9182 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9183 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9184 | { |
| 9185 | int vdev_id = 0; |
| 9186 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9187 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9188 | int vpdev = PDEV_CMD; |
| 9189 | int ret; |
| 9190 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9191 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9192 | if (ret) |
| 9193 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9194 | ret); |
| 9195 | |
| 9196 | return ret; |
| 9197 | } |
| 9198 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9199 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9200 | { |
| 9201 | int vdev_id = 0; |
| 9202 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9203 | int value = hdd_ctx->config->ani_enabled; |
| 9204 | int vpdev = PDEV_CMD; |
| 9205 | int ret; |
| 9206 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9207 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9208 | if (ret) |
| 9209 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9210 | |
| 9211 | return ret; |
| 9212 | } |
| 9213 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9214 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9215 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9216 | * @hdd_ctx: HDD context |
| 9217 | * |
| 9218 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9219 | * |
| 9220 | * Return: 0 on success and errno on failure. |
| 9221 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9222 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9223 | { |
| 9224 | int ret; |
| 9225 | QDF_STATUS status; |
| 9226 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9227 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9228 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9229 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9230 | /* |
| 9231 | * Set 802.11p config |
| 9232 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9233 | * parameter is set in CSR when we init the channel list. This should |
| 9234 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9235 | * domain. |
| 9236 | */ |
| 9237 | hdd_set_dot11p_config(hdd_ctx); |
| 9238 | |
| 9239 | /* |
| 9240 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9241 | * The cfg download must occur before we update the SME config |
| 9242 | * since the SME config operation must access the cfg database |
| 9243 | */ |
| 9244 | status = hdd_set_sme_config(hdd_ctx); |
| 9245 | |
| 9246 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9247 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9248 | ret = qdf_status_to_os_return(status); |
| 9249 | goto out; |
| 9250 | } |
| 9251 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9252 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9253 | if (QDF_STATUS_SUCCESS != status) { |
| 9254 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9255 | ret = qdf_status_to_os_return(status); |
| 9256 | goto out; |
| 9257 | } |
| 9258 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9259 | 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] | 9260 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9261 | PDEV_CMD); |
| 9262 | if (0 != ret) { |
| 9263 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9264 | goto out; |
| 9265 | } |
| 9266 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9267 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9268 | if (ret) |
| 9269 | goto out; |
| 9270 | |
| 9271 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9272 | if (ret) |
| 9273 | goto out; |
| 9274 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9275 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9276 | if (ret) |
| 9277 | goto out; |
| 9278 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9279 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9280 | hdd_ctx->config->arp_ac_category, |
| 9281 | PDEV_CMD); |
| 9282 | if (0 != ret) { |
| 9283 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9284 | hdd_ctx->config->arp_ac_category, ret); |
| 9285 | goto out; |
| 9286 | } |
| 9287 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9288 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9289 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9290 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9291 | ret = qdf_status_to_os_return(status); |
| 9292 | goto out; |
| 9293 | } |
| 9294 | |
| 9295 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9296 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9297 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9298 | ret = -EINVAL; |
| 9299 | goto out; |
| 9300 | } |
| 9301 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9302 | /* |
| 9303 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9304 | * Remove this once self sta is added as part of session open. |
| 9305 | */ |
| 9306 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9307 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9308 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9309 | |
| 9310 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9311 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9312 | hal_status, hal_status); |
| 9313 | ret = -EINVAL; |
| 9314 | goto out; |
| 9315 | } |
| 9316 | |
| 9317 | hdd_init_channel_avoidance(hdd_ctx); |
| 9318 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9319 | /* update enable sap mandatory chan list */ |
| 9320 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9321 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9322 | out: |
| 9323 | return ret; |
| 9324 | } |
| 9325 | |
| 9326 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9327 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9328 | * @context_ptr - hdd context pointer |
| 9329 | * @event_ptr - event structure pointer |
| 9330 | * |
| 9331 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9332 | * event back to supplicant to notify the stop reason. |
| 9333 | * |
| 9334 | * Return: None |
| 9335 | */ |
| 9336 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9337 | void *event_ptr) |
| 9338 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9339 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9340 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9341 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9342 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9343 | |
| 9344 | ENTER(); |
| 9345 | |
| 9346 | if (hdd_ctx == NULL) { |
| 9347 | hdd_err("Invalid HDD context pointer"); |
| 9348 | return; |
| 9349 | } |
| 9350 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9351 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9352 | if (!adapter) { |
| 9353 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9354 | evt->vdev_id); |
| 9355 | return; |
| 9356 | } |
| 9357 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9358 | vendor_event = |
| 9359 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9360 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9361 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9362 | GFP_KERNEL); |
| 9363 | |
| 9364 | if (!vendor_event) { |
| 9365 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9366 | return; |
| 9367 | } |
| 9368 | |
| 9369 | if (nla_put_u32(vendor_event, |
| 9370 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9371 | evt->reason_code)) { |
| 9372 | hdd_err("nla put failed"); |
| 9373 | kfree_skb(vendor_event); |
| 9374 | return; |
| 9375 | } |
| 9376 | |
| 9377 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9378 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9379 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9380 | } |
| 9381 | |
| 9382 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9383 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9384 | * @hdd_ctx: HDD context |
| 9385 | * |
| 9386 | * This function sends the adaptive dwell time config configuration to the |
| 9387 | * firmware via WMA |
| 9388 | * |
| 9389 | * Return: 0 - success, < 0 - failure |
| 9390 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9391 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9392 | { |
| 9393 | QDF_STATUS status; |
| 9394 | struct adaptive_dwelltime_params dwelltime_params; |
| 9395 | |
| 9396 | dwelltime_params.is_enabled = |
| 9397 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9398 | dwelltime_params.dwelltime_mode = |
| 9399 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9400 | dwelltime_params.lpf_weight = |
| 9401 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9402 | dwelltime_params.passive_mon_intval = |
| 9403 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9404 | dwelltime_params.wifi_act_threshold = |
| 9405 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9406 | |
| 9407 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9408 | &dwelltime_params); |
| 9409 | |
| 9410 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9411 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9412 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9413 | return -EAGAIN; |
| 9414 | } |
| 9415 | return 0; |
| 9416 | } |
| 9417 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9418 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9419 | { |
| 9420 | QDF_STATUS status; |
| 9421 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9422 | uint32_t i = 0; |
| 9423 | uint8_t count = 0, numentries = 0; |
| 9424 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9425 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9426 | |
| 9427 | /* check if DBS is enabled or supported */ |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9428 | if (hdd_ctx->config->dual_mac_feature_disable == |
| 9429 | DISABLE_DBS_CXN_AND_SCAN) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9430 | return -EINVAL; |
| 9431 | |
| 9432 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9433 | dbs_scan_config, &numentries, |
| 9434 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9435 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9436 | |
| 9437 | hdd_info("numentries %hu", numentries); |
| 9438 | if (!numentries) { |
| 9439 | hdd_info("Donot send scan_selection_config"); |
| 9440 | return 0; |
| 9441 | } |
| 9442 | |
| 9443 | /* hdd_set_fw_log_params */ |
| 9444 | dbs_scan_params.num_clients = 0; |
| 9445 | while (count < (numentries - 2)) { |
| 9446 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9447 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9448 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9449 | dbs_scan_config[count + 2]; |
| 9450 | dbs_scan_params.num_clients++; |
| 9451 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9452 | dbs_scan_params.module_id[i], |
| 9453 | dbs_scan_params.num_dbs_scans[i], |
| 9454 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9455 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9456 | i++; |
| 9457 | } |
| 9458 | |
| 9459 | dbs_scan_params.pdev_id = 0; |
| 9460 | |
| 9461 | hdd_debug("clients:%d pdev:%d", |
| 9462 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9463 | |
| 9464 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9465 | &dbs_scan_params); |
| 9466 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9467 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9468 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9469 | return -EAGAIN; |
| 9470 | } |
| 9471 | return 0; |
| 9472 | } |
| 9473 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9474 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9475 | /** |
| 9476 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9477 | * @hdd_ctx: HDD context |
| 9478 | * |
| 9479 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9480 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9481 | * |
| 9482 | * Return: 0 on success and errno on failure. |
| 9483 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9484 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9485 | { |
| 9486 | QDF_STATUS status; |
| 9487 | |
| 9488 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9489 | return 0; |
| 9490 | |
| 9491 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9492 | wlan_hdd_auto_shutdown_cb); |
| 9493 | if (status != QDF_STATUS_SUCCESS) |
| 9494 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9495 | status); |
| 9496 | |
| 9497 | return qdf_status_to_os_return(status); |
| 9498 | } |
| 9499 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9500 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9501 | { |
| 9502 | return 0; |
| 9503 | } |
| 9504 | #endif |
| 9505 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9506 | 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] | 9507 | { |
| 9508 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 9509 | |
| 9510 | switch (hdd_ctx->config->dual_mac_feature_disable) { |
| 9511 | case DISABLE_DBS_CXN_AND_SCAN: |
| 9512 | status = wlan_hdd_disable_all_dual_mac_features(hdd_ctx); |
| 9513 | if (status != QDF_STATUS_SUCCESS) |
| 9514 | hdd_err("Failed to disable dual mac features"); |
| 9515 | break; |
| 9516 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN: |
| 9517 | case DISABLE_DBS_CXN_AND_ENABLE_DBS_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9518 | case ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF: |
| 9519 | status = wlan_hdd_update_dbs_scan_and_fw_mode_config(hdd_ctx); |
| 9520 | if (status != QDF_STATUS_SUCCESS) |
| 9521 | hdd_err("Failed to set dbs scan and fw mode config"); |
| 9522 | break; |
| 9523 | default: |
| 9524 | break; |
| 9525 | } |
| 9526 | |
| 9527 | return status; |
| 9528 | } |
| 9529 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9530 | /** |
| 9531 | * hdd_features_init() - Init features |
| 9532 | * @hdd_ctx: HDD context |
| 9533 | * @adapter: Primary adapter context |
| 9534 | * |
| 9535 | * Initialize features and their feature context after WLAN firmware is up. |
| 9536 | * |
| 9537 | * Return: 0 on success and errno on failure. |
| 9538 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9539 | 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] | 9540 | { |
| 9541 | tSirTxPowerLimit hddtxlimit; |
| 9542 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9543 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9544 | int ret; |
| 9545 | |
| 9546 | ENTER(); |
| 9547 | |
Kiran Kumar Lokere | b1d412e | 2017-04-23 17:19:43 -0700 | [diff] [blame] | 9548 | ret = hdd_update_country_code(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9549 | if (ret) { |
| 9550 | hdd_err("Failed to update country code: %d", ret); |
| 9551 | goto out; |
| 9552 | } |
| 9553 | |
| 9554 | /* FW capabilities received, Set the Dot11 mode */ |
| 9555 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9556 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9557 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9558 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9559 | |
| 9560 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9561 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9562 | else |
| 9563 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9564 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9565 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9566 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9567 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9568 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9569 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9570 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9571 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9572 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9573 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9574 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9575 | if (hdd_lro_init(hdd_ctx)) |
| 9576 | hdd_err("Unable to initialize LRO in fw"); |
| 9577 | |
| 9578 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9579 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9580 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9581 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9582 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9583 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9584 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9585 | if (ret) { |
| 9586 | hdd_err("Error while initializing thermal information"); |
| 9587 | goto deregister_frames; |
| 9588 | } |
| 9589 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame^] | 9590 | /** |
| 9591 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9592 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9593 | * device up. |
| 9594 | */ |
| 9595 | if (cds_is_driver_recovering()) { |
| 9596 | if (hdd_ctx->is_pktlog_enabled) |
| 9597 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9598 | } else if (cds_is_packet_log_enabled()) |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9599 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
| 9600 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9601 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9602 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9603 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9604 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9605 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9606 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9607 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9608 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9609 | ret = hdd_register_cb(hdd_ctx); |
| 9610 | if (ret) { |
| 9611 | hdd_err("Failed to register HDD callbacks!"); |
| 9612 | goto deregister_frames; |
| 9613 | } |
| 9614 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9615 | status = hdd_set_dbs_scan_and_fw_mode_cfg(hdd_ctx); |
| 9616 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9617 | hdd_err("Failed to set dbs scan and fw mode cfg"); |
| 9618 | goto deregister_cb; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9619 | } |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 9620 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9621 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9622 | status = sme_enable_disable_chanavoidind_event( |
| 9623 | hdd_ctx->hHal, 0); |
| 9624 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9625 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9626 | goto deregister_cb; |
| 9627 | } |
| 9628 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9629 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9630 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 9631 | band_pref_params.rssi_boost_threshold_5g = |
| 9632 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 9633 | band_pref_params.rssi_boost_factor_5g = |
| 9634 | hdd_ctx->config->rssi_boost_factor_5g; |
| 9635 | band_pref_params.max_rssi_boost_5g = |
| 9636 | hdd_ctx->config->max_rssi_boost_5g; |
| 9637 | band_pref_params.rssi_penalize_threshold_5g = |
| 9638 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 9639 | band_pref_params.rssi_penalize_factor_5g = |
| 9640 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 9641 | band_pref_params.max_rssi_penalize_5g = |
| 9642 | hdd_ctx->config->max_rssi_penalize_5g; |
| 9643 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 9644 | } |
| 9645 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9646 | /* register P2P Listen Offload event callback */ |
| 9647 | if (wma_is_p2p_lo_capable()) |
| 9648 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 9649 | wlan_hdd_p2p_lo_event_callback); |
| 9650 | |
| 9651 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 9652 | |
| 9653 | if (ret) |
| 9654 | goto deregister_cb; |
| 9655 | |
| 9656 | EXIT(); |
| 9657 | return 0; |
| 9658 | |
| 9659 | deregister_cb: |
| 9660 | hdd_deregister_cb(hdd_ctx); |
| 9661 | deregister_frames: |
| 9662 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 9663 | out: |
| 9664 | return -EINVAL; |
| 9665 | |
| 9666 | } |
| 9667 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9668 | /** |
| 9669 | * hdd_features_deinit() - Deinit features |
| 9670 | * @hdd_ctx: HDD context |
| 9671 | * |
| 9672 | * De-Initialize features and their feature context. |
| 9673 | * |
| 9674 | * Return: none. |
| 9675 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9676 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9677 | { |
| 9678 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 9679 | } |
| 9680 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9681 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9682 | * hdd_register_bcn_cb() - register scan beacon callback |
| 9683 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9684 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 9685 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9686 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9687 | 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] | 9688 | { |
| 9689 | QDF_STATUS status; |
| 9690 | |
| 9691 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 9692 | wlan_cfg80211_inform_bss_frame, |
| 9693 | SCAN_CB_TYPE_INFORM_BCN); |
| 9694 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9695 | hdd_err("failed with status code %08d [x%08x]", |
| 9696 | status, status); |
| 9697 | return status; |
| 9698 | } |
| 9699 | |
| 9700 | return QDF_STATUS_SUCCESS; |
| 9701 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9702 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9703 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9704 | * hdd_configure_cds() - Configure cds modules |
| 9705 | * @hdd_ctx: HDD context |
| 9706 | * @adapter: Primary adapter context |
| 9707 | * |
| 9708 | * Enable Cds modules after WLAN firmware is up. |
| 9709 | * |
| 9710 | * Return: 0 on success and errno on failure. |
| 9711 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9712 | 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] | 9713 | { |
| 9714 | int ret; |
| 9715 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9716 | int set_value; |
| 9717 | uint32_t num_abg_tx_chains = 0; |
| 9718 | uint32_t num_11b_tx_chains = 0; |
| 9719 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9720 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 9721 | |
| 9722 | if (hdd_ctx->config->sifs_burst_duration) { |
| 9723 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 9724 | hdd_ctx->config->sifs_burst_duration; |
| 9725 | |
| 9726 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 9727 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 9728 | set_value, PDEV_CMD); |
| 9729 | } |
| 9730 | |
| 9731 | if (hdd_ctx->config->is_force_1x1) |
| 9732 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 9733 | 1, PDEV_CMD); |
| 9734 | /* set chip power save failure detected callback */ |
| 9735 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 9736 | hdd_chip_pwr_save_fail_detected_cb); |
| 9737 | |
| 9738 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 9739 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 9740 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 9741 | set_value, PDEV_CMD); |
| 9742 | } |
| 9743 | |
| 9744 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 9745 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 9746 | sme_cli_set_command(0, |
| 9747 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 9748 | set_value, PDEV_CMD); |
| 9749 | } |
| 9750 | |
| 9751 | if (hdd_ctx->config->sap_get_peer_info) { |
| 9752 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 9753 | sme_cli_set_command(0, |
| 9754 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 9755 | set_value, PDEV_CMD); |
| 9756 | } |
| 9757 | |
| 9758 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 9759 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 9760 | if (!hdd_ctx->config->enable2x2) { |
| 9761 | if (num_11b_tx_chains > 1) |
| 9762 | num_11b_tx_chains = 1; |
| 9763 | if (num_11ag_tx_chains > 1) |
| 9764 | num_11ag_tx_chains = 1; |
| 9765 | } |
| 9766 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9767 | num_11b_tx_chains); |
| 9768 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 9769 | num_11ag_tx_chains); |
| 9770 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 9771 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9772 | |
| 9773 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 9774 | if (ret) { |
| 9775 | hdd_err("Failed to pre-configure cds"); |
| 9776 | goto out; |
| 9777 | } |
| 9778 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9779 | /* Always get latest IPA resources allocated from cds_open and configure |
| 9780 | * IPA module before configuring them to FW. Sequence required as crash |
| 9781 | * observed otherwise. |
| 9782 | */ |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 9783 | if (hdd_ipa_uc_ol_init(hdd_ctx)) { |
| 9784 | hdd_err("Failed to setup pipes"); |
| 9785 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 9786 | } |
| 9787 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9788 | /* |
| 9789 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 9790 | * else |
| 9791 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 9792 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9793 | |
| 9794 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9795 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9796 | goto out; |
| 9797 | } |
| 9798 | |
| 9799 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 9800 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9801 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9802 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9803 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 9804 | status = hdd_register_bcn_cb(hdd_ctx); |
| 9805 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9806 | hdd_alert("hdd_post_cds_enable_config failed"); |
| 9807 | goto cds_disable; |
| 9808 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9809 | |
| 9810 | ret = hdd_features_init(hdd_ctx, adapter); |
| 9811 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9812 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9813 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9814 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9815 | 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] | 9816 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 9817 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 9818 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 9819 | goto cds_disable; |
| 9820 | } |
| 9821 | |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 9822 | if (hdd_enable_egap(hdd_ctx)) |
| 9823 | hdd_debug("enhance green ap is not enabled"); |
| 9824 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 9825 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 9826 | hdd_debug("Failed to set wow pulse"); |
| 9827 | |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 9828 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 9829 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 9830 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 9831 | |
| 9832 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 9833 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 9834 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 9835 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9836 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9837 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9838 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9839 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 9840 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9841 | out: |
| 9842 | return -EINVAL; |
| 9843 | } |
| 9844 | |
| 9845 | /** |
| 9846 | * hdd_deconfigure_cds() -De-Configure cds |
| 9847 | * @hdd_ctx: HDD context |
| 9848 | * |
| 9849 | * Deconfigure Cds modules before WLAN firmware is down. |
| 9850 | * |
| 9851 | * Return: 0 on success and errno on failure. |
| 9852 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9853 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9854 | { |
| 9855 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9856 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9857 | |
| 9858 | ENTER(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9859 | |
| 9860 | /* De-init features */ |
| 9861 | hdd_features_deinit(hdd_ctx); |
| 9862 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9863 | /* De-register the SME callbacks */ |
| 9864 | hdd_deregister_cb(hdd_ctx); |
| 9865 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 9866 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9867 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9868 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 9869 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9870 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9871 | } |
| 9872 | |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 9873 | if (hdd_ipa_uc_ol_deinit(hdd_ctx)) { |
| 9874 | hdd_err("Failed to disconnect pipes"); |
| 9875 | ret = -EINVAL; |
| 9876 | } |
| 9877 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9878 | EXIT(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 9879 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9880 | } |
| 9881 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9882 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 9883 | static void hdd_deregister_policy_manager_callback( |
| 9884 | struct wlan_objmgr_psoc *psoc) |
| 9885 | { |
| 9886 | if (QDF_STATUS_SUCCESS != |
| 9887 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 9888 | hdd_err("HDD callback deregister with policy manager failed"); |
| 9889 | } |
| 9890 | } |
| 9891 | #else |
| 9892 | static void hdd_deregister_policy_manager_callback( |
| 9893 | struct wlan_objmgr_psoc *psoc) |
| 9894 | { |
| 9895 | } |
| 9896 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9897 | |
| 9898 | /** |
| 9899 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 9900 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9901 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9902 | * |
| 9903 | * This function maintains the driver state machine it will be invoked from |
| 9904 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 9905 | * shall perform the stopping/closing of the modules. |
| 9906 | * |
| 9907 | * Return: 0 for success; non-zero for failure |
| 9908 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9909 | 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] | 9910 | { |
| 9911 | void *hif_ctx; |
| 9912 | qdf_device_t qdf_ctx; |
| 9913 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9914 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 9915 | bool is_recovery_stop = cds_is_driver_recovering(); |
| 9916 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop; |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9917 | int active_threads; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9918 | |
| 9919 | ENTER(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 9920 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 9921 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9922 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 9923 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 9924 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9925 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 9926 | if (!qdf_ctx) { |
| 9927 | hdd_err("QDF device context NULL"); |
| 9928 | return -EINVAL; |
| 9929 | } |
| 9930 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9931 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 9932 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9933 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9934 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9935 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9936 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9937 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 9938 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9939 | |
| 9940 | cds_print_external_threads(); |
| 9941 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9942 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9943 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 9944 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 9945 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 9946 | hdd_prevent_suspend_timeout( |
| 9947 | hdd_ctx->config->iface_change_wait_time, |
| 9948 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 9949 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 9950 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 9951 | return 0; |
| 9952 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 9953 | } |
| 9954 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9955 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 9956 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 9957 | /* free user wowl patterns */ |
| 9958 | hdd_free_user_wowl_ptrns(); |
| 9959 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9960 | switch (hdd_ctx->driver_status) { |
| 9961 | case DRIVER_MODULES_UNINITIALIZED: |
| 9962 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9963 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9964 | case DRIVER_MODULES_CLOSED: |
| 9965 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9966 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9967 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9968 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 9969 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 9970 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9971 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9972 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9973 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9974 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9975 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9976 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9977 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9978 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9979 | hdd_info("Wlan transitioned (now OPENED)"); |
| 9980 | |
| 9981 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9982 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9983 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9984 | break; |
| 9985 | default: |
| 9986 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 9987 | hdd_ctx->driver_status); |
| 9988 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 9989 | ret = -EINVAL; |
| 9990 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9991 | } |
| 9992 | |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 9993 | hdd_debug("Closing CDS modules!"); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 9994 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 9995 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 9996 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 9997 | qdf_status); |
| 9998 | ret = -EINVAL; |
| 9999 | QDF_ASSERT(0); |
| 10000 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10001 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10002 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10003 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 10004 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10005 | if (ret) { |
| 10006 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10007 | QDF_ASSERT(0); |
| 10008 | } |
| 10009 | |
| 10010 | /* |
| 10011 | * Reset total mac phy during module stop such that during |
| 10012 | * next module start same psoc is used to populate new service |
| 10013 | * ready data |
| 10014 | */ |
| 10015 | hdd_ctx->hdd_psoc->total_mac_phy = 0; |
| 10016 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10017 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10018 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10019 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10020 | ret = -EINVAL; |
| 10021 | QDF_ASSERT(0); |
| 10022 | } |
| 10023 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10024 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10025 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10026 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10027 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10028 | QDF_ASSERT(0); |
| 10029 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10030 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10031 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10032 | if (!hif_ctx) { |
| 10033 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10034 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10035 | } |
| 10036 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10037 | if (hdd_ctx->target_hw_name) { |
| 10038 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10039 | hdd_ctx->target_hw_name = NULL; |
| 10040 | } |
| 10041 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10042 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10043 | |
| 10044 | ol_cds_free(); |
| 10045 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10046 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10047 | ret = pld_power_off(qdf_ctx->dev); |
| 10048 | if (ret) |
| 10049 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10050 | ret); |
| 10051 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10052 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10053 | /* many adapter resources are not freed by design in SSR case */ |
| 10054 | if (!is_recovery_stop) |
| 10055 | hdd_check_for_leaks(); |
| 10056 | qdf_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
| 10057 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10058 | /* Once the firmware sequence is completed reset this flag */ |
| 10059 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10060 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10061 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10062 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10063 | done: |
| 10064 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10065 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10066 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10067 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10068 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10069 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10070 | EXIT(); |
| 10071 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10072 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10073 | } |
| 10074 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10075 | |
| 10076 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10077 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10078 | * @buf: buffer pointer |
| 10079 | * @size: size of buffer to be filled |
| 10080 | * |
| 10081 | * This function is used to dump state information of hdd layer |
| 10082 | * |
| 10083 | * Return: None |
| 10084 | */ |
| 10085 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10086 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10087 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10088 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10089 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10090 | uint16_t len = 0; |
| 10091 | char *buf = *buf_ptr; |
| 10092 | |
| 10093 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10094 | if (!hdd_ctx) { |
| 10095 | hdd_err("Failed to get hdd context "); |
| 10096 | return; |
| 10097 | } |
| 10098 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10099 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10100 | |
| 10101 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10102 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10103 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10104 | "\n is_scheduler_suspended %d", |
| 10105 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10106 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10107 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10108 | if (adapter->dev) |
| 10109 | len += scnprintf(buf + len, *size - len, |
| 10110 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10111 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10112 | "\n device_mode: %d", adapter->device_mode); |
| 10113 | switch (adapter->device_mode) { |
| 10114 | case QDF_STA_MODE: |
| 10115 | case QDF_P2P_CLIENT_MODE: |
| 10116 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10117 | len += scnprintf(buf + len, *size - len, |
| 10118 | "\n connState: %d", |
| 10119 | hdd_sta_ctx->conn_info.connState); |
| 10120 | break; |
| 10121 | |
| 10122 | default: |
| 10123 | break; |
| 10124 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10125 | } |
| 10126 | |
| 10127 | *size -= len; |
| 10128 | *buf_ptr += len; |
| 10129 | } |
| 10130 | |
| 10131 | /** |
| 10132 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10133 | * to print hdd state information |
| 10134 | * |
| 10135 | * Return: None |
| 10136 | */ |
| 10137 | static void hdd_register_debug_callback(void) |
| 10138 | { |
| 10139 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10140 | } |
| 10141 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10142 | /* |
| 10143 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10144 | * |
| 10145 | * This function is used to create bug report lock |
| 10146 | * |
| 10147 | * Return: None |
| 10148 | */ |
| 10149 | static void wlan_init_bug_report_lock(void) |
| 10150 | { |
| 10151 | p_cds_contextType p_cds_context; |
| 10152 | |
| 10153 | p_cds_context = cds_get_global_context(); |
| 10154 | if (!p_cds_context) { |
| 10155 | hdd_err("cds context is NULL"); |
| 10156 | return; |
| 10157 | } |
| 10158 | |
| 10159 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10160 | } |
| 10161 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10162 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10163 | { |
| 10164 | |
| 10165 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10166 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10167 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10168 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10169 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10170 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10171 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10172 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10173 | |
| 10174 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10175 | &num_entries, sizeof(config_params)); |
| 10176 | |
| 10177 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10178 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10179 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10180 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10181 | else if (bw_compute_interval > 1000) { |
| 10182 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10183 | thresh_time_limit = 1; |
| 10184 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10185 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10186 | |
| 10187 | switch (num_entries) { |
| 10188 | case 4: |
| 10189 | proto_bitmap = config_params[3]; |
| 10190 | case 3: |
| 10191 | verbosity = config_params[2]; |
| 10192 | case 2: |
| 10193 | thresh = config_params[1]; |
| 10194 | case 1: |
| 10195 | live_mode = config_params[0]; |
| 10196 | default: |
| 10197 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 10198 | live_mode, thresh, thresh_time_limit, |
| 10199 | verbosity, proto_bitmap); |
| 10200 | }; |
| 10201 | |
| 10202 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10203 | verbosity, proto_bitmap); |
| 10204 | |
| 10205 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10206 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10207 | * hdd_wlan_startup() - HDD init function |
| 10208 | * @dev: Pointer to the underlying device |
| 10209 | * |
| 10210 | * This is the driver startup code executed once a WLAN device has been detected |
| 10211 | * |
| 10212 | * Return: 0 for success, < 0 for failure |
| 10213 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10214 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10215 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10216 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10217 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10218 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10219 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10220 | |
| 10221 | ENTER(); |
| 10222 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10223 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10224 | |
| 10225 | if (IS_ERR(hdd_ctx)) |
| 10226 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10227 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10228 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10229 | DEFAULT_PSOC_ID); |
| 10230 | if (ret) { |
| 10231 | hdd_err("Psoc creation fails!"); |
| 10232 | QDF_BUG(0); |
| 10233 | goto err_hdd_free_context; |
| 10234 | } |
| 10235 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10236 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10237 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10238 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10239 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10240 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10241 | hdd_request_manager_init(); |
Jeff Johnson | a7e5eed | 2016-09-28 15:19:13 -0700 | [diff] [blame] | 10242 | hdd_green_ap_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10243 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10244 | memdump_init(); |
| 10245 | hdd_driver_memdump_init(); |
| 10246 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10247 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10248 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10249 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10250 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10251 | } |
| 10252 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10253 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10254 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10255 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10256 | |
| 10257 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10258 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10259 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10260 | } |
| 10261 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10262 | ret = hdd_wiphy_init(hdd_ctx); |
| 10263 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10264 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10265 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10266 | } |
| 10267 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10268 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10269 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10270 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10271 | if (hdd_ipa_init(hdd_ctx) == QDF_STATUS_E_FAILURE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10272 | goto err_wiphy_unregister; |
| 10273 | |
Kapil Gupta | 4f0c0c1 | 2017-02-07 15:21:15 +0530 | [diff] [blame] | 10274 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10275 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10276 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10277 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10278 | ret = hdd_register_notifiers(hdd_ctx); |
| 10279 | if (ret) |
| 10280 | goto err_ipa_cleanup; |
| 10281 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10282 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10283 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10284 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10285 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10286 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10287 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10288 | } |
| 10289 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10290 | hdd_release_rtnl_lock(); |
| 10291 | rtnl_held = false; |
| 10292 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10293 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10294 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10295 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10296 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10297 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10298 | hdd_skip_acs_scan_timer_handler, |
| 10299 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10300 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10301 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10302 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10303 | #endif |
| 10304 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10305 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10306 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10307 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10308 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10309 | if (hdd_ctx->rps) |
| 10310 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10311 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 10312 | status = wlansap_global_init(); |
| 10313 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10314 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10315 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10316 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10317 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10318 | else |
| 10319 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10320 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10321 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10322 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10323 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10324 | hdd_prevent_suspend_timeout( |
| 10325 | hdd_ctx->config->iface_change_wait_time, |
| 10326 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10327 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10328 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 10329 | hdd_start_complete(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10330 | goto success; |
| 10331 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10332 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10333 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10334 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10335 | err_release_rtnl_lock: |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10336 | if (rtnl_held) |
| 10337 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10338 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10339 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10340 | |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10341 | err_ipa_cleanup: |
Anurag Chouhan | ce6a405 | 2016-09-14 18:20:42 +0530 | [diff] [blame] | 10342 | hdd_ipa_cleanup(hdd_ctx); |
Yun Park | 6a46ad8 | 2016-01-04 16:48:19 -0800 | [diff] [blame] | 10343 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10344 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10345 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10346 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10347 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10348 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10349 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10350 | err_memdump_deinit: |
| 10351 | hdd_driver_memdump_deinit(); |
| 10352 | memdump_deinit(); |
| 10353 | |
Houston Hoffman | 47a4a05 | 2016-11-14 23:22:44 -0800 | [diff] [blame] | 10354 | hdd_green_ap_deinit(hdd_ctx); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10355 | hdd_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10356 | hdd_exit_netlink_services(hdd_ctx); |
| 10357 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10358 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10359 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10360 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10361 | if (cds_is_fw_down()) |
| 10362 | hdd_err("Not setting the complete event as fw is down"); |
| 10363 | else |
| 10364 | hdd_start_complete(ret); |
| 10365 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10366 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10367 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10368 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10369 | |
| 10370 | success: |
| 10371 | EXIT(); |
| 10372 | return 0; |
| 10373 | } |
| 10374 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10375 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10376 | * hdd_wlan_update_target_info() - update target type info |
| 10377 | * @hdd_ctx: HDD context |
| 10378 | * @context: hif context |
| 10379 | * |
| 10380 | * Update target info received from firmware in hdd context |
| 10381 | * Return:None |
| 10382 | */ |
| 10383 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10384 | 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] | 10385 | { |
| 10386 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10387 | |
| 10388 | if (!tgt_info) { |
| 10389 | hdd_err("Target info is Null"); |
| 10390 | return; |
| 10391 | } |
| 10392 | |
| 10393 | hdd_ctx->target_type = tgt_info->target_type; |
| 10394 | } |
| 10395 | |
| 10396 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10397 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10398 | * received from the firmware |
| 10399 | * @data: pointer to adapter. |
| 10400 | * @rsp: pointer to data received from FW. |
| 10401 | * |
| 10402 | * This is called when wlan driver received response event for |
| 10403 | * get arp stats to firmware. |
| 10404 | * |
| 10405 | * Return: None |
| 10406 | */ |
| 10407 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10408 | { |
| 10409 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10410 | struct hdd_nud_stats_context *context; |
| 10411 | int status; |
| 10412 | struct hdd_adapter *adapter = NULL; |
| 10413 | |
| 10414 | ENTER(); |
| 10415 | |
| 10416 | if (!rsp) { |
| 10417 | hdd_err("data is null"); |
| 10418 | return; |
| 10419 | } |
| 10420 | |
| 10421 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10422 | if (0 != status) |
| 10423 | return; |
| 10424 | |
| 10425 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10426 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10427 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10428 | return; |
| 10429 | } |
| 10430 | |
| 10431 | hdd_notice("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10432 | hdd_notice("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10433 | hdd_notice("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10434 | hdd_notice("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10435 | hdd_notice("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10436 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10437 | hdd_notice("rsp->dad_detected :%x", rsp->dad_detected); |
| 10438 | hdd_notice("rsp->connect_status :%x", rsp->connect_status); |
| 10439 | hdd_notice("rsp->ba_session_establishment_status :%x", |
| 10440 | rsp->ba_session_establishment_status); |
| 10441 | |
| 10442 | adapter->hdd_stats.hdd_arp_stats.tx_fw_cnt = rsp->arp_req_enqueue; |
| 10443 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
| 10444 | adapter->hdd_stats.hdd_arp_stats.tx_ack_cnt = rsp->arp_req_tx_success; |
| 10445 | adapter->dad |= rsp->dad_detected; |
| 10446 | adapter->con_status = rsp->connect_status; |
| 10447 | |
| 10448 | spin_lock(&hdd_context_lock); |
| 10449 | context = &hdd_ctx->nud_stats_context; |
| 10450 | complete(&context->response_event); |
| 10451 | spin_unlock(&hdd_context_lock); |
| 10452 | |
| 10453 | EXIT(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10454 | } |
| 10455 | |
| 10456 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10457 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10458 | * @hdd_ctx: HDD context |
| 10459 | * |
| 10460 | * Register the HDD callbacks to CDS/SME. |
| 10461 | * |
| 10462 | * Return: 0 for success or Error code for failure |
| 10463 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10464 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10465 | { |
| 10466 | QDF_STATUS status; |
| 10467 | int ret = 0; |
| 10468 | |
| 10469 | ENTER(); |
| 10470 | |
| 10471 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10472 | |
| 10473 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10474 | hdd_send_oem_data_rsp_msg); |
| 10475 | |
| 10476 | status = sme_fw_mem_dump_register_cb(hdd_ctx->hHal, |
| 10477 | wlan_hdd_cfg80211_fw_mem_dump_cb); |
| 10478 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10479 | hdd_err("Failed to register memdump callback"); |
| 10480 | ret = -EINVAL; |
| 10481 | return ret; |
| 10482 | } |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10483 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10484 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10485 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10486 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10487 | wlan_hdd_cfg80211_nan_callback); |
| 10488 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10489 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10490 | |
| 10491 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10492 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10493 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10494 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10495 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10496 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10497 | hdd_rssi_threshold_breached); |
| 10498 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10499 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10500 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10501 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10502 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10503 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10504 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10505 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10506 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10507 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10508 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10509 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10510 | hdd_lost_link_info_cb); |
| 10511 | /* print error and not block the startup process */ |
| 10512 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10513 | hdd_err("set lost link info callback failed"); |
| 10514 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10515 | ret = hdd_register_data_stall_detect_cb(); |
| 10516 | if (ret) { |
| 10517 | hdd_err("Register data stall detect detect callback failed."); |
| 10518 | return ret; |
| 10519 | } |
| 10520 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10521 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10522 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10523 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10524 | hdd_set_connection_in_progress, |
| 10525 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10526 | |
| 10527 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10528 | hdd_update_cca_info_cb); |
| 10529 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10530 | hdd_err("set congestion callback failed"); |
| 10531 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10532 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10533 | hdd_bt_activity_cb); |
| 10534 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10535 | hdd_err("set bt activity info callback failed"); |
| 10536 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10537 | EXIT(); |
| 10538 | |
| 10539 | return ret; |
| 10540 | } |
| 10541 | |
| 10542 | /** |
| 10543 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10544 | * @hdd_ctx: HDD context |
| 10545 | * |
| 10546 | * De-Register the HDD callbacks to CDS/SME. |
| 10547 | * |
| 10548 | * Return: void |
| 10549 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10550 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10551 | { |
| 10552 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10553 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10554 | |
| 10555 | ENTER(); |
| 10556 | |
| 10557 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10558 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10559 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10560 | status); |
| 10561 | |
| 10562 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10563 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10564 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10565 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10566 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10567 | |
| 10568 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10569 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10570 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10571 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10572 | status); |
| 10573 | status = sme_fw_mem_dump_unregister_cb(hdd_ctx->hHal); |
| 10574 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10575 | hdd_err("Failed to de-register the fw mem dump callback: %d", |
| 10576 | status); |
| 10577 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10578 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10579 | if (ret) |
| 10580 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10581 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10582 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10583 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10584 | |
| 10585 | EXIT(); |
| 10586 | } |
| 10587 | |
| 10588 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10589 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10590 | * @adapter: Pointer to the HDD |
| 10591 | * @enable: bool value |
| 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 | QDF_STATUS hdd_softap_sta_deauth(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 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10600 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10601 | |
| 10602 | ENTER(); |
| 10603 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10604 | /* Ignore request to deauth bcmc station */ |
| 10605 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10606 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10607 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10608 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10609 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 10610 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10611 | |
| 10612 | EXIT(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10613 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10614 | } |
| 10615 | |
| 10616 | /** |
| 10617 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 10618 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10619 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10620 | * |
| 10621 | * This to take counter measure to handle deauth req from HDD |
| 10622 | * |
| 10623 | * Return: None |
| 10624 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10625 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10626 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10627 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10628 | ENTER(); |
| 10629 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10630 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10631 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10632 | return; |
| 10633 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10634 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 10635 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10636 | } |
| 10637 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10638 | /** |
| 10639 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 10640 | * @hdd_ctx: HDD Context |
| 10641 | * |
| 10642 | * API to find if there is any STA or P2P-Client is connected |
| 10643 | * |
| 10644 | * Return: true if connected; false otherwise |
| 10645 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10646 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10647 | { |
| 10648 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 10649 | } |
| 10650 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10651 | /** |
| 10652 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 10653 | * @adapter: HDD adapter pointer |
| 10654 | * |
| 10655 | * This function loop through each adapter and disable roaming on each STA |
| 10656 | * device mode except the input adapter. |
| 10657 | * |
| 10658 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 10659 | * disable. |
| 10660 | * |
| 10661 | * Return: None |
| 10662 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10663 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10664 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10665 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10666 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10667 | |
| 10668 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10669 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10670 | QDF_STA_MODE == adapter->device_mode && |
| 10671 | policy_mgr_is_sta_active_connection_exists( |
| 10672 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10673 | hdd_debug("Connect received on STA session Id(%d)", |
| 10674 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10675 | /* |
| 10676 | * Loop through adapter and disable roaming for each STA device |
| 10677 | * mode except the input adapter. |
| 10678 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10679 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10680 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10681 | adapter->session_id != adapterIdx->session_id) { |
| 10682 | hdd_debug("Disable Roaming on session Id(%d)", |
| 10683 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10684 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 10685 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10686 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10687 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10688 | } |
| 10689 | } |
| 10690 | } |
| 10691 | |
| 10692 | /** |
| 10693 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 10694 | * @adapter: HDD adapter pointer |
| 10695 | * |
| 10696 | * This function loop through each adapter and enable roaming on each STA |
| 10697 | * device mode except the input adapter. |
| 10698 | * Note: On the input adapter no need to enable roaming because link got |
| 10699 | * disconnected on this. |
| 10700 | * |
| 10701 | * Return: None |
| 10702 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10703 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10704 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10705 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10706 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10707 | |
| 10708 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10709 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 10710 | QDF_STA_MODE == adapter->device_mode && |
| 10711 | policy_mgr_is_sta_active_connection_exists( |
| 10712 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10713 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 10714 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10715 | /* |
| 10716 | * Loop through adapter and enable roaming for each STA device |
| 10717 | * mode except the input adapter. |
| 10718 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10719 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10720 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 10721 | adapter->session_id != adapterIdx->session_id) { |
| 10722 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 10723 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10724 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 10725 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 10726 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10727 | REASON_CONNECT); |
| 10728 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10729 | } |
| 10730 | } |
| 10731 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10732 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10733 | /** |
| 10734 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 10735 | * @skb: sk buffer pointer |
| 10736 | * |
| 10737 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 10738 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 10739 | * |
| 10740 | * Return: None |
| 10741 | */ |
| 10742 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 10743 | { |
| 10744 | #ifdef CNSS_GENL |
| 10745 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 10746 | #else |
| 10747 | nl_srv_bcast(skb); |
| 10748 | #endif |
| 10749 | } |
| 10750 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10751 | 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] | 10752 | { |
| 10753 | struct sk_buff *skb; |
| 10754 | struct nlmsghdr *nlh; |
| 10755 | tAniMsgHdr *ani_hdr; |
| 10756 | void *nl_data = NULL; |
| 10757 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10758 | struct radio_index_tlv *radio_info; |
| 10759 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10760 | |
| 10761 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 10762 | flags = GFP_ATOMIC; |
| 10763 | |
| 10764 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 10765 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10766 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10767 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10768 | |
| 10769 | nlh = (struct nlmsghdr *)skb->data; |
| 10770 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 10771 | nlh->nlmsg_flags = 0; |
| 10772 | nlh->nlmsg_seq = 0; |
| 10773 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 10774 | |
| 10775 | ani_hdr = NLMSG_DATA(nlh); |
| 10776 | ani_hdr->type = type; |
| 10777 | |
| 10778 | switch (type) { |
| 10779 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 10780 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10781 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10782 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10783 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10784 | ani_hdr->length = 0; |
| 10785 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10786 | break; |
| 10787 | case WLAN_SVC_WLAN_STATUS_IND: |
| 10788 | case WLAN_SVC_WLAN_VERSION_IND: |
| 10789 | case WLAN_SVC_DFS_CAC_START_IND: |
| 10790 | case WLAN_SVC_DFS_CAC_END_IND: |
| 10791 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 10792 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 10793 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 10794 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10795 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 10796 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10797 | ani_hdr->length = len; |
| 10798 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 10799 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 10800 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10801 | break; |
| 10802 | |
| 10803 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10804 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10805 | type); |
| 10806 | kfree_skb(skb); |
| 10807 | return; |
| 10808 | } |
| 10809 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10810 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 10811 | * Add radio index at the end of the svc event in TLV format |
| 10812 | * to maintain the backward compatibility with userspace |
| 10813 | * applications. |
| 10814 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10815 | |
| 10816 | tlv_len = 0; |
| 10817 | |
| 10818 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 10819 | < WLAN_NL_MAX_PAYLOAD) { |
| 10820 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 10821 | sizeof(*ani_hdr) + len); |
| 10822 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 10823 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 10824 | radio_info->radio = radio; |
| 10825 | tlv_len = sizeof(*radio_info); |
Srinivas Girigowda | c06543c | 2017-03-09 15:10:03 -0800 | [diff] [blame] | 10826 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG, |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10827 | "Added radio index tlv - radio index %d", |
| 10828 | radio_info->radio); |
| 10829 | } |
| 10830 | |
| 10831 | nlh->nlmsg_len += tlv_len; |
| 10832 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 10833 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 10834 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10835 | } |
| 10836 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10837 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10838 | void wlan_hdd_auto_shutdown_cb(void) |
| 10839 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10840 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10841 | |
| 10842 | if (!hdd_ctx) |
| 10843 | return; |
| 10844 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10845 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10846 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 10847 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10848 | } |
| 10849 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10850 | 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] | 10851 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10852 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10853 | bool ap_connected = false, sta_connected = false; |
| 10854 | tHalHandle hal_handle; |
| 10855 | |
| 10856 | hal_handle = hdd_ctx->hHal; |
| 10857 | if (hal_handle == NULL) |
| 10858 | return; |
| 10859 | |
| 10860 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 10861 | return; |
| 10862 | |
| 10863 | if (enable == false) { |
| 10864 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10865 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 10866 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10867 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 10868 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 10869 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10870 | return; |
| 10871 | } |
| 10872 | |
| 10873 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10874 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 10875 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10876 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10877 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10878 | conn_info.connState == |
| 10879 | eConnectionState_Associated) { |
| 10880 | sta_connected = true; |
| 10881 | break; |
| 10882 | } |
| 10883 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10884 | |
| 10885 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10886 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10887 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10888 | ap_connected = true; |
| 10889 | break; |
| 10890 | } |
| 10891 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10892 | } |
| 10893 | } |
| 10894 | |
| 10895 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10896 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10897 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10898 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 10899 | |
| 10900 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 10901 | hdd_ctx->config->WlanAutoShutdown) |
| 10902 | != QDF_STATUS_SUCCESS) |
| 10903 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 10904 | else |
| 10905 | hdd_notice("Auto Shutdown timer for %d seconds enabled", |
| 10906 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10907 | } |
| 10908 | #endif |
| 10909 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10910 | struct hdd_adapter * |
| 10911 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 10912 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10913 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10914 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10915 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10916 | |
| 10917 | con_sap_adapter = NULL; |
| 10918 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10919 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 10920 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 10921 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10922 | adapter != this_sap_adapter) { |
| 10923 | if (check_start_bss) { |
| 10924 | if (test_bit(SOFTAP_BSS_STARTED, |
| 10925 | &adapter->event_flags)) { |
| 10926 | con_sap_adapter = adapter; |
| 10927 | break; |
| 10928 | } |
| 10929 | } else { |
| 10930 | con_sap_adapter = adapter; |
| 10931 | break; |
| 10932 | } |
| 10933 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10934 | } |
| 10935 | |
| 10936 | return con_sap_adapter; |
| 10937 | } |
| 10938 | |
| 10939 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10940 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10941 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10942 | return adapter->device_mode == QDF_STA_MODE || |
| 10943 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10944 | } |
| 10945 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10946 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10947 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10948 | return adapter->device_mode == QDF_SAP_MODE || |
| 10949 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 10950 | } |
| 10951 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10952 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10953 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10954 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10955 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10956 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 10957 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10958 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 10959 | conn_info.connState == eConnectionState_Associated) { |
| 10960 | return true; |
| 10961 | } |
| 10962 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10963 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 10964 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10965 | return true; |
| 10966 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10967 | } |
| 10968 | |
| 10969 | return false; |
| 10970 | } |
| 10971 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10972 | 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] | 10973 | { |
| 10974 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10975 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10976 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10977 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 10978 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10979 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10980 | return is_running; |
| 10981 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10982 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10983 | 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] | 10984 | { |
| 10985 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 10986 | hdd_ctx->bus_bw_timer_running = true; |
| 10987 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 10988 | hdd_ctx->config->busBandwidthComputeInterval); |
| 10989 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 10990 | } |
| 10991 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10992 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 10993 | { |
| 10994 | ENTER(); |
| 10995 | |
| 10996 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 10997 | hdd_debug("Bandwidth compute timer already started"); |
| 10998 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10999 | } |
| 11000 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11001 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11002 | |
| 11003 | EXIT(); |
| 11004 | } |
| 11005 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11006 | 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] | 11007 | { |
| 11008 | ENTER(); |
| 11009 | |
| 11010 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11011 | hdd_debug("Bandwidth compute timer already started"); |
| 11012 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11013 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11014 | |
| 11015 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11016 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11017 | |
| 11018 | EXIT(); |
| 11019 | } |
| 11020 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11021 | 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] | 11022 | { |
| 11023 | hdd_ipa_set_perf_level(hdd_ctx, 0, 0); |
| 11024 | |
| 11025 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11026 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11027 | hdd_ctx->bus_bw_timer_running = false; |
| 11028 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11029 | |
| 11030 | hdd_reset_tcp_delack(hdd_ctx); |
| 11031 | } |
| 11032 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11033 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11034 | { |
| 11035 | ENTER(); |
| 11036 | |
| 11037 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11038 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11039 | return; |
| 11040 | } |
| 11041 | |
| 11042 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11043 | |
| 11044 | EXIT(); |
| 11045 | } |
| 11046 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11047 | 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] | 11048 | { |
| 11049 | ENTER(); |
| 11050 | |
| 11051 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11052 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11053 | return; |
| 11054 | } |
| 11055 | |
| 11056 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11057 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11058 | |
| 11059 | EXIT(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11060 | } |
| 11061 | #endif |
| 11062 | |
| 11063 | /** |
| 11064 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11065 | * and sta's operating channel. |
| 11066 | * @sta_adapter: Describe the first argument to foobar. |
| 11067 | * @ap_adapter: Describe the second argument to foobar. |
| 11068 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11069 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11070 | * set this flag to true else false. |
| 11071 | * |
| 11072 | * This function checks the sap's operating channel and sta's operating channel. |
| 11073 | * if both are same then it will return false else it will restart the sap in |
| 11074 | * sta's channel and return true. |
| 11075 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11076 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11077 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11078 | QDF_STATUS |
| 11079 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11080 | struct hdd_adapter *ap_adapter, |
| 11081 | tCsrRoamProfile *roam_profile, |
| 11082 | tScanResultHandle *scan_cache, |
| 11083 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11084 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11085 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11086 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11087 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11088 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11089 | *concurrent_chnl_same = true; |
| 11090 | |
| 11091 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11092 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11093 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11094 | scan_cache, |
| 11095 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11096 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11097 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11098 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11099 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11100 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11101 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11102 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11103 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11104 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11105 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11106 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11107 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11108 | } |
| 11109 | } |
| 11110 | } else { |
| 11111 | /* |
| 11112 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11113 | * failed so we have to stop the SAP to avoid any channel |
| 11114 | * discrepancy between SAP's channel and STA's channel. |
| 11115 | * Return the status as failure so caller function could know |
| 11116 | * that scan look up is failed. |
| 11117 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11118 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11119 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11120 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11121 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11122 | } |
| 11123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11124 | /** |
| 11125 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11126 | * @ap_adapter: SAP adapter |
| 11127 | * |
| 11128 | * This function will process the stopping of sap adapter. |
| 11129 | * |
| 11130 | * Return: None |
| 11131 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11132 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11133 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11134 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11135 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11136 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11137 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11138 | |
| 11139 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11140 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11141 | return; |
| 11142 | } |
| 11143 | |
| 11144 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11145 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11146 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11147 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11148 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11149 | mutex_lock(&hdd_ctx->sap_lock); |
| 11150 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11151 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11152 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11153 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11154 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11155 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11156 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11157 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11158 | qdf_stop_bss_event, |
| 11159 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11160 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11161 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11162 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11163 | return; |
| 11164 | } |
| 11165 | } |
| 11166 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11167 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11168 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11169 | ap_adapter->session_id); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11170 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11171 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11172 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11173 | } |
| 11174 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11175 | } |
| 11176 | |
| 11177 | /** |
| 11178 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11179 | * @ap_adapter: SAP adapter |
| 11180 | * |
| 11181 | * This function will process the starting of sap adapter. |
| 11182 | * |
| 11183 | * Return: None |
| 11184 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11185 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11186 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11187 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11188 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11189 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11190 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11191 | tsap_Config_t *sap_config; |
| 11192 | |
| 11193 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11194 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11195 | return; |
| 11196 | } |
| 11197 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11198 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11199 | hdd_err("SoftAp role has not been enabled"); |
| 11200 | return; |
| 11201 | } |
| 11202 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11203 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11204 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11205 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11206 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11207 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11208 | mutex_lock(&hdd_ctx->sap_lock); |
| 11209 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11210 | goto end; |
| 11211 | |
| 11212 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11213 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11214 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 11215 | goto end; |
| 11216 | } |
| 11217 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11218 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11219 | 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] | 11220 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11222 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11223 | goto end; |
| 11224 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11225 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11226 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11227 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11228 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11229 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11230 | goto end; |
| 11231 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11232 | hdd_info("SAP Start Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11233 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 11234 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11235 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11236 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11237 | ap_adapter->session_id); |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11238 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11239 | |
| 11240 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11241 | end: |
| 11242 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11243 | /* SAP context and beacon cleanup will happen during driver unload |
| 11244 | * in hdd_stop_adapter |
| 11245 | */ |
| 11246 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11247 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11248 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11249 | |
| 11250 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11251 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11252 | * mac scan config |
| 11253 | * @status: Status of set antenna mode |
| 11254 | * |
| 11255 | * Callback on setting the dual mac configuration |
| 11256 | * |
| 11257 | * Return: None |
| 11258 | */ |
| 11259 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11260 | enum set_antenna_mode_status status) |
| 11261 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11262 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11263 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11264 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11265 | |
| 11266 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11267 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11268 | return; |
| 11269 | |
| 11270 | /* Signal the completion of set dual mac config */ |
| 11271 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11272 | } |
| 11273 | |
| 11274 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11275 | * hdd_get_fw_version() - Get FW version |
| 11276 | * @hdd_ctx: pointer to HDD context. |
| 11277 | * @major_spid: FW version - major spid. |
| 11278 | * @minor_spid: FW version - minor spid |
| 11279 | * @ssid: FW version - ssid |
| 11280 | * @crmid: FW version - crmid |
| 11281 | * |
| 11282 | * This function is called to get the firmware build version stored |
| 11283 | * as part of the HDD context |
| 11284 | * |
| 11285 | * Return: None |
| 11286 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11287 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11288 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11289 | uint32_t *siid, uint32_t *crmid) |
| 11290 | { |
| 11291 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11292 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11293 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11294 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11295 | } |
| 11296 | |
| 11297 | #ifdef QCA_CONFIG_SMP |
| 11298 | /** |
| 11299 | * wlan_hdd_get_cpu() - get cpu_index |
| 11300 | * |
| 11301 | * Return: cpu_index |
| 11302 | */ |
| 11303 | int wlan_hdd_get_cpu(void) |
| 11304 | { |
| 11305 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11306 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11307 | put_cpu(); |
| 11308 | return cpu_index; |
| 11309 | } |
| 11310 | #endif |
| 11311 | |
| 11312 | /** |
| 11313 | * hdd_get_fwpath() - get framework path |
| 11314 | * |
| 11315 | * This function is used to get the string written by |
| 11316 | * userspace to start the wlan driver |
| 11317 | * |
| 11318 | * Return: string |
| 11319 | */ |
| 11320 | const char *hdd_get_fwpath(void) |
| 11321 | { |
| 11322 | return fwpath.string; |
| 11323 | } |
| 11324 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11325 | static int hdd_qdf_print_init(void) |
| 11326 | { |
| 11327 | int qdf_print_idx; |
| 11328 | QDF_STATUS status; |
| 11329 | |
| 11330 | status = qdf_print_setup(); |
| 11331 | if (status != QDF_STATUS_SUCCESS) { |
| 11332 | pr_err("qdf_print_setup failed\n"); |
| 11333 | return -EINVAL; |
| 11334 | } |
| 11335 | |
| 11336 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11337 | |
| 11338 | if (qdf_print_idx < 0) { |
| 11339 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11340 | qdf_print_idx); |
| 11341 | return -EINVAL; |
| 11342 | } |
| 11343 | |
| 11344 | qdf_set_pidx(qdf_print_idx); |
| 11345 | |
| 11346 | return 0; |
| 11347 | } |
| 11348 | |
| 11349 | static void hdd_qdf_print_deinit(void) |
| 11350 | { |
| 11351 | int qdf_print_idx; |
| 11352 | |
| 11353 | qdf_print_idx = qdf_get_pidx(); |
| 11354 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11355 | } |
| 11356 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11357 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11358 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11359 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11360 | * This function initilizes CDS global context with the help of cds_init. This |
| 11361 | * has to be the first function called after probe to get a valid global |
| 11362 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11363 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11364 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11365 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11366 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11367 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11368 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11369 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11370 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11371 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11372 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11373 | hdd_err("Failed to allocate CDS context"); |
| 11374 | ret = -ENOMEM; |
| 11375 | goto err_out; |
| 11376 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11377 | |
| 11378 | wlan_init_bug_report_lock(); |
| 11379 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11380 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11381 | wlan_logging_sock_init_svc(); |
| 11382 | #endif |
| 11383 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11384 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11385 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11386 | QDF_TIMER_TYPE_SW); |
| 11387 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11388 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11389 | hdd_qdf_print_init(); |
| 11390 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11391 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11392 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11393 | err_out: |
| 11394 | return ret; |
| 11395 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11396 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11397 | /** |
| 11398 | * hdd_deinit() - Deinitialize Driver |
| 11399 | * |
| 11400 | * This function frees CDS global context with the help of cds_deinit. This |
| 11401 | * has to be the last function call in remove callback to free the global |
| 11402 | * context. |
| 11403 | */ |
| 11404 | void hdd_deinit(void) |
| 11405 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11406 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11407 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11408 | wlan_destroy_bug_report_lock(); |
| 11409 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11410 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11411 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11412 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11413 | wlan_logging_sock_deinit_svc(); |
| 11414 | #endif |
| 11415 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11416 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11417 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11418 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11419 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11420 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11421 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11422 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11423 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11424 | struct file *file) |
| 11425 | { |
| 11426 | return 0; |
| 11427 | } |
| 11428 | |
| 11429 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11430 | const char __user *user_buf, |
| 11431 | size_t count, |
| 11432 | loff_t *f_pos) |
| 11433 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11434 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11435 | static const char wlan_off_str[] = "OFF"; |
| 11436 | static const char wlan_on_str[] = "ON"; |
| 11437 | int ret; |
| 11438 | unsigned long rc; |
| 11439 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11440 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11441 | pr_err("Failed to read buffer\n"); |
| 11442 | return -EINVAL; |
| 11443 | } |
| 11444 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11445 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11446 | pr_debug("Wifi turning off from UI\n"); |
| 11447 | goto exit; |
| 11448 | } |
| 11449 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11450 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11451 | pr_err("Invalid value received from framework"); |
| 11452 | goto exit; |
| 11453 | } |
| 11454 | |
| 11455 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11456 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11457 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11458 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11459 | if (!rc) { |
| 11460 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11461 | ret = -EINVAL; |
| 11462 | hdd_start_complete(ret); |
| 11463 | return ret; |
| 11464 | } |
| 11465 | |
| 11466 | hdd_start_complete(0); |
| 11467 | } |
| 11468 | |
| 11469 | exit: |
| 11470 | return count; |
| 11471 | } |
| 11472 | |
| 11473 | |
| 11474 | const struct file_operations wlan_hdd_state_fops = { |
| 11475 | .owner = THIS_MODULE, |
| 11476 | .open = wlan_hdd_state_ctrl_param_open, |
| 11477 | .write = wlan_hdd_state_ctrl_param_write, |
| 11478 | }; |
| 11479 | |
| 11480 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11481 | { |
| 11482 | unsigned int wlan_hdd_state_major = 0; |
| 11483 | int ret; |
| 11484 | struct device *dev; |
| 11485 | |
| 11486 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11487 | |
| 11488 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11489 | if (ret) { |
| 11490 | pr_err("Failed to register qcwlanstate"); |
| 11491 | goto dev_alloc_err; |
| 11492 | } |
| 11493 | wlan_hdd_state_major = MAJOR(device); |
| 11494 | |
| 11495 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11496 | if (IS_ERR(class)) { |
| 11497 | pr_err("wlan_hdd_state class_create error"); |
| 11498 | goto class_err; |
| 11499 | } |
| 11500 | |
| 11501 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11502 | if (IS_ERR(dev)) { |
| 11503 | pr_err("wlan_hdd_statedevice_create error"); |
| 11504 | goto err_class_destroy; |
| 11505 | } |
| 11506 | |
| 11507 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11508 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11509 | if (ret) { |
| 11510 | pr_err("Failed to add cdev error"); |
| 11511 | goto cdev_add_err; |
| 11512 | } |
| 11513 | |
| 11514 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11515 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11516 | |
| 11517 | return 0; |
| 11518 | |
| 11519 | cdev_add_err: |
| 11520 | device_destroy(class, device); |
| 11521 | err_class_destroy: |
| 11522 | class_destroy(class); |
| 11523 | class_err: |
| 11524 | unregister_chrdev_region(device, dev_num); |
| 11525 | dev_alloc_err: |
| 11526 | return -ENODEV; |
| 11527 | } |
| 11528 | |
| 11529 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11530 | { |
| 11531 | cdev_del(&wlan_hdd_state_cdev); |
| 11532 | device_destroy(class, device); |
| 11533 | class_destroy(class); |
| 11534 | unregister_chrdev_region(device, dev_num); |
| 11535 | |
| 11536 | pr_info("Device node unregistered"); |
| 11537 | } |
| 11538 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11539 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11540 | * component_init - API to init cld component's |
| 11541 | * |
| 11542 | * Return: None |
| 11543 | */ |
| 11544 | static void component_init(void) |
| 11545 | { |
| 11546 | pmo_init(); |
| 11547 | } |
| 11548 | |
| 11549 | /** |
| 11550 | * component_deinit - API to deinit cld component's |
| 11551 | * |
| 11552 | * Return: None |
| 11553 | */ |
| 11554 | static void component_deinit(void) |
| 11555 | { |
| 11556 | pmo_deinit(); |
| 11557 | } |
| 11558 | |
| 11559 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11560 | * __hdd_module_init - Module init helper |
| 11561 | * |
| 11562 | * Module init helper function used by both module and static driver. |
| 11563 | * |
| 11564 | * Return: 0 for success, errno on failure |
| 11565 | */ |
| 11566 | static int __hdd_module_init(void) |
| 11567 | { |
| 11568 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11569 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11570 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11571 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11572 | g_wlan_driver_version, |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11573 | TIMER_MANAGER_STR MEMORY_DEBUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11574 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11575 | ret = wlan_hdd_state_ctrl_param_create(); |
| 11576 | if (ret) { |
| 11577 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 11578 | goto err_dev_state; |
| 11579 | } |
| 11580 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11581 | pld_init(); |
| 11582 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11583 | ret = hdd_init(); |
| 11584 | if (ret) { |
| 11585 | pr_err("hdd_init failed %x\n", ret); |
| 11586 | goto err_hdd_init; |
| 11587 | } |
| 11588 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11589 | dispatcher_init(); |
| 11590 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11591 | /* Ensure to call post objmgr init */ |
| 11592 | component_init(); |
| 11593 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11594 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11595 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11596 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11597 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11598 | ret = wlan_hdd_register_driver(); |
| 11599 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 11600 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 11601 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11602 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11603 | } |
| 11604 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11605 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11606 | |
| 11607 | return 0; |
| 11608 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11609 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 11610 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11611 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11612 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11613 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11614 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11615 | pld_deinit(); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11616 | wlan_hdd_state_ctrl_param_destroy(); |
| 11617 | err_dev_state: |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11618 | return ret; |
| 11619 | } |
| 11620 | |
| 11621 | /** |
| 11622 | * __hdd_module_exit - Module exit helper |
| 11623 | * |
| 11624 | * Module exit helper function used by both module and static driver. |
| 11625 | */ |
| 11626 | static void __hdd_module_exit(void) |
| 11627 | { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 11628 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11629 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 11630 | QWLAN_VERSIONSTR); |
| 11631 | |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 11632 | hdd_wait_for_recovery_completion(); |
| 11633 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11634 | wlan_hdd_unregister_driver(); |
| 11635 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 11636 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11637 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11638 | /* Ensure to call prior to objmgr deinit */ |
| 11639 | component_deinit(); |
| 11640 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 11641 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 11642 | |
| 11643 | hdd_sysfs_destroy_version_interface(); |
| 11644 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11645 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 11646 | pld_deinit(); |
| 11647 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11648 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11649 | } |
| 11650 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11651 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11652 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11653 | * wlan_boot_cb() - Wlan boot callback |
| 11654 | * @kobj: object whose directory we're creating the link in. |
| 11655 | * @attr: attribute the user is interacting with |
| 11656 | * @buff: the buffer containing the user data |
| 11657 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11658 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11659 | * This callback is invoked when the fs is ready to start the |
| 11660 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11661 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11662 | * 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] | 11663 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11664 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11665 | struct kobj_attribute *attr, |
| 11666 | const char *buf, |
| 11667 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11668 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11669 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11670 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11671 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 11672 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11673 | } |
| 11674 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11675 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11676 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 11677 | return -EIO; |
| 11678 | } |
| 11679 | |
| 11680 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11681 | |
| 11682 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11683 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11684 | |
| 11685 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11686 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 11687 | * |
| 11688 | * Return: None |
| 11689 | * |
| 11690 | */ |
| 11691 | static void hdd_sysfs_cleanup(void) |
| 11692 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11693 | /* remove from group */ |
| 11694 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 11695 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 11696 | wlan_loader->attr_group); |
| 11697 | |
| 11698 | /* unlink the object from parent */ |
| 11699 | kobject_del(wlan_loader->boot_wlan_obj); |
| 11700 | |
| 11701 | /* free the object */ |
| 11702 | kobject_put(wlan_loader->boot_wlan_obj); |
| 11703 | |
| 11704 | kfree(wlan_loader->attr_group); |
| 11705 | kfree(wlan_loader); |
| 11706 | |
| 11707 | wlan_loader = NULL; |
| 11708 | } |
| 11709 | |
| 11710 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11711 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 11712 | * ready |
| 11713 | * |
| 11714 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 11715 | * when the filesystem is ready. |
| 11716 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11717 | * QDF API cannot be used here since this function is called even before |
| 11718 | * initializing WLAN driver. |
| 11719 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11720 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11721 | */ |
| 11722 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11723 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11724 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11725 | |
| 11726 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11727 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11728 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11729 | |
| 11730 | wlan_loader->boot_wlan_obj = NULL; |
| 11731 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 11732 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11733 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11734 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11735 | |
| 11736 | wlan_loader->loaded_state = 0; |
| 11737 | wlan_loader->attr_group->attrs = attrs; |
| 11738 | |
| 11739 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 11740 | kernel_kobj); |
| 11741 | if (!wlan_loader->boot_wlan_obj) { |
| 11742 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11743 | goto error_return; |
| 11744 | } |
| 11745 | |
| 11746 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 11747 | wlan_loader->attr_group); |
| 11748 | if (ret) { |
| 11749 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 11750 | goto error_return; |
| 11751 | } |
| 11752 | |
| 11753 | return 0; |
| 11754 | |
| 11755 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11756 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11757 | |
| 11758 | return ret; |
| 11759 | } |
| 11760 | |
| 11761 | /** |
| 11762 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 11763 | * |
| 11764 | * Return: 0 on success or errno on failure |
| 11765 | */ |
| 11766 | static int wlan_deinit_sysfs(void) |
| 11767 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11768 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11769 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11770 | return -EINVAL; |
| 11771 | } |
| 11772 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11773 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11774 | return 0; |
| 11775 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11776 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 11777 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11778 | |
| 11779 | #ifdef MODULE |
| 11780 | /** |
| 11781 | * __hdd_module_init - Module init helper |
| 11782 | * |
| 11783 | * Module init helper function used by both module and static driver. |
| 11784 | * |
| 11785 | * Return: 0 for success, errno on failure |
| 11786 | */ |
| 11787 | static int hdd_module_init(void) |
| 11788 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11789 | if (__hdd_module_init()) { |
| 11790 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11791 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11792 | } |
| 11793 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11794 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11795 | } |
| 11796 | #else |
| 11797 | static int __init hdd_module_init(void) |
| 11798 | { |
| 11799 | int ret = -EINVAL; |
| 11800 | |
| 11801 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 11802 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11803 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 11804 | |
| 11805 | return ret; |
| 11806 | } |
| 11807 | #endif |
| 11808 | |
| 11809 | |
| 11810 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11811 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11812 | * hdd_module_exit() - Exit function |
| 11813 | * |
| 11814 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 11815 | * |
| 11816 | * Return: None |
| 11817 | */ |
| 11818 | static void __exit hdd_module_exit(void) |
| 11819 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11820 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11821 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11822 | #else |
| 11823 | static void __exit hdd_module_exit(void) |
| 11824 | { |
| 11825 | __hdd_module_exit(); |
| 11826 | wlan_deinit_sysfs(); |
| 11827 | } |
| 11828 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11829 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11830 | static int fwpath_changed_handler(const char *kmessage, struct kernel_param *kp) |
| 11831 | { |
| 11832 | return param_set_copystring(kmessage, kp); |
| 11833 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11834 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11835 | /** |
| 11836 | * is_con_mode_valid() check con mode is valid or not |
| 11837 | * @mode: global con mode |
| 11838 | * |
| 11839 | * Return: TRUE on success FALSE on failure |
| 11840 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11841 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11842 | { |
| 11843 | switch (mode) { |
| 11844 | case QDF_GLOBAL_MONITOR_MODE: |
| 11845 | case QDF_GLOBAL_FTM_MODE: |
| 11846 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11847 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11848 | return true; |
| 11849 | default: |
| 11850 | return false; |
| 11851 | } |
| 11852 | } |
| 11853 | |
| 11854 | /** |
| 11855 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 11856 | * @mode: global con mode |
| 11857 | * |
| 11858 | * Return: adapter mode |
| 11859 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11860 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11861 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11862 | { |
| 11863 | |
| 11864 | switch (mode) { |
| 11865 | case QDF_GLOBAL_MISSION_MODE: |
| 11866 | return QDF_STA_MODE; |
| 11867 | case QDF_GLOBAL_MONITOR_MODE: |
| 11868 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11869 | case QDF_GLOBAL_EPPING_MODE: |
| 11870 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11871 | case QDF_GLOBAL_FTM_MODE: |
| 11872 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11873 | case QDF_GLOBAL_QVIT_MODE: |
| 11874 | return QDF_QVIT_MODE; |
| 11875 | default: |
| 11876 | return QDF_MAX_NO_OF_MODE; |
| 11877 | } |
| 11878 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11879 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11880 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11881 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11882 | { |
| 11883 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 11884 | return; |
| 11885 | |
| 11886 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11887 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 11888 | hdd_info("Release wakelock for monitor mode!"); |
| 11889 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 11890 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 11891 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 11892 | case QDF_GLOBAL_FTM_MODE: |
| 11893 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 11894 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev); |
| 11895 | |
| 11896 | /* re-use the existing session */ |
| 11897 | hdd_stop_all_adapters(hdd_ctx, false); |
| 11898 | break; |
| 11899 | default: |
| 11900 | break; |
| 11901 | } |
| 11902 | } |
| 11903 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11904 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11905 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11906 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 11907 | int driver_status; |
| 11908 | |
| 11909 | driver_status = hdd_ctx->driver_status; |
| 11910 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11911 | switch (curr_mode) { |
| 11912 | case QDF_GLOBAL_MISSION_MODE: |
| 11913 | case QDF_GLOBAL_MONITOR_MODE: |
| 11914 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11915 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 11916 | hdd_close_all_adapters(hdd_ctx, false); |
| 11917 | break; |
| 11918 | case QDF_GLOBAL_EPPING_MODE: |
| 11919 | epping_disable(); |
| 11920 | epping_close(); |
| 11921 | break; |
| 11922 | default: |
| 11923 | return; |
| 11924 | } |
| 11925 | } |
| 11926 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11927 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 11928 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11929 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11930 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11931 | int ret = 0; |
| 11932 | bool rtnl_held; |
| 11933 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11934 | QDF_STATUS status; |
| 11935 | |
| 11936 | if (!qdf_dev) { |
| 11937 | hdd_err("qdf device context is Null return!"); |
| 11938 | return -EINVAL; |
| 11939 | } |
| 11940 | |
| 11941 | rtnl_held = hdd_hold_rtnl_lock(); |
| 11942 | switch (mode) { |
| 11943 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11944 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11945 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11946 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11947 | break; |
| 11948 | case QDF_GLOBAL_FTM_MODE: |
| 11949 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 11950 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11951 | NET_NAME_UNKNOWN, rtnl_held); |
| 11952 | if (adapter == NULL) |
| 11953 | ret = -EINVAL; |
| 11954 | break; |
| 11955 | case QDF_GLOBAL_MONITOR_MODE: |
| 11956 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 11957 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 11958 | NET_NAME_UNKNOWN, rtnl_held); |
| 11959 | if (adapter == NULL) |
| 11960 | ret = -EINVAL; |
| 11961 | break; |
| 11962 | case QDF_GLOBAL_EPPING_MODE: |
| 11963 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11964 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11965 | hdd_err("Failed to open in eeping mode: %d", status); |
| 11966 | ret = -EINVAL; |
| 11967 | break; |
| 11968 | } |
| 11969 | ret = epping_enable(qdf_dev->dev); |
| 11970 | if (ret) { |
| 11971 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 11972 | epping_close(); |
| 11973 | } |
| 11974 | break; |
| 11975 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11976 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11977 | ret = -ENOTSUPP; |
| 11978 | break; |
| 11979 | } |
| 11980 | hdd_release_rtnl_lock(); |
| 11981 | rtnl_held = false; |
| 11982 | return ret; |
| 11983 | } |
| 11984 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11985 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11986 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11987 | * @kmessage: con mode name on which driver to be bring up |
| 11988 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 11989 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11990 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11991 | * This function is invoked when user updates con mode using sys entry, |
| 11992 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11993 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 11994 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11995 | */ |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 11996 | static int __con_mode_handler(const char *kmessage, struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11997 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11998 | { |
| 11999 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12000 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12001 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12002 | enum QDF_OPMODE adapter_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12003 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12004 | hdd_info("con_mode handler: %s", kmessage); |
| 12005 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12006 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12007 | if (ret) |
| 12008 | return ret; |
| 12009 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12010 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12011 | |
| 12012 | ret = param_set_int(kmessage, kp); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12013 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12014 | if (!(is_con_mode_valid(con_mode))) { |
| 12015 | hdd_err("invlaid con_mode %d", con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12016 | ret = -EINVAL; |
| 12017 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12018 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12019 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12020 | curr_mode = hdd_get_conparam(); |
| 12021 | if (curr_mode == con_mode) { |
| 12022 | hdd_err("curr mode: %d is same as user triggered mode %d", |
| 12023 | curr_mode, con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12024 | ret = 0; |
| 12025 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12026 | } |
| 12027 | |
Sourav Mohapatra | 3bc5e98 | 2017-11-24 15:53:49 +0530 | [diff] [blame] | 12028 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12029 | hdd_warn("Waiting for monitor mode: External threads are active"); |
| 12030 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12031 | /* ensure adapters are stopped */ |
| 12032 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12033 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12034 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12035 | if (ret) { |
| 12036 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12037 | goto reset_flags; |
| 12038 | } |
| 12039 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12040 | /* Cleanup present mode before switching to new mode */ |
| 12041 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12042 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12043 | hdd_set_conparam(con_mode); |
| 12044 | |
| 12045 | /* Register for new con_mode & then kick_start modules again */ |
| 12046 | ret = hdd_register_req_mode(hdd_ctx, con_mode); |
| 12047 | if (ret) { |
| 12048 | hdd_err("Failed to register for new mode"); |
| 12049 | goto reset_flags; |
| 12050 | } |
| 12051 | |
| 12052 | adapter_mode = hdd_get_adpter_mode(con_mode); |
| 12053 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12054 | hdd_err("invalid adapter"); |
| 12055 | ret = -EINVAL; |
| 12056 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12057 | } |
| 12058 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12059 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12060 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12061 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12062 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12063 | } |
| 12064 | |
| 12065 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12066 | if (ret) { |
| 12067 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12068 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12069 | } |
| 12070 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12071 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12072 | con_mode == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12073 | if (hdd_start_adapter(adapter)) { |
| 12074 | hdd_err("Failed to start %s adapter", kmessage); |
| 12075 | ret = -EINVAL; |
| 12076 | goto reset_flags; |
| 12077 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12078 | } |
| 12079 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12080 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 12081 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12082 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12083 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12084 | } |
| 12085 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12086 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12087 | ret = 0; |
| 12088 | |
| 12089 | reset_flags: |
| 12090 | cds_set_load_in_progress(false); |
| 12091 | return ret; |
| 12092 | } |
| 12093 | |
| 12094 | |
| 12095 | static int con_mode_handler(const char *kmessage, struct kernel_param *kp) |
| 12096 | { |
| 12097 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12098 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12099 | |
| 12100 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12101 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12102 | if (ret) |
| 12103 | return ret; |
| 12104 | |
| 12105 | cds_ssr_protect(__func__); |
| 12106 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12107 | cds_ssr_unprotect(__func__); |
| 12108 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12109 | return ret; |
| 12110 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12111 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12112 | static int con_mode_handler_ftm(const char *kmessage, |
| 12113 | struct kernel_param *kp) |
| 12114 | { |
| 12115 | int ret; |
| 12116 | |
| 12117 | ret = param_set_int(kmessage, kp); |
| 12118 | |
| 12119 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12120 | pr_err("Only FTM mode supported!"); |
| 12121 | return -ENOTSUPP; |
| 12122 | } |
| 12123 | |
| 12124 | hdd_set_conparam(con_mode_ftm); |
| 12125 | con_mode = con_mode_ftm; |
| 12126 | |
| 12127 | return ret; |
| 12128 | } |
| 12129 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12130 | static int con_mode_handler_monitor(const char *kmessage, |
| 12131 | struct kernel_param *kp) |
| 12132 | { |
| 12133 | int ret; |
| 12134 | |
| 12135 | ret = param_set_int(kmessage, kp); |
| 12136 | |
| 12137 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12138 | pr_err("Only Monitor mode supported!"); |
| 12139 | return -ENOTSUPP; |
| 12140 | } |
| 12141 | |
| 12142 | hdd_set_conparam(con_mode_monitor); |
| 12143 | con_mode = con_mode_monitor; |
| 12144 | |
| 12145 | return ret; |
| 12146 | } |
| 12147 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12148 | /** |
| 12149 | * hdd_get_conparam() - driver exit point |
| 12150 | * |
| 12151 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12152 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12153 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12154 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12155 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12156 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12157 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12158 | } |
| 12159 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12160 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12161 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12162 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12163 | } |
| 12164 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12165 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12166 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12167 | * @hdd_ctx: HDD context |
| 12168 | * |
| 12169 | * Cleans up the pre cac interface, if it exists |
| 12170 | * |
| 12171 | * Return: None |
| 12172 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12173 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12174 | { |
| 12175 | uint8_t session_id; |
| 12176 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12177 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12178 | |
| 12179 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12180 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12181 | hdd_err("failed to get pre cac vdev id"); |
| 12182 | return; |
| 12183 | } |
| 12184 | |
| 12185 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12186 | if (!precac_adapter) { |
| 12187 | hdd_err("invalid pre cac adapater"); |
| 12188 | return; |
| 12189 | } |
| 12190 | |
| 12191 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12192 | wlan_hdd_sap_pre_cac_failure, |
| 12193 | (void *)precac_adapter); |
| 12194 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12195 | |
| 12196 | } |
| 12197 | |
| 12198 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12199 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12200 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12201 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12202 | * Return: void |
| 12203 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12204 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12205 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12206 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12207 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12208 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12209 | if (!ol_ctx) |
| 12210 | return; |
| 12211 | |
| 12212 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12213 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12214 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12215 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12216 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12217 | |
| 12218 | ol_init_ini_config(ol_ctx, &cfg); |
| 12219 | } |
| 12220 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12221 | #ifdef FEATURE_RUNTIME_PM |
| 12222 | /** |
| 12223 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12224 | * @hdd_ctx: hdd context |
| 12225 | * @cfg: pointer to the configuration memory being populated |
| 12226 | * |
| 12227 | * Return: void |
| 12228 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12229 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12230 | struct hif_config_info *cfg) |
| 12231 | { |
| 12232 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12233 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12234 | } |
| 12235 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12236 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12237 | struct hif_config_info *cfg) |
| 12238 | { |
| 12239 | } |
| 12240 | #endif |
| 12241 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12242 | /** |
| 12243 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12244 | * @hdd_ctx: HDD Context |
| 12245 | * |
| 12246 | * Return: void |
| 12247 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12248 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12249 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12250 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12251 | struct hif_config_info cfg; |
| 12252 | |
| 12253 | if (!scn) |
| 12254 | return; |
| 12255 | |
| 12256 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12257 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12258 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12259 | |
| 12260 | if (hdd_ctx->config->prevent_link_down) |
| 12261 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12262 | } |
| 12263 | |
| 12264 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12265 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12266 | * datapath |
| 12267 | * @hdd_ctx: HDD Context |
| 12268 | * |
| 12269 | * Return: 0 for success/errno for failure |
| 12270 | */ |
| 12271 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12272 | { |
| 12273 | struct cdp_config_params params; |
| 12274 | QDF_STATUS status; |
| 12275 | |
| 12276 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12277 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12278 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12279 | params.tx_flow_stop_queue_threshold = |
| 12280 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12281 | params.tx_flow_start_queue_offset = |
| 12282 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12283 | #endif |
| 12284 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12285 | params.napi_enable = hdd_ctx->napi_enable; |
| 12286 | params.tcp_udp_checksumoffload = |
| 12287 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12288 | |
| 12289 | status = cdp_update_config_parameters( |
| 12290 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12291 | ¶ms); |
| 12292 | if (status) { |
| 12293 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_ERROR, |
| 12294 | "%s: Failed to attach config parameters", __func__); |
| 12295 | return status; |
| 12296 | } |
| 12297 | |
| 12298 | return 0; |
| 12299 | } |
| 12300 | |
| 12301 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12302 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12303 | * @hdd_ctx: HDD Context |
| 12304 | * |
| 12305 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12306 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12308 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12309 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12310 | int ret; |
| 12311 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12312 | hdd_update_ol_config(hdd_ctx); |
| 12313 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12314 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12315 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12316 | else |
| 12317 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12318 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12319 | |
| 12320 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12321 | } |
| 12322 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12323 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12324 | /** |
| 12325 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12326 | * @psoc_cfg: pmo psoc Configuration |
| 12327 | * @hdd_ctx: Pointer to hdd context |
| 12328 | * |
| 12329 | * Return: none |
| 12330 | */ |
| 12331 | static inline void hdd_ra_populate_pmo_config( |
| 12332 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12333 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12334 | { |
| 12335 | psoc_cfg->ra_ratelimit_interval = |
| 12336 | hdd_ctx->config->RArateLimitInterval; |
| 12337 | psoc_cfg->ra_ratelimit_enable = |
| 12338 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12339 | } |
| 12340 | #else |
| 12341 | static inline void hdd_ra_populate_pmo_config( |
| 12342 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12343 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12344 | { |
| 12345 | } |
| 12346 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12347 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12348 | /** |
| 12349 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12350 | * @hdd_ctx: HDD context |
| 12351 | * |
| 12352 | * Return: void |
| 12353 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12354 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12355 | { |
| 12356 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12357 | struct pmo_psoc_cfg psoc_cfg; |
| 12358 | QDF_STATUS status; |
| 12359 | |
| 12360 | /* |
| 12361 | * Value of hdd_ctx->wowEnable can be, |
| 12362 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12363 | * 1 - Enable magic pattern match on all interfaces. |
| 12364 | * 2 - Enable pattern byte match on all interfaces. |
| 12365 | * 3 - Enable both magic patter and pattern byte match on |
| 12366 | * all interfaces. |
| 12367 | */ |
| 12368 | psoc_cfg.magic_ptrn_enable = |
| 12369 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12370 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12371 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Will Huang | fe64917 | 2017-09-06 16:52:18 +0800 | [diff] [blame] | 12372 | psoc_cfg.ptrn_id_per_vdev = wma_is_service_enabled( |
| 12373 | WMI_SERVICE_UNIFIED_WOW_CAPABILITY); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12374 | psoc_cfg.bpf_enable = |
| 12375 | hdd_ctx->config->bpf_packet_filter_enable; |
| 12376 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12377 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12378 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
| 12379 | if (hdd_ctx->config->fhostNSOffload) |
| 12380 | psoc_cfg.ns_offload_enable_dynamic = true; |
| 12381 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12382 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 12383 | psoc_cfg.active_mode_offload = |
| 12384 | hdd_ctx->config->active_mode_offload; |
| 12385 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12386 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12387 | psoc_cfg.max_wow_filters = hdd_ctx->config->maxWoWFilters; |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12388 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12389 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12390 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 12391 | psoc_cfg.power_save_mode = |
| 12392 | hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12393 | psoc_cfg.auto_power_save_fail_mode = |
| 12394 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12395 | |
| 12396 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12397 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12398 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Rajeev Kumar | d1a7ac4 | 2017-11-08 14:54:22 -0800 | [diff] [blame] | 12399 | status = ucfg_pmo_update_psoc_config(psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12400 | if (status != QDF_STATUS_SUCCESS) { |
| 12401 | hdd_err("failed pmo psoc configuration"); |
| 12402 | return -EINVAL; |
| 12403 | } |
| 12404 | |
| 12405 | return 0; |
| 12406 | } |
| 12407 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12408 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12409 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12410 | struct hdd_config *cfg) |
| 12411 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12412 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12413 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12414 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12415 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12416 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12417 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12418 | pno_cfg->channel_prediction_full_scan = |
| 12419 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12420 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12421 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12422 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12423 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12424 | } |
| 12425 | #else |
| 12426 | static inline void |
| 12427 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12428 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12429 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12430 | } |
| 12431 | #endif |
| 12432 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12433 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12434 | struct hdd_config *cfg) |
| 12435 | { |
| 12436 | uint8_t i = 0; |
| 12437 | |
| 12438 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12439 | if (!ie_whitelist->white_list) |
| 12440 | return; |
| 12441 | |
| 12442 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12443 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12444 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12445 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12446 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12447 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12448 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12449 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12450 | |
| 12451 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12452 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12453 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12454 | } |
| 12455 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12456 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12457 | { |
| 12458 | uint8_t i, score; |
| 12459 | |
| 12460 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12461 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12462 | if (score > MAX_INDEX_SCORE) |
| 12463 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12464 | MAX_INDEX_SCORE, i); |
| 12465 | } |
| 12466 | |
| 12467 | return per_index_score; |
| 12468 | } |
| 12469 | |
| 12470 | /** |
| 12471 | * hdd_update_score_config - API to update candidate scoring related params |
| 12472 | * configuration parameters |
| 12473 | * @score_config: score config to update |
| 12474 | * @cfg: config params |
| 12475 | * |
| 12476 | * Return: 0 if success else err |
| 12477 | */ |
| 12478 | static void hdd_update_score_config( |
| 12479 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12480 | { |
| 12481 | int total_weight; |
| 12482 | |
| 12483 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12484 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12485 | score_config->weight_cfg.vht_caps_weightage = |
| 12486 | cfg->vht_caps_weightage; |
| 12487 | score_config->weight_cfg.he_caps_weightage = |
| 12488 | cfg->he_caps_weightage; |
| 12489 | score_config->weight_cfg.chan_width_weightage = |
| 12490 | cfg->chan_width_weightage; |
| 12491 | score_config->weight_cfg.chan_band_weightage = |
| 12492 | cfg->chan_band_weightage; |
| 12493 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12494 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12495 | cfg->beamforming_cap_weightage; |
| 12496 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12497 | score_config->weight_cfg.channel_congestion_weightage = |
| 12498 | cfg->channel_congestion_weightage; |
| 12499 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12500 | |
| 12501 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12502 | score_config->weight_cfg.ht_caps_weightage + |
| 12503 | score_config->weight_cfg.vht_caps_weightage + |
| 12504 | score_config->weight_cfg.he_caps_weightage + |
| 12505 | score_config->weight_cfg.chan_width_weightage + |
| 12506 | score_config->weight_cfg.chan_band_weightage + |
| 12507 | score_config->weight_cfg.nss_weightage + |
| 12508 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12509 | score_config->weight_cfg.pcl_weightage + |
| 12510 | score_config->weight_cfg.channel_congestion_weightage + |
| 12511 | score_config->weight_cfg.oce_wan_weightage; |
| 12512 | |
| 12513 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12514 | hdd_err("total weight is greater than %d fallback to default values", |
| 12515 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12516 | |
| 12517 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12518 | score_config->weight_cfg.ht_caps_weightage = |
| 12519 | HT_CAPABILITY_WEIGHTAGE; |
| 12520 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12521 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12522 | score_config->weight_cfg.chan_width_weightage = |
| 12523 | CHAN_WIDTH_WEIGHTAGE; |
| 12524 | score_config->weight_cfg.chan_band_weightage = |
| 12525 | CHAN_BAND_WEIGHTAGE; |
| 12526 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12527 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12528 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12529 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12530 | score_config->weight_cfg.channel_congestion_weightage = |
| 12531 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12532 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12533 | } |
| 12534 | |
| 12535 | score_config->bandwidth_weight_per_index = |
| 12536 | hdd_limit_max_per_index_score( |
| 12537 | cfg->bandwidth_weight_per_index); |
| 12538 | score_config->nss_weight_per_index = |
| 12539 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12540 | score_config->band_weight_per_index = |
| 12541 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12542 | |
| 12543 | score_config->rssi_score.best_rssi_threshold = |
| 12544 | cfg->best_rssi_threshold; |
| 12545 | score_config->rssi_score.good_rssi_threshold = |
| 12546 | cfg->good_rssi_threshold; |
| 12547 | score_config->rssi_score.bad_rssi_threshold = |
| 12548 | cfg->bad_rssi_threshold; |
| 12549 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12550 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12551 | score_config->rssi_score.good_rssi_bucket_size = |
| 12552 | cfg->good_rssi_bucket_size; |
| 12553 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12554 | cfg->bad_rssi_bucket_size; |
| 12555 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12556 | cfg->rssi_pref_5g_rssi_thresh; |
| 12557 | |
| 12558 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12559 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12560 | hdd_limit_max_per_index_score( |
| 12561 | cfg->esp_qbss_score_slots3_to_0); |
| 12562 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 12563 | hdd_limit_max_per_index_score( |
| 12564 | cfg->esp_qbss_score_slots7_to_4); |
| 12565 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 12566 | hdd_limit_max_per_index_score( |
| 12567 | cfg->esp_qbss_score_slots11_to_8); |
| 12568 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 12569 | hdd_limit_max_per_index_score( |
| 12570 | cfg->esp_qbss_score_slots15_to_12); |
| 12571 | |
| 12572 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 12573 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 12574 | hdd_limit_max_per_index_score( |
| 12575 | cfg->oce_wan_score_slots3_to_0); |
| 12576 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 12577 | hdd_limit_max_per_index_score( |
| 12578 | cfg->oce_wan_score_slots7_to_4); |
| 12579 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 12580 | hdd_limit_max_per_index_score( |
| 12581 | cfg->oce_wan_score_slots11_to_8); |
| 12582 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 12583 | hdd_limit_max_per_index_score( |
| 12584 | cfg->oce_wan_score_slots15_to_12); |
| 12585 | |
| 12586 | |
| 12587 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 12588 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 12589 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 12590 | |
| 12591 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 12592 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 12593 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 12594 | score_config->he_cap = 1; |
| 12595 | |
| 12596 | if (score_config->he_cap || |
| 12597 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 12598 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 12599 | score_config->vht_cap = 1; |
| 12600 | |
| 12601 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 12602 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 12603 | score_config->ht_cap = 1; |
| 12604 | |
| 12605 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 12606 | score_config->vht_24G_cap = 1; |
| 12607 | |
| 12608 | if (cfg->enableTxBF) |
| 12609 | score_config->beamformee_cap = 1; |
| 12610 | |
| 12611 | } |
| 12612 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12613 | /** |
| 12614 | * hdd_update_scan_config - API to update scan configuration parameters |
| 12615 | * @hdd_ctx: HDD context |
| 12616 | * |
| 12617 | * Return: 0 if success else err |
| 12618 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12619 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12620 | { |
| 12621 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 12622 | struct scan_user_cfg scan_cfg; |
| 12623 | struct hdd_config *cfg = hdd_ctx->config; |
| 12624 | QDF_STATUS status; |
| 12625 | |
| 12626 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 12627 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 12628 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 12629 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 12630 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 12631 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 12632 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 12633 | /* convert to ms */ |
| 12634 | scan_cfg.scan_cache_aging_time = |
| 12635 | cfg->scanAgingTimeout * 1000; |
| 12636 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 12637 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 12638 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 12639 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12640 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 12641 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 12642 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 12643 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 12644 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 12645 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12646 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12647 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12648 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12649 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12650 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12651 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 12652 | if (status != QDF_STATUS_SUCCESS) { |
| 12653 | hdd_err("failed pmo psoc configuration"); |
| 12654 | return -EINVAL; |
| 12655 | } |
| 12656 | |
| 12657 | return 0; |
| 12658 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12659 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12660 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12661 | { |
| 12662 | int ret; |
| 12663 | |
| 12664 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12665 | if (ret) |
| 12666 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12667 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 12668 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12669 | if (ret) |
| 12670 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12671 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 12672 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12673 | if (ret) |
| 12674 | return ret; |
| 12675 | |
| 12676 | ret = hdd_update_dp_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12677 | |
| 12678 | return ret; |
| 12679 | } |
| 12680 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12681 | /** |
| 12682 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 12683 | * @mode : cfg80211 DFS mode |
| 12684 | * |
| 12685 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 12686 | */ |
| 12687 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 12688 | { |
| 12689 | switch (mode) { |
| 12690 | case DFS_MODE_ENABLE: |
| 12691 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12692 | case DFS_MODE_DISABLE: |
| 12693 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12694 | case DFS_MODE_DEPRIORITIZE: |
| 12695 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12696 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12697 | hdd_debug("ACS dfs mode is NONE"); |
| 12698 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12699 | } |
| 12700 | } |
| 12701 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12702 | /** |
| 12703 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 12704 | * @hddctx: pointer to hdd context |
| 12705 | * @set_value: enable/disable |
| 12706 | * |
| 12707 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 12708 | * Host(even though it is duplicate). When Host send vendor command |
| 12709 | * disable,FW doesn't perform any action. Whenever any change in |
| 12710 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 12711 | * |
| 12712 | * return - 0 on success, appropriate error values on failure. |
| 12713 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12714 | 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] | 12715 | { |
| 12716 | QDF_STATUS status; |
| 12717 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12718 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12719 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 12720 | |
| 12721 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 12722 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 12723 | return -EINVAL; |
| 12724 | } |
| 12725 | |
| 12726 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 12727 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 12728 | hdd_err("Failed to send chan avoid command to SME"); |
| 12729 | return -EINVAL; |
| 12730 | } |
| 12731 | return 0; |
| 12732 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 12733 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12734 | /** |
| 12735 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 12736 | * @value: value to set |
| 12737 | * |
| 12738 | * This function will set the passed value to roaming in progress flag. |
| 12739 | * |
| 12740 | * Return: None |
| 12741 | */ |
| 12742 | void hdd_set_roaming_in_progress(bool value) |
| 12743 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12744 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12745 | |
| 12746 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12747 | if (!hdd_ctx) { |
| 12748 | hdd_err("HDD context is NULL"); |
| 12749 | return; |
| 12750 | } |
| 12751 | |
| 12752 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12753 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12754 | } |
| 12755 | |
| 12756 | /** |
| 12757 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12758 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12759 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12760 | * 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] | 12761 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12762 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12763 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12764 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12765 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12766 | |
| 12767 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12768 | if (!hdd_ctx) { |
| 12769 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12770 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12771 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12772 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 12773 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 12774 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 12775 | hdd_ctx->roaming_in_progress); |
| 12776 | |
| 12777 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 12778 | } |
| 12779 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12780 | /** |
| 12781 | * hdd_is_connection_in_progress() - check if connection is in |
| 12782 | * progress |
| 12783 | * @session_id: session id |
| 12784 | * @reason: scan reject reason |
| 12785 | * |
| 12786 | * Go through each adapter and check if Connection is in progress |
| 12787 | * |
| 12788 | * Return: true if connection is in progress else false |
| 12789 | */ |
| 12790 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 12791 | enum scan_reject_states *reason) |
| 12792 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 12793 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12794 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12795 | uint8_t sta_id = 0; |
| 12796 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12797 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12798 | |
| 12799 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12800 | if (!hdd_ctx) { |
| 12801 | hdd_err("HDD context is NULL"); |
| 12802 | return false; |
| 12803 | } |
| 12804 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12805 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12806 | hdd_info("Adapter with device mode %s(%d) exists", |
| 12807 | hdd_device_mode_to_string(adapter->device_mode), |
| 12808 | adapter->device_mode); |
| 12809 | if (((QDF_STA_MODE == adapter->device_mode) |
| 12810 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 12811 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 12812 | && (eConnectionState_Connecting == |
| 12813 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 12814 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12815 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12816 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12817 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12818 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12819 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12820 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12821 | } |
| 12822 | return true; |
| 12823 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12824 | /* |
| 12825 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 12826 | * hdd_is_roaming_in_progress is for LFR3 |
| 12827 | */ |
| 12828 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 12829 | sme_neighbor_middle_of_roaming( |
| 12830 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12831 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 12832 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12833 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12834 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12835 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12836 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12837 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12838 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12839 | } |
| 12840 | return true; |
| 12841 | } |
| 12842 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 12843 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 12844 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 12845 | hdd_sta_ctx = |
| 12846 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12847 | if ((eConnectionState_Associated == |
| 12848 | hdd_sta_ctx->conn_info.connState) |
| 12849 | && (false == |
| 12850 | hdd_sta_ctx->conn_info.uIsAuthenticated)) { |
| 12851 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 12852 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12853 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12854 | " is in middle of WPS/EAPOL exchange.", |
| 12855 | MAC_ADDR_ARRAY(sta_mac)); |
| 12856 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12857 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12858 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12859 | } |
| 12860 | return true; |
| 12861 | } |
| 12862 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 12863 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 12864 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 12865 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12866 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12867 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12868 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12869 | continue; |
| 12870 | |
| 12871 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 12872 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 12873 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12874 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12875 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 12876 | MAC_ADDR_ARRAY(sta_mac)); |
| 12877 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12878 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12879 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12880 | } |
| 12881 | return true; |
| 12882 | } |
| 12883 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 12884 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12885 | return true; |
| 12886 | } |
| 12887 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12888 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12889 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12890 | return false; |
| 12891 | } |
| 12892 | |
| 12893 | /** |
| 12894 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12895 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12896 | * |
| 12897 | * Return: None |
| 12898 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12899 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12900 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12901 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12902 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12903 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12904 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12905 | tsap_Config_t *sap_config; |
| 12906 | void *sap_ctx; |
| 12907 | |
| 12908 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 12909 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12910 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12911 | |
| 12912 | mutex_lock(&hdd_ctx->sap_lock); |
| 12913 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 12914 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12915 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 12916 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 12917 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 12918 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12919 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12920 | qdf_stop_bss_event, |
| 12921 | SME_CMD_TIMEOUT_VALUE); |
| 12922 | |
| 12923 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12924 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12925 | goto end; |
| 12926 | } |
| 12927 | } |
| 12928 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12929 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12930 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12931 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12932 | |
| 12933 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12934 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12935 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12936 | eUPDATE_IE_ALL); |
| 12937 | goto end; |
| 12938 | } |
| 12939 | |
| 12940 | qdf_event_reset(&hostapd_state->qdf_event); |
| 12941 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 12942 | sap_config, |
| 12943 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12944 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12945 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12946 | eUPDATE_IE_ALL); |
| 12947 | goto end; |
| 12948 | } |
| 12949 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12950 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12951 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12952 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12953 | SME_CMD_TIMEOUT_VALUE); |
| 12954 | wlansap_reset_sap_config_add_ie(sap_config, |
| 12955 | eUPDATE_IE_ALL); |
| 12956 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12957 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12958 | goto end; |
| 12959 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12960 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12961 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Jeff Johnson | 0f9f87b | 2017-10-28 09:21:06 -0700 | [diff] [blame] | 12962 | if (hostapd_state->bss_state == BSS_START) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12963 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12964 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12965 | ap_adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12966 | } |
| 12967 | end: |
| 12968 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12969 | } |
| 12970 | |
| 12971 | /** |
| 12972 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 12973 | * with non dfs acs |
| 12974 | * |
| 12975 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 12976 | * |
| 12977 | * Return: None |
| 12978 | */ |
| 12979 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 12980 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12981 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12982 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12983 | cds_context_type *cds_ctx; |
| 12984 | |
| 12985 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12986 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12987 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12988 | return; |
| 12989 | } |
| 12990 | |
| 12991 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 12992 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12993 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 12994 | return; |
| 12995 | } |
| 12996 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12997 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 12998 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 12999 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13000 | return; |
| 13001 | } |
| 13002 | |
| 13003 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13004 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13005 | &ap_adapter->event_flags) && |
| 13006 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13007 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13008 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13009 | 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] | 13010 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13011 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13012 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13013 | acs_cfg.acs_mode = true; |
| 13014 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13015 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13016 | } |
| 13017 | } |
| 13018 | |
| 13019 | /** |
| 13020 | * hdd_set_connection_in_progress() - to set the connection in |
| 13021 | * progress flag |
| 13022 | * @value: value to set |
| 13023 | * |
| 13024 | * This function will set the passed value to connection in progress flag. |
| 13025 | * If value is previously being set to true then no need to set it again. |
| 13026 | * |
| 13027 | * Return: true if value is being set correctly and false otherwise. |
| 13028 | */ |
| 13029 | bool hdd_set_connection_in_progress(bool value) |
| 13030 | { |
| 13031 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13032 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13033 | |
| 13034 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13035 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13036 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13037 | return false; |
| 13038 | } |
| 13039 | |
| 13040 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13041 | /* |
| 13042 | * if the value is set to true previously and if someone is |
| 13043 | * trying to make it true again then it could be some race |
| 13044 | * condition being triggered. Avoid this situation by returning |
| 13045 | * false |
| 13046 | */ |
| 13047 | if (hdd_ctx->connection_in_progress && value) |
| 13048 | status = false; |
| 13049 | else |
| 13050 | hdd_ctx->connection_in_progress = value; |
| 13051 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13052 | return status; |
| 13053 | } |
| 13054 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13055 | 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] | 13056 | { |
| 13057 | if (!adapter) { |
| 13058 | hdd_err("Invalid adapter"); |
| 13059 | return -EINVAL; |
| 13060 | } |
| 13061 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13062 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13063 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13064 | set_value, VDEV_CMD); |
| 13065 | return 0; |
| 13066 | |
| 13067 | } |
| 13068 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13069 | 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] | 13070 | { |
| 13071 | if (!adapter) { |
| 13072 | hdd_err("Invalid adapter"); |
| 13073 | return -EINVAL; |
| 13074 | } |
| 13075 | |
| 13076 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13077 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13078 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13079 | set_value, VDEV_CMD); |
| 13080 | return 0; |
| 13081 | } |
| 13082 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13083 | 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] | 13084 | *psoc, uint8_t vdev_id) |
| 13085 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13086 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13087 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13088 | |
| 13089 | /* |
| 13090 | * Currently PSOC is not being used. But this logic will |
| 13091 | * change once we have the converged implementation of |
| 13092 | * HDD context per PSOC in place. This would break if |
| 13093 | * multiple vdev objects reuse the vdev id. |
| 13094 | */ |
| 13095 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13096 | if (!adapter) |
| 13097 | hdd_err("Get adapter by vdev id failed"); |
| 13098 | |
| 13099 | return adapter; |
| 13100 | } |
| 13101 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13102 | 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] | 13103 | int8_t *rssi, int8_t *snr) |
| 13104 | { |
| 13105 | QDF_STATUS status; |
Jeff Johnson | 2a72200 | 2017-09-30 20:02:35 -0700 | [diff] [blame] | 13106 | struct hdd_wext_state *wext_state = |
| 13107 | WLAN_HDD_GET_WEXT_STATE_PTR(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13108 | tCsrRoamProfile *profile = &wext_state->roamProfile; |
| 13109 | |
| 13110 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
| 13111 | profile, bssid, rssi, snr); |
| 13112 | if (QDF_STATUS_SUCCESS != status) { |
| 13113 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13114 | return -EINVAL; |
| 13115 | } |
| 13116 | |
| 13117 | return 0; |
| 13118 | } |
| 13119 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13120 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13121 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13122 | * @adapter - HDD adapter |
| 13123 | * @tos - type of service |
| 13124 | * @status - status of the traffic |
| 13125 | * |
| 13126 | * Return: 0 on success and non zero value on failure |
| 13127 | */ |
| 13128 | |
| 13129 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13130 | bool is_tos_active) |
| 13131 | { |
| 13132 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13133 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13134 | uint32_t max_off_chan_time = 0; |
| 13135 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13136 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13137 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13138 | |
| 13139 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13140 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13141 | |
| 13142 | if (ret < 0) { |
| 13143 | hdd_err("failed to set limit off chan params"); |
| 13144 | return ret; |
| 13145 | } |
| 13146 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13147 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13148 | |
| 13149 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13150 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13151 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13152 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13153 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13154 | if (adapter->active_ac) { |
| 13155 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13156 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13157 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13158 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13159 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13160 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13161 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13162 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13163 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13164 | PM_LATENCY); |
| 13165 | } else { |
| 13166 | /*ignore this command if only BE/BK is active */ |
| 13167 | is_tos_active = false; |
| 13168 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13169 | hdd_ctx->config->conc_system_pref); |
| 13170 | } |
| 13171 | } else { |
| 13172 | /* No active tos */ |
| 13173 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13174 | hdd_ctx->config->conc_system_pref); |
| 13175 | } |
| 13176 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13177 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13178 | is_tos_active, max_off_chan_time, |
| 13179 | hdd_ctx->config->nRestTimeConc, true); |
| 13180 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13181 | hdd_err("failed to set limit off chan params"); |
| 13182 | ret = -EINVAL; |
| 13183 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13184 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13185 | return ret; |
| 13186 | } |
| 13187 | |
| 13188 | /** |
| 13189 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13190 | * @adapter - HDD adapter |
| 13191 | * |
| 13192 | * Return: 0 on success and non zero value on failure |
| 13193 | */ |
| 13194 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13195 | { |
| 13196 | struct hdd_context *hdd_ctx; |
| 13197 | int ret; |
| 13198 | QDF_STATUS status; |
| 13199 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13200 | |
| 13201 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13202 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13203 | if (ret < 0) |
| 13204 | return ret; |
| 13205 | |
| 13206 | /* set the system preferece to default */ |
| 13207 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13208 | hdd_ctx->config->conc_system_pref); |
| 13209 | |
| 13210 | /* clear the bitmap */ |
| 13211 | adapter->active_ac = 0; |
| 13212 | |
| 13213 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13214 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13215 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13216 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13217 | false, 0, 0, false); |
| 13218 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13219 | hdd_err("failed to reset limit off chan params"); |
| 13220 | ret = -EINVAL; |
| 13221 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13222 | |
| 13223 | return ret; |
| 13224 | } |
| 13225 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13226 | /** |
| 13227 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13228 | * @drv_op: Enum indicating driver op |
| 13229 | * |
| 13230 | * Return: none |
| 13231 | */ |
| 13232 | void hdd_start_driver_ops_timer(int drv_op) |
| 13233 | { |
| 13234 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13235 | switch (drv_op) { |
| 13236 | case eHDD_DRV_OP_PROBE: |
| 13237 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13238 | break; |
| 13239 | case eHDD_DRV_OP_REMOVE: |
| 13240 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13241 | break; |
| 13242 | case eHDD_DRV_OP_SHUTDOWN: |
| 13243 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13244 | break; |
| 13245 | case eHDD_DRV_OP_REINIT: |
| 13246 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13247 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13248 | case eHDD_DRV_OP_IFF_UP: |
| 13249 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13250 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13251 | } |
| 13252 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13253 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13254 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13255 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13256 | } |
| 13257 | |
| 13258 | /** |
| 13259 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13260 | * |
| 13261 | * Return: none |
| 13262 | */ |
| 13263 | void hdd_stop_driver_ops_timer(void) |
| 13264 | { |
| 13265 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13266 | } |
| 13267 | |
| 13268 | /** |
| 13269 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13270 | * inactivity timer |
| 13271 | * |
| 13272 | * Return: None |
| 13273 | */ |
| 13274 | void hdd_drv_ops_inactivity_handler(void) |
| 13275 | { |
| 13276 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13277 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13278 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13279 | if (hdd_drv_ops_task) { |
| 13280 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13281 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13282 | } else { |
| 13283 | hdd_err("hdd_drv_ops_task is null"); |
| 13284 | } |
| 13285 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13286 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13287 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13288 | sizeof("shutdown"))) |
| 13289 | QDF_BUG(0); |
| 13290 | |
| 13291 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13292 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13293 | else |
| 13294 | QDF_BUG(0); |
| 13295 | } |
| 13296 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13297 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13298 | { |
| 13299 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13300 | |
| 13301 | if (!hdd_ctx) |
| 13302 | return; |
| 13303 | |
| 13304 | hdd_ipa_uc_force_pipe_shutdown(hdd_ctx); |
| 13305 | } |
| 13306 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13307 | /** |
| 13308 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13309 | * @struct hdd_context *hdd_ctx |
| 13310 | * @struct hdd_adapter *padapter |
| 13311 | * @bool enble |
| 13312 | * |
| 13313 | * Return: none |
| 13314 | */ |
| 13315 | void hdd_set_rx_mode_rps(bool enable) |
| 13316 | { |
| 13317 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13318 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13319 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13320 | |
| 13321 | if (adapter && hdd_ctx && |
| 13322 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13323 | if (enable && !cds_cfg->rps_enabled) |
| 13324 | hdd_send_rps_ind(adapter); |
| 13325 | else if (!enable && cds_cfg->rps_enabled) |
| 13326 | hdd_send_rps_disable_ind(adapter); |
| 13327 | } |
| 13328 | } |
| 13329 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13330 | /* Register the module init/exit functions */ |
| 13331 | module_init(hdd_module_init); |
| 13332 | module_exit(hdd_module_exit); |
| 13333 | |
| 13334 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13335 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13336 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13337 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13338 | module_param_call(con_mode, con_mode_handler, param_get_int, &con_mode, |
| 13339 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13340 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13341 | module_param_call(con_mode_ftm, con_mode_handler_ftm, param_get_int, |
| 13342 | &con_mode_ftm, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13343 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13344 | module_param_call(con_mode_monitor, con_mode_handler_monitor, param_get_int, |
| 13345 | &con_mode_monitor, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13346 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13347 | module_param_call(fwpath, fwpath_changed_handler, param_get_string, &fwpath, |
| 13348 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13349 | |
| 13350 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13351 | |
| 13352 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13353 | |
| 13354 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |