Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | /** |
| 29 | * DOC: wlan_hdd_main.c |
| 30 | * |
| 31 | * WLAN Host Device Driver implementation |
| 32 | * |
| 33 | */ |
| 34 | |
| 35 | /* Include Files */ |
| 36 | #include <wlan_hdd_includes.h> |
| 37 | #include <cds_api.h> |
| 38 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 39 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 40 | #include <linux/etherdevice.h> |
| 41 | #include <linux/firmware.h> |
| 42 | #include <wlan_hdd_tx_rx.h> |
| 43 | #include <wni_api.h> |
| 44 | #include <wlan_hdd_cfg.h> |
| 45 | #include <wlan_ptt_sock_svc.h> |
| 46 | #include <dbglog_host.h> |
| 47 | #include <wlan_logging_sock_svc.h> |
| 48 | #include <wlan_hdd_wowl.h> |
| 49 | #include <wlan_hdd_misc.h> |
| 50 | #include <wlan_hdd_wext.h> |
| 51 | #include "wlan_hdd_trace.h" |
| 52 | #include "wlan_hdd_ioctl.h" |
| 53 | #include "wlan_hdd_ftm.h" |
| 54 | #include "wlan_hdd_power.h" |
| 55 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 56 | #include "wlan_hdd_scan.h" |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 57 | #include "wlan_hdd_request_manager.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 58 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 59 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 60 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 61 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 62 | #include "qdf_str.h" |
| 63 | #include "qdf_trace.h" |
| 64 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 65 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 66 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 67 | #include <cdp_txrx_stats.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 68 | |
| 69 | #include <net/addrconf.h> |
| 70 | #include <linux/wireless.h> |
| 71 | #include <net/cfg80211.h> |
| 72 | #include <linux/inetdevice.h> |
| 73 | #include <net/addrconf.h> |
| 74 | #include "wlan_hdd_cfg80211.h" |
| 75 | #include "wlan_hdd_ext_scan.h" |
| 76 | #include "wlan_hdd_p2p.h" |
| 77 | #include <linux/rtnetlink.h> |
| 78 | #include "sap_api.h" |
| 79 | #include <linux/semaphore.h> |
| 80 | #include <linux/ctype.h> |
| 81 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 82 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 83 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 84 | #include <soc/qcom/subsystem_restart.h> |
| 85 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 86 | #include <wlan_hdd_hostapd.h> |
| 87 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 88 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | #include "cfg_api.h" |
| 90 | #include "qwlan_version.h" |
| 91 | #include "wma_types.h" |
| 92 | #include "wlan_hdd_tdls.h" |
| 93 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 94 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 95 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 96 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 97 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 98 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | #include "wlan_hdd_nan.h" |
| 100 | #include "wlan_hdd_debugfs.h" |
| 101 | #include "wlan_hdd_driver_ops.h" |
| 102 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 103 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 104 | |
| 105 | #include <wlan_hdd_ipa.h> |
| 106 | #include "hif.h" |
| 107 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 108 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 109 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 110 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 111 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 112 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 113 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 114 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 115 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 116 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 117 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 118 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 119 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 120 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 121 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 122 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 123 | #include "os_if_wifi_pos.h" |
| 124 | #include "wifi_pos_api.h" |
| 125 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 126 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 127 | #include "os_if_nan.h" |
| 128 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 129 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 130 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 131 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 132 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 133 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 134 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 135 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 136 | #include "wlan_disa_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 137 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 138 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 139 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 140 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 141 | #ifdef CNSS_GENL |
| 142 | #include <net/cnss_nl.h> |
| 143 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 144 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 145 | #include "wlan_ocb_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 146 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 147 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 148 | #ifdef MODULE |
| 149 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 150 | #else |
| 151 | #define WLAN_MODULE_NAME "wlan" |
| 152 | #endif |
| 153 | |
| 154 | #ifdef TIMER_MANAGER |
| 155 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 156 | #else |
| 157 | #define TIMER_MANAGER_STR "" |
| 158 | #endif |
| 159 | |
| 160 | #ifdef MEMORY_DEBUG |
| 161 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 162 | #else |
| 163 | #define MEMORY_DEBUG_STR "" |
| 164 | #endif |
| 165 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 166 | #ifdef PANIC_ON_BUG |
| 167 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 168 | #else |
| 169 | #define PANIC_ON_BUG_STR "" |
| 170 | #endif |
| 171 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 172 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 173 | int wlan_start_ret_val; |
| 174 | static DECLARE_COMPLETION(wlan_start_comp); |
| 175 | static unsigned int dev_num = 1; |
| 176 | static struct cdev wlan_hdd_state_cdev; |
| 177 | static struct class *class; |
| 178 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 179 | #ifndef MODULE |
| 180 | static struct gwlan_loader *wlan_loader; |
| 181 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 182 | struct kobj_attribute *attr, |
| 183 | const char *buf, size_t count); |
| 184 | struct gwlan_loader { |
| 185 | bool loaded_state; |
| 186 | struct kobject *boot_wlan_obj; |
| 187 | struct attribute_group *attr_group; |
| 188 | }; |
| 189 | |
| 190 | static struct kobj_attribute wlan_boot_attribute = |
| 191 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 192 | |
| 193 | static struct attribute *attrs[] = { |
| 194 | &wlan_boot_attribute.attr, |
| 195 | NULL, |
| 196 | }; |
| 197 | |
| 198 | #define MODULE_INITIALIZED 1 |
| 199 | #endif |
| 200 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 201 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 202 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 203 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 204 | |
| 205 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 206 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 207 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 208 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 209 | /* the Android framework expects this param even though we don't use it */ |
| 210 | #define BUF_LEN 20 |
| 211 | static char fwpath_buffer[BUF_LEN]; |
| 212 | static struct kparam_string fwpath = { |
| 213 | .string = fwpath_buffer, |
| 214 | .maxlen = BUF_LEN, |
| 215 | }; |
| 216 | |
| 217 | static char *country_code; |
| 218 | static int enable_11d = -1; |
| 219 | static int enable_dfs_chan_scan = -1; |
| 220 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 221 | /* |
| 222 | * spinlock for synchronizing asynchronous request/response |
| 223 | * (full description of use in wlan_hdd_main.h) |
| 224 | */ |
| 225 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 226 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 228 | #define WLAN_NLINK_CESIUM 30 |
| 229 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 230 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 231 | |
| 232 | #define WOW_MAX_FILTER_LISTS 1 |
| 233 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 234 | #define WOW_MIN_PATTERN_SIZE 6 |
| 235 | #define WOW_MAX_PATTERN_SIZE 64 |
| 236 | |
| 237 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 238 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 239 | .flags = WIPHY_WOWLAN_ANY | |
| 240 | WIPHY_WOWLAN_MAGIC_PKT | |
| 241 | WIPHY_WOWLAN_DISCONNECT | |
| 242 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 243 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 244 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 245 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 246 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 247 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 248 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 249 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 250 | }; |
| 251 | #endif |
| 252 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 253 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 254 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 266 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 267 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 268 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 269 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 270 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 287 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 288 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 289 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 290 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 291 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 292 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 293 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 296 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 297 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 298 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 299 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 300 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 301 | }; |
| 302 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 303 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 304 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 305 | |
| 306 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 307 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 308 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 309 | #endif |
| 310 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 311 | void hdd_start_complete(int ret) |
| 312 | { |
| 313 | wlan_start_ret_val = ret; |
| 314 | |
| 315 | complete(&wlan_start_comp); |
| 316 | } |
| 317 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 318 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 319 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 320 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 321 | * |
| 322 | * Return: none |
| 323 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 324 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 325 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 326 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 327 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 328 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 329 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 333 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 334 | * @vdev_id: vdev_id |
| 335 | * @action: action type |
| 336 | * @reason: reason type |
| 337 | * |
| 338 | * Return: none |
| 339 | */ |
| 340 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 341 | enum netif_action_type action, enum netif_reason_type reason) |
| 342 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 343 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 344 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | |
| 346 | if (!hdd_ctx) { |
| 347 | hdd_err("hdd ctx is NULL"); |
| 348 | return; |
| 349 | } |
| 350 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 351 | |
| 352 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 356 | * Store WLAN driver version and timestamp info in global variables such that |
| 357 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 358 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 359 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 360 | #ifdef BUILD_TAG |
| 361 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 362 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 363 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 364 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | |
| 366 | /** |
| 367 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 368 | * @device_mode: device mode |
| 369 | * |
| 370 | * This utility function helps log string conversion of device mode. |
| 371 | * |
| 372 | * Return: string conversion of device mode, if match found; |
| 373 | * "Unknown" otherwise. |
| 374 | */ |
| 375 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 376 | { |
| 377 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 378 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 379 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 380 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 381 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 382 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 383 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 384 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 385 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 386 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | default: |
| 388 | return "Unknown"; |
| 389 | } |
| 390 | } |
| 391 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 392 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 393 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 394 | * @hdd_ctx: HDD context |
| 395 | * @chan_list: buf hold returned chan list |
| 396 | * @chan_num: input buf size and output returned chan num |
| 397 | * |
| 398 | * This function helps get current available chan list from regulatory |
| 399 | * module. It excludes the "disabled" and "invalid" channels. |
| 400 | * |
| 401 | * Return: 0 for success. |
| 402 | */ |
| 403 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 404 | uint8_t *chan_list, |
| 405 | uint32_t *chan_num) |
| 406 | { |
| 407 | int i = 0, j = 0; |
| 408 | struct regulatory_channel *cur_chan_list; |
| 409 | struct wlan_objmgr_pdev *pdev; |
| 410 | |
| 411 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 412 | return -EINVAL; |
| 413 | |
| 414 | pdev = hdd_ctx->hdd_pdev; |
| 415 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 416 | sizeof(struct regulatory_channel)); |
| 417 | if (!cur_chan_list) |
| 418 | return -ENOMEM; |
| 419 | |
| 420 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 421 | QDF_STATUS_SUCCESS) { |
| 422 | qdf_mem_free(cur_chan_list); |
| 423 | return -EINVAL; |
| 424 | } |
| 425 | |
| 426 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 427 | uint32_t ch = cur_chan_list[i].chan_num; |
| 428 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 429 | ch); |
| 430 | |
| 431 | if (state != CHANNEL_STATE_DISABLE && |
| 432 | state != CHANNEL_STATE_INVALID && |
| 433 | j < *chan_num) { |
| 434 | chan_list[j] = (uint8_t)ch; |
| 435 | j++; |
| 436 | } |
| 437 | } |
| 438 | *chan_num = j; |
| 439 | qdf_mem_free(cur_chan_list); |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 444 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 445 | * @adapter: HDD adapter |
| 446 | * @chan_number: Channel number |
| 447 | * @chan_bw: Bandwidth |
| 448 | * |
| 449 | * Checks if the given bandwidth is valid for the given channel number. |
| 450 | * |
| 451 | * Return: 0 for success, non-zero for failure |
| 452 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 453 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 454 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 455 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 456 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 457 | uint8_t chan[NUM_CHANNELS]; |
| 458 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 459 | bool found = false; |
| 460 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 461 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 462 | |
| 463 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 464 | if (!hal) { |
| 465 | hdd_err("Invalid HAL context"); |
| 466 | return -EINVAL; |
| 467 | } |
| 468 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 469 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 470 | &len); |
| 471 | if (ret) { |
| 472 | hdd_err("error %d in getting valid channel list", ret); |
| 473 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | for (i = 0; i < len; i++) { |
| 477 | if (chan[i] == chan_number) { |
| 478 | found = true; |
| 479 | break; |
| 480 | } |
| 481 | } |
| 482 | |
| 483 | if (found == false) { |
| 484 | hdd_err("Channel not in driver's valid channel list"); |
| 485 | return -EOPNOTSUPP; |
| 486 | } |
| 487 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 488 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 489 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 490 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 491 | return -EINVAL; |
| 492 | } |
| 493 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 494 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 495 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 496 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 497 | return -EINVAL; |
| 498 | } |
| 499 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 500 | (chan_bw != CH_WIDTH_MAX)) { |
| 501 | hdd_err("Only BW20 possible on channel 14"); |
| 502 | return -EINVAL; |
| 503 | } |
| 504 | } |
| 505 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 506 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 507 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 508 | (chan_bw != CH_WIDTH_MAX)) { |
| 509 | hdd_err("Only BW20 possible on channel 165"); |
| 510 | return -EINVAL; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 517 | /** |
| 518 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 519 | * |
| 520 | * Block the unloading of the driver (or) interface up until the |
| 521 | * cds recovery is completed |
| 522 | * |
| 523 | * Return: true for recovery completion else false |
| 524 | */ |
| 525 | static bool hdd_wait_for_recovery_completion(void) |
| 526 | { |
| 527 | int retry = 0; |
| 528 | |
| 529 | /* Wait for recovery to complete */ |
| 530 | while (cds_is_driver_recovering()) { |
| 531 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 532 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 533 | |
| 534 | if (g_is_system_reboot_triggered) { |
| 535 | hdd_info("System Reboot happening ignore unload!!"); |
| 536 | return false; |
| 537 | } |
| 538 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 539 | msleep(1000); |
| 540 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 541 | hdd_err("SSR never completed, error"); |
| 542 | /* |
| 543 | * Trigger the bug_on in the internal builds, in the |
| 544 | * customer builds self-recovery will be enabled |
| 545 | * in those cases just return error. |
| 546 | */ |
| 547 | if (cds_is_self_recovery_enabled()) |
| 548 | return false; |
| 549 | QDF_BUG(0); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | hdd_info("Recovery completed successfully!"); |
| 554 | return true; |
| 555 | } |
| 556 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 557 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 558 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 559 | unsigned long state, void *data) |
| 560 | { |
| 561 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 562 | struct netdev_notifier_info *dev_notif_info = data; |
| 563 | struct net_device *dev = dev_notif_info->dev; |
| 564 | #else |
| 565 | struct net_device *dev = data; |
| 566 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 567 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 568 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 569 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 570 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 571 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 572 | /* Make sure that this callback corresponds to our device. */ |
| 573 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 574 | return NOTIFY_DONE; |
| 575 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 576 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 578 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 579 | return NOTIFY_DONE; |
| 580 | } |
| 581 | |
| 582 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 583 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | return NOTIFY_DONE; |
| 585 | } |
| 586 | |
| 587 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 588 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 589 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 590 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 591 | return NOTIFY_DONE; |
| 592 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 593 | |
| 594 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 595 | hdd_err("%s: Driver module is closed", __func__); |
| 596 | return NOTIFY_DONE; |
| 597 | } |
| 598 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 599 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 600 | return NOTIFY_DONE; |
| 601 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 602 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 603 | dev->name, state); |
| 604 | |
| 605 | switch (state) { |
| 606 | case NETDEV_REGISTER: |
| 607 | break; |
| 608 | |
| 609 | case NETDEV_UNREGISTER: |
| 610 | break; |
| 611 | |
| 612 | case NETDEV_UP: |
| 613 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 614 | break; |
| 615 | |
| 616 | case NETDEV_DOWN: |
| 617 | break; |
| 618 | |
| 619 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 620 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | complete(&adapter->linkup_event_var); |
| 622 | break; |
| 623 | |
| 624 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 625 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 626 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 627 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 628 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 630 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 631 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 632 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 633 | /* |
| 634 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 635 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 636 | * flag after which driver does not send the cfg80211_scan_done. |
| 637 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 638 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 639 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 640 | break; |
| 641 | |
| 642 | default: |
| 643 | break; |
| 644 | } |
| 645 | |
| 646 | return NOTIFY_DONE; |
| 647 | } |
| 648 | |
| 649 | /** |
| 650 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 651 | * @nb: pointer to notifier block |
| 652 | * @state: state |
| 653 | * @ndev: ndev pointer |
| 654 | * |
| 655 | * Return: 0 on success, error number otherwise. |
| 656 | */ |
| 657 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 658 | unsigned long state, |
| 659 | void *ndev) |
| 660 | { |
| 661 | int ret; |
| 662 | |
| 663 | cds_ssr_protect(__func__); |
| 664 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 665 | cds_ssr_unprotect(__func__); |
| 666 | |
| 667 | return ret; |
| 668 | } |
| 669 | |
| 670 | struct notifier_block hdd_netdev_notifier = { |
| 671 | .notifier_call = hdd_netdev_notifier_call, |
| 672 | }; |
| 673 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 674 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 675 | unsigned long msg_type, void *_unused) |
| 676 | { |
| 677 | switch (msg_type) { |
| 678 | case SYS_DOWN: |
| 679 | case SYS_HALT: |
| 680 | case SYS_POWER_OFF: |
| 681 | g_is_system_reboot_triggered = true; |
| 682 | hdd_info("reboot, reason: %ld", msg_type); |
| 683 | break; |
| 684 | default: |
| 685 | break; |
| 686 | } |
| 687 | |
| 688 | return NOTIFY_OK; |
| 689 | } |
| 690 | |
| 691 | struct notifier_block system_reboot_notifier = { |
| 692 | .notifier_call = system_reboot_notifier_call, |
| 693 | }; |
| 694 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 695 | /* variable to hold the insmod parameters */ |
| 696 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 697 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 698 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 699 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 700 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 701 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 702 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 703 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 704 | /** |
| 705 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 706 | * @ch_width: NL channel width |
| 707 | * |
| 708 | * Converts the NL channel width to the driver's internal representation |
| 709 | * |
| 710 | * Return: Converted channel width. In case of non matching NL channel width, |
| 711 | * CH_WIDTH_MAX will be returned. |
| 712 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 713 | 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] | 714 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 715 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 716 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 717 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 718 | switch (ch_width) { |
| 719 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 720 | case NL80211_CHAN_WIDTH_20: |
| 721 | return CH_WIDTH_20MHZ; |
| 722 | case NL80211_CHAN_WIDTH_40: |
| 723 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 724 | case NL80211_CHAN_WIDTH_80: |
| 725 | return CH_WIDTH_80MHZ; |
| 726 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 727 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 728 | return CH_WIDTH_80P80MHZ; |
| 729 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 730 | return CH_WIDTH_160MHZ; |
| 731 | else |
| 732 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 733 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 734 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 735 | return CH_WIDTH_160MHZ; |
| 736 | else |
| 737 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 738 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 739 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 740 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 741 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 742 | default: |
| 743 | hdd_err("Invalid channel width %d, setting to default", |
| 744 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 745 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 746 | } |
| 747 | } |
| 748 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 749 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 750 | * @hal: handler to HAL |
| 751 | * @channel: channel id |
| 752 | * @bw_offset: bandwidth offset |
| 753 | * |
| 754 | * Function invokes sme api to find the operating class |
| 755 | * |
| 756 | * Return: operating class |
| 757 | */ |
| 758 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 759 | uint8_t bw_offset) |
| 760 | { |
| 761 | uint8_t opclass = 0; |
| 762 | |
| 763 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 764 | return opclass; |
| 765 | } |
| 766 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 768 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 769 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 770 | * @bitmask: Bitmask of log levels to be enabled |
| 771 | * |
| 772 | * Called immediately after the cfg.ini is read in order to configure |
| 773 | * the desired trace levels. |
| 774 | * |
| 775 | * Return: None |
| 776 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 777 | 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] | 778 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 779 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 780 | int qdf_print_idx = -1; |
| 781 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | /* |
| 783 | * if the bitmask is the default value, then a bitmask was not |
| 784 | * specified in cfg.ini, so leave the logging level alone (it |
| 785 | * will remain at the "compiled in" default value) |
| 786 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 787 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 788 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 789 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 790 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 791 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 792 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 793 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 794 | QDF_TRACE_LEVEL_NONE, 0); |
| 795 | |
| 796 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 797 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 798 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 799 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | while (0 != bitmask) { |
| 801 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 802 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 803 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 804 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 805 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 806 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 807 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 808 | level++; |
| 809 | bitmask >>= 1; |
| 810 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 811 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 815 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 816 | * @hdd_ctx: HDD context pointer |
| 817 | * |
| 818 | * Return: 0 if the context is valid. Error code otherwise |
| 819 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 820 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 821 | { |
| 822 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 823 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 824 | return -ENODEV; |
| 825 | } |
| 826 | |
| 827 | if (cds_is_driver_recovering()) { |
| 828 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 829 | (void *)_RET_IP_, cds_get_driver_state()); |
| 830 | return -EAGAIN; |
| 831 | } |
| 832 | |
| 833 | if (hdd_ctx->start_modules_in_progress || |
| 834 | hdd_ctx->stop_modules_in_progress) { |
| 835 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 836 | (void *)_RET_IP_); |
| 837 | return -EAGAIN; |
| 838 | } |
| 839 | |
| 840 | return 0; |
| 841 | } |
| 842 | |
| 843 | |
| 844 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | * wlan_hdd_validate_context() - check the HDD context |
| 846 | * @hdd_ctx: HDD context pointer |
| 847 | * |
| 848 | * Return: 0 if the context is valid. Error code otherwise |
| 849 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 850 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 851 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 852 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 853 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 854 | return -ENODEV; |
| 855 | } |
| 856 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 857 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 858 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 859 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 860 | return -EAGAIN; |
| 861 | } |
| 862 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 863 | if (cds_is_load_or_unload_in_progress()) { |
| 864 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 865 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 867 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 868 | |
| 869 | if (hdd_ctx->start_modules_in_progress || |
| 870 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 871 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 872 | (void *)_RET_IP_); |
| 873 | return -EAGAIN; |
| 874 | } |
| 875 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 876 | if (cds_is_driver_in_bad_state()) { |
| 877 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 878 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 879 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 880 | } |
| 881 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 882 | if (cds_is_fw_down()) { |
| 883 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 884 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 885 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 886 | } |
| 887 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 888 | return 0; |
| 889 | } |
| 890 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 891 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 892 | { |
| 893 | if (!adapter) { |
| 894 | hdd_err("adapter is null"); |
| 895 | return -EINVAL; |
| 896 | } |
| 897 | |
| 898 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 899 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 900 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 901 | return -EINVAL; |
| 902 | } |
| 903 | |
| 904 | if (!adapter->dev) { |
| 905 | hdd_err("adapter net_device is null"); |
| 906 | return -EINVAL; |
| 907 | } |
| 908 | |
| 909 | if (!(adapter->dev->flags & IFF_UP)) { |
| 910 | hdd_info("adapter net_device is not up"); |
| 911 | return -EAGAIN; |
| 912 | } |
| 913 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 914 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 915 | hdd_info("adapter session is not open"); |
| 916 | return -EAGAIN; |
| 917 | } |
| 918 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 919 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 920 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 921 | return -EINVAL; |
| 922 | } |
| 923 | |
| 924 | return 0; |
| 925 | } |
| 926 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 927 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 928 | * wlan_hdd_validate_modules_state() - Check modules status |
| 929 | * @hdd_ctx: HDD context pointer |
| 930 | * |
| 931 | * Check's the driver module's state and returns true if the |
| 932 | * modules are enabled returns false if modules are closed. |
| 933 | * |
| 934 | * Return: True if modules are enabled or false. |
| 935 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 936 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 937 | { |
| 938 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 939 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 940 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 941 | hdd_info("Modules not enabled, Present status: %d", |
| 942 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 943 | return false; |
| 944 | } |
| 945 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 946 | return true; |
| 947 | } |
| 948 | |
| 949 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 950 | * 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] | 951 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 952 | * |
| 953 | * This function sets the IBSS power save config parameters to WMA |
| 954 | * which will send it to firmware if FW supports IBSS power save |
| 955 | * before vdev start. |
| 956 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 957 | * 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] | 958 | * on failure. |
| 959 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 960 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 961 | { |
| 962 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 963 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | |
| 965 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 966 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 967 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 968 | } |
| 969 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 970 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 971 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 972 | hdd_ctx->config->ibssATIMWinSize, |
| 973 | VDEV_CMD); |
| 974 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 975 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 976 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | } |
| 978 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 979 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 980 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 981 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 982 | VDEV_CMD); |
| 983 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 984 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 985 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 986 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 987 | } |
| 988 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 989 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 991 | hdd_ctx->config-> |
| 992 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 993 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 994 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 995 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 996 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | } |
| 998 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 999 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1000 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1001 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1002 | VDEV_CMD); |
| 1003 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1004 | 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] | 1005 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | } |
| 1007 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1008 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1010 | hdd_ctx->config->ibssInactivityCount, |
| 1011 | VDEV_CMD); |
| 1012 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1013 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1014 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | } |
| 1016 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1017 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1019 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1020 | VDEV_CMD); |
| 1021 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1022 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1023 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1024 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1025 | } |
| 1026 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1027 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1029 | hdd_ctx->config->ibssPsWarmupTime, |
| 1030 | VDEV_CMD); |
| 1031 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1032 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1033 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1034 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | } |
| 1036 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1037 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1039 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1040 | VDEV_CMD); |
| 1041 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1042 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1043 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1044 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1045 | } |
| 1046 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1047 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1048 | } |
| 1049 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1050 | #ifdef FEATURE_RUNTIME_PM |
| 1051 | /** |
| 1052 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1053 | * @hdd_ctx: HDD context |
| 1054 | * |
| 1055 | * Return: None |
| 1056 | */ |
| 1057 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1058 | { |
| 1059 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1060 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1061 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1062 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1063 | |
| 1064 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1065 | } |
| 1066 | |
| 1067 | /** |
| 1068 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1069 | * @hdd_ctx: HDD Context |
| 1070 | * |
| 1071 | * Return: None |
| 1072 | */ |
| 1073 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1074 | { |
| 1075 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1076 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1077 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1078 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1079 | |
| 1080 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1081 | } |
| 1082 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1083 | #else /* FEATURE_RUNTIME_PM */ |
| 1084 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1085 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1086 | #endif /* FEATURE_RUNTIME_PM */ |
| 1087 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1088 | #define INTF_MACADDR_MASK 0x7 |
| 1089 | |
| 1090 | /** |
| 1091 | * hdd_update_macaddr() - update mac address |
| 1092 | * @config: hdd configuration |
| 1093 | * @hw_macaddr: mac address |
| 1094 | * |
| 1095 | * Mac address for multiple virtual interface is found as following |
| 1096 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1097 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1098 | * define the mac address for the remaining interfaces and locally |
| 1099 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1100 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1101 | * interface). |
| 1102 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1103 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1104 | * |
| 1105 | * Return: None |
| 1106 | */ |
| 1107 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1108 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1109 | { |
| 1110 | int8_t i; |
| 1111 | uint8_t macaddr_b3, tmp_br3; |
| 1112 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1113 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1114 | QDF_MAC_ADDR_SIZE); |
| 1115 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1116 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1117 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1118 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1119 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1120 | INTF_MACADDR_MASK; |
| 1121 | macaddr_b3 += tmp_br3; |
| 1122 | |
| 1123 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1124 | * mac address range before collision |
| 1125 | */ |
| 1126 | macaddr_b3 ^= (1 << 7); |
| 1127 | |
| 1128 | /* Set locally administered bit */ |
| 1129 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1130 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1131 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1132 | MAC_ADDRESS_STR, i, |
| 1133 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1134 | } |
| 1135 | } |
| 1136 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1137 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1138 | { |
| 1139 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1140 | struct tdls_start_params tdls_cfg; |
| 1141 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1142 | struct hdd_config *cfg = hdd_ctx->config; |
| 1143 | QDF_STATUS status; |
| 1144 | |
| 1145 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1146 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1147 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1148 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1149 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1150 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1151 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1152 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1153 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1154 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1155 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1156 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1157 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1158 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1159 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1160 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1161 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1162 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1163 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1164 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1165 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1166 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1167 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1168 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1169 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1170 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1171 | (cfg->fTDLSExternalControl ? |
| 1172 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1173 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1174 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1175 | |
| 1176 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1177 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1178 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1179 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1180 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1181 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1182 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1183 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1184 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1185 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1186 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1187 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1188 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1189 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1190 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1191 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1192 | |
| 1193 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1194 | if (status != QDF_STATUS_SUCCESS) { |
| 1195 | hdd_err("failed pmo psoc configuration"); |
| 1196 | return -EINVAL; |
| 1197 | } |
| 1198 | |
| 1199 | hdd_ctx->tdls_umac_comp_active = true; |
| 1200 | /* enable napier specific tdls data path */ |
| 1201 | hdd_ctx->tdls_nap_active = true; |
| 1202 | |
| 1203 | return 0; |
| 1204 | } |
| 1205 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1206 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | struct wma_tgt_services *cfg) |
| 1208 | { |
| 1209 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1210 | |
| 1211 | /* Set up UAPSD */ |
| 1212 | config->apUapsdEnabled &= cfg->uapsd; |
| 1213 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1214 | /* 11AX mode support */ |
| 1215 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1216 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1217 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1219 | /* 11AC mode support */ |
| 1220 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1221 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1222 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | |
| 1224 | /* ARP offload: override user setting if invalid */ |
| 1225 | config->fhostArpOffload &= cfg->arp_offload; |
| 1226 | |
| 1227 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1228 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1229 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1230 | if (cfg->pno_offload) |
| 1231 | config->PnoOffload = true; |
| 1232 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | #ifdef FEATURE_WLAN_TDLS |
| 1234 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1235 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1236 | cfg->en_tdls_offchan; |
| 1237 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1238 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1239 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1241 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1243 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1244 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1245 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1246 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1247 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1248 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1249 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1250 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1251 | |
| 1252 | } |
| 1253 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1254 | /** |
| 1255 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1256 | * @hdd_ctx: HDD context |
| 1257 | * |
| 1258 | * Sets the Nss per vdev type based on INI |
| 1259 | * |
| 1260 | * Return: None |
| 1261 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1262 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1263 | { |
| 1264 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1265 | uint8_t max_supp_nss = 1; |
| 1266 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1267 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1268 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1269 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1270 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1271 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1272 | |
| 1273 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1274 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1275 | |
| 1276 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1277 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1278 | } |
| 1279 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1280 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1281 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1282 | * @hdd_ctx: HDD context |
| 1283 | * |
| 1284 | * Updates wiphy vhtcap fields |
| 1285 | * |
| 1286 | * Return: None |
| 1287 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1288 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1289 | { |
| 1290 | struct ieee80211_supported_band *band_5g = |
| 1291 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1292 | uint32_t val; |
| 1293 | |
| 1294 | if (!band_5g) { |
| 1295 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1296 | return; |
| 1297 | } |
| 1298 | |
| 1299 | val = hdd_ctx->config->txBFCsnValue; |
| 1300 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1301 | |
| 1302 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1303 | band_5g->vht_cap.cap |= |
| 1304 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1305 | |
| 1306 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1307 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1308 | } |
| 1309 | |
| 1310 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1311 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1312 | * @hdd_ctx: HDD context |
| 1313 | * |
| 1314 | * Sets the DBS capability as per INI and firmware capability |
| 1315 | * |
| 1316 | * Return: None |
| 1317 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1318 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1319 | { |
| 1320 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1321 | uint8_t hw_dbs_capable = 0; |
| 1322 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1323 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1324 | ((cfg_ini->dual_mac_feature_disable == |
| 1325 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1326 | (cfg_ini->dual_mac_feature_disable == |
| 1327 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1328 | hw_dbs_capable = 1; |
| 1329 | |
| 1330 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1331 | } |
| 1332 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1333 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1334 | struct wma_tgt_ht_cap *cfg) |
| 1335 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1336 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1337 | uint32_t value, val32; |
| 1338 | uint16_t val16; |
| 1339 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1340 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1341 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1342 | uint8_t enable_tx_stbc; |
| 1343 | |
| 1344 | /* check and update RX STBC */ |
| 1345 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1346 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1347 | |
| 1348 | /* get the MPDU density */ |
| 1349 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1350 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1351 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1352 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1353 | value = 0; |
| 1354 | } |
| 1355 | |
| 1356 | /* |
| 1357 | * MPDU density: |
| 1358 | * override user's setting if value is larger |
| 1359 | * than the one supported by target |
| 1360 | */ |
| 1361 | if (value > cfg->mpdu_density) { |
| 1362 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1363 | cfg->mpdu_density); |
| 1364 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1365 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1366 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1367 | } |
| 1368 | |
| 1369 | /* get the HT capability info */ |
| 1370 | 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] | 1371 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1372 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | return; |
| 1374 | } |
| 1375 | val16 = (uint16_t) val32; |
| 1376 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1377 | |
| 1378 | /* Set the LDPC capability */ |
| 1379 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1380 | |
| 1381 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1382 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1383 | |
| 1384 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1385 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1386 | |
| 1387 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1388 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1389 | |
| 1390 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1391 | |
| 1392 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1393 | pconfig->enable2x2 = 1; |
| 1394 | } else { |
| 1395 | pconfig->enable2x2 = 0; |
| 1396 | enable_tx_stbc = 0; |
| 1397 | |
| 1398 | /* 1x1 */ |
| 1399 | /* Update Rx Highest Long GI data Rate */ |
| 1400 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1401 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1402 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1403 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1404 | 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] | 1405 | } |
| 1406 | |
| 1407 | /* Update Tx Highest Long GI data Rate */ |
| 1408 | if (sme_cfg_set_int |
| 1409 | (hdd_ctx->hHal, |
| 1410 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1411 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1412 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1413 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1414 | } |
| 1415 | } |
| 1416 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1417 | enable_tx_stbc = 0; |
| 1418 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1419 | |
| 1420 | val32 = val16; |
| 1421 | 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] | 1422 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1423 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1424 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1425 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1426 | 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] | 1427 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1428 | hdd_debug("Read MCS rate set"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1429 | |
| 1430 | if (pconfig->enable2x2) { |
| 1431 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1432 | mcs_set[value] = |
| 1433 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1434 | |
| 1435 | status = |
| 1436 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1437 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1438 | mcs_set, |
| 1439 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1440 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1441 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1445 | } |
| 1446 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1447 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1448 | struct wma_tgt_vht_cap *cfg) |
| 1449 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1450 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | uint32_t value = 0; |
| 1452 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1453 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1454 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1455 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1456 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1457 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1458 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1459 | struct wma_caps_per_phy caps_per_phy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1461 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1462 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1463 | return; |
| 1464 | } |
| 1465 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | /* Get the current MPDU length */ |
| 1467 | status = |
| 1468 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1469 | &value); |
| 1470 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1471 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1472 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1473 | value = 0; |
| 1474 | } |
| 1475 | |
| 1476 | /* |
| 1477 | * VHT max MPDU length: |
| 1478 | * override if user configured value is too high |
| 1479 | * that the target cannot support |
| 1480 | */ |
| 1481 | if (value > cfg->vht_max_mpdu) { |
| 1482 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1483 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1484 | cfg->vht_max_mpdu); |
| 1485 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1486 | if (status == QDF_STATUS_E_FAILURE) |
| 1487 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | } |
| 1489 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1490 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1491 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1492 | |
| 1493 | if (pconfig->enable2x2) |
| 1494 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1495 | |
| 1496 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1497 | QDF_STATUS_E_FAILURE) { |
| 1498 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1499 | } |
| 1500 | |
| 1501 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1502 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1503 | if (pconfig->enable2x2) |
| 1504 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1505 | |
| 1506 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1507 | QDF_STATUS_E_FAILURE) { |
| 1508 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1509 | } |
| 1510 | |
| 1511 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1512 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1513 | if (pconfig->enable2x2) |
| 1514 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1515 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1516 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1517 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1518 | |
| 1519 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1520 | QDF_STATUS_E_FAILURE) { |
| 1521 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1522 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1524 | 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] | 1525 | &value); |
| 1526 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1527 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1528 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | value = 0; |
| 1530 | } |
| 1531 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1532 | /* Set HW RX LDPC capability */ |
| 1533 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1534 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1536 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1537 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1538 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1539 | if (status == QDF_STATUS_E_FAILURE) |
| 1540 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | } |
| 1542 | |
| 1543 | /* Get current GI 80 value */ |
| 1544 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1545 | &value); |
| 1546 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1547 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1548 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1549 | value = 0; |
| 1550 | } |
| 1551 | |
| 1552 | /* set the Guard interval 80MHz */ |
| 1553 | if (value && !cfg->vht_short_gi_80) { |
| 1554 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1555 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1556 | cfg->vht_short_gi_80); |
| 1557 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1558 | if (status == QDF_STATUS_E_FAILURE) |
| 1559 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | } |
| 1561 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1562 | /* Get VHT TX STBC cap */ |
| 1563 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1564 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1565 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1566 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | value = 0; |
| 1568 | } |
| 1569 | |
| 1570 | /* VHT TX STBC cap */ |
| 1571 | if (value && !cfg->vht_tx_stbc) { |
| 1572 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1573 | cfg->vht_tx_stbc); |
| 1574 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1575 | if (status == QDF_STATUS_E_FAILURE) |
| 1576 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | /* Get VHT RX STBC cap */ |
| 1580 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1581 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1582 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1583 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | value = 0; |
| 1585 | } |
| 1586 | |
| 1587 | /* VHT RX STBC cap */ |
| 1588 | if (value && !cfg->vht_rx_stbc) { |
| 1589 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1590 | cfg->vht_rx_stbc); |
| 1591 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1592 | if (status == QDF_STATUS_E_FAILURE) |
| 1593 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | } |
| 1595 | |
| 1596 | /* Get VHT SU Beamformer cap */ |
| 1597 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1598 | &value); |
| 1599 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1600 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1601 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1602 | value = 0; |
| 1603 | } |
| 1604 | |
| 1605 | /* set VHT SU Beamformer cap */ |
| 1606 | if (value && !cfg->vht_su_bformer) { |
| 1607 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1608 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1609 | cfg->vht_su_bformer); |
| 1610 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1611 | if (status == QDF_STATUS_E_FAILURE) |
| 1612 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | } |
| 1614 | |
| 1615 | /* check and update SU BEAMFORMEE capabality */ |
| 1616 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1617 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1618 | |
| 1619 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1620 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1621 | pconfig->enableTxBF); |
| 1622 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1623 | if (status == QDF_STATUS_E_FAILURE) |
| 1624 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | |
| 1626 | /* Get VHT MU Beamformer cap */ |
| 1627 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1628 | &value); |
| 1629 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1630 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1631 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1632 | value = 0; |
| 1633 | } |
| 1634 | |
| 1635 | /* set VHT MU Beamformer cap */ |
| 1636 | if (value && !cfg->vht_mu_bformer) { |
| 1637 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1638 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1639 | cfg->vht_mu_bformer); |
| 1640 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1641 | if (status == QDF_STATUS_E_FAILURE) |
| 1642 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1643 | } |
| 1644 | |
| 1645 | /* Get VHT MU Beamformee cap */ |
| 1646 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1647 | &value); |
| 1648 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1649 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1650 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | value = 0; |
| 1652 | } |
| 1653 | |
| 1654 | /* set VHT MU Beamformee cap */ |
| 1655 | if (value && !cfg->vht_mu_bformee) { |
| 1656 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1657 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1658 | cfg->vht_mu_bformee); |
| 1659 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1660 | if (status == QDF_STATUS_E_FAILURE) |
| 1661 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | /* Get VHT MAX AMPDU Len exp */ |
| 1665 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1666 | &value); |
| 1667 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1668 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1669 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | value = 0; |
| 1671 | } |
| 1672 | |
| 1673 | /* |
| 1674 | * VHT max AMPDU len exp: |
| 1675 | * override if user configured value is too high |
| 1676 | * that the target cannot support. |
| 1677 | * Even though Rome publish ampdu_len=7, it can |
| 1678 | * only support 4 because of some h/w bug. |
| 1679 | */ |
| 1680 | |
| 1681 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1682 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1683 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1684 | cfg->vht_max_ampdu_len_exp); |
| 1685 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1686 | if (status == QDF_STATUS_E_FAILURE) |
| 1687 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | } |
| 1689 | |
| 1690 | /* Get VHT TXOP PS CAP */ |
| 1691 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1692 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1693 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1694 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1695 | value = 0; |
| 1696 | } |
| 1697 | |
| 1698 | /* set VHT TXOP PS cap */ |
| 1699 | if (value && !cfg->vht_txop_ps) { |
| 1700 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1701 | cfg->vht_txop_ps); |
| 1702 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1703 | if (status == QDF_STATUS_E_FAILURE) |
| 1704 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1705 | } |
| 1706 | |
| 1707 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1708 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1709 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1710 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1711 | else |
| 1712 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1713 | |
| 1714 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1715 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1716 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1717 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1718 | VHT_CAP_160_AND_80P80_SUPP); |
| 1719 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1720 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1721 | band_5g->vht_cap.cap |= |
| 1722 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1723 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1724 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1725 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1726 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1727 | VHT_CAP_160_SUPP); |
| 1728 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1729 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | band_5g->vht_cap.cap |= |
| 1731 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1732 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1733 | } |
| 1734 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1735 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1736 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1737 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1738 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1739 | &value); |
| 1740 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1741 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1742 | value = 0; |
| 1743 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1744 | /* set the Guard interval 160MHz */ |
| 1745 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1746 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1747 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1748 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1749 | |
| 1750 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1751 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1752 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1753 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1754 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1755 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1756 | hdd_debug("VHT RxLDPC capability is set"); |
| 1757 | } else { |
| 1758 | /* |
| 1759 | * Get the RX LDPC capability for the NON DBS |
| 1760 | * hardware mode for 5G band |
| 1761 | */ |
| 1762 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1763 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1764 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1765 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1766 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1767 | hdd_debug("VHT RX LDPC capability is set"); |
| 1768 | } |
| 1769 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1770 | |
| 1771 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1772 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1773 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1774 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1775 | |
| 1776 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1777 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1778 | |
| 1779 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1780 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1781 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1782 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1783 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1784 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1785 | |
| 1786 | band_5g->vht_cap.cap |= |
| 1787 | (cfg->vht_max_ampdu_len_exp << |
| 1788 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1789 | |
| 1790 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1791 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1792 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1793 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1794 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1795 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1796 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1797 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1798 | |
| 1799 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1800 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1801 | |
| 1802 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1803 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1804 | /** |
| 1805 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1806 | * @hdd_ctx: Pointer to the HDD context |
| 1807 | * |
| 1808 | * Auto-generate mac address using device serial number. |
| 1809 | * Keep the first 3 bytes of OUI as before and replace |
| 1810 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1811 | * |
| 1812 | * Return: 0 for success |
| 1813 | * Non zero failure code for errors |
| 1814 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1815 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1816 | { |
| 1817 | unsigned int serialno = 0; |
| 1818 | struct qdf_mac_addr mac_addr = { |
| 1819 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1820 | }; |
| 1821 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1822 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1823 | if (serialno == 0) |
| 1824 | return -EINVAL; |
| 1825 | |
| 1826 | serialno &= 0x00ffffff; |
| 1827 | |
| 1828 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1829 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1830 | mac_addr.bytes[5] = serialno & 0xff; |
| 1831 | |
| 1832 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1833 | return 0; |
| 1834 | } |
| 1835 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1836 | /** |
| 1837 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1838 | * configuration to cfg_ini in HDD |
| 1839 | * @hdd_ctx: Pointer to hdd_ctx |
| 1840 | * @cfg: target configuration |
| 1841 | * |
| 1842 | * Return: None |
| 1843 | */ |
| 1844 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1845 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1846 | struct wma_tgt_cfg *cfg) |
| 1847 | { |
| 1848 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1849 | } |
| 1850 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1851 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1852 | struct wma_tgt_cfg *cfg) |
| 1853 | { |
| 1854 | } |
| 1855 | #endif |
| 1856 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1857 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1858 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1859 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1860 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1861 | struct wma_tgt_cfg *cfg = param; |
| 1862 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1863 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1864 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1865 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1866 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1867 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1868 | if (ret) { |
| 1869 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1870 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1871 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1872 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1873 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1874 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1875 | hdd_err("dispatcher pdev open failed"); |
| 1876 | QDF_BUG(0); |
| 1877 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1878 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1879 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1880 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1881 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1882 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1883 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1884 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1885 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1886 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1887 | hdd_softap_hard_start_xmit); |
| 1888 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1889 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1890 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1891 | if (cds_cfg) { |
| 1892 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1893 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1894 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1895 | cds_cfg->sub_20_channel_width = |
| 1896 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1897 | } else { |
| 1898 | cds_cfg->sub_20_channel_width = |
| 1899 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1900 | } |
| 1901 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1902 | |
| 1903 | /* first store the INI band capability */ |
| 1904 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1905 | |
| 1906 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1907 | hdd_ctx->is_fils_roaming_supported = |
| 1908 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1910 | hdd_ctx->config->is_11k_offload_supported = |
| 1911 | cfg->services.is_11k_offload_supported; |
| 1912 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1913 | /* |
| 1914 | * now overwrite the target band capability with INI |
| 1915 | * setting if INI setting is a subset |
| 1916 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1917 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1918 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1919 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1921 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1922 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1923 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1924 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1925 | } |
| 1926 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1927 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1928 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1929 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1931 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1932 | } |
| 1933 | |
| 1934 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1935 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1936 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1937 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1938 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1939 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1940 | static struct qdf_mac_addr default_mac_addr = { |
| 1941 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1942 | }; |
| 1943 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1944 | &default_mac_addr)) { |
| 1945 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1946 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1947 | MAC_ADDRESS_STR, |
| 1948 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1949 | intfMacAddr[0].bytes)); |
| 1950 | } else { |
| 1951 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1952 | MAC_ADDRESS_STR, |
| 1953 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1954 | intfMacAddr[0].bytes)); |
| 1955 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1956 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1957 | } |
| 1958 | |
| 1959 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1960 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1961 | |
| 1962 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1963 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1964 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1965 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1966 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1967 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1968 | |
| 1969 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1970 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1971 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1972 | if (cfg->services.en_11ax) { |
| 1973 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1974 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1975 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1976 | |
| 1977 | hdd_update_vdev_nss(hdd_ctx); |
| 1978 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1979 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1980 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1981 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1982 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1983 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1984 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1985 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1986 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1987 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1988 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1989 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1990 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1991 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1992 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1993 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1994 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1995 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1996 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1997 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1998 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1999 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2000 | hdd_ctx->config->txBFCsnValue = |
| 2001 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2002 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2003 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2004 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2005 | hdd_ctx->config->txBFCsnValue); |
| 2006 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2007 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2008 | |
| 2009 | |
| 2010 | hdd_debug("Target BPF %d Host BPF %d 8ss fw support %d txBFCsnValue %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2011 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 2012 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2013 | |
| 2014 | /* |
| 2015 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2016 | */ |
| 2017 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2018 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2019 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2020 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2021 | /* |
| 2022 | * This needs to be done after HDD pdev is created and stored since |
| 2023 | * it will access the HDD pdev object lock. |
| 2024 | */ |
| 2025 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2026 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2027 | /* Configure NAN datapath features */ |
| 2028 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2029 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2030 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2031 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2032 | cfg->obss_detection_offloaded); |
| 2033 | if (QDF_IS_STATUS_ERROR(status)) |
| 2034 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2035 | |
| 2036 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2037 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2038 | cfg->obss_color_collision_offloaded); |
| 2039 | if (QDF_IS_STATUS_ERROR(status)) |
| 2040 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2041 | } |
| 2042 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2043 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2044 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2045 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2046 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2047 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2048 | if (!hdd_ctx) { |
| 2049 | hdd_info("Couldn't get hdd_ctx"); |
| 2050 | return true; |
| 2051 | } |
| 2052 | |
| 2053 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2054 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2055 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2056 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2057 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2058 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2059 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2060 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2061 | |
| 2062 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2063 | QDF_P2P_GO_MODE == adapter->device_mode) && |
| 2064 | (wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2065 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2066 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2067 | true; |
| 2068 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2069 | adapter->session_id); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2070 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2071 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2072 | |
| 2073 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2074 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2075 | |
| 2076 | /** |
| 2077 | * hdd_is_valid_mac_address() - validate MAC address |
| 2078 | * @pMacAddr: Pointer to the input MAC address |
| 2079 | * |
| 2080 | * This function validates whether the given MAC address is valid or not |
| 2081 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2082 | * where X is the hexa decimal digit character and separated by ':' |
| 2083 | * This algorithm works even if MAC address is not separated by ':' |
| 2084 | * |
| 2085 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2086 | * digits and a separator colon : appears in the input string only after |
| 2087 | * an even number of hex digits. |
| 2088 | * |
| 2089 | * Return: 1 for valid and 0 for invalid |
| 2090 | */ |
| 2091 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2092 | { |
| 2093 | int xdigit = 0; |
| 2094 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2095 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2096 | while (*pMacAddr) { |
| 2097 | if (isxdigit(*pMacAddr)) { |
| 2098 | xdigit++; |
| 2099 | } else if (':' == *pMacAddr) { |
| 2100 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2101 | break; |
| 2102 | |
| 2103 | ++separator; |
| 2104 | } else { |
| 2105 | /* Invalid MAC found */ |
| 2106 | return 0; |
| 2107 | } |
| 2108 | ++pMacAddr; |
| 2109 | } |
| 2110 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2111 | } |
| 2112 | |
| 2113 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2114 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2115 | * @dev: Handle to struct net_device to be updated. |
| 2116 | * |
| 2117 | * Return: None |
| 2118 | */ |
| 2119 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2120 | { |
| 2121 | dev->header_ops = NULL; |
| 2122 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2123 | dev->hard_header_len = ETH_HLEN; |
| 2124 | dev->mtu = ETH_DATA_LEN; |
| 2125 | dev->addr_len = ETH_ALEN; |
| 2126 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2127 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2128 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2129 | |
| 2130 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2131 | } |
| 2132 | |
| 2133 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2134 | * __hdd__mon_open() - HDD Open function |
| 2135 | * @dev: Pointer to net_device structure |
| 2136 | * |
| 2137 | * This is called in response to ifconfig up |
| 2138 | * |
| 2139 | * Return: 0 for success; non-zero for failure |
| 2140 | */ |
| 2141 | static int __hdd_mon_open(struct net_device *dev) |
| 2142 | { |
| 2143 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2144 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2145 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2146 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2147 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2148 | |
| 2149 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2150 | if (ret) |
| 2151 | return ret; |
| 2152 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2153 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2154 | |
| 2155 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 2156 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2157 | if (ret) { |
| 2158 | hdd_err("Failed to start WLAN modules return"); |
| 2159 | return ret; |
| 2160 | } |
| 2161 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2162 | |
| 2163 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2164 | ret = hdd_start_adapter(adapter); |
| 2165 | if (ret) { |
| 2166 | hdd_err("Failed to start adapter :%d", |
| 2167 | adapter->device_mode); |
| 2168 | return ret; |
| 2169 | } |
| 2170 | hdd_err("hdd_start_adapters() successful !"); |
| 2171 | } |
| 2172 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2173 | } |
| 2174 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2175 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2176 | |
| 2177 | if (!ret) |
| 2178 | ret = hdd_enable_monitor_mode(dev); |
| 2179 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2180 | return ret; |
| 2181 | } |
| 2182 | |
| 2183 | /** |
| 2184 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2185 | * @dev: Pointer to net_device structure |
| 2186 | * |
| 2187 | * This is called in response to ifconfig up |
| 2188 | * |
| 2189 | * Return: 0 for success; non-zero for failure |
| 2190 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2191 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2192 | { |
| 2193 | int ret; |
| 2194 | |
| 2195 | cds_ssr_protect(__func__); |
| 2196 | ret = __hdd_mon_open(dev); |
| 2197 | cds_ssr_unprotect(__func__); |
| 2198 | |
| 2199 | return ret; |
| 2200 | } |
| 2201 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2202 | static QDF_STATUS |
| 2203 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2204 | { |
| 2205 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2206 | QDF_STATUS status; |
| 2207 | uint32_t channel_select_logic_conc; |
| 2208 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2209 | |
| 2210 | if (!hdd_ctx) { |
| 2211 | hdd_err("HDD context is NULL"); |
| 2212 | return QDF_STATUS_E_FAILURE; |
| 2213 | } |
| 2214 | |
| 2215 | |
| 2216 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2217 | return QDF_STATUS_SUCCESS; |
| 2218 | |
| 2219 | cfg.scan_config = 0; |
| 2220 | cfg.fw_mode_config = 0; |
| 2221 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2222 | |
| 2223 | channel_select_logic_conc = hdd_ctx->config-> |
| 2224 | channel_select_logic_conc; |
| 2225 | |
| 2226 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2227 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2228 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2229 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2230 | &cfg.fw_mode_config, |
| 2231 | hdd_ctx->config->dual_mac_feature_disable, |
| 2232 | channel_select_logic_conc); |
| 2233 | |
| 2234 | if (status != QDF_STATUS_SUCCESS) { |
| 2235 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2236 | status); |
| 2237 | return status; |
| 2238 | } |
| 2239 | } |
| 2240 | |
| 2241 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2242 | cfg.scan_config, cfg.fw_mode_config); |
| 2243 | |
| 2244 | status = sme_soc_set_dual_mac_config(cfg); |
| 2245 | if (status != QDF_STATUS_SUCCESS) { |
| 2246 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2247 | return status; |
| 2248 | } |
| 2249 | |
| 2250 | return QDF_STATUS_SUCCESS; |
| 2251 | } |
| 2252 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2253 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2254 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2255 | * @adapter: pointer to HDD adapter |
| 2256 | * |
| 2257 | * This function is called to start the device specific adapter for |
| 2258 | * the mode passed in the adapter's device_mode. |
| 2259 | * |
| 2260 | * Return: 0 for success; non-zero for failure |
| 2261 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2262 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2263 | { |
| 2264 | |
| 2265 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2266 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2267 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2268 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2269 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2270 | |
| 2271 | switch (device_mode) { |
| 2272 | case QDF_P2P_CLIENT_MODE: |
| 2273 | case QDF_P2P_DEVICE_MODE: |
| 2274 | case QDF_OCB_MODE: |
| 2275 | case QDF_STA_MODE: |
| 2276 | case QDF_MONITOR_MODE: |
| 2277 | ret = hdd_start_station_adapter(adapter); |
| 2278 | if (ret) |
| 2279 | goto err_start_adapter; |
| 2280 | break; |
| 2281 | case QDF_P2P_GO_MODE: |
| 2282 | case QDF_SAP_MODE: |
| 2283 | ret = hdd_start_ap_adapter(adapter); |
| 2284 | if (ret) |
| 2285 | goto err_start_adapter; |
| 2286 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2287 | case QDF_IBSS_MODE: |
| 2288 | /* |
| 2289 | * For IBSS interface is initialized as part of |
| 2290 | * hdd_init_station_mode() |
| 2291 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2292 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2293 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2294 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2295 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2296 | default: |
| 2297 | hdd_err("Invalid session type %d", device_mode); |
| 2298 | QDF_ASSERT(0); |
| 2299 | goto err_start_adapter; |
| 2300 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2301 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2302 | if (hdd_set_fw_params(adapter)) |
| 2303 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2304 | |
| 2305 | /* |
| 2306 | * Action frame registered in one adapter which will |
| 2307 | * applicable to all interfaces |
| 2308 | */ |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2309 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2310 | if (ret < 0) { |
| 2311 | hdd_err("Failed to register frames - ret %d", ret); |
| 2312 | goto err_start_adapter; |
| 2313 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2314 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2315 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2316 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2317 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2318 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2319 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2320 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2321 | err_start_adapter: |
| 2322 | return -EINVAL; |
| 2323 | } |
| 2324 | |
| 2325 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2326 | * hdd_enable_power_management() - API to Enable Power Management |
| 2327 | * |
| 2328 | * API invokes Bus Interface Layer power management functionality |
| 2329 | * |
| 2330 | * Return: None |
| 2331 | */ |
| 2332 | static void hdd_enable_power_management(void) |
| 2333 | { |
| 2334 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2335 | |
| 2336 | if (!hif_ctx) { |
| 2337 | hdd_err("Bus Interface Context is Invalid"); |
| 2338 | return; |
| 2339 | } |
| 2340 | |
| 2341 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2342 | } |
| 2343 | |
| 2344 | /** |
| 2345 | * hdd_disable_power_management() - API to disable Power Management |
| 2346 | * |
| 2347 | * API disable Bus Interface Layer Power management functionality |
| 2348 | * |
| 2349 | * Return: None |
| 2350 | */ |
| 2351 | static void hdd_disable_power_management(void) |
| 2352 | { |
| 2353 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2354 | |
| 2355 | if (!hif_ctx) { |
| 2356 | hdd_err("Bus Interface Context is Invalid"); |
| 2357 | return; |
| 2358 | } |
| 2359 | |
| 2360 | hif_disable_power_management(hif_ctx); |
| 2361 | } |
| 2362 | |
| 2363 | /** |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2364 | * hdd_update_hw_sw_info() - API to update the HW/SW information |
| 2365 | * |
| 2366 | * API to update the HW and SW information in the driver |
| 2367 | * |
| 2368 | * Return: None |
| 2369 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2370 | static void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2371 | { |
| 2372 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2373 | size_t target_hw_name_len; |
| 2374 | const char *target_hw_name; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2375 | |
| 2376 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2377 | if (!hif_sc) { |
| 2378 | hdd_err("HIF context is NULL"); |
| 2379 | return; |
| 2380 | } |
| 2381 | |
| 2382 | /* |
| 2383 | * target hw version/revision would only be retrieved after firmware |
| 2384 | * download |
| 2385 | */ |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2386 | hif_get_hw_info(hif_sc, |
| 2387 | &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2388 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2389 | &target_hw_name); |
| 2390 | |
| 2391 | if (hdd_ctx->target_hw_name) |
| 2392 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2393 | |
| 2394 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2395 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2396 | if (hdd_ctx->target_hw_name) |
| 2397 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2398 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2399 | |
| 2400 | /* Get the wlan hw/fw version */ |
| 2401 | hdd_wlan_get_version(hdd_ctx, NULL, NULL); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2402 | } |
| 2403 | |
| 2404 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2405 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2406 | * @hdd_ctx: Pointer to hdd context |
| 2407 | * |
| 2408 | * Return: none |
| 2409 | */ |
| 2410 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2411 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2412 | { |
| 2413 | uint8_t num_entries = 0; |
| 2414 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2415 | uint8_t *tx_sched_wrr_ac; |
| 2416 | int i; |
| 2417 | cds_context_type *cds_ctx; |
| 2418 | |
| 2419 | if (NULL == hdd_ctx) |
| 2420 | return; |
| 2421 | |
| 2422 | if (NULL == hdd_ctx->config) { |
| 2423 | /* Do nothing if hdd_ctx is invalid */ |
| 2424 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2425 | return; |
| 2426 | } |
| 2427 | |
| 2428 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2429 | |
| 2430 | if (!cds_ctx) { |
| 2431 | hdd_err("Invalid CDS Context"); |
| 2432 | return; |
| 2433 | } |
| 2434 | |
| 2435 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2436 | switch (i) { |
| 2437 | case OL_TX_WMM_AC_BE: |
| 2438 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2439 | break; |
| 2440 | case OL_TX_WMM_AC_BK: |
| 2441 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2442 | break; |
| 2443 | case OL_TX_WMM_AC_VI: |
| 2444 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2445 | break; |
| 2446 | case OL_TX_WMM_AC_VO: |
| 2447 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2448 | break; |
| 2449 | default: |
| 2450 | tx_sched_wrr_ac = NULL; |
| 2451 | break; |
| 2452 | } |
| 2453 | |
| 2454 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2455 | tx_sched_wrr_param, |
| 2456 | &num_entries, |
| 2457 | sizeof(tx_sched_wrr_param)); |
| 2458 | |
| 2459 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2460 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2461 | tx_sched_wrr_param[0]; |
| 2462 | cds_ctx->ac_specs[i].credit_threshold = |
| 2463 | tx_sched_wrr_param[1]; |
| 2464 | cds_ctx->ac_specs[i].send_limit = |
| 2465 | tx_sched_wrr_param[2]; |
| 2466 | cds_ctx->ac_specs[i].credit_reserve = |
| 2467 | tx_sched_wrr_param[3]; |
| 2468 | cds_ctx->ac_specs[i].discard_weight = |
| 2469 | tx_sched_wrr_param[4]; |
| 2470 | } |
| 2471 | |
| 2472 | num_entries = 0; |
| 2473 | } |
| 2474 | } |
| 2475 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2476 | #ifdef IPA_OFFLOAD |
| 2477 | /** |
| 2478 | * hdd_update_ipa_component_config() - update ipa config |
| 2479 | * @hdd_ctx: Pointer to hdd context |
| 2480 | * |
| 2481 | * Return: none |
| 2482 | */ |
| 2483 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2484 | { |
| 2485 | struct hdd_config *cfg = hdd_ctx->config; |
| 2486 | struct wlan_ipa_config ipa_cfg; |
| 2487 | |
| 2488 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2489 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2490 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2491 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2492 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2493 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2494 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2495 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2496 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2497 | |
| 2498 | ucfg_ipa_update_config(&ipa_cfg); |
| 2499 | } |
| 2500 | #else |
| 2501 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2502 | { |
| 2503 | } |
| 2504 | #endif |
| 2505 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2506 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2507 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2508 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2509 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2510 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2511 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2512 | |
| 2513 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2514 | if (!adapter) { |
| 2515 | hdd_err("Adapter is NULL"); |
| 2516 | return PM_MAX_NUM_OF_MODE; |
| 2517 | } |
| 2518 | |
| 2519 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2520 | adapter->device_mode); |
| 2521 | } |
| 2522 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2523 | static void hdd_register_policy_manager_callback( |
| 2524 | struct wlan_objmgr_psoc *psoc) |
| 2525 | { |
| 2526 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2527 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2528 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2529 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2530 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2531 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2532 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2533 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2534 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2535 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2536 | if (QDF_STATUS_SUCCESS != |
| 2537 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2538 | hdd_err("HDD callback registration with policy manager failed"); |
| 2539 | } |
| 2540 | } |
| 2541 | #else |
| 2542 | static void hdd_register_policy_manager_callback( |
| 2543 | struct wlan_objmgr_psoc *psoc) |
| 2544 | { |
| 2545 | } |
| 2546 | #endif |
| 2547 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2548 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2549 | { |
| 2550 | struct nan_callbacks cb_obj = {0}; |
| 2551 | |
| 2552 | cb_obj.ndi_open = hdd_ndi_open; |
| 2553 | cb_obj.ndi_close = hdd_ndi_close; |
| 2554 | cb_obj.ndi_start = hdd_ndi_start; |
| 2555 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2556 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2557 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2558 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2559 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2560 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2561 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2562 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2563 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2564 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2565 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2566 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2567 | /** |
| 2568 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2569 | * |
| 2570 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2571 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2572 | * |
| 2573 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2574 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2575 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2576 | * fixed. |
| 2577 | * |
| 2578 | * Return: None |
| 2579 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2580 | static void hdd_check_for_leaks(void) |
| 2581 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2582 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2583 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2584 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2585 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2586 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2587 | } |
| 2588 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2589 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2590 | #else |
| 2591 | static inline void hdd_check_for_leaks(void) {} |
| 2592 | |
| 2593 | #define hdd_debug_domain_set(domain) |
| 2594 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2595 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2596 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2597 | * hdd_update_country_code - Update country code |
| 2598 | * @hdd_ctx: HDD context |
| 2599 | * |
| 2600 | * Update country code based on module parameter country_code |
| 2601 | * |
| 2602 | * Return: 0 on success and errno on failure |
| 2603 | */ |
| 2604 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2605 | { |
| 2606 | if (!country_code) |
| 2607 | return 0; |
| 2608 | |
| 2609 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2610 | } |
| 2611 | |
| 2612 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2613 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2614 | * @hdd_ctx: HDD context |
| 2615 | * @adapter: HDD adapter |
| 2616 | * @reinit: flag to indicate from SSR or normal path |
| 2617 | * |
| 2618 | * This function maintains the driver state machine it will be invoked from |
| 2619 | * startup, reinit and change interface. Depending on the driver state shall |
| 2620 | * perform the opening of the modules. |
| 2621 | * |
| 2622 | * Return: 0 for success; non-zero for failure |
| 2623 | */ |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2624 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, |
| 2625 | struct hdd_adapter *adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2626 | bool reinit) |
| 2627 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2628 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2629 | qdf_device_t qdf_dev; |
| 2630 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2631 | bool unint = false; |
| 2632 | void *hif_ctx; |
| 2633 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2634 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2635 | |
| 2636 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2637 | if (!qdf_dev) { |
| 2638 | hdd_err("QDF Device Context is Invalid return"); |
| 2639 | return -EINVAL; |
| 2640 | } |
| 2641 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2642 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2643 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2644 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2645 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2646 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2647 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2648 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2649 | return 0; |
| 2650 | } |
| 2651 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2652 | hdd_ctx->start_modules_in_progress = true; |
| 2653 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2654 | switch (hdd_ctx->driver_status) { |
| 2655 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2656 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2657 | unint = true; |
| 2658 | /* Fall through dont add break here */ |
| 2659 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2660 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2661 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2662 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2663 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2664 | if (!reinit && !unint) { |
| 2665 | ret = pld_power_on(qdf_dev->dev); |
| 2666 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2667 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2668 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2669 | goto release_lock; |
| 2670 | } |
| 2671 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2672 | |
| 2673 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2674 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2675 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2676 | qdf_dev->bus_type, |
| 2677 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2678 | HIF_ENABLE_TYPE_PROBE); |
| 2679 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2680 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2681 | goto power_down; |
| 2682 | } |
| 2683 | |
| 2684 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2685 | if (!hif_ctx) { |
| 2686 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2687 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2688 | goto power_down; |
| 2689 | } |
| 2690 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2691 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2692 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2693 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2694 | status); |
| 2695 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2696 | goto hif_close; |
| 2697 | } |
| 2698 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2699 | hdd_update_ipa_component_config(hdd_ctx); |
| 2700 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2701 | ret = hdd_update_config(hdd_ctx); |
| 2702 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2703 | hdd_err("Failed to update configuration; errno: %d", |
| 2704 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2705 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2706 | } |
| 2707 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2708 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2709 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2710 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2711 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2712 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2713 | ret = qdf_status_to_os_return(status); |
| 2714 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2715 | } |
| 2716 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2717 | /* initalize components configurations after psoc open */ |
| 2718 | ret = hdd_update_components_config(hdd_ctx); |
| 2719 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2720 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2721 | ret); |
| 2722 | goto close; |
| 2723 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2724 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2725 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2726 | hdd_err("Failed to Open cds post open; status: %d", |
| 2727 | status); |
| 2728 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2729 | goto close; |
| 2730 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2731 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2732 | /* |
| 2733 | * NAN compoenet requires certian operations like, open adapter, |
| 2734 | * close adapter, etc. to be initiated by HDD, for those |
| 2735 | * register HDD callbacks with UMAC's NAN componenet. |
| 2736 | */ |
| 2737 | hdd_nan_register_callbacks(hdd_ctx); |
| 2738 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2739 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2740 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2741 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2742 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2743 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2744 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2745 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2746 | } |
| 2747 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2748 | hdd_register_policy_manager_callback( |
| 2749 | hdd_ctx->hdd_psoc); |
| 2750 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2751 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2752 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2753 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2754 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2755 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2756 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2757 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2758 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2759 | break; |
| 2760 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2761 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2762 | /* Fall through dont add break here */ |
| 2763 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2764 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2765 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2766 | if (!adapter) { |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2767 | hdd_alert("adapter is Null"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2768 | ret = -EINVAL; |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2769 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2770 | } |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2771 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2772 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2773 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2774 | break; |
| 2775 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2776 | |
| 2777 | ret = hdd_configure_cds(hdd_ctx, adapter); |
| 2778 | if (ret) { |
| 2779 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2780 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2781 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2782 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2783 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2784 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2785 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2786 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2787 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2788 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | default: |
| 2790 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2791 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2792 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2793 | goto release_lock; |
| 2794 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2795 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2796 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2797 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2798 | ret = hdd_update_country_code(hdd_ctx); |
| 2799 | if (ret) |
| 2800 | hdd_err("Failed to update command line country code!"); |
| 2801 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2802 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2803 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2804 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2805 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2806 | return 0; |
| 2807 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2808 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2809 | cds_post_disable(); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 2810 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 2811 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2812 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2813 | cds_txrx_free: |
| 2814 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2815 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2816 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2817 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2818 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2819 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2820 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2821 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2822 | deinit_config: |
| 2823 | cds_deinit_ini_config(); |
| 2824 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2825 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2826 | ol_cds_free(); |
| 2827 | |
| 2828 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2829 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2830 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2831 | power_down: |
| 2832 | if (!reinit && !unint) |
| 2833 | pld_power_off(qdf_dev->dev); |
| 2834 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2835 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2836 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2837 | |
| 2838 | /* many adapter resources are not freed by design in SSR case */ |
| 2839 | if (!reinit) |
| 2840 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2841 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2842 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2843 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2844 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2845 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2846 | } |
| 2847 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2848 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2849 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2850 | { |
| 2851 | int ret = os_if_wifi_pos_register_nl(); |
| 2852 | |
| 2853 | if (ret) |
| 2854 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2855 | |
| 2856 | return ret; |
| 2857 | } |
| 2858 | |
| 2859 | static int hdd_deactivate_wifi_pos(void) |
| 2860 | { |
| 2861 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2862 | |
| 2863 | if (ret) |
| 2864 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2865 | |
| 2866 | return ret; |
| 2867 | } |
| 2868 | |
| 2869 | /** |
| 2870 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2871 | * @hdd_ctx: hdd context |
| 2872 | * |
| 2873 | * Return: status of operation |
| 2874 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2875 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2876 | { |
| 2877 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2878 | struct hdd_config *cfg = hdd_ctx->config; |
| 2879 | |
| 2880 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2881 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2882 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2883 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2884 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2885 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2886 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2887 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2888 | } |
| 2889 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2890 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2891 | { |
| 2892 | return oem_activate_service(hdd_ctx); |
| 2893 | } |
| 2894 | |
| 2895 | static int hdd_deactivate_wifi_pos(void) |
| 2896 | { |
| 2897 | return 0; |
| 2898 | } |
| 2899 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2900 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2901 | { |
| 2902 | } |
| 2903 | #endif |
| 2904 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2905 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2906 | * __hdd_open() - HDD Open function |
| 2907 | * @dev: Pointer to net_device structure |
| 2908 | * |
| 2909 | * This is called in response to ifconfig up |
| 2910 | * |
| 2911 | * Return: 0 for success; non-zero for failure |
| 2912 | */ |
| 2913 | static int __hdd_open(struct net_device *dev) |
| 2914 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2915 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2916 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2917 | int ret; |
| 2918 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2919 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2920 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2921 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2922 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2923 | /* Nothing to be done if device is unloading */ |
| 2924 | if (cds_is_driver_unloading()) { |
| 2925 | hdd_err("Driver is unloading can not open the hdd"); |
| 2926 | return -EBUSY; |
| 2927 | } |
| 2928 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2929 | if (cds_is_driver_recovering()) { |
| 2930 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2931 | return -EBUSY; |
| 2932 | } |
| 2933 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2934 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 2935 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 2936 | return -EBUSY; |
| 2937 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2938 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2939 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2940 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2941 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2942 | /* |
| 2943 | * This scenario can be hit in cases where in the wlan driver after |
| 2944 | * registering the netdevices and there is a failure in driver |
| 2945 | * initialization. So return error gracefully because the netdevices |
| 2946 | * will be de-registered as part of the load failure. |
| 2947 | */ |
| 2948 | |
| 2949 | if (!cds_is_driver_loaded()) { |
| 2950 | hdd_err("Failed to start the wlan driver!!"); |
| 2951 | ret = -EIO; |
| 2952 | goto err_hdd_hdd_init_deinit_lock; |
| 2953 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2954 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2955 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2956 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 2957 | if (ret) { |
| 2958 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2959 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2960 | } |
| 2961 | |
| 2962 | |
| 2963 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2964 | ret = hdd_start_adapter(adapter); |
| 2965 | if (ret) { |
| 2966 | hdd_err("Failed to start adapter :%d", |
| 2967 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2968 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2969 | } |
| 2970 | } |
| 2971 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2972 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2973 | 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] | 2974 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2975 | /* Enable TX queues only when we are connected */ |
| 2976 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2977 | WLAN_START_ALL_NETIF_QUEUE, |
| 2978 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2979 | } |
| 2980 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2981 | /* Enable carrier and transmit queues for NDI */ |
| 2982 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 2983 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 2984 | wlan_hdd_netif_queue_control(adapter, |
| 2985 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 2986 | WLAN_CONTROL_PATH); |
| 2987 | } |
| 2988 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2989 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 2990 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2991 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2992 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2993 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2994 | return ret; |
| 2995 | } |
| 2996 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2997 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2998 | /** |
| 2999 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3000 | * @dev: Pointer to net_device structure |
| 3001 | * |
| 3002 | * This is called in response to ifconfig up |
| 3003 | * |
| 3004 | * Return: 0 for success; non-zero for failure |
| 3005 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3006 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | { |
| 3008 | int ret; |
| 3009 | |
| 3010 | cds_ssr_protect(__func__); |
| 3011 | ret = __hdd_open(dev); |
| 3012 | cds_ssr_unprotect(__func__); |
| 3013 | |
| 3014 | return ret; |
| 3015 | } |
| 3016 | |
| 3017 | /** |
| 3018 | * __hdd_stop() - HDD stop function |
| 3019 | * @dev: Pointer to net_device structure |
| 3020 | * |
| 3021 | * This is called in response to ifconfig down |
| 3022 | * |
| 3023 | * Return: 0 for success; non-zero for failure |
| 3024 | */ |
| 3025 | static int __hdd_stop(struct net_device *dev) |
| 3026 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3027 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3028 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3029 | int ret; |
| 3030 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3031 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3032 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3033 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3034 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3035 | |
| 3036 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3037 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3038 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3039 | |
| 3040 | /* Nothing to be done if the interface is not opened */ |
| 3041 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3042 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3043 | return -ENODEV; |
| 3044 | } |
| 3045 | |
| 3046 | /* Make sure the interface is marked as closed */ |
| 3047 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3048 | |
| 3049 | hdd_debug("Disabling Auto Power save timer"); |
| 3050 | sme_ps_disable_auto_ps_timer( |
| 3051 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3052 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3053 | |
| 3054 | /* |
| 3055 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3056 | * be called on that interface |
| 3057 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3058 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3059 | hdd_device_mode_to_string(adapter->device_mode), |
| 3060 | adapter->device_mode); |
| 3061 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3062 | wlan_hdd_netif_queue_control(adapter, |
| 3063 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3064 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3065 | |
| 3066 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3067 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3068 | * bursty in nature and depends on the need to transfer. The service |
| 3069 | * layer may down the interface after the usage and up again when |
| 3070 | * required. In some sense, the NDI is expected to be available |
| 3071 | * (like SAP) iface until NDI delete request is issued by the service |
| 3072 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3073 | * interface (NDI). |
| 3074 | */ |
| 3075 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3076 | return 0; |
| 3077 | |
| 3078 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3079 | * The interface is marked as down for outside world (aka kernel) |
| 3080 | * But the driver is pretty much alive inside. The driver needs to |
| 3081 | * tear down the existing connection on the netdev (session) |
| 3082 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3083 | * for this interface. The call also needs to wait until the above |
| 3084 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3085 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3087 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3088 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3089 | |
| 3090 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3091 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3092 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3093 | |
| 3094 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3095 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3096 | * this is the last cli iface, flush the scan database. |
| 3097 | */ |
| 3098 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3099 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3100 | |
| 3101 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3102 | * Find if any iface is up. If any iface is up then can't put device to |
| 3103 | * sleep/power save mode |
| 3104 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3105 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3106 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3107 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3108 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3109 | hdd_prevent_suspend_timeout( |
| 3110 | hdd_ctx->config->iface_change_wait_time, |
| 3111 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3112 | } |
| 3113 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3114 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | return 0; |
| 3116 | } |
| 3117 | |
| 3118 | /** |
| 3119 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3120 | * @dev: pointer to net_device structure |
| 3121 | * |
| 3122 | * This is called in response to ifconfig down |
| 3123 | * |
| 3124 | * Return: 0 for success and error number for failure |
| 3125 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3126 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | { |
| 3128 | int ret; |
| 3129 | |
| 3130 | cds_ssr_protect(__func__); |
| 3131 | ret = __hdd_stop(dev); |
| 3132 | cds_ssr_unprotect(__func__); |
| 3133 | |
| 3134 | return ret; |
| 3135 | } |
| 3136 | |
| 3137 | /** |
| 3138 | * __hdd_uninit() - HDD uninit function |
| 3139 | * @dev: Pointer to net_device structure |
| 3140 | * |
| 3141 | * This is called during the netdev unregister to uninitialize all data |
| 3142 | * associated with the device |
| 3143 | * |
| 3144 | * Return: None |
| 3145 | */ |
| 3146 | static void __hdd_uninit(struct net_device *dev) |
| 3147 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3148 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3149 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3150 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3151 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3152 | |
| 3153 | do { |
| 3154 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3155 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3156 | break; |
| 3157 | } |
| 3158 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3159 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3160 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3161 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3162 | break; |
| 3163 | } |
| 3164 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3165 | if (dev != adapter->dev) |
| 3166 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3167 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3168 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | |
| 3170 | /* after uninit our adapter structure will no longer be valid */ |
| 3171 | adapter->dev = NULL; |
| 3172 | adapter->magic = 0; |
| 3173 | } while (0); |
| 3174 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3175 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3176 | } |
| 3177 | |
| 3178 | /** |
| 3179 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3180 | * @dev: pointer to net_device structure |
| 3181 | * |
| 3182 | * This is called during the netdev unregister to uninitialize all data |
| 3183 | * associated with the device |
| 3184 | * |
| 3185 | * Return: none |
| 3186 | */ |
| 3187 | static void hdd_uninit(struct net_device *dev) |
| 3188 | { |
| 3189 | cds_ssr_protect(__func__); |
| 3190 | __hdd_uninit(dev); |
| 3191 | cds_ssr_unprotect(__func__); |
| 3192 | } |
| 3193 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3194 | static int hdd_open_cesium_nl_sock(void) |
| 3195 | { |
| 3196 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3197 | struct netlink_kernel_cfg cfg = { |
| 3198 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3199 | .input = NULL |
| 3200 | }; |
| 3201 | #endif |
| 3202 | int ret = 0; |
| 3203 | |
| 3204 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3205 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3206 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3207 | THIS_MODULE, |
| 3208 | #endif |
| 3209 | &cfg); |
| 3210 | #else |
| 3211 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3212 | WLAN_NLINK_MCAST_GRP_ID, |
| 3213 | NULL, NULL, THIS_MODULE); |
| 3214 | #endif |
| 3215 | |
| 3216 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3217 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3218 | ret = -ECONNREFUSED; |
| 3219 | } |
| 3220 | |
| 3221 | return ret; |
| 3222 | } |
| 3223 | |
| 3224 | static void hdd_close_cesium_nl_sock(void) |
| 3225 | { |
| 3226 | if (NULL != cesium_nl_srv_sock) { |
| 3227 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3228 | cesium_nl_srv_sock = NULL; |
| 3229 | } |
| 3230 | } |
| 3231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3232 | /** |
| 3233 | * __hdd_set_mac_address() - set the user specified mac address |
| 3234 | * @dev: Pointer to the net device. |
| 3235 | * @addr: Pointer to the sockaddr. |
| 3236 | * |
| 3237 | * This function sets the user specified mac address using |
| 3238 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3239 | * |
| 3240 | * Return: 0 for success, non zero for failure |
| 3241 | */ |
| 3242 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3243 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3244 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3245 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3246 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3247 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3248 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3249 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3250 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3251 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3252 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3253 | if (netif_running(dev)) { |
| 3254 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3255 | return -EBUSY; |
| 3256 | } |
| 3257 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3259 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3260 | if (0 != ret) |
| 3261 | return ret; |
| 3262 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3263 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3264 | |
| 3265 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3266 | hdd_err("MAC is all zero"); |
| 3267 | return -EINVAL; |
| 3268 | } |
| 3269 | |
| 3270 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3271 | hdd_err("MAC is Broadcast"); |
| 3272 | return -EINVAL; |
| 3273 | } |
| 3274 | |
| 3275 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3276 | hdd_err("MAC is Multicast"); |
| 3277 | return -EINVAL; |
| 3278 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame^] | 3279 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3280 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3281 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3282 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3283 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3284 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3285 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3286 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | } |
| 3288 | |
| 3289 | /** |
| 3290 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3291 | * function from SSR |
| 3292 | * @dev: pointer to net_device structure |
| 3293 | * @addr: Pointer to the sockaddr |
| 3294 | * |
| 3295 | * This function sets the user specified mac address using |
| 3296 | * the command ifconfig wlanX hw ether <mac adress>. |
| 3297 | * |
| 3298 | * Return: 0 for success. |
| 3299 | */ |
| 3300 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3301 | { |
| 3302 | int ret; |
| 3303 | |
| 3304 | cds_ssr_protect(__func__); |
| 3305 | ret = __hdd_set_mac_address(dev, addr); |
| 3306 | cds_ssr_unprotect(__func__); |
| 3307 | |
| 3308 | return ret; |
| 3309 | } |
| 3310 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3311 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3312 | { |
| 3313 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3314 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3315 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3317 | break; |
| 3318 | } |
| 3319 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3320 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3321 | return NULL; |
| 3322 | |
| 3323 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3324 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3325 | } |
| 3326 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3327 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3328 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3329 | { |
| 3330 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3331 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3332 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | if (!memcmp(releaseAddr, |
| 3334 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3335 | 6)) { |
| 3336 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3337 | break; |
| 3338 | } |
| 3339 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3340 | } |
| 3341 | |
| 3342 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3343 | /** |
| 3344 | * __hdd_set_multicast_list() - set the multicast address list |
| 3345 | * @dev: Pointer to the WLAN device. |
| 3346 | * @skb: Pointer to OS packet (sk_buff). |
| 3347 | * |
| 3348 | * This funciton sets the multicast address list. |
| 3349 | * |
| 3350 | * Return: None |
| 3351 | */ |
| 3352 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3353 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3354 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | int i = 0, status; |
| 3356 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3357 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3358 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3359 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3360 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3362 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3363 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3364 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3366 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3367 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3368 | goto out; |
| 3369 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3370 | status = hdd_validate_adapter(adapter); |
| 3371 | if (status) |
| 3372 | goto out; |
| 3373 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3374 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3375 | hdd_err("%s: Driver module is closed", __func__); |
| 3376 | return; |
| 3377 | } |
| 3378 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3379 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3380 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3381 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3382 | goto out; |
| 3383 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3384 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3385 | /* Delete already configured multicast address list */ |
| 3386 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3387 | hdd_info("clear previously configured MC address list"); |
| 3388 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3389 | pmo_mc_list_change_notify); |
| 3390 | } |
| 3391 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3392 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3393 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3394 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3395 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3396 | } else { |
| 3397 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3398 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3399 | 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] | 3400 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3401 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3402 | pmo_mc_list_change_notify); |
| 3403 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3405 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3406 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3407 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3408 | if (i == mc_count) |
| 3409 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3410 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3411 | 0, ETH_ALEN); |
| 3412 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3413 | ha->addr, ETH_ALEN); |
| 3414 | hdd_info("mlist[%d] = %pM", i, |
| 3415 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3416 | i++; |
| 3417 | } |
| 3418 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3419 | |
| 3420 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3421 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3422 | mc_list_request->count = mc_count; |
| 3423 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3424 | if (status == 0) { |
| 3425 | hdd_enable_mc_addr_filtering(adapter, |
| 3426 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3427 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3428 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3430 | out: |
| 3431 | if (mc_list_request) |
| 3432 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3433 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3434 | } |
| 3435 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3436 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3437 | /** |
| 3438 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3439 | * @dev: pointer to net_device |
| 3440 | * |
| 3441 | * Return: none |
| 3442 | */ |
| 3443 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3444 | { |
| 3445 | cds_ssr_protect(__func__); |
| 3446 | __hdd_set_multicast_list(dev); |
| 3447 | cds_ssr_unprotect(__func__); |
| 3448 | } |
| 3449 | #endif |
| 3450 | |
| 3451 | /** |
| 3452 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3453 | * @dev: Pointer to the WLAN device. |
| 3454 | * @skb: Pointer to OS packet (sk_buff). |
| 3455 | * |
| 3456 | * This function is registered with the Linux OS for network |
| 3457 | * core to decide which queue to use first. |
| 3458 | * |
| 3459 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3460 | */ |
| 3461 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3462 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3463 | , void *accel_priv |
| 3464 | #endif |
| 3465 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3466 | , select_queue_fallback_t fallback |
| 3467 | #endif |
| 3468 | ) |
| 3469 | { |
| 3470 | return hdd_wmm_select_queue(dev, skb); |
| 3471 | } |
| 3472 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3473 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3474 | .ndo_open = hdd_open, |
| 3475 | .ndo_stop = hdd_stop, |
| 3476 | .ndo_uninit = hdd_uninit, |
| 3477 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3478 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3479 | .ndo_get_stats = hdd_get_stats, |
| 3480 | .ndo_do_ioctl = hdd_ioctl, |
| 3481 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3482 | .ndo_select_queue = hdd_select_queue, |
| 3483 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3484 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3485 | #endif |
| 3486 | }; |
| 3487 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3488 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3489 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3490 | .ndo_open = hdd_mon_open, |
| 3491 | .ndo_stop = hdd_stop, |
| 3492 | .ndo_get_stats = hdd_get_stats, |
| 3493 | }; |
| 3494 | |
| 3495 | /** |
| 3496 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3497 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3498 | * Return: None |
| 3499 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3500 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3501 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3502 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3503 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3504 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3505 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3506 | } |
| 3507 | |
| 3508 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3509 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3510 | * @hdd_ctx: global hdd context |
| 3511 | * @macAddr: mac address to assign to the interface |
| 3512 | * @name: User-visible name of the interface |
| 3513 | * |
| 3514 | * hdd adapter pointer would point to the netdev->priv space, this function |
| 3515 | * would retrive the pointer, and setup the hdd adapter configuration. |
| 3516 | * |
| 3517 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3518 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3519 | 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] | 3520 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3521 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | const char *name) |
| 3523 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3524 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3525 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3526 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3527 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3528 | /* |
| 3529 | * cfg80211 initialization and registration.... |
| 3530 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3531 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3532 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3533 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3534 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3535 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3536 | hdd_mon_mode_ether_setup : ether_setup), |
| 3537 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3539 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3540 | |
| 3541 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3542 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3544 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3545 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3546 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3547 | sizeof(sta_ctx->conn_info.staId), |
| 3548 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3549 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3550 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3552 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3553 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3554 | qdf_status = qdf_event_create( |
| 3555 | &adapter->qdf_session_open_event); |
| 3556 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3557 | hdd_err("Session open QDF event init failed!"); |
| 3558 | free_netdev(adapter->dev); |
| 3559 | return NULL; |
| 3560 | } |
| 3561 | |
| 3562 | qdf_status = qdf_event_create( |
| 3563 | &adapter->qdf_session_close_event); |
| 3564 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3565 | hdd_err("Session close QDF event init failed!"); |
| 3566 | free_netdev(adapter->dev); |
| 3567 | return NULL; |
| 3568 | } |
| 3569 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3570 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3571 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3572 | init_completion(&adapter->linkup_event_var); |
| 3573 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3574 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3575 | init_completion(&adapter->sta_authorized_event); |
| 3576 | init_completion(&adapter->offchannel_tx_event); |
| 3577 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3578 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3579 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | |
| 3581 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3582 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3583 | adapter->disconnection_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3584 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3585 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3586 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3587 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3588 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3589 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3591 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | |
| 3593 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3594 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3595 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3596 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3597 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3598 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3599 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3600 | hdd_set_station_ops(adapter->dev); |
| 3601 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3602 | hdd_dev_setup_destructor(dev); |
| 3603 | dev->ieee80211_ptr = &adapter->wdev; |
| 3604 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3605 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3606 | adapter->wdev.netdev = dev; |
| 3607 | /* set dev's parent to underlying device */ |
| 3608 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3609 | hdd_wmm_init(adapter); |
| 3610 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3611 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3612 | } |
| 3613 | |
| 3614 | return adapter; |
| 3615 | } |
| 3616 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3617 | 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] | 3618 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3619 | struct net_device *dev = adapter->dev; |
| 3620 | int ret; |
| 3621 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3622 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3623 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3624 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3625 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3626 | |
| 3627 | ret = dev_alloc_name(dev, dev->name); |
| 3628 | if (ret < 0) { |
| 3629 | hdd_err( |
| 3630 | "unable to get dev name: %s, err = 0x%x", |
| 3631 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3632 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3633 | } |
| 3634 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3635 | |
| 3636 | ret = register_netdevice(dev); |
| 3637 | if (ret) { |
| 3638 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3639 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3640 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3641 | } |
| 3642 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3643 | ret = register_netdev(dev); |
| 3644 | if (ret) { |
| 3645 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3646 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3647 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3648 | } |
| 3649 | } |
| 3650 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3651 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3652 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3653 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3654 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3655 | } |
| 3656 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3657 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3658 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3659 | struct hdd_adapter *adapter; |
| 3660 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3661 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3662 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3663 | if (!hdd_ctx) { |
| 3664 | hdd_err("Invalid HDD_CTX"); |
| 3665 | return QDF_STATUS_E_FAILURE; |
| 3666 | } |
| 3667 | |
| 3668 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3669 | if (NULL == adapter) { |
| 3670 | hdd_err("NULL adapter"); |
| 3671 | return QDF_STATUS_E_INVAL; |
| 3672 | } |
| 3673 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3674 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3675 | hdd_debug("session %d opened", adapter->session_id); |
| 3676 | |
| 3677 | return QDF_STATUS_SUCCESS; |
| 3678 | } |
| 3679 | |
| 3680 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3681 | { |
| 3682 | struct hdd_adapter *adapter; |
| 3683 | struct hdd_context *hdd_ctx; |
| 3684 | |
| 3685 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3686 | if (!hdd_ctx) { |
| 3687 | hdd_err("Invalid HDD_CTX"); |
| 3688 | return QDF_STATUS_E_FAILURE; |
| 3689 | } |
| 3690 | |
| 3691 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3693 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3694 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3695 | } |
| 3696 | |
| 3697 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3698 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3699 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | } |
| 3701 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3702 | /* |
| 3703 | * For NAN Data interface, the close session results in the final |
| 3704 | * indication to the userspace |
| 3705 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3706 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3707 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3708 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3709 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3710 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3711 | /* |
| 3712 | * We can be blocked while waiting for scheduled work to be |
| 3713 | * flushed, and the adapter structure can potentially be freed, in |
| 3714 | * which case the magic will have been reset. So make sure the |
| 3715 | * magic is still good, and hence the adapter structure is still |
| 3716 | * valid, before signaling completion |
| 3717 | */ |
| 3718 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3719 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3720 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3721 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3722 | } |
| 3723 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3724 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3725 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3726 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3728 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3729 | if (QDF_IS_STATUS_ERROR(status)) |
| 3730 | return qdf_status_to_os_return(status); |
| 3731 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3732 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3733 | if (QDF_IS_STATUS_ERROR(status)) |
| 3734 | return qdf_status_to_os_return(status); |
| 3735 | |
| 3736 | if (wma_capability_enhanced_mcast_filter()) |
| 3737 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3738 | else |
| 3739 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3740 | |
| 3741 | return qdf_status_to_os_return(status); |
| 3742 | } |
| 3743 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3744 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3745 | { |
| 3746 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3747 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3748 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3749 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3750 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3751 | vdev_id = adapter->session_id; |
| 3752 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3753 | |
| 3754 | /* vdev created sanity check */ |
| 3755 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3756 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3757 | return -EINVAL; |
| 3758 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3759 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3760 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3761 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3762 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3763 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3764 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3765 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3766 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3767 | errno = qdf_status_to_os_return(status); |
| 3768 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3769 | } |
| 3770 | |
| 3771 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3772 | status = qdf_wait_for_event_completion( |
| 3773 | &adapter->qdf_session_close_event, |
| 3774 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3775 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3776 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3777 | hdd_ndp_session_end_handler(adapter); |
| 3778 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3779 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3780 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3781 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3782 | errno = -ETIMEDOUT; |
| 3783 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3784 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3785 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3786 | errno = -EINVAL; |
| 3787 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3788 | } else { |
| 3789 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3790 | errno = -EINVAL; |
| 3791 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3792 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3793 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3794 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3795 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3796 | /* |
| 3797 | * In SSR or driver unloading case, directly exit may cause objects |
| 3798 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3799 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3800 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3801 | return errno; |
| 3802 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3803 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3804 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3805 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3806 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3807 | return errno; |
| 3808 | } |
| 3809 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3810 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3811 | |
| 3812 | return 0; |
| 3813 | } |
| 3814 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3815 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3816 | struct sme_session_params *session_param, |
| 3817 | csr_roam_completeCallback callback, |
| 3818 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3819 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3820 | uint32_t type; |
| 3821 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3822 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3823 | |
| 3824 | /* determine vdev (sub)type */ |
| 3825 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3826 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3827 | hdd_err("failed to get vdev type: %d", status); |
| 3828 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3829 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3830 | session_param->sme_session_id = adapter->session_id; |
| 3831 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3832 | session_param->type_of_persona = type; |
| 3833 | session_param->subtype_of_persona = sub_type; |
| 3834 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3835 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3836 | session_param->callback = callback; |
| 3837 | session_param->callback_ctx = callback_ctx; |
| 3838 | |
| 3839 | return 0; |
| 3840 | } |
| 3841 | |
| 3842 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3843 | csr_roam_completeCallback callback, void *ctx) |
| 3844 | { |
| 3845 | QDF_STATUS status; |
| 3846 | int errno; |
| 3847 | struct hdd_context *hdd_ctx; |
| 3848 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3849 | |
| 3850 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3851 | |
| 3852 | /* do vdev create via objmgr */ |
| 3853 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3854 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3855 | if (errno) { |
| 3856 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3857 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3859 | |
| 3860 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3861 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3862 | if (QDF_STATUS_SUCCESS != status) { |
| 3863 | hdd_err("failed to reinit session open event"); |
| 3864 | return -EINVAL; |
| 3865 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3866 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3867 | callback, ctx); |
| 3868 | if (errno) { |
| 3869 | hdd_err("failed to populating SME params"); |
| 3870 | goto objmgr_vdev_destroy_procedure; |
| 3871 | } |
| 3872 | |
| 3873 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3874 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3875 | hdd_err("failed to open sme session: %d", status); |
| 3876 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3877 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3878 | } |
| 3879 | |
| 3880 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3881 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3882 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3883 | if (QDF_STATUS_SUCCESS != status) { |
| 3884 | if (adapter->qdf_session_open_event.force_set) { |
| 3885 | /* |
| 3886 | * SSR/PDR has caused shutdown, which has forcefully |
| 3887 | * set the event. Return without the closing session. |
| 3888 | */ |
| 3889 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3890 | hdd_err("Session open event forcefully set"); |
| 3891 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3892 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3893 | |
| 3894 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3895 | hdd_err("Session failed to open within timeout period"); |
| 3896 | else |
| 3897 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3898 | status); |
| 3899 | errno = -ETIMEDOUT; |
| 3900 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3901 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3902 | } |
| 3903 | |
| 3904 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3905 | errno = hdd_vdev_ready(adapter); |
| 3906 | if (errno) { |
| 3907 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3908 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3909 | } |
| 3910 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 3911 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3912 | hdd_debug("setting RTT mac randomization param: %d", |
| 3913 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 3914 | errno = sme_cli_set_command(adapter->session_id, |
| 3915 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 3916 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 3917 | VDEV_CMD); |
| 3918 | if (0 != errno) |
| 3919 | hdd_err("RTT mac randomization param set failed %d", |
| 3920 | errno); |
| 3921 | } |
| 3922 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3923 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3924 | |
| 3925 | return 0; |
| 3926 | |
| 3927 | /* |
| 3928 | * Due to legacy constraints, we need to destroy in the same order as |
| 3929 | * create. So, split error handling into 2 cases to accommodate. |
| 3930 | */ |
| 3931 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3932 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3933 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3934 | |
| 3935 | return errno; |
| 3936 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3937 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3938 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3939 | |
| 3940 | return errno; |
| 3941 | } |
| 3942 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3943 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3944 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3945 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3946 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3947 | QDF_STATUS status; |
| 3948 | int ret_val; |
| 3949 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3950 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3951 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3952 | 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] | 3953 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3954 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 3955 | hdd_roam_profile_init(adapter); |
| 3956 | hdd_register_wext(adapter->dev); |
| 3957 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3958 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3959 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3960 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3961 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3962 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3963 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3964 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 3965 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3966 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3967 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3968 | hdd_ctx->config->OperatingChannel; |
| 3969 | |
| 3970 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3971 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3972 | |
| 3973 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3974 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3975 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3976 | status, status); |
| 3977 | goto error_init_txrx; |
| 3978 | } |
| 3979 | |
| 3980 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 3981 | |
| 3982 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3983 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3984 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3985 | status, status); |
| 3986 | goto error_wmm_init; |
| 3987 | } |
| 3988 | |
| 3989 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 3990 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3991 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3992 | WMI_PDEV_PARAM_BURST_ENABLE, |
| 3993 | hdd_ctx->config->enableSifsBurst, |
| 3994 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3995 | if (ret_val) |
| 3996 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3997 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 3998 | /* |
| 3999 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4000 | * during that time, then as part of SSR init, do not enable |
| 4001 | * the LRO again. Keep the LRO state same as before SSR. |
| 4002 | */ |
| 4003 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Dhanashri Atre | 1a6a4ce | 2017-05-03 19:40:33 -0700 | [diff] [blame] | 4004 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4005 | |
| 4006 | /* rcpi info initialization */ |
| 4007 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4008 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4009 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4011 | error_wmm_init: |
| 4012 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4013 | hdd_deinit_tx_rx(adapter); |
| 4014 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4015 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4016 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4017 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4018 | return status; |
| 4019 | } |
| 4020 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4021 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4022 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4023 | * @hdd_ctx: global hdd context |
| 4024 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4025 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4026 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4027 | * |
| 4028 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4029 | * |
| 4030 | * Return: None. |
| 4031 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4032 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4033 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4034 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4035 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4036 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4037 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4038 | if (adapter->dev) { |
| 4039 | if (rtnl_held) |
| 4040 | adapter->dev->wireless_handlers = NULL; |
| 4041 | else { |
| 4042 | rtnl_lock(); |
| 4043 | adapter->dev->wireless_handlers = NULL; |
| 4044 | rtnl_unlock(); |
| 4045 | } |
| 4046 | } |
| 4047 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4048 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4049 | hdd_deinit_tx_rx(adapter); |
| 4050 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4051 | } |
| 4052 | |
| 4053 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4054 | hdd_wmm_adapter_close(adapter); |
| 4055 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4056 | } |
| 4057 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4058 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4059 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4060 | } |
| 4061 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4062 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4063 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4064 | bool rtnl_held) |
| 4065 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4066 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4067 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4068 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4069 | case QDF_STA_MODE: |
| 4070 | case QDF_P2P_CLIENT_MODE: |
| 4071 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4072 | case QDF_IBSS_MODE: |
| 4073 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4074 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4075 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4076 | break; |
| 4077 | } |
| 4078 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4079 | case QDF_SAP_MODE: |
| 4080 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4081 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4082 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4083 | break; |
| 4084 | } |
| 4085 | |
| 4086 | default: |
| 4087 | break; |
| 4088 | } |
| 4089 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4090 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4091 | } |
| 4092 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4093 | 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] | 4094 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4095 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4096 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4097 | |
| 4098 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4099 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4100 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4101 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | return; |
| 4103 | } |
| 4104 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4105 | hdd_nud_deinit_tracking(adapter); |
| 4106 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4107 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4108 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4110 | /* |
| 4111 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4112 | * the driver is almost closed and cannot handle either control |
| 4113 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4114 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4115 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4116 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4117 | * the interface is closed and restricts any operations on that |
| 4118 | */ |
| 4119 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4120 | |
| 4121 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4122 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4123 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4124 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4125 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4126 | /* |
| 4127 | * Note that the adapter is no longer valid at this point |
| 4128 | * since the memory has been reclaimed |
| 4129 | */ |
| 4130 | } |
| 4131 | } |
| 4132 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4133 | 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] | 4134 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4136 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4137 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4138 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4139 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4140 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4141 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4142 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4143 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4144 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4145 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4146 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4147 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4148 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4149 | /** |
| 4150 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4151 | * @hdd_ctx: HDD Context |
| 4152 | * @adapter: HDD Adapter |
| 4153 | * |
| 4154 | * This function set the FW Debug log level based on the INI. |
| 4155 | * |
| 4156 | * Return: None |
| 4157 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4158 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4159 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4160 | { |
| 4161 | uint8_t count = 0, numentries = 0, |
| 4162 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4163 | uint32_t value = 0; |
| 4164 | int ret; |
| 4165 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4166 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4167 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4168 | 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] | 4169 | return; |
| 4170 | } |
| 4171 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4172 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4173 | hdd_ctx->fw_log_settings.dl_type = |
| 4174 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4175 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4176 | WMI_DBGLOG_TYPE, |
| 4177 | hdd_ctx->config->enableFwLogType, |
| 4178 | DBG_CMD); |
| 4179 | if (ret != 0) |
| 4180 | hdd_err("Failed to enable FW log type ret %d", |
| 4181 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4182 | |
| 4183 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4184 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4185 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4186 | WMI_DBGLOG_LOG_LEVEL, |
| 4187 | hdd_ctx->config->enableFwLogLevel, |
| 4188 | DBG_CMD); |
| 4189 | if (ret != 0) |
| 4190 | hdd_err("Failed to enable FW log level ret %d", |
| 4191 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4192 | |
| 4193 | hdd_string_to_u8_array( |
| 4194 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4195 | moduleloglevel, |
| 4196 | &numentries, |
| 4197 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4198 | |
| 4199 | while (count < numentries) { |
| 4200 | /* |
| 4201 | * FW module log level input string looks like |
| 4202 | * below: |
| 4203 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4204 | * <Log Level>,... |
| 4205 | * For example: |
| 4206 | * gFwDebugModuleLoglevel= |
| 4207 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4208 | * Above input string means : |
| 4209 | * For FW module ID 1 enable log level 0 |
| 4210 | * For FW module ID 2 enable log level 1 |
| 4211 | * For FW module ID 3 enable log level 2 |
| 4212 | * For FW module ID 4 enable log level 3 |
| 4213 | * For FW module ID 5 enable log level 4 |
| 4214 | * For FW module ID 6 enable log level 5 |
| 4215 | * For FW module ID 7 enable log level 6 |
| 4216 | */ |
| 4217 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4218 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4219 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4220 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4221 | moduleloglevel[count], |
| 4222 | moduleloglevel[count + 1]); |
| 4223 | return; |
| 4224 | } |
| 4225 | |
| 4226 | value = moduleloglevel[count] << 16; |
| 4227 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4228 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4229 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4230 | value, DBG_CMD); |
| 4231 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4232 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4233 | value, ret); |
| 4234 | |
| 4235 | count += 2; |
| 4236 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4237 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4238 | } |
| 4239 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4240 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4241 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4242 | { |
| 4243 | } |
| 4244 | |
| 4245 | #endif |
| 4246 | |
| 4247 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4248 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4249 | * @adapter: HDD adapter |
| 4250 | * |
| 4251 | * Return: 0 on success or errno on failure |
| 4252 | */ |
| 4253 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4254 | { |
| 4255 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4256 | QDF_STATUS status; |
| 4257 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4258 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4259 | |
| 4260 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4261 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4262 | hdd_ctx->config->txchainmask1x1, |
| 4263 | hdd_ctx->config->rxchainmask1x1); |
| 4264 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4265 | hdd_ctx->config->dual_mac_feature_disable, |
| 4266 | hdd_ctx->config->tx_chain_mask_2g, |
| 4267 | hdd_ctx->config->rx_chain_mask_2g); |
| 4268 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4269 | hdd_ctx->config->tx_chain_mask_5g, |
| 4270 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4271 | hdd_debug("enable_bt_chain_separation %d", |
| 4272 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4273 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4274 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4275 | HW_MODE_DBS_NONE, |
| 4276 | CDS_BAND_ALL); |
| 4277 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4278 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4279 | return qdf_status_to_os_return(status); |
| 4280 | } |
| 4281 | |
| 4282 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4283 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4284 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4285 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
| 4286 | hdd_info("firmware not capable. skip chain mask programming"); |
| 4287 | return 0; |
| 4288 | } |
| 4289 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4290 | if (hdd_ctx->config->enable2x2 && |
| 4291 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4292 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4293 | return 0; |
| 4294 | } |
| 4295 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4296 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4297 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4298 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4299 | hdd_ctx->config->dual_mac_feature_disable); |
| 4300 | return 0; |
| 4301 | } |
| 4302 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4303 | if (hdd_ctx->lte_coex_ant_share) { |
| 4304 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4305 | return 0; |
| 4306 | } |
| 4307 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4308 | if (hdd_ctx->config->txchainmask1x1) { |
| 4309 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4310 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4311 | hdd_ctx->config->txchainmask1x1, |
| 4312 | PDEV_CMD); |
| 4313 | if (ret_val) |
| 4314 | goto error; |
| 4315 | } |
| 4316 | |
| 4317 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4318 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4319 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4320 | hdd_ctx->config->rxchainmask1x1, |
| 4321 | PDEV_CMD); |
| 4322 | if (ret_val) |
| 4323 | goto error; |
| 4324 | } |
| 4325 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4326 | if (hdd_ctx->config->txchainmask1x1 || |
| 4327 | hdd_ctx->config->rxchainmask1x1) { |
| 4328 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4329 | return 0; |
| 4330 | } |
| 4331 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4332 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4333 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4334 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4335 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4336 | if (0 != ret_val) |
| 4337 | goto error; |
| 4338 | } |
| 4339 | |
| 4340 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4341 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4342 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4343 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4344 | if (0 != ret_val) |
| 4345 | goto error; |
| 4346 | } |
| 4347 | |
| 4348 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4349 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4350 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4351 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4352 | if (0 != ret_val) |
| 4353 | goto error; |
| 4354 | } |
| 4355 | |
| 4356 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4357 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4358 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4359 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4360 | if (0 != ret_val) |
| 4361 | goto error; |
| 4362 | } |
| 4363 | |
| 4364 | return 0; |
| 4365 | |
| 4366 | error: |
| 4367 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4368 | return -EINVAL; |
| 4369 | } |
| 4370 | |
| 4371 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4372 | * hdd_set_fw_params() - Set parameters to firmware |
| 4373 | * @adapter: HDD adapter |
| 4374 | * |
| 4375 | * This function Sets various parameters to fw once the |
| 4376 | * adapter is started. |
| 4377 | * |
| 4378 | * Return: 0 on success or errno on failure |
| 4379 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4380 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4381 | { |
| 4382 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4383 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4384 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4385 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4386 | |
| 4387 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4388 | if (!hdd_ctx) |
| 4389 | return -EINVAL; |
| 4390 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4391 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4392 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4393 | return 0; |
| 4394 | } |
| 4395 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4396 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4397 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4398 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4399 | if (ret) { |
| 4400 | hdd_err("Failed to set LPRx"); |
| 4401 | goto error; |
| 4402 | } |
| 4403 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4404 | |
| 4405 | ret = sme_cli_set_command( |
| 4406 | adapter->session_id, |
| 4407 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4408 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4409 | PDEV_CMD); |
| 4410 | if (ret) { |
| 4411 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4412 | goto error; |
| 4413 | } |
| 4414 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4415 | ret = sme_cli_set_command( |
| 4416 | adapter->session_id, |
| 4417 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4418 | hdd_ctx->config->enable_tx_sch_delay, |
| 4419 | PDEV_CMD); |
| 4420 | if (ret) { |
| 4421 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4422 | goto error; |
| 4423 | } |
| 4424 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4425 | ret = sme_cli_set_command( |
| 4426 | adapter->session_id, |
| 4427 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4428 | hdd_ctx->config->enable_secondary_rate, |
| 4429 | PDEV_CMD); |
| 4430 | if (ret) { |
| 4431 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4432 | goto error; |
| 4433 | } |
| 4434 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4435 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4436 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4437 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4438 | hdd_ctx->config->upper_brssi_thresh); |
| 4439 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4440 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4441 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4442 | hdd_ctx->config->lower_brssi_thresh); |
| 4443 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4444 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4445 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4446 | hdd_ctx->config->enable_dtim_1chrx); |
| 4447 | } |
| 4448 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4449 | if (hdd_ctx->config->enable2x2) { |
| 4450 | hdd_debug("configuring 2x2 mode fw params"); |
| 4451 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4452 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4453 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4454 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4455 | PDEV_CMD); |
| 4456 | if (ret) { |
| 4457 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4458 | ret); |
| 4459 | goto error; |
| 4460 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4461 | |
| 4462 | if (hdd_configure_chain_mask(adapter)) |
| 4463 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4464 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4465 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4466 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4467 | hdd_debug("configuring 1x1 mode fw params"); |
| 4468 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4469 | /* |
| 4470 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4471 | * we are passing two value |
| 4472 | * as param_id << 29 | param_value. |
| 4473 | * Below param_value = 0(disable) |
| 4474 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4475 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4476 | WMI_STA_SMPS_PARAM_CMDID, |
| 4477 | HDD_DTIM_1CHAIN_RX_ID << |
| 4478 | HDD_SMPS_PARAM_VALUE_S, |
| 4479 | VDEV_CMD); |
| 4480 | if (ret) { |
| 4481 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4482 | goto error; |
| 4483 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4484 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4485 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4486 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4487 | |
| 4488 | if (hdd_configure_chain_mask(adapter)) |
| 4489 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4490 | } |
| 4491 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4492 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4493 | WMI_PDEV_PARAM_HYST_EN, |
| 4494 | hdd_ctx->config->enableMemDeepSleep, |
| 4495 | PDEV_CMD); |
| 4496 | if (ret) { |
| 4497 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4498 | goto error; |
| 4499 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4500 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4501 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4502 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4503 | hdd_ctx->config->rts_profile, |
| 4504 | VDEV_CMD); |
| 4505 | if (ret) { |
| 4506 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4507 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4508 | } |
| 4509 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4510 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4511 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4512 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4513 | GEN_VDEV_PARAM_AMSDU, |
| 4514 | hdd_ctx->config->max_amsdu_num, |
| 4515 | GEN_CMD); |
| 4516 | if (ret != 0) { |
| 4517 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4518 | goto error; |
| 4519 | } |
| 4520 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4521 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4522 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4523 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4524 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4525 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4526 | error: |
| 4527 | return -EINVAL; |
| 4528 | } |
| 4529 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4530 | /** |
| 4531 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4532 | * @hdd_ctx: global hdd context |
| 4533 | * @session_type: type of the interface to be created |
| 4534 | * @iface_name: User-visible name of the interface |
| 4535 | * @macAddr: MAC address to assign to the interface |
| 4536 | * @name_assign_type: the name of assign type of the netdev |
| 4537 | * @rtnl_held: the rtnl lock hold flag |
| 4538 | * |
| 4539 | * This function open and setup the hdd adpater according to the device |
| 4540 | * type request, assign the name, the mac address assigned, and then prepared |
| 4541 | * the hdd related parameters, queue, lock and ready to start. |
| 4542 | * |
| 4543 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4544 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4545 | 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] | 4546 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4547 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4548 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4549 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4550 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4551 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4552 | |
| 4553 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4554 | /* |
| 4555 | * Max limit reached on the number of vdevs configured by the |
| 4556 | * host. Return error |
| 4557 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4558 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4559 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4560 | return NULL; |
| 4561 | } |
| 4562 | |
| 4563 | if (macAddr == NULL) { |
| 4564 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4565 | 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] | 4566 | return NULL; |
| 4567 | } |
| 4568 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4569 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4570 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4571 | " already exists", |
| 4572 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4573 | return NULL; |
| 4574 | } |
| 4575 | |
| 4576 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4577 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4578 | /* Reset locally administered bit if the device mode is STA */ |
| 4579 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4580 | hdd_info("locally administered bit reset in sta mode: " |
| 4581 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4582 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4583 | case QDF_P2P_CLIENT_MODE: |
| 4584 | case QDF_P2P_DEVICE_MODE: |
| 4585 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4586 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4587 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4588 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4589 | name_assign_type, |
| 4590 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4591 | |
| 4592 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4593 | hdd_err("failed to allocate adapter for session %d", |
| 4594 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4595 | return NULL; |
| 4596 | } |
| 4597 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4598 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4599 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4600 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4601 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4602 | else if (QDF_MONITOR_MODE == session_type) |
| 4603 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4604 | else |
| 4605 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4606 | |
| 4607 | adapter->device_mode = session_type; |
| 4608 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4609 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4610 | /* |
| 4611 | * Workqueue which gets scheduled in IPv4 notification |
| 4612 | * callback |
| 4613 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4614 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4615 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | |
| 4617 | #ifdef WLAN_NS_OFFLOAD |
| 4618 | /* |
| 4619 | * Workqueue which gets scheduled in IPv6 |
| 4620 | * notification callback. |
| 4621 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4622 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4623 | hdd_ipv6_notifier_work_queue); |
| 4624 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4626 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4627 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4628 | |
| 4629 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4630 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4631 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4632 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4633 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4634 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4635 | /* Initialize NAN Data Interface */ |
| 4636 | if (QDF_NDI_MODE == session_type) { |
| 4637 | status = hdd_init_nan_data_mode(adapter); |
| 4638 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4639 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4640 | } |
| 4641 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4642 | hdd_nud_init_tracking(adapter); |
| 4643 | |
| 4644 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4645 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4646 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4647 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4648 | case QDF_P2P_GO_MODE: |
| 4649 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4650 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4651 | name_assign_type, |
| 4652 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4653 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4654 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4655 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | return NULL; |
| 4657 | } |
| 4658 | |
| 4659 | adapter->wdev.iftype = |
| 4660 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4661 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | NL80211_IFTYPE_P2P_GO; |
| 4663 | adapter->device_mode = session_type; |
| 4664 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4665 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4666 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4667 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4668 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4669 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4670 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4671 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4672 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4673 | |
| 4674 | /* |
| 4675 | * Workqueue which gets scheduled in IPv4 notification |
| 4676 | * callback |
| 4677 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4678 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4679 | hdd_ipv4_notifier_work_queue); |
| 4680 | |
| 4681 | #ifdef WLAN_NS_OFFLOAD |
| 4682 | /* |
| 4683 | * Workqueue which gets scheduled in IPv6 |
| 4684 | * notification callback. |
| 4685 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4686 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4687 | hdd_ipv6_notifier_work_queue); |
| 4688 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4689 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4690 | case QDF_FTM_MODE: |
| 4691 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4692 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4693 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4694 | if (NULL == adapter) { |
| 4695 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4696 | return NULL; |
| 4697 | } |
| 4698 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4699 | adapter->device_mode = session_type; |
| 4700 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4701 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4702 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4703 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4704 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4705 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4706 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4707 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4708 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4709 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4711 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4712 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4713 | return NULL; |
| 4714 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4715 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4716 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4717 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4718 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4719 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4720 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4721 | } |
| 4722 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4723 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4724 | if (NULL != adapter) { |
| 4725 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4726 | adapter = NULL; |
| 4727 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4728 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4729 | return NULL; |
| 4730 | } |
| 4731 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4732 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4733 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4734 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4735 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4736 | /* Adapter successfully added. Increment the vdev count */ |
| 4737 | hdd_ctx->current_intf_count++; |
| 4738 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4739 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4740 | hdd_ctx->current_intf_count); |
| 4741 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4742 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4743 | } |
| 4744 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4745 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4746 | hdd_err("Interface %s wow debug_fs init failed", |
| 4747 | netdev_name(adapter->dev)); |
| 4748 | |
| 4749 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4750 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4751 | |
| 4752 | return adapter; |
| 4753 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4754 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4755 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4756 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4757 | |
| 4758 | return NULL; |
| 4759 | } |
| 4760 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4761 | #ifdef MSM_PLATFORM |
| 4762 | static inline |
| 4763 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4764 | { |
| 4765 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4766 | } |
| 4767 | #else |
| 4768 | static inline |
| 4769 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4770 | { |
| 4771 | } |
| 4772 | #endif |
| 4773 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4774 | 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] | 4775 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4777 | /* |
| 4778 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4779 | * |
| 4780 | * The reason is to fix one race condition between |
| 4781 | * bus bandwidth work and cleaning up an adapter. |
| 4782 | * Under some conditions, it is possible for the bus bandwidth |
| 4783 | * work to access a particularly destroyed adapter, leading to |
| 4784 | * use-after-free. |
| 4785 | */ |
| 4786 | hdd_debug("wait for bus bw work to flush"); |
| 4787 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4788 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4789 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4790 | /* cleanup adapter */ |
| 4791 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4792 | adapter->device_mode); |
| 4793 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4794 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4795 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4796 | /* conditionally restart the bw timer */ |
| 4797 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4798 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4799 | /* Adapter removed. Decrement vdev count */ |
| 4800 | if (hdd_ctx->current_intf_count != 0) |
| 4801 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4802 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4803 | /* Fw will take care incase of concurrency */ |
| 4804 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4805 | } |
| 4806 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4807 | /** |
| 4808 | * hdd_close_all_adapters - Close all open adapters |
| 4809 | * @hdd_ctx: Hdd context |
| 4810 | * rtnl_held: True if RTNL lock held |
| 4811 | * |
| 4812 | * Close all open adapters. |
| 4813 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4814 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4815 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4816 | 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] | 4817 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4818 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4819 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4821 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4822 | |
| 4823 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4824 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4825 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4826 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4827 | adapter->mac_addr.bytes); |
| 4828 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4829 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4830 | /* Adapter removed. Decrement vdev count */ |
| 4831 | if (hdd_ctx->current_intf_count != 0) |
| 4832 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4833 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4834 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4835 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4836 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4837 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4838 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | } |
| 4840 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4841 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4842 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4843 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4845 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4846 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4847 | case QDF_STA_MODE: |
| 4848 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4849 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4850 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4851 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4852 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | break; |
| 4854 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4855 | case QDF_SAP_MODE: |
| 4856 | case QDF_P2P_GO_MODE: |
| 4857 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4858 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4859 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | break; |
| 4861 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4862 | case QDF_FTM_MODE: |
| 4863 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4864 | default: |
| 4865 | /* |
| 4866 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4867 | * for these kind of devices |
| 4868 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4869 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4870 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | return; |
| 4872 | } |
| 4873 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4874 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4875 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | updateIE.ieBufferlength = 0; |
| 4877 | updateIE.pAdditionIEBuffer = NULL; |
| 4878 | updateIE.append = true; |
| 4879 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4880 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4881 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4882 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4883 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4884 | } |
| 4885 | } |
| 4886 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4887 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4888 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4889 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4890 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4891 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | union iwreq_data wrqu; |
| 4893 | tSirUpdateIE updateIE; |
| 4894 | unsigned long rc; |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 4895 | tsap_Config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4896 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4897 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4899 | hdd_nud_ignore_tracking(adapter, true); |
| 4900 | hdd_nud_reset_tracking(adapter); |
| 4901 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4902 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4903 | wlan_hdd_netif_queue_control(adapter, |
| 4904 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4905 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4906 | /* |
| 4907 | * if this is the last active connection check & stop the |
| 4908 | * opportunistic timer first |
| 4909 | */ |
| 4910 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4911 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4912 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4913 | adapter->device_mode), NULL) == 1)) || |
| 4914 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4915 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4916 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4917 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4918 | case QDF_STA_MODE: |
| 4919 | case QDF_P2P_CLIENT_MODE: |
| 4920 | case QDF_IBSS_MODE: |
| 4921 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4922 | case QDF_NDI_MODE: |
| 4923 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4924 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4925 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4926 | hdd_is_connecting( |
| 4927 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4928 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4929 | roam_profile = hdd_roam_profile(adapter); |
| 4930 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4931 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4932 | qdf_ret_status = sme_roam_disconnect( |
| 4933 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4934 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4935 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4936 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4937 | eCSR_BSS_TYPE_START_IBSS) |
| 4938 | qdf_ret_status = sme_roam_disconnect( |
| 4939 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4940 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4941 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4942 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4943 | qdf_ret_status = |
| 4944 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4945 | hdd_debug("Send disconnected event to userspace"); |
| 4946 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4947 | adapter->dev, true, |
| 4948 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 4949 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4950 | qdf_ret_status = sme_roam_disconnect( |
| 4951 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4952 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4953 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4954 | /* success implies disconnect command got |
| 4955 | * queued up successfully |
| 4956 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4957 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4958 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4959 | rc = wait_for_completion_timeout( |
| 4960 | &adapter->disconnect_comp_var, |
| 4961 | msecs_to_jiffies |
| 4962 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4963 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4964 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4965 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4966 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 4967 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4968 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 4969 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 4970 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 4971 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 4972 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 4973 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 4974 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4975 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 4976 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 4977 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4978 | |
| 4979 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4980 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4981 | #endif |
| 4982 | |
| 4983 | hdd_deregister_tx_flow_control(adapter); |
| 4984 | |
| 4985 | #ifdef WLAN_NS_OFFLOAD |
| 4986 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4987 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4988 | #endif |
| 4989 | #endif |
| 4990 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 4991 | if (adapter->device_mode == QDF_STA_MODE) |
| 4992 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 4993 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4994 | |
| 4995 | if (wlan_hdd_try_disconnect(adapter)) { |
| 4996 | hdd_err("Error: Can't disconnect adapter"); |
| 4997 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 4998 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4999 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5000 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5001 | break; |
| 5002 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5003 | case QDF_MONITOR_MODE: |
| 5004 | wlan_hdd_scan_abort(adapter); |
| 5005 | hdd_deregister_tx_flow_control(adapter); |
| 5006 | hdd_vdev_destroy(adapter); |
| 5007 | break; |
| 5008 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5009 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5010 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5011 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5012 | sap_config = &adapter->session.ap.sap_config; |
| 5013 | if (sap_config) |
| 5014 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5015 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5016 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 5017 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5018 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5019 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5020 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5021 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5022 | cds_flush_delayed_work( |
| 5023 | &adapter->acs_pending_work); |
| 5024 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5025 | } |
| 5026 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5027 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5028 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5029 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5030 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5031 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5032 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5033 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5034 | |
| 5035 | hdd_deregister_tx_flow_control(adapter); |
| 5036 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5037 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | mutex_lock(&hdd_ctx->sap_lock); |
| 5039 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5040 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5041 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5042 | |
| 5043 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5044 | status = wlansap_stop_bss( |
| 5045 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5046 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5047 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5048 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5049 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5050 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5051 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5052 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5053 | qdf_wait_for_event_completion( |
| 5054 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5055 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5056 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5057 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5058 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5059 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5060 | } |
| 5061 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5062 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5063 | } |
| 5064 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5065 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5066 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5067 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5068 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5069 | adapter->device_mode, |
| 5070 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5072 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5073 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5074 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5075 | updateIE.ieBufferlength = 0; |
| 5076 | updateIE.pAdditionIEBuffer = NULL; |
| 5077 | updateIE.append = false; |
| 5078 | updateIE.notify = false; |
| 5079 | /* Probe bcn reset */ |
| 5080 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5081 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5082 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5083 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | } |
| 5085 | /* Assoc resp reset */ |
| 5086 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5087 | &updateIE, |
| 5088 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5089 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5090 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5091 | } |
| 5092 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5093 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5095 | qdf_mem_free(adapter->session.ap.beacon); |
| 5096 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5097 | /* |
| 5098 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5099 | */ |
| 5100 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5101 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5102 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5103 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5104 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5105 | #endif |
| 5106 | |
| 5107 | #ifdef WLAN_NS_OFFLOAD |
| 5108 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5109 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5110 | #endif |
| 5111 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5112 | |
| 5113 | hdd_vdev_destroy(adapter); |
| 5114 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5115 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5116 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5117 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5118 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5119 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5120 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5121 | hdd_deregister_tx_flow_control(adapter); |
| 5122 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5123 | break; |
| 5124 | default: |
| 5125 | break; |
| 5126 | } |
| 5127 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5128 | if (adapter->scan_info.default_scan_ies) { |
| 5129 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5130 | adapter->scan_info.default_scan_ies = NULL; |
| 5131 | } |
| 5132 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5133 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5134 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5135 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5136 | } |
| 5137 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5138 | /** |
| 5139 | * hdd_deinit_all_adapters - deinit all adapters |
| 5140 | * @hdd_ctx: HDD context |
| 5141 | * @rtnl_held: True if RTNL lock held |
| 5142 | * |
| 5143 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5144 | 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] | 5145 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5146 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5147 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5148 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5149 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5150 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5151 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5152 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5153 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5154 | } |
| 5155 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5156 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5158 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5159 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5160 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5161 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5162 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5163 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5164 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5165 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5166 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5167 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5168 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5169 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5170 | } |
| 5171 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5172 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5173 | struct hdd_adapter *adapter) |
| 5174 | { |
| 5175 | switch (adapter->device_mode) { |
| 5176 | case QDF_STA_MODE: |
| 5177 | case QDF_P2P_CLIENT_MODE: |
| 5178 | case QDF_IBSS_MODE: |
| 5179 | case QDF_P2P_DEVICE_MODE: |
| 5180 | case QDF_NDI_MODE: |
| 5181 | wlan_hdd_scan_abort(adapter); |
| 5182 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5183 | if (adapter->device_mode == QDF_STA_MODE) |
| 5184 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5185 | adapter->dev); |
| 5186 | break; |
| 5187 | case QDF_P2P_GO_MODE: |
| 5188 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5189 | break; |
| 5190 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5191 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5192 | wlan_hdd_undo_acs(adapter); |
| 5193 | break; |
| 5194 | default: |
| 5195 | break; |
| 5196 | } |
| 5197 | } |
| 5198 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5199 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5200 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5201 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5202 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5203 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5204 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5205 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5206 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5207 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5208 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5209 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5210 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5211 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5212 | hdd_device_mode_to_string(adapter->device_mode), |
| 5213 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5214 | |
| 5215 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5216 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5217 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5218 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5219 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5220 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5221 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5222 | if (hdd_ctx->config->sap_internal_restart && |
| 5223 | adapter->device_mode == QDF_SAP_MODE) { |
| 5224 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5225 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5226 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5227 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5228 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5229 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5230 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5231 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5232 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5233 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5235 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5236 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5237 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5238 | |
| 5239 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5240 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5241 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5242 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5243 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5245 | hdd_wmm_adapter_close(adapter); |
| 5246 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5247 | } |
| 5248 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5249 | if (adapter->device_mode == QDF_STA_MODE) |
| 5250 | hdd_clear_fils_connection_info(adapter); |
| 5251 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5252 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5253 | /* |
| 5254 | * If adapter is SAP, set session ID to invalid |
| 5255 | * since SAP session will be cleanup during SSR. |
| 5256 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5257 | wlansap_set_invalid_session( |
| 5258 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5259 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5260 | wlansap_cleanup_cac_timer( |
| 5261 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5262 | } |
| 5263 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5264 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5265 | if (adapter->device_mode == QDF_STA_MODE || |
| 5266 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5267 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5268 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5269 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5270 | |
| 5271 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5272 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5273 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5274 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5275 | if (adapter->sta_info[sta_id].in_use) { |
| 5276 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5277 | sta_id); |
| 5278 | hdd_softap_deregister_sta(adapter, |
| 5279 | sta_id); |
| 5280 | adapter->sta_info[sta_id].in_use = 0; |
| 5281 | } |
| 5282 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5283 | } |
| 5284 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5285 | hdd_nud_reset_tracking(adapter); |
| 5286 | hdd_nud_ignore_tracking(adapter, true); |
| 5287 | hdd_set_disconnect_status(adapter, false); |
| 5288 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5289 | hdd_softap_deinit_tx_rx(adapter); |
| 5290 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5291 | /* Destroy vdev which will be recreated during reinit. */ |
| 5292 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5293 | } |
| 5294 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5295 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5296 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5297 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5298 | } |
| 5299 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5300 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5301 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5302 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5303 | bool close_modules = true; |
| 5304 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5305 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5306 | hdd_info("FTM mode, don't close the module"); |
| 5307 | return false; |
| 5308 | } |
| 5309 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5310 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5311 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5312 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5313 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5314 | close_modules = false; |
| 5315 | break; |
| 5316 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5317 | } |
| 5318 | |
| 5319 | return close_modules; |
| 5320 | } |
| 5321 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5322 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5323 | { |
| 5324 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5325 | return true; |
| 5326 | else |
| 5327 | return false; |
| 5328 | } |
| 5329 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5330 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5331 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5332 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5333 | struct ieee80211_channel *channel, |
| 5334 | const u8 *bssid, const u8 *ssid, |
| 5335 | size_t ssid_len) |
| 5336 | { |
| 5337 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5338 | ssid, ssid_len, |
| 5339 | WLAN_CAPABILITY_ESS, |
| 5340 | WLAN_CAPABILITY_ESS); |
| 5341 | } |
| 5342 | #else |
| 5343 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5344 | struct ieee80211_channel *channel, |
| 5345 | const u8 *bssid, const u8 *ssid, |
| 5346 | size_t ssid_len) |
| 5347 | { |
| 5348 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5349 | ssid, ssid_len, |
| 5350 | IEEE80211_BSS_TYPE_ESS, |
| 5351 | IEEE80211_PRIVACY_ANY); |
| 5352 | } |
| 5353 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5354 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5355 | #if defined CFG80211_CONNECT_BSS || \ |
| 5356 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5357 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5358 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5359 | /** |
| 5360 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5361 | * @timeout_reason: reason for connect timeout |
| 5362 | * |
| 5363 | * This function is used to convert host timeout |
| 5364 | * reason enum to kernel specific enum. |
| 5365 | * |
| 5366 | * Return: nl timeout enum |
| 5367 | */ |
| 5368 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5369 | tSirResultCodes timeout_reason) |
| 5370 | { |
| 5371 | switch (timeout_reason) { |
| 5372 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5373 | return NL80211_TIMEOUT_SCAN; |
| 5374 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5375 | return NL80211_TIMEOUT_AUTH; |
| 5376 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5377 | return NL80211_TIMEOUT_ASSOC; |
| 5378 | default: |
| 5379 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5380 | } |
| 5381 | } |
| 5382 | |
| 5383 | /** |
| 5384 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5385 | * @dev: network device |
| 5386 | * @bssid: bssid to which we want to associate |
| 5387 | * @timeout_reason: reason for connect timeout |
| 5388 | * |
| 5389 | * This API is used to send connection timeout reason to supplicant |
| 5390 | * |
| 5391 | * Return: void |
| 5392 | */ |
| 5393 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5394 | const u8 *bssid, |
| 5395 | tSirResultCodes timeout_reason) |
| 5396 | { |
| 5397 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5398 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5399 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5400 | |
| 5401 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5402 | nl_timeout_reason); |
| 5403 | } |
| 5404 | |
| 5405 | /** |
| 5406 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5407 | * @dev: network device |
| 5408 | * @bssid: bssid to which we want to associate |
| 5409 | * @req_ie: Request Information Element |
| 5410 | * @req_ie_len: len of the req IE |
| 5411 | * @resp_ie: Response IE |
| 5412 | * @resp_ie_len: len of ht response IE |
| 5413 | * @status: status |
| 5414 | * @gfp: Kernel Flag |
| 5415 | * @timeout_reason: reason for connect timeout |
| 5416 | * |
| 5417 | * Return: void |
| 5418 | */ |
| 5419 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5420 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5421 | size_t req_ie_len, const u8 *resp_ie, |
| 5422 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5423 | tSirResultCodes timeout_reason) |
| 5424 | { |
| 5425 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5426 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5427 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5428 | |
| 5429 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5430 | resp_ie, resp_ie_len, status, gfp, |
| 5431 | nl_timeout_reason); |
| 5432 | } |
| 5433 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5434 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5435 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5436 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5437 | const u8 *bssid, |
| 5438 | tSirResultCodes timeout_reason) |
| 5439 | { |
| 5440 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5441 | } |
| 5442 | #endif |
| 5443 | |
| 5444 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5445 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5446 | size_t req_ie_len, const u8 *resp_ie, |
| 5447 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5448 | tSirResultCodes timeout_reason) |
| 5449 | { |
| 5450 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5451 | resp_ie, resp_ie_len, status, gfp); |
| 5452 | } |
| 5453 | #endif |
| 5454 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5455 | /** |
| 5456 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5457 | * @dev: network device |
| 5458 | * @bssid: bssid to which we want to associate |
| 5459 | * @req_ie: Request Information Element |
| 5460 | * @req_ie_len: len of the req IE |
| 5461 | * @resp_ie: Response IE |
| 5462 | * @resp_ie_len: len of ht response IE |
| 5463 | * @status: status |
| 5464 | * @gfp: Kernel Flag |
| 5465 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5466 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5467 | * |
| 5468 | * The API is a wrapper to send connection status to supplicant |
| 5469 | * |
| 5470 | * Return: Void |
| 5471 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5472 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5473 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5474 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5475 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5476 | size_t req_ie_len, const u8 *resp_ie, |
| 5477 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5478 | bool connect_timeout, |
| 5479 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5480 | { |
| 5481 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5482 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5483 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5484 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5485 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5486 | } |
| 5487 | #else |
| 5488 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5489 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5490 | size_t req_ie_len, const u8 *resp_ie, |
| 5491 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5492 | bool connect_timeout, |
| 5493 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5494 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5495 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5496 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5497 | } |
| 5498 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5499 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5500 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5501 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5502 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5503 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5504 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5505 | /** |
| 5506 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5507 | * @fils_params: connect response to supplicant |
| 5508 | * @fils_kek: FILS kek |
| 5509 | * @fils_kek_len: FILS kek length |
| 5510 | * @pmk: FILS PMK |
| 5511 | * @pmk_len: FILS PMK length |
| 5512 | * @pmkid: PMKID |
| 5513 | * @fils_seq_num: FILS Seq number |
| 5514 | * |
| 5515 | * Return: None |
| 5516 | */ |
| 5517 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5518 | *fils_params, const uint8_t *fils_kek, |
| 5519 | size_t fils_kek_len, const uint8_t *pmk, |
| 5520 | size_t pmk_len, const uint8_t *pmkid, |
| 5521 | uint16_t fils_seq_num) |
| 5522 | { |
| 5523 | /* Increament seq number to be used for next FILS */ |
| 5524 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5525 | fils_params->update_erp_next_seq_num = true; |
| 5526 | fils_params->fils_kek = fils_kek; |
| 5527 | fils_params->fils_kek_len = fils_kek_len; |
| 5528 | fils_params->pmk = pmk; |
| 5529 | fils_params->pmk_len = pmk_len; |
| 5530 | fils_params->pmkid = pmkid; |
| 5531 | } |
| 5532 | #else |
| 5533 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5534 | *fils_params, const uint8_t |
| 5535 | *fils_kek, size_t fils_kek_len, |
| 5536 | const uint8_t *pmk, size_t pmk_len, |
| 5537 | const uint8_t *pmkid, |
| 5538 | uint16_t fils_seq_num) |
| 5539 | { } |
| 5540 | #endif |
| 5541 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5542 | void hdd_update_hlp_info(struct net_device *dev, |
| 5543 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5544 | { |
| 5545 | struct sk_buff *skb; |
| 5546 | uint16_t skb_len; |
| 5547 | struct llc_snap_hdr_t *llc_hdr; |
| 5548 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5549 | uint8_t *hlp_data; |
| 5550 | uint16_t hlp_data_len; |
| 5551 | struct fils_join_rsp_params *roam_fils_params |
| 5552 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5553 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5554 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5555 | if (!roam_fils_params) { |
| 5556 | hdd_err("FILS Roam Param NULL"); |
| 5557 | return; |
| 5558 | } |
| 5559 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5560 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5561 | hdd_err("FILS HLP Data NULL, len %d", |
| 5562 | roam_fils_params->hlp_data_len); |
| 5563 | return; |
| 5564 | } |
| 5565 | |
| 5566 | hlp_data = roam_fils_params->hlp_data; |
| 5567 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5568 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5569 | /* Calculate skb length */ |
| 5570 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5571 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5572 | if (skb == NULL) { |
| 5573 | hdd_err("HLP packet nbuf alloc fails"); |
| 5574 | return; |
| 5575 | } |
| 5576 | |
| 5577 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5578 | QDF_MAC_ADDR_SIZE); |
| 5579 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5580 | QDF_MAC_ADDR_SIZE); |
| 5581 | |
| 5582 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5583 | if (IS_SNAP(llc_hdr)) { |
| 5584 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5585 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5586 | } |
| 5587 | |
| 5588 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5589 | |
| 5590 | /* |
| 5591 | * This HLP packet is formed from HLP info encapsulated |
| 5592 | * in assoc response frame which is AEAD encrypted. |
| 5593 | * Hence, this checksum validation can be set unnecessary. |
| 5594 | * i.e. network layer need not worry about checksum. |
| 5595 | */ |
| 5596 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5597 | |
| 5598 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5599 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5600 | hdd_err("Sending HLP packet fails"); |
| 5601 | return; |
| 5602 | } |
| 5603 | hdd_debug("send HLP packet to netif successfully"); |
| 5604 | } |
| 5605 | |
| 5606 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5607 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5608 | * @dev: network device |
| 5609 | * @bssid: bssid to which we want to associate |
| 5610 | * @bss: cfg80211 bss info |
| 5611 | * @roam_info: information about connected bss |
| 5612 | * @req_ie: Request Information Element |
| 5613 | * @req_ie_len: len of the req IE |
| 5614 | * @resp_ie: Response IE |
| 5615 | * @resp_ie_len: len of ht response IE |
| 5616 | * @status: status |
| 5617 | * @gfp: allocation flags |
| 5618 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5619 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5620 | * |
| 5621 | * This API is used as wrapper to send FILS key/sequence number |
| 5622 | * params etc. to supplicant in case of FILS connection |
| 5623 | * |
| 5624 | * Return: None |
| 5625 | */ |
| 5626 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5627 | struct cfg80211_bss *bss, |
| 5628 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5629 | const u8 *req_ie, size_t req_ie_len, |
| 5630 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5631 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5632 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5633 | { |
| 5634 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5635 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5636 | struct fils_join_rsp_params *roam_fils_params = |
| 5637 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5638 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5639 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5640 | |
| 5641 | if (!roam_fils_params) { |
| 5642 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5643 | } else { |
| 5644 | fils_params.status = status; |
| 5645 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5646 | fils_params.timeout_reason = |
| 5647 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5648 | fils_params.req_ie = req_ie; |
| 5649 | fils_params.req_ie_len = req_ie_len; |
| 5650 | fils_params.resp_ie = resp_ie; |
| 5651 | fils_params.resp_ie_len = resp_ie_len; |
| 5652 | fils_params.bss = bss; |
| 5653 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5654 | roam_fils_params->kek_len, |
| 5655 | roam_fils_params->fils_pmk, |
| 5656 | roam_fils_params->fils_pmk_len, |
| 5657 | roam_fils_params->fils_pmkid, |
| 5658 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5659 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5660 | } |
| 5661 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5662 | fils_params.status, |
| 5663 | fils_params.fils_erp_next_seq_num); |
| 5664 | |
| 5665 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5666 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5667 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5668 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5669 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5670 | /* Clear all the FILS key info */ |
| 5671 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5672 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5673 | if (roam_fils_params) |
| 5674 | qdf_mem_free(roam_fils_params); |
| 5675 | roam_info->fils_join_rsp = NULL; |
| 5676 | } |
| 5677 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5678 | static inline void |
| 5679 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5680 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5681 | const u8 *req_ie, size_t req_ie_len, |
| 5682 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5683 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5684 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5685 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5686 | #endif |
| 5687 | #endif |
| 5688 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5689 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5690 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5691 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5692 | /** |
| 5693 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5694 | * supplicant. |
| 5695 | * @dev: network device |
| 5696 | * @bssid: bssid to which we want to associate |
| 5697 | * @bss: cfg80211 bss info |
| 5698 | * @roam_info: information about connected bss |
| 5699 | * @req_ie: Request Information Element |
| 5700 | * @req_ie_len: len of the req IE |
| 5701 | * @resp_ie: Response IE |
| 5702 | * @resp_ie_len: len of ht response IE |
| 5703 | * @status: status |
| 5704 | * @gfp: allocation flags |
| 5705 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5706 | * @timeout_reason: reason for connect timeout |
| 5707 | * |
| 5708 | * The API is a wrapper to send connection status to supplicant |
| 5709 | * |
| 5710 | * Return: 0 if success else failure |
| 5711 | */ |
| 5712 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5713 | const u8 *bssid, |
| 5714 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5715 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5716 | size_t req_ie_len, const u8 *resp_ie, |
| 5717 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5718 | bool connect_timeout, |
| 5719 | tSirResultCodes timeout_reason) |
| 5720 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5721 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5722 | if (!roam_info || !roam_info->is_fils_connection) |
| 5723 | return -EINVAL; |
| 5724 | |
| 5725 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5726 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5727 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5728 | return 0; |
| 5729 | } |
| 5730 | #else |
| 5731 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5732 | const u8 *bssid, |
| 5733 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5734 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5735 | size_t req_ie_len, const u8 *resp_ie, |
| 5736 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5737 | bool connect_timeout, |
| 5738 | tSirResultCodes timeout_reason) |
| 5739 | { |
| 5740 | return -EINVAL; |
| 5741 | } |
| 5742 | #endif |
| 5743 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5744 | /** |
| 5745 | * hdd_connect_result() - API to send connection status to supplicant |
| 5746 | * @dev: network device |
| 5747 | * @bssid: bssid to which we want to associate |
| 5748 | * @roam_info: information about connected bss |
| 5749 | * @req_ie: Request Information Element |
| 5750 | * @req_ie_len: len of the req IE |
| 5751 | * @resp_ie: Response IE |
| 5752 | * @resp_ie_len: len of ht response IE |
| 5753 | * @status: status |
| 5754 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5755 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5756 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5757 | * |
| 5758 | * The API is a wrapper to send connection status to supplicant |
| 5759 | * and allow runtime suspend |
| 5760 | * |
| 5761 | * Return: Void |
| 5762 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5763 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5764 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5765 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5766 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5767 | bool connect_timeout, |
| 5768 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5769 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5770 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5771 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5772 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5773 | |
| 5774 | if (WLAN_STATUS_SUCCESS == status) { |
| 5775 | struct ieee80211_channel *chan; |
| 5776 | int freq; |
| 5777 | int chan_no = roam_info->pBssDesc->channelId; |
| 5778 | |
| 5779 | if (chan_no <= 14) |
| 5780 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5781 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5782 | else |
| 5783 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5784 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5785 | |
| 5786 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5787 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5788 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5789 | roam_info->u.pConnectedProfile->SSID.length); |
| 5790 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5791 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5792 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5793 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5794 | resp_ie_len, status, gfp, connect_timeout, |
| 5795 | timeout_reason) != 0) { |
| 5796 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5797 | req_ie_len, resp_ie, resp_ie_len, |
| 5798 | status, gfp, connect_timeout, timeout_reason); |
| 5799 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5800 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5801 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5802 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5803 | } |
| 5804 | #else |
| 5805 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5806 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5807 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5808 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5809 | bool connect_timeout, |
| 5810 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5811 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5812 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5813 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5814 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5815 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5816 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5817 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5818 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5819 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5820 | } |
| 5821 | #endif |
| 5822 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5823 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 5824 | uint32_t bandwidth) |
| 5825 | { |
| 5826 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5827 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5828 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 5829 | QDF_STATUS status; |
| 5830 | tHalHandle hal_hdl = hdd_ctx->hHal; |
| 5831 | struct qdf_mac_addr bssid; |
| 5832 | struct csr_roam_profile roam_profile; |
| 5833 | struct ch_params ch_params; |
| 5834 | |
| 5835 | if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) { |
| 5836 | hdd_err("Not supported, device is not in monitor mode"); |
| 5837 | return -EINVAL; |
| 5838 | } |
| 5839 | |
| 5840 | hdd_debug("Set monitor mode Channel %d", chan); |
| 5841 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 5842 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 5843 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 5844 | roam_profile.phyMode = ch_info->phy_mode; |
| 5845 | roam_profile.ch_params.ch_width = bandwidth; |
| 5846 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
| 5847 | |
| 5848 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 5849 | QDF_MAC_ADDR_SIZE); |
| 5850 | |
| 5851 | ch_params.ch_width = bandwidth; |
| 5852 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 5853 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 5854 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 5855 | return -EINVAL; |
| 5856 | } |
| 5857 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 5858 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 5859 | hdd_err("Failed to change hw mode"); |
| 5860 | return -EINVAL; |
| 5861 | } |
| 5862 | |
| 5863 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 5864 | &roam_profile); |
| 5865 | if (status) { |
| 5866 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 5867 | status); |
| 5868 | } |
| 5869 | |
| 5870 | adapter->mon_chan = chan; |
| 5871 | adapter->mon_bandwidth = bandwidth; |
| 5872 | return qdf_status_to_os_return(status); |
| 5873 | } |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5874 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5875 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5876 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5877 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5878 | #ifndef MSM_PLATFORM |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5879 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5880 | #endif |
| 5881 | eConnectionState connState; |
| 5882 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5883 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5884 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5885 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5886 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5887 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5888 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5889 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5890 | hdd_device_mode_to_string(adapter->device_mode), |
| 5891 | adapter->device_mode); |
| 5892 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5893 | hdd_wmm_init(adapter); |
| 5894 | |
| 5895 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5896 | case QDF_STA_MODE: |
| 5897 | case QDF_P2P_CLIENT_MODE: |
| 5898 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5899 | |
| 5900 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5901 | ->conn_info.connState; |
| 5902 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5903 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5904 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5905 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5906 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5907 | /* Indicate disconnect event to supplicant |
| 5908 | * if associated previously |
| 5909 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5910 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5911 | eConnectionState_IbssConnected == connState || |
| 5912 | eConnectionState_NotConnected == connState || |
| 5913 | eConnectionState_IbssDisconnected == connState || |
| 5914 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5915 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5916 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5917 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5918 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5919 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5920 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5921 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5922 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5923 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5924 | |
| 5925 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5926 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5927 | adapter->dev, false, |
| 5928 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5929 | } else if (eConnectionState_Connecting == connState) { |
| 5930 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5931 | * Indicate connect failure to supplicant if we |
| 5932 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5933 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5934 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5935 | NULL, 0, NULL, 0, |
| 5936 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5937 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5938 | } |
| 5939 | |
| 5940 | hdd_register_tx_flow_control(adapter, |
| 5941 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 5942 | hdd_tx_resume_cb, |
| 5943 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5944 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5945 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5946 | break; |
| 5947 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5948 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5949 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5950 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5951 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5952 | break; |
| 5953 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5954 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5955 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5956 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5957 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5958 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5959 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5960 | /* event supplicant to restart */ |
| 5961 | cfg80211_del_sta(adapter->dev, |
| 5962 | (const u8 *)&bcastMac.bytes[0], |
| 5963 | GFP_KERNEL); |
| 5964 | #endif |
| 5965 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5966 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5967 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 5968 | hdd_set_mon_rx_cb(adapter->dev); |
| 5969 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 5970 | adapter->mon_bandwidth); |
| 5971 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5972 | default: |
| 5973 | break; |
| 5974 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 5975 | /* |
| 5976 | * Action frame registered in one adapter which will |
| 5977 | * applicable to all interfaces |
| 5978 | */ |
| 5979 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5980 | } |
| 5981 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5982 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5983 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5984 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5985 | } |
| 5986 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5987 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5988 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5989 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 5990 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5991 | qdf_list_node_t *node; |
| 5992 | |
| 5993 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5994 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5995 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5996 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 5997 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5998 | |
| 5999 | if (QDF_IS_STATUS_ERROR(status)) |
| 6000 | return status; |
| 6001 | |
| 6002 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6003 | |
| 6004 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6005 | } |
| 6006 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6007 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6008 | struct hdd_adapter *current_adapter, |
| 6009 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6010 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6011 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6012 | qdf_list_node_t *node; |
| 6013 | |
| 6014 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6015 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6016 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6017 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6018 | ¤t_adapter->node, |
| 6019 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6020 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6021 | |
| 6022 | if (QDF_IS_STATUS_ERROR(status)) |
| 6023 | return status; |
| 6024 | |
| 6025 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6026 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6027 | return status; |
| 6028 | } |
| 6029 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6030 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6031 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6032 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6033 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6034 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6035 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6036 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6037 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6039 | return status; |
| 6040 | } |
| 6041 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6042 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6043 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6045 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6046 | qdf_list_node_t *node; |
| 6047 | |
| 6048 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6049 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6050 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6051 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6052 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6053 | |
| 6054 | if (QDF_IS_STATUS_ERROR(status)) |
| 6055 | return status; |
| 6056 | |
| 6057 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6058 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6059 | return status; |
| 6060 | } |
| 6061 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6062 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6063 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6064 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6065 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6066 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6067 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6068 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6069 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6070 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6071 | return status; |
| 6072 | } |
| 6073 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6074 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6075 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6076 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6077 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6078 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6079 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6080 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6081 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6083 | return status; |
| 6084 | } |
| 6085 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6086 | 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] | 6087 | tSirMacAddr macAddr) |
| 6088 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6089 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6090 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6091 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6092 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6093 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6094 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6095 | } |
| 6096 | |
| 6097 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6098 | } |
| 6099 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6100 | 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] | 6101 | uint32_t vdev_id) |
| 6102 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6103 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6104 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6105 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6106 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6107 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6108 | } |
| 6109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6110 | return NULL; |
| 6111 | } |
| 6112 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6113 | /** |
| 6114 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6115 | * the sessionid |
| 6116 | * @hdd_ctx: hdd context. |
| 6117 | * @sme_session_id: sme session is for the adapter to get. |
| 6118 | * |
| 6119 | * This function is used to get the adapter with provided session id |
| 6120 | * |
| 6121 | * Return: adapter pointer if found |
| 6122 | * |
| 6123 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6124 | struct hdd_adapter * |
| 6125 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6126 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6127 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6128 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6129 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6130 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6131 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6132 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6133 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6134 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6135 | return NULL; |
| 6136 | } |
| 6137 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6138 | 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] | 6139 | const char *iface_name) |
| 6140 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6141 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6142 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6143 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6144 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6145 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6146 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6147 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6148 | return NULL; |
| 6149 | } |
| 6150 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6151 | /** |
| 6152 | * hdd_get_adapter() - to get adapter matching the mode |
| 6153 | * @hdd_ctx: hdd context |
| 6154 | * @mode: adapter mode |
| 6155 | * |
| 6156 | * This routine will return the pointer to adapter matching |
| 6157 | * with the passed mode. |
| 6158 | * |
| 6159 | * Return: pointer to adapter or null |
| 6160 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6161 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6162 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6163 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6164 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6165 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6166 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6167 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6169 | } |
| 6170 | |
| 6171 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6172 | } |
| 6173 | |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6174 | enum tQDF_ADAPTER_MODE hdd_get_device_mode(uint32_t session_id) |
| 6175 | { |
| 6176 | struct hdd_context *hdd_ctx; |
| 6177 | struct hdd_adapter *adapter; |
| 6178 | |
| 6179 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6180 | if (!hdd_ctx) { |
| 6181 | hdd_err("Invalid HDD context"); |
| 6182 | return QDF_MAX_NO_OF_MODE; |
| 6183 | } |
| 6184 | |
| 6185 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6186 | if (!adapter) { |
| 6187 | hdd_err("Invalid HDD adapter"); |
| 6188 | return QDF_MAX_NO_OF_MODE; |
| 6189 | } |
| 6190 | |
| 6191 | return adapter->device_mode; |
| 6192 | } |
| 6193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6194 | /** |
| 6195 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6196 | * @hdd_ctx: Pointer to the HDD context. |
| 6197 | * @mode: Device mode for which operating channel is required. |
| 6198 | * Suported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6199 | * QDF_STA_MODE, |
| 6200 | * QDF_P2P_CLIENT_MODE, |
| 6201 | * QDF_SAP_MODE, |
| 6202 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6203 | * |
| 6204 | * This API returns the operating channel of the requested device mode |
| 6205 | * |
| 6206 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6207 | * not connected. |
| 6208 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6209 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6210 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6211 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6212 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6213 | uint8_t operatingChannel = 0; |
| 6214 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6215 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6216 | if (mode == adapter->device_mode) { |
| 6217 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6218 | case QDF_STA_MODE: |
| 6219 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6220 | if (hdd_conn_is_connected |
| 6221 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6222 | (adapter))) { |
| 6223 | operatingChannel = |
| 6224 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6225 | (adapter))->conn_info. |
| 6226 | operationChannel; |
| 6227 | } |
| 6228 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6229 | case QDF_SAP_MODE: |
| 6230 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6231 | /* softap connection info */ |
| 6232 | if (test_bit |
| 6233 | (SOFTAP_BSS_STARTED, |
| 6234 | &adapter->event_flags)) |
| 6235 | operatingChannel = |
| 6236 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6237 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6238 | break; |
| 6239 | default: |
| 6240 | break; |
| 6241 | } |
| 6242 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6243 | /* Found the device of interest. break the loop */ |
| 6244 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6245 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6246 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6247 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6248 | return operatingChannel; |
| 6249 | } |
| 6250 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6251 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | hdd_ctx) |
| 6253 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6254 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6255 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6256 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6257 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6258 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6259 | if (adapter->device_mode == QDF_STA_MODE || |
| 6260 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6261 | adapter->device_mode == QDF_IBSS_MODE || |
| 6262 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6263 | adapter->device_mode == QDF_SAP_MODE || |
| 6264 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6265 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 6266 | hdd_unregister_wext(adapter->dev); |
| 6267 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6268 | } |
| 6269 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6270 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6271 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6272 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6273 | } |
| 6274 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6275 | 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] | 6276 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6277 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6278 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6279 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6281 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6282 | if (adapter->device_mode == QDF_STA_MODE || |
| 6283 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6284 | adapter->device_mode == QDF_IBSS_MODE || |
| 6285 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6286 | adapter->device_mode == QDF_SAP_MODE || |
| 6287 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6288 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6289 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6290 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6291 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6292 | } |
| 6293 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6294 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6295 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6296 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6297 | } |
| 6298 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6299 | /** |
| 6300 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6301 | * adapters |
| 6302 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6303 | * |
| 6304 | * return: QDF_STATUS_SUCCESS |
| 6305 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6306 | 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] | 6307 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6308 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6309 | int err; |
| 6310 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6311 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6312 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6313 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6314 | if (adapter->device_mode == QDF_STA_MODE || |
| 6315 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6316 | adapter->device_mode == QDF_IBSS_MODE || |
| 6317 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6318 | adapter->device_mode == QDF_SAP_MODE || |
| 6319 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6320 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6321 | if (err) |
| 6322 | hdd_err("Unable to stop scheduled scan"); |
| 6323 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6324 | } |
| 6325 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6326 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6327 | |
| 6328 | return QDF_STATUS_SUCCESS; |
| 6329 | } |
| 6330 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | #ifdef WLAN_NS_OFFLOAD |
| 6332 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6333 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6334 | * @hdd_ctx: Pointer to hdd context |
| 6335 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6336 | * Unregister for IPv6 address change notifications. |
| 6337 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6338 | * Return: None |
| 6339 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6340 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | { |
| 6342 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6343 | } |
| 6344 | |
| 6345 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6346 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6347 | * @hdd_ctx: Pointer to hdd context |
| 6348 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6349 | * Register for IPv6 address change notifications. |
| 6350 | * |
| 6351 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6352 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6353 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | { |
| 6355 | int ret; |
| 6356 | |
| 6357 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6358 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6359 | if (ret) { |
| 6360 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6361 | goto out; |
| 6362 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6363 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6364 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6365 | out: |
| 6366 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6367 | } |
| 6368 | #else |
| 6369 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6370 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6371 | * @hdd_ctx: Pointer to hdd context |
| 6372 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6373 | * Unregister for IPv6 address change notifications. |
| 6374 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6375 | * Return: None |
| 6376 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6377 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6378 | { |
| 6379 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6380 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6381 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6382 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6383 | * @hdd_ctx: Pointer to hdd context |
| 6384 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6385 | * Register for IPv6 address change notifications. |
| 6386 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6387 | * Return: None |
| 6388 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6389 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6390 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6391 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6392 | } |
| 6393 | #endif |
| 6394 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6395 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6396 | { |
| 6397 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6398 | adapter->disconnection_in_progress = status; |
| 6399 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6400 | hdd_debug("setting disconnection status: %d", status); |
| 6401 | } |
| 6402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6403 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6404 | * hdd_register_notifiers - Register netdev notifiers. |
| 6405 | * @hdd_ctx: HDD context |
| 6406 | * |
| 6407 | * Register netdev notifiers like IPv4 and IPv6. |
| 6408 | * |
| 6409 | * Return: 0 on success and errno on failure |
| 6410 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6411 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6412 | { |
| 6413 | int ret; |
| 6414 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6415 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6416 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6417 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6418 | |
| 6419 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6420 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6421 | if (ret) { |
| 6422 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6423 | goto unregister_ip6_notifier; |
| 6424 | } |
| 6425 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6426 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6427 | if (ret) { |
| 6428 | hdd_err("Failed to register netevent notifier: %d", |
| 6429 | ret); |
| 6430 | goto unregister_inetaddr_notifier; |
| 6431 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6432 | return 0; |
| 6433 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6434 | unregister_inetaddr_notifier: |
| 6435 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6436 | unregister_ip6_notifier: |
| 6437 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6438 | out: |
| 6439 | return ret; |
| 6440 | |
| 6441 | } |
| 6442 | |
| 6443 | /** |
| 6444 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6445 | * @hdd_ctx: HDD context |
| 6446 | * |
| 6447 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6448 | * |
| 6449 | * Return: None. |
| 6450 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6451 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6452 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6453 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6454 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6455 | |
| 6456 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6457 | } |
| 6458 | |
| 6459 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6460 | * hdd_exit_netlink_services - Exit netlink services |
| 6461 | * @hdd_ctx: HDD context |
| 6462 | * |
| 6463 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6464 | * nl service. |
| 6465 | * |
| 6466 | * Return: None. |
| 6467 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6468 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6469 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6470 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6471 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6472 | ptt_sock_deactivate_svc(); |
| 6473 | |
| 6474 | nl_srv_exit(); |
| 6475 | } |
| 6476 | |
| 6477 | /** |
| 6478 | * hdd_init_netlink_services- Init netlink services |
| 6479 | * @hdd_ctx: HDD context |
| 6480 | * |
| 6481 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6482 | * nl service. |
| 6483 | * |
| 6484 | * Return: 0 on success and errno on failure. |
| 6485 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6486 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6487 | { |
| 6488 | int ret; |
| 6489 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6490 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6491 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6492 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6493 | goto out; |
| 6494 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6495 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6496 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6497 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6498 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6499 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6500 | goto err_nl_srv; |
| 6501 | } |
| 6502 | |
| 6503 | ret = ptt_sock_activate_svc(); |
| 6504 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6505 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6506 | goto err_nl_srv; |
| 6507 | } |
| 6508 | |
| 6509 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6510 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6511 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6512 | |
| 6513 | ret = cnss_diag_activate_service(); |
| 6514 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6515 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6516 | goto err_close_cesium; |
| 6517 | } |
| 6518 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6519 | ret = spectral_scan_activate_service(); |
| 6520 | if (ret) { |
| 6521 | hdd_alert("spectral_scan_activate_service failed: %d", ret); |
| 6522 | goto err_close_cesium; |
| 6523 | } |
| 6524 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6525 | return 0; |
| 6526 | |
| 6527 | err_close_cesium: |
| 6528 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6529 | ptt_sock_deactivate_svc(); |
| 6530 | err_nl_srv: |
| 6531 | nl_srv_exit(); |
| 6532 | out: |
| 6533 | return ret; |
| 6534 | } |
| 6535 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6536 | /** |
| 6537 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6538 | * @hdd_ctx: HDD context. |
| 6539 | * |
| 6540 | * Destroy RX wakelock. |
| 6541 | * |
| 6542 | * Return: None. |
| 6543 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6544 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6545 | { |
| 6546 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6547 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6548 | |
| 6549 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6550 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6551 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6552 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6553 | * Create RX wakelock. |
| 6554 | * |
| 6555 | * Return: None. |
| 6556 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6557 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6558 | { |
| 6559 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6560 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6561 | |
| 6562 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6563 | * hdd_context_deinit() - Deinitialize HDD context |
| 6564 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6565 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6566 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6567 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6568 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6569 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6570 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6571 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6572 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6573 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6574 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6575 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6576 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6577 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6578 | hdd_sap_context_destroy(hdd_ctx); |
| 6579 | |
| 6580 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6581 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6582 | hdd_scan_context_destroy(hdd_ctx); |
| 6583 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6584 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6585 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6586 | return 0; |
| 6587 | } |
| 6588 | |
| 6589 | /** |
| 6590 | * hdd_context_destroy() - Destroy HDD context |
| 6591 | * @hdd_ctx: HDD context to be destroyed. |
| 6592 | * |
| 6593 | * Free config and HDD context as well as destroy all the resources. |
| 6594 | * |
| 6595 | * Return: None |
| 6596 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6597 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6598 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6599 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6600 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6601 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6602 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6603 | hdd_context_deinit(hdd_ctx); |
| 6604 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6605 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6606 | hdd_ctx->config = NULL; |
| 6607 | |
| 6608 | wiphy_free(hdd_ctx->wiphy); |
| 6609 | } |
| 6610 | |
| 6611 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6612 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6613 | * |
| 6614 | * This function is used to destroy bug report lock |
| 6615 | * |
| 6616 | * Return: None |
| 6617 | */ |
| 6618 | static void wlan_destroy_bug_report_lock(void) |
| 6619 | { |
| 6620 | p_cds_contextType p_cds_context; |
| 6621 | |
| 6622 | p_cds_context = cds_get_global_context(); |
| 6623 | if (!p_cds_context) { |
| 6624 | hdd_err("cds context is NULL"); |
| 6625 | return; |
| 6626 | } |
| 6627 | |
| 6628 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6629 | } |
| 6630 | |
| 6631 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6633 | * @hdd_ctx: Pointer to the HDD Context |
| 6634 | * |
| 6635 | * This is the driver exit point (invoked during rmmod) |
| 6636 | * |
| 6637 | * Return: None |
| 6638 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6639 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6640 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6641 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6642 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6643 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6644 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6645 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6646 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6647 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6648 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6649 | |
| 6650 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6651 | if (QDF_TIMER_STATE_RUNNING == |
| 6652 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6653 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6654 | } |
| 6655 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6656 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6657 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6658 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6659 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6660 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6661 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6662 | hdd_ctx->last_acs_channel_list = NULL; |
| 6663 | hdd_ctx->num_of_channels = 0; |
| 6664 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6665 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6666 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6667 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6668 | driver_status = hdd_ctx->driver_status; |
| 6669 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6670 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6671 | /* |
| 6672 | * Powersave Offload Case |
| 6673 | * Disable Idle Power Save Mode |
| 6674 | */ |
| 6675 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6676 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6677 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6678 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6679 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6680 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6681 | /* |
| 6682 | * Cancel any outstanding scan requests. We are about to close |
| 6683 | * all of our adapters, but an adapter structure is what SME |
| 6684 | * passes back to our callback function. Hence if there |
| 6685 | * are any outstanding scan requests then there is a |
| 6686 | * race condition between when the adapter is closed and |
| 6687 | * when the callback is invoked. We try to resolve that |
| 6688 | * race condition here by canceling any outstanding scans |
| 6689 | * before we close the adapters. |
| 6690 | * Note that the scans may be cancelled in an asynchronous |
| 6691 | * manner, so ideally there needs to be some kind of |
| 6692 | * synchronization. Rather than introduce a new |
| 6693 | * synchronization here, we will utilize the fact that we are |
| 6694 | * about to Request Full Power, and since that is synchronized, |
| 6695 | * the expectation is that by the time Request Full Power has |
| 6696 | * completed, all scans will be cancelled |
| 6697 | */ |
| 6698 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6699 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6700 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6701 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6702 | } |
| 6703 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6704 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6705 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6706 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6707 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6708 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6709 | hdd_driver_memdump_deinit(); |
| 6710 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6711 | qdf_nbuf_deinit_replenish_timer(); |
| 6712 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6713 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6714 | hdd_info("Release wakelock for monitor mode!"); |
| 6715 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6716 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6717 | } |
| 6718 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6719 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6720 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6721 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6722 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6723 | /* |
| 6724 | * Close CDS |
| 6725 | * This frees pMac(HAL) context. There should not be any call |
| 6726 | * that requires pMac access after this. |
| 6727 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6729 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 6730 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6731 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6732 | hdd_close_all_adapters(hdd_ctx, false); |
| 6733 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6734 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6735 | /* |
| 6736 | * If there is re_init failure wiphy would have already de-registered |
| 6737 | * check the wiphy status before un-registering again |
| 6738 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6739 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6740 | wiphy_unregister(wiphy); |
| 6741 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6742 | hdd_lpass_notify_stop(hdd_ctx); |
| 6743 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6744 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6745 | hdd_exit_netlink_services(hdd_ctx); |
| 6746 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6747 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6748 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6749 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6750 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6751 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6752 | if (driver_status) |
| 6753 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6754 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6755 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6756 | } |
| 6757 | |
| 6758 | void __hdd_wlan_exit(void) |
| 6759 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6760 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6761 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6762 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6763 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6764 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6765 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6766 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6767 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6768 | return; |
| 6769 | } |
| 6770 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6771 | /* Do all the cleanup before deregistering the driver */ |
| 6772 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6773 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6774 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6775 | } |
| 6776 | |
| 6777 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6778 | /** |
| 6779 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6780 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6781 | * |
| 6782 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6783 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6784 | * scan information. |
| 6785 | * |
| 6786 | * Return: void |
| 6787 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6788 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6789 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6790 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6791 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6792 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6793 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6794 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6795 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6796 | hdd_ctx->last_acs_channel_list = NULL; |
| 6797 | hdd_ctx->num_of_channels = 0; |
| 6798 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6799 | |
| 6800 | if (!hdd_ctx->hHal) |
| 6801 | return; |
| 6802 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6803 | } |
| 6804 | #endif |
| 6805 | |
| 6806 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6807 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6808 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6809 | { |
| 6810 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6811 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6812 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6813 | |
| 6814 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6815 | |
| 6816 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6817 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6818 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6819 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6820 | if (!hdd_ctx->hHal) |
| 6821 | return -EINVAL; |
| 6822 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6823 | 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] | 6824 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6825 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6826 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6827 | return -EINVAL; |
| 6828 | } |
| 6829 | |
| 6830 | return 0; |
| 6831 | } |
| 6832 | #endif |
| 6833 | |
| 6834 | /** |
| 6835 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6836 | * @state: state |
| 6837 | * |
| 6838 | * This function notifies FW with modem power status |
| 6839 | * |
| 6840 | * Return: 0 if successful, error number otherwise |
| 6841 | */ |
| 6842 | int hdd_wlan_notify_modem_power_state(int state) |
| 6843 | { |
| 6844 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6845 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6846 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6847 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6848 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6849 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6850 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6851 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6852 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6853 | if (!hdd_ctx->hHal) |
| 6854 | return -EINVAL; |
| 6855 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6856 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6857 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6858 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6859 | state); |
| 6860 | return -EINVAL; |
| 6861 | } |
| 6862 | return 0; |
| 6863 | } |
| 6864 | |
| 6865 | /** |
| 6866 | * |
| 6867 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6868 | * @adapter - Pointer to the HDD |
| 6869 | * |
| 6870 | * Return: None |
| 6871 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6872 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6873 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6874 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | |
| 6876 | /* |
| 6877 | * Send ready indication to the HDD. This will kick off the MAC |
| 6878 | * into a 'running' state and should kick off an initial scan. |
| 6879 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6880 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6881 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6882 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6883 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6884 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6885 | } |
| 6886 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6887 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6888 | } |
| 6889 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 6890 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 6891 | { |
| 6892 | struct hdd_adapter *adapter; |
| 6893 | |
| 6894 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6895 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 6896 | return adapter; |
| 6897 | } |
| 6898 | |
| 6899 | return NULL; |
| 6900 | } |
| 6901 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6902 | /* wake lock APIs for HDD */ |
| 6903 | void hdd_prevent_suspend(uint32_t reason) |
| 6904 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6905 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6906 | } |
| 6907 | |
| 6908 | void hdd_allow_suspend(uint32_t reason) |
| 6909 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6910 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6911 | } |
| 6912 | |
| 6913 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6914 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6915 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6916 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6917 | } |
| 6918 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6919 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6920 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6921 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6922 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6923 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6924 | hdd_ctx->reg.alpha2, |
| 6925 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6926 | } |
| 6927 | |
| 6928 | /** |
| 6929 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6930 | * @hdd_ctx: Pointer to the hdd context |
| 6931 | * |
| 6932 | * HDD function to know if hardware supports 5GHz |
| 6933 | * |
| 6934 | * Return: true if hardware supports 5GHz |
| 6935 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6936 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6937 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 6938 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6939 | return true; |
| 6940 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 6941 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 6942 | return true; |
| 6943 | else |
| 6944 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6945 | } |
| 6946 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6947 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | { |
| 6949 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6950 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | |
| 6952 | wiphy = hdd_ctx->wiphy; |
| 6953 | |
| 6954 | /* |
| 6955 | * The channel information in |
| 6956 | * wiphy needs to be initialized before wiphy registration |
| 6957 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6958 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 6959 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6960 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6961 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6962 | } |
| 6963 | |
| 6964 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 6965 | wiphy->wowlan = &wowlan_support_reg_init; |
| 6966 | #else |
| 6967 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 6968 | WIPHY_WOWLAN_MAGIC_PKT | |
| 6969 | WIPHY_WOWLAN_DISCONNECT | |
| 6970 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 6971 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 6972 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 6973 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 6974 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 6975 | |
| 6976 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 6977 | WOW_MAX_FILTERS_PER_LIST); |
| 6978 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 6979 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 6980 | #endif |
| 6981 | |
| 6982 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6983 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6984 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6985 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 6986 | return ret_val; |
| 6987 | } |
| 6988 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 6989 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6990 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 6991 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6992 | } |
| 6993 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 6994 | #ifdef MSM_PLATFORM |
| 6995 | /** |
| 6996 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 6997 | * @hdd_ctx - handle to hdd context |
| 6998 | * @bool data_in_interval - true, if data detected in bw time interval |
| 6999 | * |
| 7000 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7001 | * Stats show up in wlan driver logs. |
| 7002 | * |
| 7003 | * Returns: None |
| 7004 | */ |
| 7005 | static inline |
| 7006 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7007 | bool data_in_interval) |
| 7008 | { |
| 7009 | static u32 counter; |
| 7010 | static bool data_in_time_period; |
| 7011 | ol_txrx_pdev_handle pdev; |
| 7012 | |
| 7013 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7014 | return; |
| 7015 | |
| 7016 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7017 | if (!pdev) { |
| 7018 | hdd_err("pdev is NULL"); |
| 7019 | return; |
| 7020 | } |
| 7021 | |
| 7022 | counter++; |
| 7023 | if (data_in_interval) |
| 7024 | data_in_time_period = data_in_interval; |
| 7025 | |
| 7026 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7027 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7028 | if (data_in_time_period) { |
| 7029 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7030 | CDP_TXRX_PATH_STATS, |
| 7031 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7032 | wlan_hdd_display_netif_queue_history |
| 7033 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7034 | qdf_dp_trace_dump_stats(); |
| 7035 | } |
| 7036 | counter = 0; |
| 7037 | data_in_time_period = false; |
| 7038 | } |
| 7039 | } |
| 7040 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7041 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7042 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7043 | * @hdd_ctx - handle to hdd context |
| 7044 | * @tx_packets - transmit packet count |
| 7045 | * @rx_packets - receive packet count |
| 7046 | * |
| 7047 | * The function controls the bus bandwidth and dynamic control of |
| 7048 | * tcp delayed ack configuration |
| 7049 | * |
| 7050 | * Returns: None |
| 7051 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7052 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7053 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7054 | const uint64_t tx_packets, |
| 7055 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7056 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7057 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7058 | uint64_t temp_rx = 0; |
| 7059 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7060 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7061 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7062 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7063 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7064 | uint16_t index = 0; |
| 7065 | bool vote_level_change = false; |
| 7066 | bool rx_level_change = false; |
| 7067 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7068 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7069 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7070 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7071 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7072 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7073 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7074 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7075 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7076 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7077 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7078 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7079 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7080 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7081 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7082 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7083 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7084 | if (next_vote_level == PLD_BUS_WIDTH_LOW) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7085 | if (hdd_ctx->hbw_requested) { |
| 7086 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7087 | hdd_ctx->hbw_requested = false; |
| 7088 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7089 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7090 | hdd_warn("low bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7091 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7092 | if (!hdd_ctx->hbw_requested) { |
| 7093 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7094 | hdd_ctx->hbw_requested = true; |
| 7095 | } |
| 7096 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7097 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7098 | hdd_warn("high bandwidth set rx affinity fail"); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7099 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 7100 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7101 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7102 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 7103 | qdf_dp_trace_throttle_live_mode( |
| 7104 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 7105 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7106 | /* fine-tuning parameters for RX Flows */ |
| 7107 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 7108 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7110 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7111 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
| 7112 | hdd_disable_lro_for_low_tput(hdd_ctx, true); |
| 7113 | else |
| 7114 | hdd_disable_lro_for_low_tput(hdd_ctx, false); |
| 7115 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7116 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 7117 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7118 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7119 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7120 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7121 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7122 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7123 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7124 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7126 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7127 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7128 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7129 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7130 | next_rx_level, temp_rx); |
| 7131 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7132 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7133 | /* Send throughput indication only if it is enabled. |
| 7134 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7135 | * to default delayed ack. Note that this will disable the |
| 7136 | * dynamic delayed ack mechanism across the system |
| 7137 | */ |
| 7138 | if (hdd_ctx->config->enable_tcp_delack) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7139 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7140 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7141 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7142 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7143 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7144 | rx_tp_data.level = next_rx_level; |
| 7145 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7146 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7147 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7148 | } |
| 7149 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7150 | /* fine-tuning parameters for TX Flows */ |
| 7151 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7152 | hdd_ctx->prev_tx = tx_packets; |
| 7153 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7154 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7155 | else |
| 7156 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7157 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7158 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7159 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7160 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7161 | next_tx_level, temp_tx); |
| 7162 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7163 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7164 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7165 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7166 | &next_tx_level, |
| 7167 | sizeof(next_tx_level)); |
| 7168 | } |
| 7169 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7170 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7171 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7172 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7173 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7174 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7175 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7176 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7177 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7178 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7179 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7180 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7181 | |
| 7182 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7183 | } |
| 7184 | |
| 7185 | #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] | 7186 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7187 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7188 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7189 | bus_bw_work); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7190 | struct hdd_adapter *adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7191 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7192 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7193 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7194 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7195 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7196 | bool connected = false; |
| 7197 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7198 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7199 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7200 | return; |
| 7201 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7202 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7203 | goto restart_timer; |
| 7204 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7205 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7206 | /* |
| 7207 | * Validate magic so we don't end up accessing |
| 7208 | * an invalid adapter. |
| 7209 | */ |
| 7210 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7211 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7212 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7213 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7214 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7215 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7216 | != eConnectionState_Associated) { |
| 7217 | |
| 7218 | continue; |
| 7219 | } |
| 7220 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7221 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7222 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7223 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7224 | |
| 7225 | continue; |
| 7226 | } |
| 7227 | |
| 7228 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7229 | adapter->prev_tx_packets); |
| 7230 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7231 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7232 | |
| 7233 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7234 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7235 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7236 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7237 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7238 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7239 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7240 | &fwd_tx_packets, &fwd_rx_packets); |
| 7241 | if (ret == A_OK) { |
| 7242 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7243 | fwd_tx_packets, |
| 7244 | adapter->prev_fwd_tx_packets); |
| 7245 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7246 | fwd_tx_packets, |
| 7247 | adapter->prev_fwd_rx_packets); |
| 7248 | } |
| 7249 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7250 | |
| 7251 | total_rx += adapter->stats.rx_packets; |
| 7252 | total_tx += adapter->stats.tx_packets; |
| 7253 | |
| 7254 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7255 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7256 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7257 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7258 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7259 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7260 | connected = true; |
| 7261 | } |
| 7262 | |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7263 | /* add intra bss forwarded tx and rx packets */ |
| 7264 | tx_packets += fwd_tx_packets_diff; |
| 7265 | rx_packets += fwd_rx_packets_diff; |
| 7266 | |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 7267 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7268 | &ipa_rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7269 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7270 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7271 | |
| 7272 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7273 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7274 | return; |
| 7275 | } |
| 7276 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7277 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7278 | |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 7279 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
Sravan Kumar Kairam | 271fab2 | 2018-03-07 18:57:41 +0530 | [diff] [blame] | 7280 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7281 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7282 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7283 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7284 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7285 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7286 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7287 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7288 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7289 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7290 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7291 | /** |
| 7292 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7293 | * @arg: Argument of timer function |
| 7294 | * |
| 7295 | * Schedule a workqueue in this function where all the processing is done. |
| 7296 | * |
| 7297 | * Return: None. |
| 7298 | */ |
| 7299 | static void __hdd_bus_bw_cbk(void *arg) |
| 7300 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7301 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7302 | |
| 7303 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7304 | return; |
| 7305 | |
| 7306 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7307 | } |
| 7308 | |
| 7309 | /** |
| 7310 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7311 | * @arg: Argument of timer function |
| 7312 | * |
| 7313 | * Return: None. |
| 7314 | */ |
| 7315 | static void hdd_bus_bw_cbk(void *arg) |
| 7316 | { |
| 7317 | cds_ssr_protect(__func__); |
| 7318 | __hdd_bus_bw_cbk(arg); |
| 7319 | cds_ssr_unprotect(__func__); |
| 7320 | } |
| 7321 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7322 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7323 | { |
| 7324 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7325 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7326 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7327 | hdd_ctx->bus_bw_timer_running = false; |
| 7328 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7329 | qdf_timer_init(NULL, |
| 7330 | &hdd_ctx->bus_bw_timer, |
| 7331 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7332 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7333 | |
| 7334 | return 0; |
| 7335 | } |
| 7336 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7337 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7338 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7339 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7340 | hdd_reset_tcp_delack(hdd_ctx); |
| 7341 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7342 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7343 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7344 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7345 | hdd_ctx->bus_bw_timer_running = false; |
| 7346 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7347 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7348 | |
| 7349 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7350 | { |
| 7351 | if (hdd_ctx) |
| 7352 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7353 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7354 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | #endif |
| 7356 | |
| 7357 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7358 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7359 | * @hdd_ctx: hdd context |
| 7360 | * |
| 7361 | * Return: 0 for success or error code |
| 7362 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7363 | 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] | 7364 | { |
| 7365 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7366 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7367 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7368 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7369 | return -ENOMEM; |
| 7370 | } |
| 7371 | return 0; |
| 7372 | } |
| 7373 | |
| 7374 | /** |
| 7375 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7376 | * @hdd_ctx: hdd context |
| 7377 | * |
| 7378 | * Return: none |
| 7379 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7380 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7381 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7382 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7383 | return; |
| 7384 | |
| 7385 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7386 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7387 | } |
| 7388 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7389 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7390 | { |
| 7391 | switch (level) { |
| 7392 | /* initialize the wlan sub system */ |
| 7393 | case WLAN_SVC_TP_NONE: |
| 7394 | return "NONE"; |
| 7395 | case WLAN_SVC_TP_LOW: |
| 7396 | return "LOW"; |
| 7397 | case WLAN_SVC_TP_MEDIUM: |
| 7398 | return "MED"; |
| 7399 | case WLAN_SVC_TP_HIGH: |
| 7400 | return "HIGH"; |
| 7401 | default: |
| 7402 | return "INVAL"; |
| 7403 | } |
| 7404 | } |
| 7405 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7406 | |
| 7407 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7408 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7409 | * @hdd_ctx: hdd context |
| 7410 | * |
| 7411 | * Return: none |
| 7412 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7413 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7414 | { |
| 7415 | int i; |
| 7416 | |
| 7417 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7418 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7419 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7420 | 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] | 7421 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7422 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7423 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7424 | hdd_debug("Enable TCP DEL ACK: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7425 | hdd_ctx->config->enable_tcp_delack); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7426 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7427 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7428 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7429 | 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] | 7430 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7431 | #endif |
| 7432 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7433 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7434 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7435 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7436 | 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] | 7437 | |
| 7438 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7439 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7440 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7441 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7442 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7443 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7444 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7445 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7446 | hdd_ctx->hdd_txrx_hist[i]. |
| 7447 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7448 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7449 | hdd_ctx->hdd_txrx_hist[i]. |
| 7450 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7451 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7452 | hdd_ctx->hdd_txrx_hist[i]. |
| 7453 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7454 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7455 | } |
| 7456 | |
| 7457 | /** |
| 7458 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7459 | * @hdd_ctx: hdd context |
| 7460 | * |
| 7461 | * Return: none |
| 7462 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7463 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7464 | { |
| 7465 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7466 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7467 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7468 | } |
| 7469 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7470 | /* length of the netif queue log needed per adapter */ |
| 7471 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7472 | |
| 7473 | /** |
| 7474 | * |
| 7475 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7476 | * @hdd_ctx: hdd context |
| 7477 | * |
| 7478 | * Return: none |
| 7479 | */ |
| 7480 | static void |
| 7481 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7482 | { |
| 7483 | int adapter_num = 0; |
| 7484 | int i; |
| 7485 | int bytes_written; |
| 7486 | u32 tbytes; |
| 7487 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7488 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7489 | char *comb_log_str; |
| 7490 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7491 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7492 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7493 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7494 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7495 | if (!comb_log_str) { |
| 7496 | hdd_err("failed to alloc comb_log_str"); |
| 7497 | return; |
| 7498 | } |
| 7499 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7500 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7501 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7502 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7503 | curr_time = qdf_system_ticks(); |
| 7504 | total = curr_time - adapter->start_time; |
| 7505 | delta = curr_time - adapter->last_time; |
| 7506 | |
| 7507 | if (adapter->pause_map) { |
| 7508 | pause = adapter->total_pause_time + delta; |
| 7509 | unpause = adapter->total_unpause_time; |
| 7510 | } else { |
| 7511 | unpause = adapter->total_unpause_time + delta; |
| 7512 | pause = adapter->total_pause_time; |
| 7513 | } |
| 7514 | |
| 7515 | tbytes = 0; |
| 7516 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7517 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7518 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7519 | continue; |
| 7520 | tbytes += |
| 7521 | snprintf( |
| 7522 | &temp_str[tbytes], |
| 7523 | (tbytes >= sizeof(temp_str) ? |
| 7524 | 0 : sizeof(temp_str) - tbytes), |
| 7525 | "%d(%d,%d) ", |
| 7526 | i, |
| 7527 | adapter->queue_oper_stats[i]. |
| 7528 | pause_count, |
| 7529 | adapter->queue_oper_stats[i]. |
| 7530 | unpause_count); |
| 7531 | } |
| 7532 | if (tbytes >= sizeof(temp_str)) |
| 7533 | hdd_warn("log truncated"); |
| 7534 | |
| 7535 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7536 | bytes_written >= comb_log_str_size ? 0 : |
| 7537 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7538 | "[%d %d] (%d) %u/%ums %s|", |
| 7539 | adapter->session_id, adapter->device_mode, |
| 7540 | adapter->pause_map, |
| 7541 | qdf_system_ticks_to_msecs(pause), |
| 7542 | qdf_system_ticks_to_msecs(total), |
| 7543 | temp_str); |
| 7544 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7545 | adapter_num++; |
| 7546 | } |
| 7547 | |
| 7548 | /* using QDF_TRACE to avoid printing function name */ |
| 7549 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7550 | "STATS |%s", comb_log_str); |
| 7551 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7552 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7553 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7554 | |
| 7555 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7556 | } |
| 7557 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7559 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7560 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7561 | * |
| 7562 | * Return: none |
| 7563 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7564 | void |
| 7565 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7566 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7567 | { |
| 7568 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7569 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7570 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7571 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7572 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7573 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7574 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7575 | return; |
| 7576 | } |
| 7577 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7578 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7579 | hdd_debug("Netif queue operation statistics:"); |
| 7580 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7581 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7582 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7583 | curr_time = qdf_system_ticks(); |
| 7584 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7585 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7586 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7587 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7588 | unpause = adapter->total_unpause_time; |
| 7589 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7590 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7591 | pause = adapter->total_pause_time; |
| 7592 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7593 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7594 | qdf_system_ticks_to_msecs(total), |
| 7595 | qdf_system_ticks_to_msecs(pause), |
| 7596 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7597 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7598 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7599 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7600 | qdf_time_t pause_delta = 0; |
| 7601 | |
| 7602 | if (adapter->pause_map & (1 << i)) |
| 7603 | pause_delta = delta; |
| 7604 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7605 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7606 | hdd_debug("%s: %d: %d: %ums", |
| 7607 | hdd_reason_type_to_string(i), |
| 7608 | adapter->queue_oper_stats[i].pause_count, |
| 7609 | adapter->queue_oper_stats[i].unpause_count, |
| 7610 | qdf_system_ticks_to_msecs( |
| 7611 | adapter->queue_oper_stats[i].total_pause_time + |
| 7612 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7613 | } |
| 7614 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7615 | hdd_debug("Netif queue operation history:"); |
| 7616 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7617 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7618 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7619 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7620 | |
| 7621 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7622 | /* using hdd_log to avoid printing function name */ |
| 7623 | if (adapter->queue_oper_history[i].time == 0) |
| 7624 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7625 | hdd_debug("%d: %u: %s: %s: %x", |
| 7626 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7627 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7628 | hdd_action_type_to_string( |
| 7629 | adapter->queue_oper_history[i].netif_action), |
| 7630 | hdd_reason_type_to_string( |
| 7631 | adapter->queue_oper_history[i].netif_reason), |
| 7632 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7633 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7634 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7635 | } |
| 7636 | |
| 7637 | /** |
| 7638 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7639 | * @hdd_ctx: hdd context |
| 7640 | * |
| 7641 | * Return: none |
| 7642 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7643 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7644 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7645 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7646 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7647 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7648 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7649 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7650 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7651 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7652 | adapter->history_index = 0; |
| 7653 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7654 | adapter->total_pause_time = 0; |
| 7655 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7656 | } |
| 7657 | } |
| 7658 | |
| 7659 | /** |
| 7660 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7661 | * @halHandle: Hal handle |
| 7662 | * @pContext: Pointer to the context |
| 7663 | * @sessionId: Session ID |
| 7664 | * @scanId: Scan ID |
| 7665 | * @status: Status |
| 7666 | * |
| 7667 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7668 | * the scan results |
| 7669 | * |
| 7670 | * 11d scan is done during driver load and is a passive scan on all |
| 7671 | * channels supported by the device, 11d scans may find some APs on |
| 7672 | * frequencies which are forbidden to be used in the regulatory domain |
| 7673 | * the device is operating in. If these APs are notified to the supplicant |
| 7674 | * it may try to connect to these APs, thus flush out all the scan results |
| 7675 | * which are present in SME after 11d scan is done. |
| 7676 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7677 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7678 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7679 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7680 | uint8_t sessionId, uint32_t scanId, |
| 7681 | eCsrScanStatus status) |
| 7682 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7683 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7684 | |
| 7685 | sme_scan_flush_result(halHandle); |
| 7686 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7687 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7688 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7689 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7690 | } |
| 7691 | |
| 7692 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7693 | /** |
| 7694 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7695 | * @hdd_ctx: hdd global context |
| 7696 | * |
| 7697 | * Return: none |
| 7698 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7699 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7700 | { |
| 7701 | uint8_t i; |
| 7702 | |
| 7703 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7704 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7705 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7706 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7707 | } |
| 7708 | } |
| 7709 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7710 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7711 | { |
| 7712 | } |
| 7713 | #endif |
| 7714 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7715 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7716 | /** |
| 7717 | * 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] | 7718 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7719 | * @enable: enable or disable this behaviour |
| 7720 | * |
| 7721 | * Return: int |
| 7722 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7723 | 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] | 7724 | { |
| 7725 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7726 | struct wow_pulse_mode wow_pulse_set_info; |
| 7727 | QDF_STATUS status; |
| 7728 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7729 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7730 | |
| 7731 | if (false == phddctx->config->wow_pulse_support) |
| 7732 | return 0; |
| 7733 | |
| 7734 | /* prepare the request to send to SME */ |
| 7735 | if (enable == true) { |
| 7736 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7737 | wow_pulse_set_info.wow_pulse_pin = |
| 7738 | pcfg_ini->wow_pulse_pin; |
| 7739 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7740 | pcfg_ini->wow_pulse_interval_low; |
| 7741 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7742 | pcfg_ini->wow_pulse_interval_high; |
| 7743 | } else { |
| 7744 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7745 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7746 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7747 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7748 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7749 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7750 | wow_pulse_set_info.wow_pulse_enable, |
| 7751 | wow_pulse_set_info.wow_pulse_pin, |
| 7752 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7753 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7754 | |
| 7755 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7756 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7757 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7758 | return -EIO; |
| 7759 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7760 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7761 | return 0; |
| 7762 | } |
| 7763 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7764 | 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] | 7765 | { |
| 7766 | return 0; |
| 7767 | } |
| 7768 | #endif |
| 7769 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7770 | #ifdef WLAN_FEATURE_FASTPATH |
| 7771 | /** |
| 7772 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7773 | * @hdd_cfg: hdd config |
| 7774 | * @context: lower layer context |
| 7775 | * |
| 7776 | * Return: none |
| 7777 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7778 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7779 | void *context) |
| 7780 | { |
| 7781 | if (hdd_cfg->fastpath_enable) |
| 7782 | hif_enable_fastpath(context); |
| 7783 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7784 | #endif |
| 7785 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7786 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7787 | /** |
| 7788 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7789 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7790 | * @level: thermal level |
| 7791 | * |
| 7792 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7793 | * than 0, and restore the original data path when throttle level is 0 |
| 7794 | * |
| 7795 | * Return: none |
| 7796 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7797 | 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] | 7798 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7799 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7801 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7802 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7803 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7804 | else |
| 7805 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7806 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, hdd_ctx->mcc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7807 | } |
| 7808 | |
| 7809 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7810 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7811 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7812 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7813 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7814 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7815 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7816 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7817 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7818 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7819 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7820 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7821 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7822 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7823 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7824 | struct sir_pcl_list pcl; |
| 7825 | QDF_STATUS status; |
| 7826 | uint32_t i, j; |
| 7827 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7828 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7829 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7830 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7831 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7832 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7833 | if (!hdd_ctx) { |
| 7834 | hdd_err("invalid HDD context"); |
| 7835 | return INVALID_CHANNEL_ID; |
| 7836 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7837 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7838 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7839 | if (!hal_handle) { |
| 7840 | hdd_err("invalid HAL handle"); |
| 7841 | return INVALID_CHANNEL_ID; |
| 7842 | } |
| 7843 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7844 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7845 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7846 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7847 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7848 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7849 | hdd_err("Get PCL failed"); |
| 7850 | return INVALID_CHANNEL_ID; |
| 7851 | } |
| 7852 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7853 | /* |
| 7854 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7855 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7856 | * try to choose a safe channel from acs range. |
| 7857 | */ |
| 7858 | if (!pcl.pcl_len) |
| 7859 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7860 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7861 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7862 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7863 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7864 | |
| 7865 | /* PCL already takes unsafe channel into account */ |
| 7866 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7867 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7868 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7869 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7870 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7871 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7872 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7873 | return pcl.pcl_list[i]; |
| 7874 | } |
| 7875 | } |
| 7876 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7877 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7878 | |
| 7879 | /* Try for safe channel from all valid channel */ |
| 7880 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7881 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7882 | &pcl.pcl_len); |
| 7883 | if (ret) { |
| 7884 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7885 | return INVALID_CHANNEL_ID; |
| 7886 | } |
| 7887 | |
| 7888 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7889 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7890 | found = false; |
| 7891 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7892 | if (pcl.pcl_list[i] == |
| 7893 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7894 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7895 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7896 | break; |
| 7897 | } |
| 7898 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7899 | |
| 7900 | if (found) |
| 7901 | continue; |
| 7902 | |
| 7903 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7904 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7905 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7906 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7907 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7908 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7909 | } |
| 7910 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7911 | |
| 7912 | return INVALID_CHANNEL_ID; |
| 7913 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7914 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7915 | |
| 7916 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7917 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7918 | * @adapter: AP adapter |
| 7919 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7920 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7921 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 7922 | * Moves the SAP interface by invoking the function which |
| 7923 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7924 | * |
| 7925 | * Return: None |
| 7926 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7927 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 7928 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7929 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 7930 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7931 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7932 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7933 | |
| 7934 | if (!adapter) { |
| 7935 | hdd_err("invalid adapter"); |
| 7936 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7937 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7938 | |
| 7939 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 7940 | |
| 7941 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7942 | if (!hal_handle) { |
| 7943 | hdd_err("invalid HAL handle"); |
| 7944 | return; |
| 7945 | } |
| 7946 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7947 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7948 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7949 | hdd_ap_ctx->sap_config.channel = channel; |
| 7950 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 7951 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7952 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7953 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7954 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7955 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 7956 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 7957 | hdd_ap_ctx->sap_config.channel, |
| 7958 | hdd_ap_ctx->sap_config.sec_ch, |
| 7959 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7960 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7961 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7962 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 7963 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7964 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7965 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7966 | 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] | 7967 | { |
| 7968 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7969 | int status; |
| 7970 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7971 | |
| 7972 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 7973 | |
| 7974 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7975 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7976 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7977 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7978 | } |
| 7979 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7980 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7981 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7982 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7983 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7984 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 7985 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 7986 | hdd_err("failed to start external acs timer"); |
| 7987 | return -ENOSPC; |
| 7988 | } |
| 7989 | /* Update config to application */ |
| 7990 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 7991 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7992 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 7993 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 7994 | } |
| 7995 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7996 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 7997 | /** |
| 7998 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 7999 | * @hdd_ctx: hdd context pointer |
| 8000 | * |
| 8001 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8002 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8003 | * sap. User space on LTE coex indication restart driver. |
| 8004 | * |
| 8005 | * Return - none |
| 8006 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8007 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8008 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8009 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8010 | uint32_t i; |
| 8011 | bool found = false; |
| 8012 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8013 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8014 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8015 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8016 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8017 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8018 | adapter->device_mode, |
| 8019 | adapter->session.ap.sap_config. |
| 8020 | acs_cfg.acs_mode); |
| 8021 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8022 | } |
| 8023 | |
| 8024 | found = false; |
| 8025 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8026 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8027 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8028 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8029 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8030 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8031 | break; |
| 8032 | } |
| 8033 | } |
| 8034 | |
| 8035 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8036 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8037 | adapter->session.ap.operating_channel); |
| 8038 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8039 | } |
| 8040 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8041 | if (hdd_ctxt->config->vendor_acs_support && |
| 8042 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8043 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8044 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8045 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8046 | } else |
| 8047 | restart_chan = |
| 8048 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8049 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8050 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8051 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8052 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8053 | /* |
| 8054 | * SAP restart due to unsafe channel. While |
| 8055 | * restarting the SAP, make sure to clear |
| 8056 | * acs_channel, channel to reset to |
| 8057 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8058 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8059 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8060 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8061 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8062 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8063 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8064 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8065 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8066 | hdd_debug("driver to start sap: %d", |
| 8067 | hdd_ctxt->config->sap_internal_restart); |
| 8068 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8069 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8070 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8071 | else |
| 8072 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8073 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8074 | } |
| 8075 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8076 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8077 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8078 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8079 | * @hdd_ctx: HDD global context |
| 8080 | * |
| 8081 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8082 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8083 | * down to the lower layers. Then subscribe to subsequent channel |
| 8084 | * avoidance events. |
| 8085 | * |
| 8086 | * Return: None |
| 8087 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8088 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8089 | { |
| 8090 | uint16_t unsafe_channel_count; |
| 8091 | int index; |
| 8092 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8093 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8094 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8095 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8096 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8097 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8098 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8099 | hdd_ctx->unsafe_channel_count); |
| 8100 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8101 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8102 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8103 | |
| 8104 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8105 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8106 | hdd_ctx->unsafe_channel_list[index]); |
| 8107 | |
| 8108 | } |
| 8109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8110 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8111 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8112 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8113 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8114 | { |
| 8115 | uint8_t restart_chan; |
| 8116 | |
| 8117 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8118 | if (!restart_chan) { |
| 8119 | hdd_alert("fail to restart SAP"); |
| 8120 | return; |
| 8121 | } |
| 8122 | |
| 8123 | /* SAP restart due to unsafe channel. While restarting |
| 8124 | * the SAP, make sure to clear acs_channel, channel to |
| 8125 | * reset to 0. Otherwise these settings will override |
| 8126 | * the ACS while restart. |
| 8127 | */ |
| 8128 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8129 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8130 | |
| 8131 | hdd_debug("sending coex indication"); |
| 8132 | |
| 8133 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8134 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8135 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8136 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8137 | |
| 8138 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8139 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8140 | { |
| 8141 | uint32_t size; |
| 8142 | uint16_t *unsafe_list; |
| 8143 | uint16_t chan_count; |
| 8144 | |
| 8145 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8146 | return -EINVAL; |
| 8147 | |
| 8148 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8149 | NUM_CHANNELS); |
| 8150 | if (chan_count) { |
| 8151 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8152 | unsafe_list = qdf_mem_malloc(size); |
| 8153 | if (!unsafe_list) { |
| 8154 | hdd_err("No memory for unsafe chan list size%d", |
| 8155 | size); |
| 8156 | return -ENOMEM; |
| 8157 | } |
| 8158 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8159 | } else { |
| 8160 | unsafe_list = NULL; |
| 8161 | } |
| 8162 | |
| 8163 | *local_unsafe_list = unsafe_list; |
| 8164 | *local_unsafe_list_count = chan_count; |
| 8165 | |
| 8166 | return 0; |
| 8167 | } |
| 8168 | |
| 8169 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8170 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8171 | { |
| 8172 | int i, j; |
| 8173 | |
| 8174 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8175 | return true; |
| 8176 | if (local_unsafe_list_count == 0) |
| 8177 | return false; |
| 8178 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8179 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8180 | if (local_unsafe_list[i] == |
| 8181 | hdd_ctx->unsafe_channel_list[j]) |
| 8182 | break; |
| 8183 | if (j >= local_unsafe_list_count) |
| 8184 | break; |
| 8185 | } |
| 8186 | if (i >= local_unsafe_list_count) { |
| 8187 | hdd_info("unsafe chan list same"); |
| 8188 | return false; |
| 8189 | } |
| 8190 | |
| 8191 | return true; |
| 8192 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8193 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8194 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8195 | { |
| 8196 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8197 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8198 | 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] | 8199 | { |
| 8200 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8201 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8202 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8203 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8204 | { |
| 8205 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8206 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8207 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8208 | |
| 8209 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8210 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8211 | * user space |
| 8212 | * @frame_ind: Management frame data to be informed. |
| 8213 | * |
| 8214 | * This function is used to indicate management frame to |
| 8215 | * user space |
| 8216 | * |
| 8217 | * Return: None |
| 8218 | * |
| 8219 | */ |
| 8220 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8221 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8222 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8223 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8224 | int i; |
| 8225 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8226 | /* Get the HDD context.*/ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8227 | hdd_ctx = (struct hdd_context *)cds_get_context(QDF_MODULE_ID_HDD); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8228 | |
| 8229 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 8230 | return; |
| 8231 | |
| 8232 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8233 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8234 | adapter = |
| 8235 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8236 | if (adapter) |
| 8237 | break; |
| 8238 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8239 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8240 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8241 | if ((NULL != adapter) && |
| 8242 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8243 | __hdd_indicate_mgmt_frame(adapter, |
| 8244 | frame_ind->frame_len, |
| 8245 | frame_ind->frameBuf, |
| 8246 | frame_ind->frameType, |
| 8247 | frame_ind->rxChan, |
| 8248 | frame_ind->rxRssi); |
| 8249 | } |
| 8250 | } |
| 8251 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8252 | } else { |
| 8253 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8254 | frame_ind->sessionId); |
| 8255 | } |
| 8256 | |
| 8257 | if ((NULL != adapter) && |
| 8258 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8259 | __hdd_indicate_mgmt_frame(adapter, |
| 8260 | frame_ind->frame_len, |
| 8261 | frame_ind->frameBuf, |
| 8262 | frame_ind->frameType, |
| 8263 | frame_ind->rxChan, |
| 8264 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8265 | } |
| 8266 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8267 | void hdd_acs_response_timeout_handler(void *context) |
| 8268 | { |
| 8269 | struct hdd_external_acs_timer_context *timer_context = |
| 8270 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8271 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8272 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8273 | uint8_t reason; |
| 8274 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8275 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8276 | if (!timer_context) { |
| 8277 | hdd_err("invlaid timer context"); |
| 8278 | return; |
| 8279 | } |
| 8280 | adapter = timer_context->adapter; |
| 8281 | reason = timer_context->reason; |
| 8282 | |
| 8283 | |
| 8284 | if ((!adapter) || |
| 8285 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8286 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8287 | return; |
| 8288 | } |
| 8289 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8290 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8291 | return; |
| 8292 | |
| 8293 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8294 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8295 | else |
| 8296 | return; |
| 8297 | |
| 8298 | hdd_err("ACS timeout happened for %s reason %d", |
| 8299 | adapter->dev->name, reason); |
| 8300 | switch (reason) { |
| 8301 | /* SAP init case */ |
| 8302 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8303 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8304 | false); |
| 8305 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8306 | break; |
| 8307 | /* DFS detected on current channel */ |
| 8308 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8309 | wlan_sap_update_next_channel( |
| 8310 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8311 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8312 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8313 | break; |
| 8314 | /* LTE coex event on current channel */ |
| 8315 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8316 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8317 | break; |
| 8318 | default: |
| 8319 | hdd_info("invalid reason for timer invoke"); |
| 8320 | |
| 8321 | } |
| 8322 | } |
| 8323 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8324 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8325 | * hdd_override_ini_config - Override INI config |
| 8326 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8327 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8328 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8329 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8330 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8331 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8332 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8333 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8334 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8335 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8336 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8337 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8338 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8339 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8340 | if (0 == enable_11d || 1 == enable_11d) { |
| 8341 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8342 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8343 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8344 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8345 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8346 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8347 | hdd_debug("IpaConfig override to %d", |
| 8348 | hdd_ctx->config->IpaConfig); |
| 8349 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8350 | |
| 8351 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8352 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8353 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8354 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8355 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8356 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8357 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8358 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8359 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8360 | /** |
| 8361 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8362 | * @hdd_ctx - HDD context |
| 8363 | * |
| 8364 | * Set trace level for each module based on INI config. |
| 8365 | * |
| 8366 | * Return: None |
| 8367 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8368 | 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] | 8369 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8370 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8371 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8372 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8373 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8374 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8375 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8376 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8377 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8378 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8379 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8380 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8381 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8382 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8383 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8384 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8385 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8386 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8387 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8388 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8389 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8390 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8391 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8392 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8393 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8394 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8395 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8396 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8397 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8398 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8399 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8400 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8401 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8402 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8403 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8404 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8405 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8406 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8407 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8408 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8409 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8410 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8411 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8412 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8413 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8414 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8415 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8416 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8417 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8418 | } |
| 8419 | |
| 8420 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8421 | * hdd_context_init() - Initialize HDD context |
| 8422 | * @hdd_ctx: HDD context. |
| 8423 | * |
| 8424 | * Initialize HDD context along with all the feature specific contexts. |
| 8425 | * |
| 8426 | * return: 0 on success and errno on failure. |
| 8427 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8428 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8429 | { |
| 8430 | int ret; |
| 8431 | |
| 8432 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8433 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8434 | |
| 8435 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8436 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8437 | |
| 8438 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8439 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8440 | |
| 8441 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8442 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8443 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8444 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8445 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8446 | |
| 8447 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8448 | |
| 8449 | ret = hdd_scan_context_init(hdd_ctx); |
| 8450 | if (ret) |
| 8451 | goto list_destroy; |
| 8452 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8453 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8454 | |
| 8455 | ret = hdd_sap_context_init(hdd_ctx); |
| 8456 | if (ret) |
| 8457 | goto scan_destroy; |
| 8458 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8459 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8460 | |
| 8461 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8462 | |
| 8463 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8464 | hdd_ctx->config); |
| 8465 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8466 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8467 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8468 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8469 | "monitor_mode_wakelock"); |
| 8470 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8471 | return 0; |
| 8472 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8473 | sap_destroy: |
| 8474 | hdd_sap_context_destroy(hdd_ctx); |
| 8475 | |
| 8476 | scan_destroy: |
| 8477 | hdd_scan_context_destroy(hdd_ctx); |
| 8478 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8479 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8480 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8481 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8482 | return ret; |
| 8483 | } |
| 8484 | |
| 8485 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8486 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8487 | * @hdd_ctx: pointer to hdd context |
| 8488 | * |
| 8489 | * Return: status of initialization |
| 8490 | * 0 - success |
| 8491 | * negative value - failure |
| 8492 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8493 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8494 | { |
| 8495 | int ret; |
| 8496 | |
| 8497 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8498 | return 0; |
| 8499 | |
| 8500 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8501 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8502 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8503 | return -EINVAL; |
| 8504 | } |
| 8505 | |
| 8506 | /* parse ini string probe req oui */ |
| 8507 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8508 | if (ret) { |
| 8509 | hdd_err("parsing error: disable ie whitelisting"); |
| 8510 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8511 | } |
| 8512 | |
| 8513 | return ret; |
| 8514 | } |
| 8515 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8516 | /** |
| 8517 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8518 | * @priv: pointer to hdd context |
| 8519 | * |
| 8520 | * This function is invoked when the timer waiting for the interface change |
| 8521 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8522 | * |
| 8523 | * Return: void |
| 8524 | */ |
| 8525 | static void hdd_iface_change_callback(void *priv) |
| 8526 | { |
| 8527 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8528 | int ret; |
| 8529 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8530 | |
| 8531 | if (status) |
| 8532 | return; |
| 8533 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8534 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8535 | hdd_debug("Interface change timer expired close the modules!"); |
| 8536 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8537 | if (ret) |
| 8538 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8539 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8540 | } |
| 8541 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8542 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8543 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8544 | { |
| 8545 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8546 | wlan_logging_to_console); |
| 8547 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8548 | } |
| 8549 | #else |
| 8550 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8551 | { } |
| 8552 | #endif |
| 8553 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8554 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8555 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8556 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8557 | * |
| 8558 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8559 | * wiphy allocation and then context is initialized. |
| 8560 | * |
| 8561 | * Return: HDD context on success and ERR_PTR on failure |
| 8562 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8563 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8564 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8565 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8566 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8567 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8568 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8569 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8570 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8571 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8572 | if (hdd_ctx == NULL) { |
| 8573 | ret = -ENOMEM; |
| 8574 | goto err_out; |
| 8575 | } |
| 8576 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8577 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8578 | hdd_iface_change_callback, |
| 8579 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8580 | |
| 8581 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8582 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8583 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8584 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8585 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8586 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8587 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8588 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8589 | ret = -ENOMEM; |
| 8590 | goto err_free_hdd_context; |
| 8591 | } |
| 8592 | |
| 8593 | /* Read and parse the qcom_cfg.ini file */ |
| 8594 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8595 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8596 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8597 | WLAN_INI_FILE); |
| 8598 | ret = -EINVAL; |
| 8599 | goto err_free_config; |
| 8600 | } |
| 8601 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8602 | ie_whitelist_attrs_init(hdd_ctx); |
| 8603 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8604 | hdd_debug("setting timer multiplier: %u", |
| 8605 | hdd_ctx->config->timer_multiplier); |
| 8606 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8607 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8608 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8609 | if (hdd_ctx->config->fhostNSOffload) |
| 8610 | hdd_ctx->ns_offload_enable = true; |
| 8611 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8612 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8613 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8614 | hdd_override_ini_config(hdd_ctx); |
| 8615 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8616 | ret = hdd_context_init(hdd_ctx); |
| 8617 | |
| 8618 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8619 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8620 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8621 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8622 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8623 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8624 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8625 | goto skip_multicast_logging; |
| 8626 | |
| 8627 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8628 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8629 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8630 | if (ret) |
| 8631 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8632 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8633 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8634 | if (ret) |
| 8635 | goto err_deinit_txrx_histogram; |
| 8636 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8637 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8638 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8639 | skip_multicast_logging: |
| 8640 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8641 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8642 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8643 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8644 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8645 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8646 | return hdd_ctx; |
| 8647 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8648 | err_deinit_txrx_histogram: |
| 8649 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8650 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8651 | err_deinit_hdd_context: |
| 8652 | hdd_context_deinit(hdd_ctx); |
| 8653 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8654 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8655 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8656 | |
| 8657 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8658 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8659 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8660 | |
| 8661 | err_out: |
| 8662 | return ERR_PTR(ret); |
| 8663 | } |
| 8664 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8665 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8666 | /** |
| 8667 | * hdd_open_p2p_interface - Open P2P interface |
| 8668 | * @hdd_ctx: HDD context |
| 8669 | * @rtnl_held: True if RTNL lock held |
| 8670 | * |
| 8671 | * Open P2P interface during probe. This function called to open the P2P |
| 8672 | * interface at probe along with STA interface. |
| 8673 | * |
| 8674 | * Return: 0 on success and errno on failure |
| 8675 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8676 | 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] | 8677 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8678 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8679 | uint8_t *p2p_dev_addr; |
| 8680 | |
| 8681 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8682 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8683 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8684 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8685 | sizeof(tSirMacAddr)); |
| 8686 | |
| 8687 | /* |
| 8688 | * Generate the P2P Device Address. This consists of |
| 8689 | * the device's primary MAC address with the locally |
| 8690 | * administered bit set. |
| 8691 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8692 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8693 | } else { |
| 8694 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8695 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8696 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8697 | return -ENOSPC; |
| 8698 | } |
| 8699 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8700 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8701 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8702 | } |
| 8703 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8704 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8705 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8706 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8707 | |
| 8708 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8709 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8710 | return -ENOSPC; |
| 8711 | } |
| 8712 | |
| 8713 | return 0; |
| 8714 | } |
| 8715 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8716 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8717 | bool rtnl_held) |
| 8718 | { |
| 8719 | return 0; |
| 8720 | } |
| 8721 | #endif |
| 8722 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8723 | 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] | 8724 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8725 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8726 | int ret = 0; |
| 8727 | |
| 8728 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8729 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8730 | NET_NAME_UNKNOWN, rtnl_held); |
| 8731 | if (adapter == NULL) { |
| 8732 | hdd_err("Failed to open 802.11p interface"); |
| 8733 | ret = -ENOSPC; |
| 8734 | } |
| 8735 | |
| 8736 | return ret; |
| 8737 | } |
| 8738 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8739 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8740 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8741 | * @adapter: HDD adapter |
| 8742 | * |
| 8743 | * This function initializes the adapter for the station mode. |
| 8744 | * |
| 8745 | * Return: 0 on success or errno on failure. |
| 8746 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8747 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8748 | { |
| 8749 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8750 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8751 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8752 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8753 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8754 | hdd_err("session is already opened, %d", |
| 8755 | adapter->session_id); |
| 8756 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8757 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8758 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8759 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8760 | if (ret) { |
| 8761 | hdd_err("failed to create vdev: %d", ret); |
| 8762 | return ret; |
| 8763 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8764 | status = hdd_init_station_mode(adapter); |
| 8765 | |
| 8766 | if (QDF_STATUS_SUCCESS != status) { |
| 8767 | hdd_err("Error Initializing station mode: %d", status); |
| 8768 | return qdf_status_to_os_return(status); |
| 8769 | } |
| 8770 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8771 | hdd_register_tx_flow_control(adapter, |
| 8772 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8773 | hdd_tx_resume_cb, |
| 8774 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8775 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8776 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8777 | return 0; |
| 8778 | } |
| 8779 | |
| 8780 | /** |
| 8781 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8782 | * @adapter: HDD adapter |
| 8783 | * |
| 8784 | * This function initializes the adapter for the AP mode. |
| 8785 | * |
| 8786 | * Return: 0 on success errno on failure. |
| 8787 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8788 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8789 | { |
| 8790 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8791 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8792 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8793 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8794 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8795 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8796 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8797 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8798 | hdd_err("session is already opened, %d", |
| 8799 | adapter->session_id); |
| 8800 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8801 | } |
| 8802 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8803 | * In SSR case no need to create new sap context. |
| 8804 | * Otherwise create sap context first and then create |
| 8805 | * vdev as while creating the vdev, driver needs to |
| 8806 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8807 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8808 | if (adapter->session.ap.sap_context) { |
| 8809 | is_ssr = true; |
| 8810 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8811 | hdd_err("sap creation failed"); |
| 8812 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8813 | } |
| 8814 | |
| 8815 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8816 | adapter->session.ap.sap_context); |
| 8817 | if (ret) { |
| 8818 | hdd_err("failed to create vdev, status:%d", ret); |
| 8819 | hdd_sap_destroy_ctx(adapter); |
| 8820 | return ret; |
| 8821 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8822 | |
| 8823 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8824 | sme_cli_set_command(adapter->session_id, |
| 8825 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8826 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8827 | WMI_FW_AP_RTT_RESPR), |
| 8828 | VDEV_CMD); |
| 8829 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8830 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8831 | |
| 8832 | if (QDF_STATUS_SUCCESS != status) { |
| 8833 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8834 | return qdf_status_to_os_return(status); |
| 8835 | } |
| 8836 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8837 | hdd_register_tx_flow_control(adapter, |
| 8838 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8839 | hdd_softap_tx_resume_cb, |
| 8840 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8841 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8842 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8843 | return 0; |
| 8844 | } |
| 8845 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8846 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8847 | bool rtnl_held) |
| 8848 | { |
| 8849 | struct hdd_adapter *adapter; |
| 8850 | |
| 8851 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8852 | hdd_ctx->config->enableConcurrentSTA, |
| 8853 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8854 | NET_NAME_UNKNOWN, rtnl_held); |
| 8855 | |
| 8856 | if (!adapter) |
| 8857 | return -ENOSPC; |
| 8858 | |
| 8859 | return 0; |
| 8860 | } |
| 8861 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8862 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8863 | * hdd_open_interfaces - Open all required interfaces |
| 8864 | * hdd_ctx: HDD context |
| 8865 | * rtnl_held: True if RTNL lock is held |
| 8866 | * |
| 8867 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8868 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8869 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8870 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8871 | 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] | 8872 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8873 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8874 | int ret; |
| 8875 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8876 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8877 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8878 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8879 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8880 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8881 | |
| 8882 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8883 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8884 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8885 | if (!adapter) { |
| 8886 | hdd_err("open adapter failed"); |
| 8887 | return -ENOSPC; |
| 8888 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8889 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8890 | return 0; |
| 8891 | } |
| 8892 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8893 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8894 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8895 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8896 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8897 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8898 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8899 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8900 | |
| 8901 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8902 | return -ENOSPC; |
| 8903 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8904 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8905 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8906 | if (ret) |
| 8907 | hdd_err("Cannot create concurrent STA interface"); |
| 8908 | } |
| 8909 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8910 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 8911 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8912 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8913 | |
| 8914 | /* Open 802.11p Interface */ |
| 8915 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8916 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 8917 | if (ret) |
| 8918 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8919 | } |
| 8920 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8921 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8922 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8923 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8924 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8925 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8926 | } |
| 8927 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8928 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8929 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 8930 | /** |
| 8931 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 8932 | * @cds_cfg: CDS Configuration |
| 8933 | * @hdd_ctx: Pointer to hdd context |
| 8934 | * |
| 8935 | * Return: none |
| 8936 | */ |
| 8937 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8938 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8939 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8940 | { |
| 8941 | cds_cfg->tx_flow_stop_queue_th = |
| 8942 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 8943 | cds_cfg->tx_flow_start_queue_offset = |
| 8944 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 8945 | } |
| 8946 | #else |
| 8947 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 8948 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8949 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8950 | { |
| 8951 | } |
| 8952 | #endif |
| 8953 | |
| 8954 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 8955 | /** |
| 8956 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 8957 | * @cds_cfg: CDS Configuration |
| 8958 | * @hdd_ctx: Pointer to hdd context |
| 8959 | * |
| 8960 | * Return: none |
| 8961 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8962 | 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] | 8963 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8964 | { |
| 8965 | cds_cfg->ra_ratelimit_interval = |
| 8966 | hdd_ctx->config->RArateLimitInterval; |
| 8967 | cds_cfg->is_ra_ratelimit_enabled = |
| 8968 | hdd_ctx->config->IsRArateLimitEnabled; |
| 8969 | } |
| 8970 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 8971 | 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] | 8972 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8973 | { |
| 8974 | } |
| 8975 | #endif |
| 8976 | |
| 8977 | /** |
| 8978 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 8979 | * @hdd_ctx: HDD Context |
| 8980 | * |
| 8981 | * Return: 0 for Success, errno on failure |
| 8982 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8983 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 8984 | { |
| 8985 | struct cds_config_info *cds_cfg; |
| 8986 | |
| 8987 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 8988 | if (!cds_cfg) { |
| 8989 | hdd_err("failed to allocate cds config"); |
| 8990 | return -ENOMEM; |
| 8991 | } |
| 8992 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 8993 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 8994 | if (!hdd_ctx->config->nMaxPsPoll || |
| 8995 | !hdd_ctx->config->enablePowersaveOffload) { |
| 8996 | cds_cfg->powersave_offload_enabled = |
| 8997 | hdd_ctx->config->enablePowersaveOffload; |
| 8998 | } else { |
| 8999 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9000 | PS_QPOWER_NODEEPSLEEP) || |
| 9001 | (hdd_ctx->config->enablePowersaveOffload == |
| 9002 | PS_LEGACY_NODEEPSLEEP)) |
| 9003 | cds_cfg->powersave_offload_enabled = |
| 9004 | PS_LEGACY_NODEEPSLEEP; |
| 9005 | else |
| 9006 | cds_cfg->powersave_offload_enabled = |
| 9007 | PS_LEGACY_DEEPSLEEP; |
| 9008 | hdd_info("Qpower disabled in cds config, %d", |
| 9009 | cds_cfg->powersave_offload_enabled); |
| 9010 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9011 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9012 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9013 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9014 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9015 | |
| 9016 | /* |
| 9017 | * Copy the DFS Phyerr Filtering Offload status. |
| 9018 | * This parameter reflects the value of the |
| 9019 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9020 | */ |
| 9021 | cds_cfg->dfs_phyerr_filter_offload = |
| 9022 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9023 | if (hdd_ctx->config->ssdp) |
| 9024 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9025 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9026 | cds_cfg->force_target_assert_enabled = |
| 9027 | hdd_ctx->config->crash_inject_enabled; |
| 9028 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9029 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9030 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9031 | |
| 9032 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9033 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9034 | |
| 9035 | cds_cfg->ap_disable_intrabss_fwd = |
| 9036 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9037 | |
| 9038 | cds_cfg->dfs_pri_multiplier = |
| 9039 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9040 | cds_cfg->reorder_offload = |
| 9041 | hdd_ctx->config->reorderOffloadSupport; |
| 9042 | |
| 9043 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9044 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9045 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9046 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9047 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9048 | hdd_ctx->config->IpaUcTxBufCount); |
| 9049 | hdd_ctx->config->IpaUcTxBufCount = |
| 9050 | rounddown_pow_of_two( |
| 9051 | hdd_ctx->config->IpaUcTxBufCount); |
| 9052 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9053 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9054 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9055 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9056 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9057 | hdd_ctx->config->IpaUcTxBufCount); |
| 9058 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9059 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9060 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9061 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9062 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9063 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9064 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9065 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9066 | rounddown_pow_of_two( |
| 9067 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9068 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9069 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9070 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9071 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9072 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9073 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9074 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9075 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9076 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9077 | cds_cfg->uc_tx_partition_base = |
| 9078 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9079 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9080 | |
| 9081 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9082 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9083 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9084 | cds_cfg->ce_classify_enabled = |
| 9085 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 9086 | cds_cfg->bpf_packet_filter_enable = |
| 9087 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9088 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9089 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9090 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9091 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9092 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9093 | cds_cfg->max_msdus_per_rxinorderind = |
| 9094 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9095 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9096 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 9097 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 9098 | 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] | 9099 | cds_cfg->auto_power_save_fail_mode = |
| 9100 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9101 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9102 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9103 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9104 | cds_cfg->delay_before_vdev_stop = |
| 9105 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9106 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9107 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9108 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9109 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9110 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9111 | cds_init_ini_config(cds_cfg); |
| 9112 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9113 | |
| 9114 | exit: |
| 9115 | qdf_mem_free(cds_cfg); |
| 9116 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9117 | } |
| 9118 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9119 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9120 | * hdd_update_user_config() - API to update user configuration |
| 9121 | * parameters to obj mgr which are used by multiple components |
| 9122 | * @hdd_ctx: HDD Context |
| 9123 | * |
| 9124 | * Return: 0 for Success, errno on failure |
| 9125 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9126 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9127 | { |
| 9128 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9129 | |
| 9130 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9131 | if (user_config == NULL) { |
| 9132 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9133 | return -ENOMEM; |
| 9134 | } |
| 9135 | |
| 9136 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9137 | user_config->dual_mac_feature_disable = |
| 9138 | hdd_ctx->config->dual_mac_feature_disable; |
| 9139 | user_config->indoor_channel_support = |
| 9140 | hdd_ctx->config->indoor_channel_support; |
| 9141 | user_config->is_11d_support_enabled = |
| 9142 | hdd_ctx->config->Is11dSupportEnabled; |
| 9143 | user_config->is_11h_support_enabled = |
| 9144 | hdd_ctx->config->Is11hSupportEnabled; |
| 9145 | user_config->optimize_chan_avoid_event = |
| 9146 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9147 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9148 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9149 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9150 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9151 | |
| 9152 | qdf_mem_free(user_config); |
| 9153 | return 0; |
| 9154 | } |
| 9155 | |
| 9156 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9157 | * hdd_init_thermal_info - Initialize thermal level |
| 9158 | * @hdd_ctx: HDD context |
| 9159 | * |
| 9160 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9161 | * which would be called when a configured thermal threshold is hit. |
| 9162 | * |
| 9163 | * Return: 0 on success and errno on failure |
| 9164 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9165 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9166 | { |
| 9167 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9168 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9169 | |
| 9170 | thermal_param.smeThermalMgmtEnabled = |
| 9171 | hdd_ctx->config->thermalMitigationEnable; |
| 9172 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9173 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9174 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9175 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9176 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9177 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9178 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9179 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9180 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9181 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9182 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9183 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9184 | hdd_ctx->config->thermalTempMinLevel0; |
| 9185 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9186 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9187 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9188 | hdd_ctx->config->thermalTempMinLevel1; |
| 9189 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9190 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9191 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9192 | hdd_ctx->config->thermalTempMinLevel2; |
| 9193 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9194 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9195 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9196 | hdd_ctx->config->thermalTempMinLevel3; |
| 9197 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9198 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9199 | |
| 9200 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9201 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9202 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9203 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9204 | |
| 9205 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9206 | hdd_set_thermal_level_cb); |
| 9207 | |
| 9208 | return 0; |
| 9209 | |
| 9210 | } |
| 9211 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9212 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9213 | /** |
| 9214 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9215 | * |
| 9216 | * Hold RTNL lock |
| 9217 | * |
| 9218 | * Return: True if held and false otherwise |
| 9219 | */ |
| 9220 | static inline bool hdd_hold_rtnl_lock(void) |
| 9221 | { |
| 9222 | rtnl_lock(); |
| 9223 | return true; |
| 9224 | } |
| 9225 | |
| 9226 | /** |
| 9227 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9228 | * |
| 9229 | * Release RTNL lock |
| 9230 | * |
| 9231 | * Return: None |
| 9232 | */ |
| 9233 | static inline void hdd_release_rtnl_lock(void) |
| 9234 | { |
| 9235 | rtnl_unlock(); |
| 9236 | } |
| 9237 | #else |
| 9238 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9239 | static inline void hdd_release_rtnl_lock(void) { } |
| 9240 | #endif |
| 9241 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9242 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9243 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9244 | /* MAX iwpriv command support */ |
| 9245 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9246 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9247 | #define MAX_PKTLOG_SIZE 16 |
| 9248 | |
| 9249 | /** |
| 9250 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9251 | * @hdd_ctx: hdd context |
| 9252 | * @set_value2: pktlog buffer size value |
| 9253 | * |
| 9254 | * |
| 9255 | * Return: 0 for success or error. |
| 9256 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9257 | 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] | 9258 | { |
| 9259 | struct sir_wifi_start_log start_log = { 0 }; |
| 9260 | QDF_STATUS status; |
| 9261 | |
| 9262 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9263 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9264 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9265 | start_log.user_triggered = 1; |
| 9266 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9267 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9268 | |
| 9269 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9270 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9271 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9272 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9273 | return -EINVAL; |
| 9274 | } |
| 9275 | |
| 9276 | return 0; |
| 9277 | } |
| 9278 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9279 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9280 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9281 | * @hdd_ctx: hdd context |
| 9282 | * |
| 9283 | * Return: 0 for success or error. |
| 9284 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9285 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9286 | { |
| 9287 | struct sir_wifi_start_log start_log; |
| 9288 | QDF_STATUS status; |
| 9289 | |
| 9290 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9291 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9292 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9293 | start_log.user_triggered = 1; |
| 9294 | start_log.size = 0; |
| 9295 | start_log.is_pktlog_buff_clear = true; |
| 9296 | |
| 9297 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9298 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9299 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9300 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9301 | return -EINVAL; |
| 9302 | } |
| 9303 | |
| 9304 | return 0; |
| 9305 | } |
| 9306 | |
| 9307 | |
| 9308 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9309 | * hdd_process_pktlog_command() - process pktlog command |
| 9310 | * @hdd_ctx: hdd context |
| 9311 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9312 | * @set_value2: pktlog buffer size value |
| 9313 | * |
| 9314 | * This function process pktlog command. |
| 9315 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9316 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9317 | * |
| 9318 | * Return: 0 for success or error. |
| 9319 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9320 | 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] | 9321 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9322 | { |
| 9323 | int ret; |
| 9324 | bool enable; |
| 9325 | uint8_t user_triggered = 0; |
| 9326 | |
| 9327 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9328 | if (0 != ret) |
| 9329 | return ret; |
| 9330 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9331 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9332 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9333 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9334 | hdd_err("invalid pktlog value %d", set_value); |
| 9335 | return -EINVAL; |
| 9336 | } |
| 9337 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9338 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9339 | if (set_value2 <= 0) { |
| 9340 | hdd_err("invalid pktlog size %d", set_value2); |
| 9341 | return -EINVAL; |
| 9342 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9343 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9344 | return -EINVAL; |
| 9345 | } |
| 9346 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9347 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9348 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9349 | } |
| 9350 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9351 | /* |
| 9352 | * set_value = 0 then disable packetlog |
| 9353 | * set_value = 1 enable packetlog forcefully |
| 9354 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9355 | * enable packetlog with AUTO type. |
| 9356 | */ |
| 9357 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9358 | true : false; |
| 9359 | |
| 9360 | if (1 == set_value) { |
| 9361 | enable = true; |
| 9362 | user_triggered = 1; |
| 9363 | } |
| 9364 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9365 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9366 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9367 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9368 | /** |
| 9369 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9370 | * @hdd_ctx: HDD context |
| 9371 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9372 | * @user_triggered: triggered through iwpriv |
| 9373 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9374 | * |
| 9375 | * Return: 0 on success; error number otherwise |
| 9376 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9377 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9378 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9379 | { |
| 9380 | struct sir_wifi_start_log start_log; |
| 9381 | QDF_STATUS status; |
| 9382 | |
| 9383 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9384 | start_log.verbose_level = |
| 9385 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9386 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9387 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9388 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9389 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9390 | /* |
| 9391 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9392 | * commands. Host uses this flag to decide whether to send pktlog |
| 9393 | * disable command to fw without sending pktlog enable command |
| 9394 | * previously. For eg, If vendor sends pktlog disable command without |
| 9395 | * sending pktlog enable command, then host discards the packet |
| 9396 | * but for iwpriv command, host will send it to fw. |
| 9397 | */ |
| 9398 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9399 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9400 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9401 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9402 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9403 | return -EINVAL; |
| 9404 | } |
| 9405 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9406 | if (enable == true) |
| 9407 | hdd_ctx->is_pktlog_enabled = 1; |
| 9408 | else |
| 9409 | hdd_ctx->is_pktlog_enabled = 0; |
| 9410 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9411 | return 0; |
| 9412 | } |
| 9413 | #endif /* REMOVE_PKT_LOG */ |
| 9414 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9415 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9416 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9417 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9418 | * @dev: Device Pointer |
| 9419 | * @num: Number of Valid Mac address |
| 9420 | * |
| 9421 | * Return: Pointer to MAC address buffer |
| 9422 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9423 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9424 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9425 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9426 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9427 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9428 | |
| 9429 | /** |
| 9430 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9431 | * @hdd_ctx: HDD Context |
| 9432 | * @num: Number of random mac addresses needed |
| 9433 | * |
| 9434 | * Generate random addresses using bit manipulation on the base mac address |
| 9435 | * |
| 9436 | * Return: None |
| 9437 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9438 | 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] | 9439 | { |
| 9440 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9441 | uint32_t iter; |
| 9442 | struct hdd_config *ini = hdd_ctx->config; |
| 9443 | uint8_t *buf = NULL; |
| 9444 | uint8_t macaddr_b3, tmp_br3; |
| 9445 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9446 | |
| 9447 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9448 | buf = ini->intfMacAddr[iter].bytes; |
| 9449 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9450 | macaddr_b3 = buf[3]; |
| 9451 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9452 | INTF_MACADDR_MASK; |
| 9453 | macaddr_b3 += tmp_br3; |
| 9454 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9455 | buf[0] |= 0x02; |
| 9456 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9457 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9458 | } |
| 9459 | } |
| 9460 | |
| 9461 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9462 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9463 | * @hdd_ctx: HDD Context |
| 9464 | * |
| 9465 | * API to get mac addresses from platform driver and update the driver |
| 9466 | * structures and configure FW with the base mac address. |
| 9467 | * Return: int |
| 9468 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9469 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9470 | { |
| 9471 | uint32_t no_of_mac_addr, iter; |
| 9472 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9473 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9474 | uint8_t *addr, *buf; |
| 9475 | struct device *dev = hdd_ctx->parent_dev; |
| 9476 | struct hdd_config *ini = hdd_ctx->config; |
| 9477 | tSirMacAddr mac_addr; |
| 9478 | QDF_STATUS status; |
| 9479 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9480 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9481 | |
| 9482 | if (no_of_mac_addr == 0 || !addr) { |
| 9483 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9484 | return -EINVAL; |
| 9485 | } |
| 9486 | |
| 9487 | if (no_of_mac_addr > max_mac_addr) |
| 9488 | no_of_mac_addr = max_mac_addr; |
| 9489 | |
| 9490 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9491 | |
| 9492 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9493 | buf = ini->intfMacAddr[iter].bytes; |
| 9494 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9495 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9496 | } |
| 9497 | |
| 9498 | status = sme_set_custom_mac_addr(mac_addr); |
| 9499 | |
| 9500 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9501 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9502 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9503 | if (no_of_mac_addr < max_mac_addr) |
| 9504 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9505 | no_of_mac_addr); |
| 9506 | return 0; |
| 9507 | } |
| 9508 | |
| 9509 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9510 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9511 | * @hdd_ctx: HDD Context |
| 9512 | * |
| 9513 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9514 | * will generate its own MAC and update it to FW. |
| 9515 | * |
| 9516 | * Return: 0 for success |
| 9517 | * Non-zero error code for failure |
| 9518 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9519 | 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] | 9520 | { |
| 9521 | tSirMacAddr customMacAddr; |
| 9522 | QDF_STATUS status; |
| 9523 | |
| 9524 | qdf_mem_copy(&customMacAddr, |
| 9525 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9526 | sizeof(tSirMacAddr)); |
| 9527 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9528 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9529 | return -EAGAIN; |
| 9530 | return 0; |
| 9531 | } |
| 9532 | |
| 9533 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9534 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9535 | * @hdd_ctx: HDD Context |
| 9536 | * |
| 9537 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9538 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9539 | * wlan_mac.bin to update HW MAC addresses. |
| 9540 | * |
| 9541 | * Return: None |
| 9542 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9543 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9544 | { |
| 9545 | QDF_STATUS status; |
| 9546 | int ret; |
| 9547 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9548 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9549 | if (ret == 0) |
| 9550 | return; |
| 9551 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9552 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9553 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9554 | |
| 9555 | status = hdd_update_mac_config(hdd_ctx); |
| 9556 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9557 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9558 | return; |
| 9559 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9560 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9561 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9562 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9563 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9564 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9565 | if (ret != 0) { |
| 9566 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9567 | QDF_ASSERT(ret); |
| 9568 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9569 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9570 | } |
| 9571 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9572 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9573 | { |
| 9574 | int vdev_id = 0; |
| 9575 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9576 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9577 | int vpdev = PDEV_CMD; |
| 9578 | int ret; |
| 9579 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9580 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9581 | if (ret) |
| 9582 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9583 | |
| 9584 | return ret; |
| 9585 | } |
| 9586 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9587 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9588 | { |
| 9589 | int vdev_id = 0; |
| 9590 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9591 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9592 | int vpdev = PDEV_CMD; |
| 9593 | int ret; |
| 9594 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9595 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9596 | if (ret) |
| 9597 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9598 | ret); |
| 9599 | |
| 9600 | return ret; |
| 9601 | } |
| 9602 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9603 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9604 | { |
| 9605 | int vdev_id = 0; |
| 9606 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9607 | int value = hdd_ctx->config->ani_enabled; |
| 9608 | int vpdev = PDEV_CMD; |
| 9609 | int ret; |
| 9610 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9611 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9612 | if (ret) |
| 9613 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9614 | |
| 9615 | return ret; |
| 9616 | } |
| 9617 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9618 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9619 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9620 | * @hdd_ctx: HDD context |
| 9621 | * |
| 9622 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9623 | * |
| 9624 | * Return: 0 on success and errno on failure. |
| 9625 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9626 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9627 | { |
| 9628 | int ret; |
| 9629 | QDF_STATUS status; |
| 9630 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9631 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9632 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9633 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9634 | /* |
| 9635 | * Set 802.11p config |
| 9636 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9637 | * parameter is set in CSR when we init the channel list. This should |
| 9638 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9639 | * domain. |
| 9640 | */ |
| 9641 | hdd_set_dot11p_config(hdd_ctx); |
| 9642 | |
| 9643 | /* |
| 9644 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9645 | * The cfg download must occur before we update the SME config |
| 9646 | * since the SME config operation must access the cfg database |
| 9647 | */ |
| 9648 | status = hdd_set_sme_config(hdd_ctx); |
| 9649 | |
| 9650 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9651 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9652 | ret = qdf_status_to_os_return(status); |
| 9653 | goto out; |
| 9654 | } |
| 9655 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9656 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9657 | if (QDF_STATUS_SUCCESS != status) { |
| 9658 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9659 | ret = qdf_status_to_os_return(status); |
| 9660 | goto out; |
| 9661 | } |
| 9662 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9663 | 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] | 9664 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9665 | PDEV_CMD); |
| 9666 | if (0 != ret) { |
| 9667 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9668 | goto out; |
| 9669 | } |
| 9670 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9671 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9672 | if (ret) |
| 9673 | goto out; |
| 9674 | |
| 9675 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9676 | if (ret) |
| 9677 | goto out; |
| 9678 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9679 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9680 | if (ret) |
| 9681 | goto out; |
| 9682 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9683 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9684 | hdd_ctx->config->arp_ac_category, |
| 9685 | PDEV_CMD); |
| 9686 | if (0 != ret) { |
| 9687 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9688 | hdd_ctx->config->arp_ac_category, ret); |
| 9689 | goto out; |
| 9690 | } |
| 9691 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9692 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9693 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9694 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9695 | ret = qdf_status_to_os_return(status); |
| 9696 | goto out; |
| 9697 | } |
| 9698 | |
| 9699 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9700 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9701 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9702 | ret = -EINVAL; |
| 9703 | goto out; |
| 9704 | } |
| 9705 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9706 | /* |
| 9707 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9708 | * Remove this once self sta is added as part of session open. |
| 9709 | */ |
| 9710 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9711 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9712 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9713 | |
| 9714 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9715 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9716 | hal_status, hal_status); |
| 9717 | ret = -EINVAL; |
| 9718 | goto out; |
| 9719 | } |
| 9720 | |
| 9721 | hdd_init_channel_avoidance(hdd_ctx); |
| 9722 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9723 | /* update enable sap mandatory chan list */ |
| 9724 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9725 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9726 | out: |
| 9727 | return ret; |
| 9728 | } |
| 9729 | |
| 9730 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9731 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9732 | * @context_ptr - hdd context pointer |
| 9733 | * @event_ptr - event structure pointer |
| 9734 | * |
| 9735 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9736 | * event back to supplicant to notify the stop reason. |
| 9737 | * |
| 9738 | * Return: None |
| 9739 | */ |
| 9740 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9741 | void *event_ptr) |
| 9742 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9743 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9744 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9745 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9746 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9747 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9748 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9749 | |
| 9750 | if (hdd_ctx == NULL) { |
| 9751 | hdd_err("Invalid HDD context pointer"); |
| 9752 | return; |
| 9753 | } |
| 9754 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9755 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9756 | if (!adapter) { |
| 9757 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9758 | evt->vdev_id); |
| 9759 | return; |
| 9760 | } |
| 9761 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9762 | vendor_event = |
| 9763 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9764 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9765 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9766 | GFP_KERNEL); |
| 9767 | |
| 9768 | if (!vendor_event) { |
| 9769 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9770 | return; |
| 9771 | } |
| 9772 | |
| 9773 | if (nla_put_u32(vendor_event, |
| 9774 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9775 | evt->reason_code)) { |
| 9776 | hdd_err("nla put failed"); |
| 9777 | kfree_skb(vendor_event); |
| 9778 | return; |
| 9779 | } |
| 9780 | |
| 9781 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9782 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9783 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9784 | } |
| 9785 | |
| 9786 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9787 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9788 | * @hdd_ctx: HDD context |
| 9789 | * |
| 9790 | * This function sends the adaptive dwell time config configuration to the |
| 9791 | * firmware via WMA |
| 9792 | * |
| 9793 | * Return: 0 - success, < 0 - failure |
| 9794 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9795 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9796 | { |
| 9797 | QDF_STATUS status; |
| 9798 | struct adaptive_dwelltime_params dwelltime_params; |
| 9799 | |
| 9800 | dwelltime_params.is_enabled = |
| 9801 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9802 | dwelltime_params.dwelltime_mode = |
| 9803 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9804 | dwelltime_params.lpf_weight = |
| 9805 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9806 | dwelltime_params.passive_mon_intval = |
| 9807 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9808 | dwelltime_params.wifi_act_threshold = |
| 9809 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9810 | |
| 9811 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9812 | &dwelltime_params); |
| 9813 | |
| 9814 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9815 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9816 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9817 | return -EAGAIN; |
| 9818 | } |
| 9819 | return 0; |
| 9820 | } |
| 9821 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9822 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9823 | { |
| 9824 | QDF_STATUS status; |
| 9825 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9826 | uint32_t i = 0; |
| 9827 | uint8_t count = 0, numentries = 0; |
| 9828 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9829 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9830 | |
| 9831 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 9832 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 9833 | DISABLE_DBS_CXN_AND_SCAN) || |
| 9834 | (hdd_ctx->config->dual_mac_feature_disable == |
| 9835 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9836 | return -EINVAL; |
| 9837 | |
| 9838 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9839 | dbs_scan_config, &numentries, |
| 9840 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9841 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9842 | |
| 9843 | hdd_info("numentries %hu", numentries); |
| 9844 | if (!numentries) { |
| 9845 | hdd_info("Donot send scan_selection_config"); |
| 9846 | return 0; |
| 9847 | } |
| 9848 | |
| 9849 | /* hdd_set_fw_log_params */ |
| 9850 | dbs_scan_params.num_clients = 0; |
| 9851 | while (count < (numentries - 2)) { |
| 9852 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9853 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9854 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9855 | dbs_scan_config[count + 2]; |
| 9856 | dbs_scan_params.num_clients++; |
| 9857 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9858 | dbs_scan_params.module_id[i], |
| 9859 | dbs_scan_params.num_dbs_scans[i], |
| 9860 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9861 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9862 | i++; |
| 9863 | } |
| 9864 | |
| 9865 | dbs_scan_params.pdev_id = 0; |
| 9866 | |
| 9867 | hdd_debug("clients:%d pdev:%d", |
| 9868 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9869 | |
| 9870 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9871 | &dbs_scan_params); |
| 9872 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9873 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9874 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9875 | return -EAGAIN; |
| 9876 | } |
| 9877 | return 0; |
| 9878 | } |
| 9879 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9880 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9881 | /** |
| 9882 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9883 | * @hdd_ctx: HDD context |
| 9884 | * |
| 9885 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9886 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9887 | * |
| 9888 | * Return: 0 on success and errno on failure. |
| 9889 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9890 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9891 | { |
| 9892 | QDF_STATUS status; |
| 9893 | |
| 9894 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9895 | return 0; |
| 9896 | |
| 9897 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9898 | wlan_hdd_auto_shutdown_cb); |
| 9899 | if (status != QDF_STATUS_SUCCESS) |
| 9900 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9901 | status); |
| 9902 | |
| 9903 | return qdf_status_to_os_return(status); |
| 9904 | } |
| 9905 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9906 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9907 | { |
| 9908 | return 0; |
| 9909 | } |
| 9910 | #endif |
| 9911 | |
| 9912 | /** |
| 9913 | * hdd_features_init() - Init features |
| 9914 | * @hdd_ctx: HDD context |
| 9915 | * @adapter: Primary adapter context |
| 9916 | * |
| 9917 | * Initialize features and their feature context after WLAN firmware is up. |
| 9918 | * |
| 9919 | * Return: 0 on success and errno on failure. |
| 9920 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9921 | 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] | 9922 | { |
| 9923 | tSirTxPowerLimit hddtxlimit; |
| 9924 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9925 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9926 | int ret; |
| 9927 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9928 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9929 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9930 | /* FW capabilities received, Set the Dot11 mode */ |
| 9931 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 9932 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 9933 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9934 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9935 | |
| 9936 | if (hdd_ctx->config->fIsImpsEnabled) |
| 9937 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 9938 | else |
| 9939 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 9940 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 9941 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 9942 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 9943 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 9944 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9945 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9946 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 9947 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 9948 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 9949 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 9950 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9951 | if (hdd_lro_init(hdd_ctx)) |
| 9952 | hdd_err("Unable to initialize LRO in fw"); |
| 9953 | |
| 9954 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 9955 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 9956 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9957 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 9958 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 9959 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9960 | ret = hdd_init_thermal_info(hdd_ctx); |
| 9961 | if (ret) { |
| 9962 | hdd_err("Error while initializing thermal information"); |
| 9963 | goto deregister_frames; |
| 9964 | } |
| 9965 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9966 | /** |
| 9967 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 9968 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 9969 | * device up. |
| 9970 | */ |
| 9971 | if (cds_is_driver_recovering()) { |
| 9972 | if (hdd_ctx->is_pktlog_enabled) |
| 9973 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 9974 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 9975 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9976 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 9977 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 9978 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 9979 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9980 | hdd_err("Error setting txlimit in sme: %d", status); |
| 9981 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 9982 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9983 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9984 | ret = hdd_register_cb(hdd_ctx); |
| 9985 | if (ret) { |
| 9986 | hdd_err("Failed to register HDD callbacks!"); |
| 9987 | goto deregister_frames; |
| 9988 | } |
| 9989 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 9990 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 9991 | status = sme_enable_disable_chanavoidind_event( |
| 9992 | hdd_ctx->hHal, 0); |
| 9993 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9994 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 9995 | goto deregister_cb; |
| 9996 | } |
| 9997 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9998 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 9999 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10000 | band_pref_params.rssi_boost_threshold_5g = |
| 10001 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10002 | band_pref_params.rssi_boost_factor_5g = |
| 10003 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10004 | band_pref_params.max_rssi_boost_5g = |
| 10005 | hdd_ctx->config->max_rssi_boost_5g; |
| 10006 | band_pref_params.rssi_penalize_threshold_5g = |
| 10007 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10008 | band_pref_params.rssi_penalize_factor_5g = |
| 10009 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10010 | band_pref_params.max_rssi_penalize_5g = |
| 10011 | hdd_ctx->config->max_rssi_penalize_5g; |
| 10012 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 10013 | } |
| 10014 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10015 | /* register P2P Listen Offload event callback */ |
| 10016 | if (wma_is_p2p_lo_capable()) |
| 10017 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 10018 | wlan_hdd_p2p_lo_event_callback); |
| 10019 | |
| 10020 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10021 | |
| 10022 | if (ret) |
| 10023 | goto deregister_cb; |
| 10024 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10025 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10026 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10027 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10028 | return 0; |
| 10029 | |
| 10030 | deregister_cb: |
| 10031 | hdd_deregister_cb(hdd_ctx); |
| 10032 | deregister_frames: |
| 10033 | wlan_hdd_cfg80211_deregister_frames(adapter); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10034 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10035 | } |
| 10036 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10037 | /** |
| 10038 | * hdd_features_deinit() - Deinit features |
| 10039 | * @hdd_ctx: HDD context |
| 10040 | * |
| 10041 | * De-Initialize features and their feature context. |
| 10042 | * |
| 10043 | * Return: none. |
| 10044 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10045 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10046 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10047 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10048 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10049 | } |
| 10050 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10051 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10052 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10053 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10054 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10055 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10056 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10057 | 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] | 10058 | { |
| 10059 | QDF_STATUS status; |
| 10060 | |
| 10061 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10062 | wlan_cfg80211_inform_bss_frame, |
| 10063 | SCAN_CB_TYPE_INFORM_BCN); |
| 10064 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10065 | hdd_err("failed with status code %08d [x%08x]", |
| 10066 | status, status); |
| 10067 | return status; |
| 10068 | } |
| 10069 | |
| 10070 | return QDF_STATUS_SUCCESS; |
| 10071 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10072 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10073 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10074 | * hdd_configure_cds() - Configure cds modules |
| 10075 | * @hdd_ctx: HDD context |
| 10076 | * @adapter: Primary adapter context |
| 10077 | * |
| 10078 | * Enable Cds modules after WLAN firmware is up. |
| 10079 | * |
| 10080 | * Return: 0 on success and errno on failure. |
| 10081 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10082 | 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] | 10083 | { |
| 10084 | int ret; |
| 10085 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10086 | int set_value; |
| 10087 | uint32_t num_abg_tx_chains = 0; |
| 10088 | uint32_t num_11b_tx_chains = 0; |
| 10089 | uint32_t num_11ag_tx_chains = 0; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10090 | struct policy_mgr_dp_cbacks dp_cbs; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10091 | |
| 10092 | if (hdd_ctx->config->sifs_burst_duration) { |
| 10093 | set_value = (SIFS_BURST_DUR_MULTIPLIER) * |
| 10094 | hdd_ctx->config->sifs_burst_duration; |
| 10095 | |
| 10096 | if ((set_value > 0) && (set_value <= SIFS_BURST_DUR_MAX)) |
| 10097 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_BURST_DUR, |
| 10098 | set_value, PDEV_CMD); |
| 10099 | } |
| 10100 | |
| 10101 | if (hdd_ctx->config->is_force_1x1) |
| 10102 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10103 | 1, PDEV_CMD); |
| 10104 | /* set chip power save failure detected callback */ |
| 10105 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 10106 | hdd_chip_pwr_save_fail_detected_cb); |
| 10107 | |
| 10108 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10109 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10110 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10111 | set_value, PDEV_CMD); |
| 10112 | } |
| 10113 | |
| 10114 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10115 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10116 | sme_cli_set_command(0, |
| 10117 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10118 | set_value, PDEV_CMD); |
| 10119 | } |
| 10120 | |
| 10121 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10122 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10123 | sme_cli_set_command(0, |
| 10124 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10125 | set_value, PDEV_CMD); |
| 10126 | } |
| 10127 | |
| 10128 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10129 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10130 | if (!hdd_ctx->config->enable2x2) { |
| 10131 | if (num_11b_tx_chains > 1) |
| 10132 | num_11b_tx_chains = 1; |
| 10133 | if (num_11ag_tx_chains > 1) |
| 10134 | num_11ag_tx_chains = 1; |
| 10135 | } |
| 10136 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10137 | num_11b_tx_chains); |
| 10138 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10139 | num_11ag_tx_chains); |
| 10140 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10141 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10142 | |
| 10143 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10144 | if (ret) { |
| 10145 | hdd_err("Failed to pre-configure cds"); |
| 10146 | goto out; |
| 10147 | } |
| 10148 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10149 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10150 | * IPA module before configuring them to FW. Sequence required as crash |
| 10151 | * observed otherwise. |
| 10152 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10153 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10154 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10155 | hdd_err("Failed to setup pipes"); |
| 10156 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10157 | } |
| 10158 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10159 | /* |
| 10160 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10161 | * else |
| 10162 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10163 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10164 | |
| 10165 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10166 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10167 | goto out; |
| 10168 | } |
| 10169 | |
| 10170 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10171 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10172 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10173 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10174 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10175 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10176 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10177 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10178 | goto cds_disable; |
| 10179 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10180 | |
| 10181 | ret = hdd_features_init(hdd_ctx, adapter); |
| 10182 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10183 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10184 | |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10185 | dp_cbs.hdd_disable_lro_in_concurrency = hdd_disable_lro_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10186 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10187 | dp_cbs.hdd_ipa_set_mcc_mode_cb = hdd_ipa_set_mcc_mode; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10188 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10189 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10190 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10191 | goto cds_disable; |
| 10192 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10193 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10194 | wlan_hdd_send_mode_change_event); |
| 10195 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10196 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10197 | goto cds_disable; |
| 10198 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10199 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10200 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10201 | hdd_debug("enhance green ap is not enabled"); |
| 10202 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10203 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10204 | hdd_debug("Failed to set wow pulse"); |
| 10205 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10206 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10207 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10208 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10209 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10210 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10211 | |
| 10212 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10213 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10214 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10215 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10216 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10217 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10218 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10219 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10220 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10221 | out: |
| 10222 | return -EINVAL; |
| 10223 | } |
| 10224 | |
| 10225 | /** |
| 10226 | * hdd_deconfigure_cds() -De-Configure cds |
| 10227 | * @hdd_ctx: HDD context |
| 10228 | * |
| 10229 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10230 | * |
| 10231 | * Return: 0 on success and errno on failure. |
| 10232 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10233 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10234 | { |
| 10235 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10236 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10237 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10238 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10239 | |
| 10240 | /* De-init features */ |
| 10241 | hdd_features_deinit(hdd_ctx); |
| 10242 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10243 | /* De-register the SME callbacks */ |
| 10244 | hdd_deregister_cb(hdd_ctx); |
| 10245 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10246 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10247 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10248 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10249 | } |
| 10250 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10251 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10252 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10253 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10254 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10255 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10256 | } |
| 10257 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10258 | if (ucfg_ipa_uc_ol_deinit(hdd_ctx->hdd_pdev) != QDF_STATUS_SUCCESS) { |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 10259 | hdd_err("Failed to disconnect pipes"); |
| 10260 | ret = -EINVAL; |
| 10261 | } |
| 10262 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10263 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10264 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10265 | } |
| 10266 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10267 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10268 | static void hdd_deregister_policy_manager_callback( |
| 10269 | struct wlan_objmgr_psoc *psoc) |
| 10270 | { |
| 10271 | if (QDF_STATUS_SUCCESS != |
| 10272 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10273 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10274 | } |
| 10275 | } |
| 10276 | #else |
| 10277 | static void hdd_deregister_policy_manager_callback( |
| 10278 | struct wlan_objmgr_psoc *psoc) |
| 10279 | { |
| 10280 | } |
| 10281 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10282 | |
| 10283 | /** |
| 10284 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10285 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10286 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10287 | * |
| 10288 | * This function maintains the driver state machine it will be invoked from |
| 10289 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10290 | * shall perform the stopping/closing of the modules. |
| 10291 | * |
| 10292 | * Return: 0 for success; non-zero for failure |
| 10293 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10294 | 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] | 10295 | { |
| 10296 | void *hif_ctx; |
| 10297 | qdf_device_t qdf_ctx; |
| 10298 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10299 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10300 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10301 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10302 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10303 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10304 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10305 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10306 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10307 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10308 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10309 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10310 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10311 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10312 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10313 | if (!qdf_ctx) { |
| 10314 | hdd_err("QDF device context NULL"); |
| 10315 | return -EINVAL; |
| 10316 | } |
| 10317 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10318 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10319 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10320 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10321 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10322 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10323 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10324 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10325 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10326 | |
| 10327 | cds_print_external_threads(); |
| 10328 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10329 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10330 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10331 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10332 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10333 | hdd_prevent_suspend_timeout( |
| 10334 | hdd_ctx->config->iface_change_wait_time, |
| 10335 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10336 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10337 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10338 | return 0; |
| 10339 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10340 | } |
| 10341 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10342 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10343 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10344 | /* free user wowl patterns */ |
| 10345 | hdd_free_user_wowl_ptrns(); |
| 10346 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10347 | switch (hdd_ctx->driver_status) { |
| 10348 | case DRIVER_MODULES_UNINITIALIZED: |
| 10349 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10350 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10351 | case DRIVER_MODULES_CLOSED: |
| 10352 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10353 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10354 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10355 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10356 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10357 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10358 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10359 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10360 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10361 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10362 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10363 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10364 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10365 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10366 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10367 | |
| 10368 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10369 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10370 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10371 | break; |
| 10372 | default: |
| 10373 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10374 | hdd_ctx->driver_status); |
| 10375 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10376 | ret = -EINVAL; |
| 10377 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10378 | } |
| 10379 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10380 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10381 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10382 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10383 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10384 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10385 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10386 | qdf_status); |
| 10387 | ret = -EINVAL; |
| 10388 | QDF_ASSERT(0); |
| 10389 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10390 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10391 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10392 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10393 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10394 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10395 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10396 | ret = -EINVAL; |
| 10397 | QDF_ASSERT(0); |
| 10398 | } |
| 10399 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10400 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10401 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10402 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10403 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10404 | QDF_ASSERT(0); |
| 10405 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10406 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10407 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10408 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10409 | if (ret) { |
| 10410 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10411 | QDF_ASSERT(0); |
| 10412 | } |
| 10413 | |
| 10414 | /* |
| 10415 | * Reset total mac phy during module stop such that during |
| 10416 | * next module start same psoc is used to populate new service |
| 10417 | * ready data |
| 10418 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10419 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10420 | if (tgt_hdl) |
| 10421 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10422 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10423 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10424 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10425 | if (!hif_ctx) { |
| 10426 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10427 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10428 | } |
| 10429 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10430 | if (hdd_ctx->target_hw_name) { |
| 10431 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10432 | hdd_ctx->target_hw_name = NULL; |
| 10433 | } |
| 10434 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10435 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10436 | |
| 10437 | ol_cds_free(); |
| 10438 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10439 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10440 | ret = pld_power_off(qdf_ctx->dev); |
| 10441 | if (ret) |
| 10442 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10443 | ret); |
| 10444 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10445 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10446 | /* many adapter resources are not freed by design in SSR case */ |
| 10447 | if (!is_recovery_stop) |
| 10448 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10449 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10450 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10451 | /* Once the firmware sequence is completed reset this flag */ |
| 10452 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10453 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10454 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10455 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10456 | done: |
| 10457 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10458 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10459 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10460 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10461 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10462 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10463 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10464 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10465 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10466 | } |
| 10467 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10468 | |
| 10469 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10470 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10471 | * @buf: buffer pointer |
| 10472 | * @size: size of buffer to be filled |
| 10473 | * |
| 10474 | * This function is used to dump state information of hdd layer |
| 10475 | * |
| 10476 | * Return: None |
| 10477 | */ |
| 10478 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10479 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10480 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10481 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10482 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10483 | uint16_t len = 0; |
| 10484 | char *buf = *buf_ptr; |
| 10485 | |
| 10486 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10487 | if (!hdd_ctx) { |
| 10488 | hdd_err("Failed to get hdd context "); |
| 10489 | return; |
| 10490 | } |
| 10491 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10492 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10493 | |
| 10494 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10495 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10496 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10497 | "\n is_scheduler_suspended %d", |
| 10498 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10499 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10500 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10501 | if (adapter->dev) |
| 10502 | len += scnprintf(buf + len, *size - len, |
| 10503 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10504 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10505 | "\n device_mode: %d", adapter->device_mode); |
| 10506 | switch (adapter->device_mode) { |
| 10507 | case QDF_STA_MODE: |
| 10508 | case QDF_P2P_CLIENT_MODE: |
| 10509 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10510 | len += scnprintf(buf + len, *size - len, |
| 10511 | "\n connState: %d", |
| 10512 | hdd_sta_ctx->conn_info.connState); |
| 10513 | break; |
| 10514 | |
| 10515 | default: |
| 10516 | break; |
| 10517 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10518 | } |
| 10519 | |
| 10520 | *size -= len; |
| 10521 | *buf_ptr += len; |
| 10522 | } |
| 10523 | |
| 10524 | /** |
| 10525 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10526 | * to print hdd state information |
| 10527 | * |
| 10528 | * Return: None |
| 10529 | */ |
| 10530 | static void hdd_register_debug_callback(void) |
| 10531 | { |
| 10532 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10533 | } |
| 10534 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10535 | /* |
| 10536 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10537 | * |
| 10538 | * This function is used to create bug report lock |
| 10539 | * |
| 10540 | * Return: None |
| 10541 | */ |
| 10542 | static void wlan_init_bug_report_lock(void) |
| 10543 | { |
| 10544 | p_cds_contextType p_cds_context; |
| 10545 | |
| 10546 | p_cds_context = cds_get_global_context(); |
| 10547 | if (!p_cds_context) { |
| 10548 | hdd_err("cds context is NULL"); |
| 10549 | return; |
| 10550 | } |
| 10551 | |
| 10552 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10553 | } |
| 10554 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10555 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10556 | { |
| 10557 | |
| 10558 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10559 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10560 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10561 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10562 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10563 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10564 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10565 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10566 | |
| 10567 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10568 | &num_entries, sizeof(config_params)); |
| 10569 | |
| 10570 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10571 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10572 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10573 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10574 | else if (bw_compute_interval > 1000) { |
| 10575 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10576 | thresh_time_limit = 1; |
| 10577 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10578 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10579 | |
| 10580 | switch (num_entries) { |
| 10581 | case 4: |
| 10582 | proto_bitmap = config_params[3]; |
| 10583 | case 3: |
| 10584 | verbosity = config_params[2]; |
| 10585 | case 2: |
| 10586 | thresh = config_params[1]; |
| 10587 | case 1: |
| 10588 | live_mode = config_params[0]; |
| 10589 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10590 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10591 | live_mode, thresh, thresh_time_limit, |
| 10592 | verbosity, proto_bitmap); |
| 10593 | }; |
| 10594 | |
| 10595 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10596 | verbosity, proto_bitmap); |
| 10597 | |
| 10598 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10599 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10600 | * hdd_wlan_startup() - HDD init function |
| 10601 | * @dev: Pointer to the underlying device |
| 10602 | * |
| 10603 | * This is the driver startup code executed once a WLAN device has been detected |
| 10604 | * |
| 10605 | * Return: 0 for success, < 0 for failure |
| 10606 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10607 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10608 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10609 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10610 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10611 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10612 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10613 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10614 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10615 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10616 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10617 | |
| 10618 | if (IS_ERR(hdd_ctx)) |
| 10619 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10620 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10621 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10622 | DEFAULT_PSOC_ID); |
| 10623 | if (ret) { |
| 10624 | hdd_err("Psoc creation fails!"); |
| 10625 | QDF_BUG(0); |
| 10626 | goto err_hdd_free_context; |
| 10627 | } |
| 10628 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10629 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10630 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10631 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10632 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10633 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10634 | osif_request_manager_init(); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10635 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10636 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10637 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10638 | hdd_driver_memdump_init(); |
| 10639 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10640 | ret = hdd_wlan_start_modules(hdd_ctx, NULL, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10641 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10642 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10643 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10644 | } |
| 10645 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10646 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10647 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10648 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10649 | |
| 10650 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10651 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10652 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10653 | } |
| 10654 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10655 | ret = hdd_wiphy_init(hdd_ctx); |
| 10656 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10657 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10658 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10659 | } |
| 10660 | |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10661 | if (hdd_ctx->config->enable_dp_trace) |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10662 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10663 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10664 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10665 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10666 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10667 | if (ret) { |
| 10668 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10669 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10670 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10671 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10672 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 10673 | if (ret) { |
| 10674 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 10675 | goto err_unregister_netdev; |
| 10676 | } |
| 10677 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10678 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10679 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10680 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10681 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10682 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10683 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10684 | } |
| 10685 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10686 | hdd_release_rtnl_lock(); |
| 10687 | rtnl_held = false; |
| 10688 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10689 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10690 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10691 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10692 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10693 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10694 | hdd_skip_acs_scan_timer_handler, |
| 10695 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10696 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10697 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10698 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10699 | #endif |
| 10700 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10701 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10702 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10703 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10704 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10705 | if (hdd_ctx->rps) |
| 10706 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10707 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10708 | ret = hdd_register_notifiers(hdd_ctx); |
| 10709 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10710 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10711 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10712 | status = wlansap_global_init(); |
| 10713 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10714 | hdd_unregister_notifiers(hdd_ctx); |
| 10715 | goto err_close_adapters; |
| 10716 | } |
| 10717 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10718 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10719 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10720 | else |
| 10721 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10722 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10723 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10724 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10725 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10726 | hdd_prevent_suspend_timeout( |
| 10727 | hdd_ctx->config->iface_change_wait_time, |
| 10728 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10729 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10730 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10731 | goto success; |
| 10732 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10733 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10734 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10735 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10736 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10737 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10738 | if (rtnl_held) |
| 10739 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10740 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10741 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10742 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10743 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10744 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10745 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10746 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10747 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10748 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10749 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10750 | err_memdump_deinit: |
| 10751 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10752 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10753 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10754 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10755 | hdd_exit_netlink_services(hdd_ctx); |
| 10756 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10757 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10758 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10759 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10760 | if (cds_is_fw_down()) |
| 10761 | hdd_err("Not setting the complete event as fw is down"); |
| 10762 | else |
| 10763 | hdd_start_complete(ret); |
| 10764 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10765 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10766 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10767 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10768 | |
| 10769 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10770 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10771 | return 0; |
| 10772 | } |
| 10773 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10774 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10775 | * hdd_wlan_update_target_info() - update target type info |
| 10776 | * @hdd_ctx: HDD context |
| 10777 | * @context: hif context |
| 10778 | * |
| 10779 | * Update target info received from firmware in hdd context |
| 10780 | * Return:None |
| 10781 | */ |
| 10782 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10783 | 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] | 10784 | { |
| 10785 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10786 | |
| 10787 | if (!tgt_info) { |
| 10788 | hdd_err("Target info is Null"); |
| 10789 | return; |
| 10790 | } |
| 10791 | |
| 10792 | hdd_ctx->target_type = tgt_info->target_type; |
| 10793 | } |
| 10794 | |
| 10795 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10796 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10797 | * received from the firmware |
| 10798 | * @data: pointer to adapter. |
| 10799 | * @rsp: pointer to data received from FW. |
| 10800 | * |
| 10801 | * This is called when wlan driver received response event for |
| 10802 | * get arp stats to firmware. |
| 10803 | * |
| 10804 | * Return: None |
| 10805 | */ |
| 10806 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10807 | { |
| 10808 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10809 | struct hdd_nud_stats_context *context; |
| 10810 | int status; |
| 10811 | struct hdd_adapter *adapter = NULL; |
| 10812 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10813 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10814 | |
| 10815 | if (!rsp) { |
| 10816 | hdd_err("data is null"); |
| 10817 | return; |
| 10818 | } |
| 10819 | |
| 10820 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10821 | if (0 != status) |
| 10822 | return; |
| 10823 | |
| 10824 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10825 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10826 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10827 | return; |
| 10828 | } |
| 10829 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 10830 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10831 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10832 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10833 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10834 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10835 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10836 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 10837 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 10838 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 10839 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10840 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10841 | adapter->hdd_stats.hdd_arp_stats.rx_fw_cnt = rsp->arp_rsp_recvd; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10842 | adapter->dad |= rsp->dad_detected; |
| 10843 | adapter->con_status = rsp->connect_status; |
| 10844 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10845 | /* Flag true indicates connectivity check stats present. */ |
| 10846 | if (rsp->connect_stats_present) { |
| 10847 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 10848 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 10849 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 10850 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 10851 | rsp->icmpv4_rsp_recvd; |
| 10852 | } |
| 10853 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10854 | spin_lock(&hdd_context_lock); |
| 10855 | context = &hdd_ctx->nud_stats_context; |
| 10856 | complete(&context->response_event); |
| 10857 | spin_unlock(&hdd_context_lock); |
| 10858 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10859 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10860 | } |
| 10861 | |
| 10862 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10863 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10864 | * @hdd_ctx: HDD context |
| 10865 | * |
| 10866 | * Register the HDD callbacks to CDS/SME. |
| 10867 | * |
| 10868 | * Return: 0 for success or Error code for failure |
| 10869 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10870 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10871 | { |
| 10872 | QDF_STATUS status; |
| 10873 | int ret = 0; |
| 10874 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10875 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10876 | |
| 10877 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10878 | |
| 10879 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10880 | hdd_send_oem_data_rsp_msg); |
| 10881 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10882 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10883 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10884 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10885 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10886 | wlan_hdd_cfg80211_nan_callback); |
| 10887 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10888 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10889 | |
| 10890 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10891 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10892 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10893 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10894 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10895 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10896 | hdd_rssi_threshold_breached); |
| 10897 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10898 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10899 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10900 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 10901 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 10902 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 10903 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 10904 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 10905 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 10906 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 10907 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 10908 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 10909 | hdd_lost_link_info_cb); |
| 10910 | /* print error and not block the startup process */ |
| 10911 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10912 | hdd_err("set lost link info callback failed"); |
| 10913 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10914 | ret = hdd_register_data_stall_detect_cb(); |
| 10915 | if (ret) { |
| 10916 | hdd_err("Register data stall detect detect callback failed."); |
| 10917 | return ret; |
| 10918 | } |
| 10919 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10920 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 10921 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 10922 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 10923 | hdd_set_connection_in_progress, |
| 10924 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 10925 | |
| 10926 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 10927 | hdd_update_cca_info_cb); |
| 10928 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10929 | hdd_err("set congestion callback failed"); |
| 10930 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 10931 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 10932 | hdd_bt_activity_cb); |
| 10933 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10934 | hdd_err("set bt activity info callback failed"); |
| 10935 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10936 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 10937 | hdd_tx_queue_cb); |
| 10938 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10939 | hdd_err("Register tx queue callback failed"); |
| 10940 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10941 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10942 | |
| 10943 | return ret; |
| 10944 | } |
| 10945 | |
| 10946 | /** |
| 10947 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 10948 | * @hdd_ctx: HDD context |
| 10949 | * |
| 10950 | * De-Register the HDD callbacks to CDS/SME. |
| 10951 | * |
| 10952 | * Return: void |
| 10953 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10954 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10955 | { |
| 10956 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10957 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10958 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10959 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10960 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 10961 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10962 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 10963 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10964 | hdd_err("De-register of dcc stats callback failed: %d", |
| 10965 | status); |
| 10966 | |
| 10967 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10968 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 10969 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10970 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10971 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10972 | |
| 10973 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 10974 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 10975 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10976 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 10977 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10978 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 10979 | ret = hdd_deregister_data_stall_detect_cb(); |
| 10980 | if (ret) |
| 10981 | hdd_err("Failed to de-register data stall detect event callback"); |
| 10982 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10983 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 10984 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 10985 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10986 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10987 | } |
| 10988 | |
| 10989 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10990 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 10991 | * @adapter: Pointer to the HDD |
| 10992 | * @enable: bool value |
| 10993 | * |
| 10994 | * This to take counter measure to handle deauth req from HDD |
| 10995 | * |
| 10996 | * Return: None |
| 10997 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10998 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 10999 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11000 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11001 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11002 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11003 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11004 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11005 | /* Ignore request to deauth bcmc station */ |
| 11006 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11007 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11008 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11009 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11010 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11011 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11012 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11013 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11014 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11015 | } |
| 11016 | |
| 11017 | /** |
| 11018 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11019 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11020 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11021 | * |
| 11022 | * This to take counter measure to handle deauth req from HDD |
| 11023 | * |
| 11024 | * Return: None |
| 11025 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11026 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11027 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11028 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11029 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11030 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11031 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11032 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11033 | return; |
| 11034 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11035 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11036 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11037 | } |
| 11038 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11039 | /** |
| 11040 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11041 | * @hdd_ctx: HDD Context |
| 11042 | * |
| 11043 | * API to find if there is any STA or P2P-Client is connected |
| 11044 | * |
| 11045 | * Return: true if connected; false otherwise |
| 11046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11047 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11048 | { |
| 11049 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 11050 | } |
| 11051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11052 | /** |
| 11053 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 11054 | * @adapter: HDD adapter pointer |
| 11055 | * |
| 11056 | * This function loop through each adapter and disable roaming on each STA |
| 11057 | * device mode except the input adapter. |
| 11058 | * |
| 11059 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 11060 | * disable. |
| 11061 | * |
| 11062 | * Return: None |
| 11063 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11064 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11065 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11066 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11067 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11068 | |
| 11069 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11070 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11071 | QDF_STA_MODE == adapter->device_mode && |
| 11072 | policy_mgr_is_sta_active_connection_exists( |
| 11073 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11074 | hdd_debug("Connect received on STA session Id(%d)", |
| 11075 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11076 | /* |
| 11077 | * Loop through adapter and disable roaming for each STA device |
| 11078 | * mode except the input adapter. |
| 11079 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11080 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11081 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11082 | adapter->session_id != adapterIdx->session_id) { |
| 11083 | hdd_debug("Disable Roaming on session Id(%d)", |
| 11084 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11085 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 11086 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11087 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11088 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11089 | } |
| 11090 | } |
| 11091 | } |
| 11092 | |
| 11093 | /** |
| 11094 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 11095 | * @adapter: HDD adapter pointer |
| 11096 | * |
| 11097 | * This function loop through each adapter and enable roaming on each STA |
| 11098 | * device mode except the input adapter. |
| 11099 | * Note: On the input adapter no need to enable roaming because link got |
| 11100 | * disconnected on this. |
| 11101 | * |
| 11102 | * Return: None |
| 11103 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11104 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11105 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11106 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11107 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11108 | |
| 11109 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11110 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11111 | QDF_STA_MODE == adapter->device_mode && |
| 11112 | policy_mgr_is_sta_active_connection_exists( |
| 11113 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11114 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 11115 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11116 | /* |
| 11117 | * Loop through adapter and enable roaming for each STA device |
| 11118 | * mode except the input adapter. |
| 11119 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11120 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11121 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11122 | adapter->session_id != adapterIdx->session_id) { |
| 11123 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 11124 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11125 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 11126 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11127 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11128 | REASON_CONNECT); |
| 11129 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11130 | } |
| 11131 | } |
| 11132 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11133 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11134 | /** |
| 11135 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11136 | * @skb: sk buffer pointer |
| 11137 | * |
| 11138 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11139 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11140 | * |
| 11141 | * Return: None |
| 11142 | */ |
| 11143 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11144 | { |
| 11145 | #ifdef CNSS_GENL |
| 11146 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11147 | #else |
| 11148 | nl_srv_bcast(skb); |
| 11149 | #endif |
| 11150 | } |
| 11151 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11152 | 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] | 11153 | { |
| 11154 | struct sk_buff *skb; |
| 11155 | struct nlmsghdr *nlh; |
| 11156 | tAniMsgHdr *ani_hdr; |
| 11157 | void *nl_data = NULL; |
| 11158 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11159 | struct radio_index_tlv *radio_info; |
| 11160 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11161 | |
| 11162 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11163 | flags = GFP_ATOMIC; |
| 11164 | |
| 11165 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11166 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11167 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11168 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11169 | |
| 11170 | nlh = (struct nlmsghdr *)skb->data; |
| 11171 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11172 | nlh->nlmsg_flags = 0; |
| 11173 | nlh->nlmsg_seq = 0; |
| 11174 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11175 | |
| 11176 | ani_hdr = NLMSG_DATA(nlh); |
| 11177 | ani_hdr->type = type; |
| 11178 | |
| 11179 | switch (type) { |
| 11180 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11181 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11182 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11183 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11184 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11185 | ani_hdr->length = 0; |
| 11186 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11187 | break; |
| 11188 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11189 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11190 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11191 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11192 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11193 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11194 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11195 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11196 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11197 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11198 | ani_hdr->length = len; |
| 11199 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11200 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11201 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11202 | break; |
| 11203 | |
| 11204 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11205 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11206 | type); |
| 11207 | kfree_skb(skb); |
| 11208 | return; |
| 11209 | } |
| 11210 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11211 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11212 | * Add radio index at the end of the svc event in TLV format |
| 11213 | * to maintain the backward compatibility with userspace |
| 11214 | * applications. |
| 11215 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11216 | |
| 11217 | tlv_len = 0; |
| 11218 | |
| 11219 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11220 | < WLAN_NL_MAX_PAYLOAD) { |
| 11221 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11222 | sizeof(*ani_hdr) + len); |
| 11223 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11224 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11225 | radio_info->radio = radio; |
| 11226 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11227 | hdd_debug("Added radio index tlv - radio index %d", |
| 11228 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11229 | } |
| 11230 | |
| 11231 | nlh->nlmsg_len += tlv_len; |
| 11232 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11233 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11234 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11235 | } |
| 11236 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11237 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11238 | void wlan_hdd_auto_shutdown_cb(void) |
| 11239 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11240 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11241 | |
| 11242 | if (!hdd_ctx) |
| 11243 | return; |
| 11244 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11245 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11246 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11247 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11248 | } |
| 11249 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11250 | 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] | 11251 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11252 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11253 | bool ap_connected = false, sta_connected = false; |
| 11254 | tHalHandle hal_handle; |
| 11255 | |
| 11256 | hal_handle = hdd_ctx->hHal; |
| 11257 | if (hal_handle == NULL) |
| 11258 | return; |
| 11259 | |
| 11260 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11261 | return; |
| 11262 | |
| 11263 | if (enable == false) { |
| 11264 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11265 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11266 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11267 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11268 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11269 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11270 | return; |
| 11271 | } |
| 11272 | |
| 11273 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11274 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11275 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11276 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11277 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11278 | conn_info.connState == |
| 11279 | eConnectionState_Associated) { |
| 11280 | sta_connected = true; |
| 11281 | break; |
| 11282 | } |
| 11283 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11284 | |
| 11285 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11286 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11287 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11288 | ap_connected = true; |
| 11289 | break; |
| 11290 | } |
| 11291 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11292 | } |
| 11293 | } |
| 11294 | |
| 11295 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11296 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11297 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11298 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11299 | |
| 11300 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11301 | hdd_ctx->config->WlanAutoShutdown) |
| 11302 | != QDF_STATUS_SUCCESS) |
| 11303 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11304 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11305 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11306 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11307 | } |
| 11308 | #endif |
| 11309 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11310 | struct hdd_adapter * |
| 11311 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11312 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11313 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11314 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11315 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11316 | |
| 11317 | con_sap_adapter = NULL; |
| 11318 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11319 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11320 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11321 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11322 | adapter != this_sap_adapter) { |
| 11323 | if (check_start_bss) { |
| 11324 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11325 | &adapter->event_flags)) { |
| 11326 | con_sap_adapter = adapter; |
| 11327 | break; |
| 11328 | } |
| 11329 | } else { |
| 11330 | con_sap_adapter = adapter; |
| 11331 | break; |
| 11332 | } |
| 11333 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11334 | } |
| 11335 | |
| 11336 | return con_sap_adapter; |
| 11337 | } |
| 11338 | |
| 11339 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11340 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11341 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11342 | return adapter->device_mode == QDF_STA_MODE || |
| 11343 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11344 | } |
| 11345 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11346 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11347 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11348 | return adapter->device_mode == QDF_SAP_MODE || |
| 11349 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11350 | } |
| 11351 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11352 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11353 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11354 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11355 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11356 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11357 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11358 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11359 | conn_info.connState == eConnectionState_Associated) { |
| 11360 | return true; |
| 11361 | } |
| 11362 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11363 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11364 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11365 | return true; |
| 11366 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11367 | } |
| 11368 | |
| 11369 | return false; |
| 11370 | } |
| 11371 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11372 | 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] | 11373 | { |
| 11374 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11375 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11376 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11377 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11378 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11379 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11380 | return is_running; |
| 11381 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11382 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11383 | 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] | 11384 | { |
| 11385 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11386 | hdd_ctx->bus_bw_timer_running = true; |
| 11387 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11388 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11389 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11390 | } |
| 11391 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11392 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11393 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11394 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11395 | |
| 11396 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11397 | hdd_debug("Bandwidth compute timer already started"); |
| 11398 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11399 | } |
| 11400 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11401 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11402 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11403 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11404 | } |
| 11405 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11406 | 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] | 11407 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11408 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11409 | |
| 11410 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11411 | hdd_debug("Bandwidth compute timer already started"); |
| 11412 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11413 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11414 | |
| 11415 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11416 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11417 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11418 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11419 | } |
| 11420 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11421 | 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] | 11422 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11423 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11424 | |
| 11425 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11426 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11427 | hdd_ctx->bus_bw_timer_running = false; |
| 11428 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11429 | |
| 11430 | hdd_reset_tcp_delack(hdd_ctx); |
| 11431 | } |
| 11432 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11433 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11434 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11435 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11436 | |
| 11437 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11438 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11439 | return; |
| 11440 | } |
| 11441 | |
| 11442 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11443 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11444 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11445 | } |
| 11446 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11447 | 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] | 11448 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11449 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11450 | |
| 11451 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11452 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11453 | return; |
| 11454 | } |
| 11455 | |
| 11456 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11457 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11458 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11459 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11460 | } |
| 11461 | #endif |
| 11462 | |
| 11463 | /** |
| 11464 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11465 | * and sta's operating channel. |
| 11466 | * @sta_adapter: Describe the first argument to foobar. |
| 11467 | * @ap_adapter: Describe the second argument to foobar. |
| 11468 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11469 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11470 | * set this flag to true else false. |
| 11471 | * |
| 11472 | * This function checks the sap's operating channel and sta's operating channel. |
| 11473 | * if both are same then it will return false else it will restart the sap in |
| 11474 | * sta's channel and return true. |
| 11475 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11476 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11477 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11478 | QDF_STATUS |
| 11479 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11480 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11481 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11482 | tScanResultHandle *scan_cache, |
| 11483 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11484 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11485 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11486 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11487 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11488 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11489 | *concurrent_chnl_same = true; |
| 11490 | |
| 11491 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11492 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11493 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11494 | scan_cache, |
| 11495 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11496 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11497 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11498 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11499 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11500 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11501 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11502 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11503 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11504 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11505 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11506 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11507 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11508 | } |
| 11509 | } |
| 11510 | } else { |
| 11511 | /* |
| 11512 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11513 | * failed so we have to stop the SAP to avoid any channel |
| 11514 | * discrepancy between SAP's channel and STA's channel. |
| 11515 | * Return the status as failure so caller function could know |
| 11516 | * that scan look up is failed. |
| 11517 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11518 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11519 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11520 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11521 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11522 | } |
| 11523 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11524 | /** |
| 11525 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11526 | * @ap_adapter: SAP adapter |
| 11527 | * |
| 11528 | * This function will process the stopping of sap adapter. |
| 11529 | * |
| 11530 | * Return: None |
| 11531 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11532 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11533 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11534 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11535 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11536 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11537 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11538 | |
| 11539 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11540 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11541 | return; |
| 11542 | } |
| 11543 | |
| 11544 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11545 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11546 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11547 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11548 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11549 | mutex_lock(&hdd_ctx->sap_lock); |
| 11550 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11551 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11552 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11553 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11554 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11555 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11556 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11557 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11558 | qdf_stop_bss_event, |
| 11559 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11560 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11561 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11562 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11563 | return; |
| 11564 | } |
| 11565 | } |
| 11566 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11567 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11568 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11569 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11570 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11571 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11572 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11573 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11574 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11575 | } |
| 11576 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11577 | } |
| 11578 | |
| 11579 | /** |
| 11580 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11581 | * @ap_adapter: SAP adapter |
| 11582 | * |
| 11583 | * This function will process the starting of sap adapter. |
| 11584 | * |
| 11585 | * Return: None |
| 11586 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11587 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11588 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11589 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11590 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11591 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11592 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11593 | tsap_Config_t *sap_config; |
| 11594 | |
| 11595 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11596 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11597 | return; |
| 11598 | } |
| 11599 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11600 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11601 | hdd_err("SoftAp role has not been enabled"); |
| 11602 | return; |
| 11603 | } |
| 11604 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11605 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11606 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11607 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11608 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11609 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11610 | mutex_lock(&hdd_ctx->sap_lock); |
| 11611 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11612 | goto end; |
| 11613 | |
| 11614 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11615 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11616 | goto end; |
| 11617 | } |
| 11618 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11619 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11620 | 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] | 11621 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11622 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11623 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11624 | goto end; |
| 11625 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11626 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11627 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11628 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11629 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11630 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11631 | goto end; |
| 11632 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11633 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11634 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11635 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11636 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11637 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11638 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11639 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11640 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11641 | true); |
| 11642 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11643 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11644 | |
| 11645 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11646 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11647 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11648 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11649 | /* SAP context and beacon cleanup will happen during driver unload |
| 11650 | * in hdd_stop_adapter |
| 11651 | */ |
| 11652 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11653 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11654 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11655 | |
| 11656 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11657 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11658 | * mac scan config |
| 11659 | * @status: Status of set antenna mode |
| 11660 | * |
| 11661 | * Callback on setting the dual mac configuration |
| 11662 | * |
| 11663 | * Return: None |
| 11664 | */ |
| 11665 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11666 | enum set_antenna_mode_status status) |
| 11667 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11668 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11669 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11670 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11671 | |
| 11672 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11673 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11674 | return; |
| 11675 | |
| 11676 | /* Signal the completion of set dual mac config */ |
| 11677 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11678 | } |
| 11679 | |
| 11680 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11681 | * hdd_get_fw_version() - Get FW version |
| 11682 | * @hdd_ctx: pointer to HDD context. |
| 11683 | * @major_spid: FW version - major spid. |
| 11684 | * @minor_spid: FW version - minor spid |
| 11685 | * @ssid: FW version - ssid |
| 11686 | * @crmid: FW version - crmid |
| 11687 | * |
| 11688 | * This function is called to get the firmware build version stored |
| 11689 | * as part of the HDD context |
| 11690 | * |
| 11691 | * Return: None |
| 11692 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11693 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11694 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11695 | uint32_t *siid, uint32_t *crmid) |
| 11696 | { |
| 11697 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11698 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11699 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11700 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11701 | } |
| 11702 | |
| 11703 | #ifdef QCA_CONFIG_SMP |
| 11704 | /** |
| 11705 | * wlan_hdd_get_cpu() - get cpu_index |
| 11706 | * |
| 11707 | * Return: cpu_index |
| 11708 | */ |
| 11709 | int wlan_hdd_get_cpu(void) |
| 11710 | { |
| 11711 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11712 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11713 | put_cpu(); |
| 11714 | return cpu_index; |
| 11715 | } |
| 11716 | #endif |
| 11717 | |
| 11718 | /** |
| 11719 | * hdd_get_fwpath() - get framework path |
| 11720 | * |
| 11721 | * This function is used to get the string written by |
| 11722 | * userspace to start the wlan driver |
| 11723 | * |
| 11724 | * Return: string |
| 11725 | */ |
| 11726 | const char *hdd_get_fwpath(void) |
| 11727 | { |
| 11728 | return fwpath.string; |
| 11729 | } |
| 11730 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11731 | static int hdd_qdf_print_init(void) |
| 11732 | { |
| 11733 | int qdf_print_idx; |
| 11734 | QDF_STATUS status; |
| 11735 | |
| 11736 | status = qdf_print_setup(); |
| 11737 | if (status != QDF_STATUS_SUCCESS) { |
| 11738 | pr_err("qdf_print_setup failed\n"); |
| 11739 | return -EINVAL; |
| 11740 | } |
| 11741 | |
| 11742 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11743 | |
| 11744 | if (qdf_print_idx < 0) { |
| 11745 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11746 | qdf_print_idx); |
| 11747 | return -EINVAL; |
| 11748 | } |
| 11749 | |
| 11750 | qdf_set_pidx(qdf_print_idx); |
| 11751 | |
| 11752 | return 0; |
| 11753 | } |
| 11754 | |
| 11755 | static void hdd_qdf_print_deinit(void) |
| 11756 | { |
| 11757 | int qdf_print_idx; |
| 11758 | |
| 11759 | qdf_print_idx = qdf_get_pidx(); |
| 11760 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11761 | } |
| 11762 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11763 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11764 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11765 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11766 | * This function initilizes CDS global context with the help of cds_init. This |
| 11767 | * has to be the first function called after probe to get a valid global |
| 11768 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11769 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11770 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11771 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11772 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11773 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11774 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11775 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11776 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11777 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11778 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11779 | hdd_err("Failed to allocate CDS context"); |
| 11780 | ret = -ENOMEM; |
| 11781 | goto err_out; |
| 11782 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11783 | |
| 11784 | wlan_init_bug_report_lock(); |
| 11785 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11786 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11787 | wlan_logging_sock_init_svc(); |
| 11788 | #endif |
| 11789 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11790 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11791 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11792 | QDF_TIMER_TYPE_SW); |
| 11793 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11794 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11795 | hdd_qdf_print_init(); |
| 11796 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11797 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11798 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11799 | err_out: |
| 11800 | return ret; |
| 11801 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11802 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11803 | /** |
| 11804 | * hdd_deinit() - Deinitialize Driver |
| 11805 | * |
| 11806 | * This function frees CDS global context with the help of cds_deinit. This |
| 11807 | * has to be the last function call in remove callback to free the global |
| 11808 | * context. |
| 11809 | */ |
| 11810 | void hdd_deinit(void) |
| 11811 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11812 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11813 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11814 | wlan_destroy_bug_report_lock(); |
| 11815 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11816 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11817 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11818 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11819 | wlan_logging_sock_deinit_svc(); |
| 11820 | #endif |
| 11821 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11822 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11823 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11824 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11825 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11826 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11827 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11828 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11829 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11830 | struct file *file) |
| 11831 | { |
| 11832 | return 0; |
| 11833 | } |
| 11834 | |
| 11835 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11836 | const char __user *user_buf, |
| 11837 | size_t count, |
| 11838 | loff_t *f_pos) |
| 11839 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11840 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11841 | static const char wlan_off_str[] = "OFF"; |
| 11842 | static const char wlan_on_str[] = "ON"; |
| 11843 | int ret; |
| 11844 | unsigned long rc; |
| 11845 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11846 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11847 | pr_err("Failed to read buffer\n"); |
| 11848 | return -EINVAL; |
| 11849 | } |
| 11850 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11851 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11852 | pr_debug("Wifi turning off from UI\n"); |
| 11853 | goto exit; |
| 11854 | } |
| 11855 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11856 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 11857 | pr_info("Wifi Turning On from UI\n"); |
| 11858 | } |
| 11859 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11860 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11861 | pr_err("Invalid value received from framework"); |
| 11862 | goto exit; |
| 11863 | } |
| 11864 | |
| 11865 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11866 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11867 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11868 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11869 | if (!rc) { |
| 11870 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11871 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11872 | return ret; |
| 11873 | } |
| 11874 | |
| 11875 | hdd_start_complete(0); |
| 11876 | } |
| 11877 | |
| 11878 | exit: |
| 11879 | return count; |
| 11880 | } |
| 11881 | |
| 11882 | |
| 11883 | const struct file_operations wlan_hdd_state_fops = { |
| 11884 | .owner = THIS_MODULE, |
| 11885 | .open = wlan_hdd_state_ctrl_param_open, |
| 11886 | .write = wlan_hdd_state_ctrl_param_write, |
| 11887 | }; |
| 11888 | |
| 11889 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11890 | { |
| 11891 | unsigned int wlan_hdd_state_major = 0; |
| 11892 | int ret; |
| 11893 | struct device *dev; |
| 11894 | |
| 11895 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11896 | |
| 11897 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11898 | if (ret) { |
| 11899 | pr_err("Failed to register qcwlanstate"); |
| 11900 | goto dev_alloc_err; |
| 11901 | } |
| 11902 | wlan_hdd_state_major = MAJOR(device); |
| 11903 | |
| 11904 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 11905 | if (IS_ERR(class)) { |
| 11906 | pr_err("wlan_hdd_state class_create error"); |
| 11907 | goto class_err; |
| 11908 | } |
| 11909 | |
| 11910 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 11911 | if (IS_ERR(dev)) { |
| 11912 | pr_err("wlan_hdd_statedevice_create error"); |
| 11913 | goto err_class_destroy; |
| 11914 | } |
| 11915 | |
| 11916 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 11917 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 11918 | if (ret) { |
| 11919 | pr_err("Failed to add cdev error"); |
| 11920 | goto cdev_add_err; |
| 11921 | } |
| 11922 | |
| 11923 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 11924 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 11925 | |
| 11926 | return 0; |
| 11927 | |
| 11928 | cdev_add_err: |
| 11929 | device_destroy(class, device); |
| 11930 | err_class_destroy: |
| 11931 | class_destroy(class); |
| 11932 | class_err: |
| 11933 | unregister_chrdev_region(device, dev_num); |
| 11934 | dev_alloc_err: |
| 11935 | return -ENODEV; |
| 11936 | } |
| 11937 | |
| 11938 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 11939 | { |
| 11940 | cdev_del(&wlan_hdd_state_cdev); |
| 11941 | device_destroy(class, device); |
| 11942 | class_destroy(class); |
| 11943 | unregister_chrdev_region(device, dev_num); |
| 11944 | |
| 11945 | pr_info("Device node unregistered"); |
| 11946 | } |
| 11947 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11948 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11949 | * component_init - API to init cld component's |
| 11950 | * |
| 11951 | * Return: None |
| 11952 | */ |
| 11953 | static void component_init(void) |
| 11954 | { |
| 11955 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11956 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11957 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11958 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11959 | } |
| 11960 | |
| 11961 | /** |
| 11962 | * component_deinit - API to deinit cld component's |
| 11963 | * |
| 11964 | * Return: None |
| 11965 | */ |
| 11966 | static void component_deinit(void) |
| 11967 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 11968 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11969 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11970 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11971 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11972 | } |
| 11973 | |
| 11974 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 11975 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11976 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11977 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11978 | } |
| 11979 | |
| 11980 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 11981 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 11982 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 11983 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 11984 | } |
| 11985 | |
| 11986 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11987 | * __hdd_module_init - Module init helper |
| 11988 | * |
| 11989 | * Module init helper function used by both module and static driver. |
| 11990 | * |
| 11991 | * Return: 0 for success, errno on failure |
| 11992 | */ |
| 11993 | static int __hdd_module_init(void) |
| 11994 | { |
| 11995 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11996 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11997 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 11998 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 11999 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12000 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12001 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12002 | pld_init(); |
| 12003 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12004 | ret = hdd_init(); |
| 12005 | if (ret) { |
| 12006 | pr_err("hdd_init failed %x\n", ret); |
| 12007 | goto err_hdd_init; |
| 12008 | } |
| 12009 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12010 | dispatcher_init(); |
| 12011 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12012 | /* Ensure to call post objmgr init */ |
| 12013 | component_init(); |
| 12014 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12015 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12016 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12017 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12018 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12019 | ret = wlan_hdd_register_driver(); |
| 12020 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12021 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12022 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12023 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12024 | } |
| 12025 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12026 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12027 | if (ret) { |
| 12028 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12029 | goto out; |
| 12030 | } |
| 12031 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12032 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12033 | |
| 12034 | return 0; |
| 12035 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12036 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12037 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12038 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12039 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12040 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12041 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12042 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12043 | return ret; |
| 12044 | } |
| 12045 | |
| 12046 | /** |
| 12047 | * __hdd_module_exit - Module exit helper |
| 12048 | * |
| 12049 | * Module exit helper function used by both module and static driver. |
| 12050 | */ |
| 12051 | static void __hdd_module_exit(void) |
| 12052 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12053 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 12054 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12055 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12056 | QWLAN_VERSIONSTR); |
| 12057 | |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12058 | if (!hdd_ctx) { |
| 12059 | hdd_err("hdd context is NULL return!!"); |
| 12060 | return; |
| 12061 | } |
| 12062 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12063 | if (!hdd_wait_for_recovery_completion()) |
| 12064 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12065 | |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12066 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
| 12067 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12068 | wlan_hdd_unregister_driver(); |
| 12069 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12070 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12071 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12072 | /* Ensure to call prior to objmgr deinit */ |
| 12073 | component_deinit(); |
| 12074 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12075 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12076 | |
| 12077 | hdd_sysfs_destroy_version_interface(); |
| 12078 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12079 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12080 | pld_deinit(); |
| 12081 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12082 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12083 | } |
| 12084 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12085 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12086 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12087 | * wlan_boot_cb() - Wlan boot callback |
| 12088 | * @kobj: object whose directory we're creating the link in. |
| 12089 | * @attr: attribute the user is interacting with |
| 12090 | * @buff: the buffer containing the user data |
| 12091 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12092 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12093 | * This callback is invoked when the fs is ready to start the |
| 12094 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12095 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12096 | * 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] | 12097 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12098 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12099 | struct kobj_attribute *attr, |
| 12100 | const char *buf, |
| 12101 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12102 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12103 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12104 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12105 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12106 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12107 | } |
| 12108 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12109 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12110 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12111 | return -EIO; |
| 12112 | } |
| 12113 | |
| 12114 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12115 | |
| 12116 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12117 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12118 | |
| 12119 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12120 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12121 | * |
| 12122 | * Return: None |
| 12123 | * |
| 12124 | */ |
| 12125 | static void hdd_sysfs_cleanup(void) |
| 12126 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12127 | /* remove from group */ |
| 12128 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12129 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12130 | wlan_loader->attr_group); |
| 12131 | |
| 12132 | /* unlink the object from parent */ |
| 12133 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12134 | |
| 12135 | /* free the object */ |
| 12136 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12137 | |
| 12138 | kfree(wlan_loader->attr_group); |
| 12139 | kfree(wlan_loader); |
| 12140 | |
| 12141 | wlan_loader = NULL; |
| 12142 | } |
| 12143 | |
| 12144 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12145 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12146 | * ready |
| 12147 | * |
| 12148 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12149 | * when the filesystem is ready. |
| 12150 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12151 | * QDF API cannot be used here since this function is called even before |
| 12152 | * initializing WLAN driver. |
| 12153 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12154 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12155 | */ |
| 12156 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12157 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12158 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12159 | |
| 12160 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12161 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12162 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12163 | |
| 12164 | wlan_loader->boot_wlan_obj = NULL; |
| 12165 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12166 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12167 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12168 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12169 | |
| 12170 | wlan_loader->loaded_state = 0; |
| 12171 | wlan_loader->attr_group->attrs = attrs; |
| 12172 | |
| 12173 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12174 | kernel_kobj); |
| 12175 | if (!wlan_loader->boot_wlan_obj) { |
| 12176 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12177 | goto error_return; |
| 12178 | } |
| 12179 | |
| 12180 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12181 | wlan_loader->attr_group); |
| 12182 | if (ret) { |
| 12183 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12184 | goto error_return; |
| 12185 | } |
| 12186 | |
| 12187 | return 0; |
| 12188 | |
| 12189 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12190 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12191 | |
| 12192 | return ret; |
| 12193 | } |
| 12194 | |
| 12195 | /** |
| 12196 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12197 | * |
| 12198 | * Return: 0 on success or errno on failure |
| 12199 | */ |
| 12200 | static int wlan_deinit_sysfs(void) |
| 12201 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12202 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12203 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12204 | return -EINVAL; |
| 12205 | } |
| 12206 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12207 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12208 | return 0; |
| 12209 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12210 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12211 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12212 | |
| 12213 | #ifdef MODULE |
| 12214 | /** |
| 12215 | * __hdd_module_init - Module init helper |
| 12216 | * |
| 12217 | * Module init helper function used by both module and static driver. |
| 12218 | * |
| 12219 | * Return: 0 for success, errno on failure |
| 12220 | */ |
| 12221 | static int hdd_module_init(void) |
| 12222 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12223 | if (__hdd_module_init()) { |
| 12224 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12225 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12226 | } |
| 12227 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12228 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12229 | } |
| 12230 | #else |
| 12231 | static int __init hdd_module_init(void) |
| 12232 | { |
| 12233 | int ret = -EINVAL; |
| 12234 | |
| 12235 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12236 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12237 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12238 | |
| 12239 | return ret; |
| 12240 | } |
| 12241 | #endif |
| 12242 | |
| 12243 | |
| 12244 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12245 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12246 | * hdd_module_exit() - Exit function |
| 12247 | * |
| 12248 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12249 | * |
| 12250 | * Return: None |
| 12251 | */ |
| 12252 | static void __exit hdd_module_exit(void) |
| 12253 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12254 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12255 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12256 | #else |
| 12257 | static void __exit hdd_module_exit(void) |
| 12258 | { |
| 12259 | __hdd_module_exit(); |
| 12260 | wlan_deinit_sysfs(); |
| 12261 | } |
| 12262 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12263 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12264 | static int fwpath_changed_handler(const char *kmessage, |
| 12265 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12266 | { |
| 12267 | return param_set_copystring(kmessage, kp); |
| 12268 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12269 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12270 | /** |
| 12271 | * is_con_mode_valid() check con mode is valid or not |
| 12272 | * @mode: global con mode |
| 12273 | * |
| 12274 | * Return: TRUE on success FALSE on failure |
| 12275 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12276 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12277 | { |
| 12278 | switch (mode) { |
| 12279 | case QDF_GLOBAL_MONITOR_MODE: |
| 12280 | case QDF_GLOBAL_FTM_MODE: |
| 12281 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12282 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12283 | return true; |
| 12284 | default: |
| 12285 | return false; |
| 12286 | } |
| 12287 | } |
| 12288 | |
| 12289 | /** |
| 12290 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12291 | * @mode: global con mode |
| 12292 | * |
| 12293 | * Return: adapter mode |
| 12294 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12295 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12296 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12297 | { |
| 12298 | |
| 12299 | switch (mode) { |
| 12300 | case QDF_GLOBAL_MISSION_MODE: |
| 12301 | return QDF_STA_MODE; |
| 12302 | case QDF_GLOBAL_MONITOR_MODE: |
| 12303 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12304 | case QDF_GLOBAL_EPPING_MODE: |
| 12305 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12306 | case QDF_GLOBAL_FTM_MODE: |
| 12307 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12308 | case QDF_GLOBAL_QVIT_MODE: |
| 12309 | return QDF_QVIT_MODE; |
| 12310 | default: |
| 12311 | return QDF_MAX_NO_OF_MODE; |
| 12312 | } |
| 12313 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12314 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12315 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12316 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12317 | { |
| 12318 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12319 | return; |
| 12320 | |
| 12321 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12322 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12323 | hdd_info("Release wakelock for monitor mode!"); |
| 12324 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12325 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12326 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12327 | case QDF_GLOBAL_FTM_MODE: |
| 12328 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12329 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12330 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12331 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12332 | break; |
| 12333 | default: |
| 12334 | break; |
| 12335 | } |
| 12336 | } |
| 12337 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12338 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12339 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12340 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12341 | int driver_status; |
| 12342 | |
| 12343 | driver_status = hdd_ctx->driver_status; |
| 12344 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12345 | switch (curr_mode) { |
| 12346 | case QDF_GLOBAL_MISSION_MODE: |
| 12347 | case QDF_GLOBAL_MONITOR_MODE: |
| 12348 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12349 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12350 | hdd_close_all_adapters(hdd_ctx, false); |
| 12351 | break; |
| 12352 | case QDF_GLOBAL_EPPING_MODE: |
| 12353 | epping_disable(); |
| 12354 | epping_close(); |
| 12355 | break; |
| 12356 | default: |
| 12357 | return; |
| 12358 | } |
| 12359 | } |
| 12360 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12361 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12362 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12363 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12364 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12365 | int ret = 0; |
| 12366 | bool rtnl_held; |
| 12367 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12368 | QDF_STATUS status; |
| 12369 | |
| 12370 | if (!qdf_dev) { |
| 12371 | hdd_err("qdf device context is Null return!"); |
| 12372 | return -EINVAL; |
| 12373 | } |
| 12374 | |
| 12375 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12376 | switch (mode) { |
| 12377 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12378 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12379 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12380 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12381 | break; |
| 12382 | case QDF_GLOBAL_FTM_MODE: |
| 12383 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12384 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12385 | NET_NAME_UNKNOWN, rtnl_held); |
| 12386 | if (adapter == NULL) |
| 12387 | ret = -EINVAL; |
| 12388 | break; |
| 12389 | case QDF_GLOBAL_MONITOR_MODE: |
| 12390 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12391 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12392 | NET_NAME_UNKNOWN, rtnl_held); |
| 12393 | if (adapter == NULL) |
| 12394 | ret = -EINVAL; |
| 12395 | break; |
| 12396 | case QDF_GLOBAL_EPPING_MODE: |
| 12397 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12398 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12399 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12400 | ret = -EINVAL; |
| 12401 | break; |
| 12402 | } |
| 12403 | ret = epping_enable(qdf_dev->dev); |
| 12404 | if (ret) { |
| 12405 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12406 | epping_close(); |
| 12407 | } |
| 12408 | break; |
| 12409 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12410 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12411 | ret = -ENOTSUPP; |
| 12412 | break; |
| 12413 | } |
| 12414 | hdd_release_rtnl_lock(); |
| 12415 | rtnl_held = false; |
| 12416 | return ret; |
| 12417 | } |
| 12418 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12419 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12420 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12421 | * @kmessage: con mode name on which driver to be bring up |
| 12422 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12423 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12424 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12425 | * This function is invoked when user updates con mode using sys entry, |
| 12426 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12427 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12428 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12429 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12430 | static int __con_mode_handler(const char *kmessage, |
| 12431 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12432 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12433 | { |
| 12434 | int ret; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12435 | struct hdd_adapter *adapter; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12436 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12437 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12438 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12439 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12440 | hdd_info("con_mode handler: %s", kmessage); |
| 12441 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12442 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12443 | if (ret) |
| 12444 | return ret; |
| 12445 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12446 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12447 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12448 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12449 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12450 | if (ret) { |
| 12451 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12452 | goto reset_flags; |
| 12453 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12454 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12455 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12456 | if (!is_con_mode_valid(new_con_mode)) { |
| 12457 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12458 | ret = -EINVAL; |
| 12459 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12460 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12461 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12462 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12463 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12464 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12465 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12466 | ret = 0; |
| 12467 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12468 | } |
| 12469 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12470 | /* ensure adapters are stopped */ |
| 12471 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12472 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12473 | /* Cleanup present mode before switching to new mode */ |
| 12474 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12475 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12476 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12477 | if (ret) { |
| 12478 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12479 | goto reset_flags; |
| 12480 | } |
| 12481 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12482 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12483 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12484 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12485 | /* |
| 12486 | * Set ACTIVE domain before adapters created, otherwise check domain |
| 12487 | * match will fail when cleanup adapters. |
| 12488 | */ |
| 12489 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12490 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12491 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12492 | if (ret) { |
| 12493 | hdd_err("Failed to register for new mode"); |
| 12494 | goto reset_flags; |
| 12495 | } |
| 12496 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12497 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12498 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12499 | hdd_err("invalid adapter"); |
| 12500 | ret = -EINVAL; |
| 12501 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12502 | } |
| 12503 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12504 | adapter = hdd_get_adapter(hdd_ctx, adapter_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12505 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12506 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12507 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12508 | } |
| 12509 | |
| 12510 | ret = hdd_wlan_start_modules(hdd_ctx, adapter, false); |
| 12511 | if (ret) { |
| 12512 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12513 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12514 | } |
| 12515 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12516 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12517 | if (hdd_start_adapter(adapter)) { |
| 12518 | hdd_err("Failed to start %s adapter", kmessage); |
| 12519 | ret = -EINVAL; |
| 12520 | goto reset_flags; |
| 12521 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12522 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12523 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12524 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12525 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12526 | } |
| 12527 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12528 | /* con_mode is a global module parameter */ |
| 12529 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12530 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12531 | ret = 0; |
| 12532 | |
| 12533 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12534 | mutex_unlock(&hdd_init_deinit_lock); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12535 | cds_set_load_in_progress(false); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12536 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12537 | return ret; |
| 12538 | } |
| 12539 | |
| 12540 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12541 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12542 | { |
| 12543 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12544 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12545 | |
| 12546 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12547 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12548 | if (ret) |
| 12549 | return ret; |
| 12550 | |
| 12551 | cds_ssr_protect(__func__); |
| 12552 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12553 | cds_ssr_unprotect(__func__); |
| 12554 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12555 | return ret; |
| 12556 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12557 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12558 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12559 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12560 | { |
| 12561 | int ret; |
| 12562 | |
| 12563 | ret = param_set_int(kmessage, kp); |
| 12564 | |
| 12565 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12566 | pr_err("Only FTM mode supported!"); |
| 12567 | return -ENOTSUPP; |
| 12568 | } |
| 12569 | |
| 12570 | hdd_set_conparam(con_mode_ftm); |
| 12571 | con_mode = con_mode_ftm; |
| 12572 | |
| 12573 | return ret; |
| 12574 | } |
| 12575 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12576 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12577 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12578 | { |
| 12579 | int ret; |
| 12580 | |
| 12581 | ret = param_set_int(kmessage, kp); |
| 12582 | |
| 12583 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12584 | pr_err("Only Monitor mode supported!"); |
| 12585 | return -ENOTSUPP; |
| 12586 | } |
| 12587 | |
| 12588 | hdd_set_conparam(con_mode_monitor); |
| 12589 | con_mode = con_mode_monitor; |
| 12590 | |
| 12591 | return ret; |
| 12592 | } |
| 12593 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12594 | /** |
| 12595 | * hdd_get_conparam() - driver exit point |
| 12596 | * |
| 12597 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12598 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12599 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12600 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12601 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12602 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12603 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12604 | } |
| 12605 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12606 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12607 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12608 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12609 | } |
| 12610 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12611 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12612 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12613 | * @hdd_ctx: HDD context |
| 12614 | * |
| 12615 | * Cleans up the pre cac interface, if it exists |
| 12616 | * |
| 12617 | * Return: None |
| 12618 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12619 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12620 | { |
| 12621 | uint8_t session_id; |
| 12622 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12623 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12624 | |
| 12625 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12626 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12627 | hdd_err("failed to get pre cac vdev id"); |
| 12628 | return; |
| 12629 | } |
| 12630 | |
| 12631 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12632 | if (!precac_adapter) { |
| 12633 | hdd_err("invalid pre cac adapater"); |
| 12634 | return; |
| 12635 | } |
| 12636 | |
| 12637 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12638 | wlan_hdd_sap_pre_cac_failure, |
| 12639 | (void *)precac_adapter); |
| 12640 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12641 | |
| 12642 | } |
| 12643 | |
| 12644 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12645 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12646 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12647 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12648 | * Return: void |
| 12649 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12650 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12651 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12652 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12653 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12654 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12655 | if (!ol_ctx) |
| 12656 | return; |
| 12657 | |
| 12658 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12659 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12660 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12661 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12662 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12663 | |
| 12664 | ol_init_ini_config(ol_ctx, &cfg); |
| 12665 | } |
| 12666 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12667 | #ifdef FEATURE_RUNTIME_PM |
| 12668 | /** |
| 12669 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12670 | * @hdd_ctx: hdd context |
| 12671 | * @cfg: pointer to the configuration memory being populated |
| 12672 | * |
| 12673 | * Return: void |
| 12674 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12675 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12676 | struct hif_config_info *cfg) |
| 12677 | { |
| 12678 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12679 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12680 | } |
| 12681 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12682 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12683 | struct hif_config_info *cfg) |
| 12684 | { |
| 12685 | } |
| 12686 | #endif |
| 12687 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12688 | /** |
| 12689 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12690 | * @hdd_ctx: HDD Context |
| 12691 | * |
| 12692 | * Return: void |
| 12693 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12694 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12695 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12696 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12697 | struct hif_config_info cfg; |
| 12698 | |
| 12699 | if (!scn) |
| 12700 | return; |
| 12701 | |
| 12702 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12703 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12704 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12705 | |
| 12706 | if (hdd_ctx->config->prevent_link_down) |
| 12707 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12708 | } |
| 12709 | |
| 12710 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12711 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12712 | * datapath |
| 12713 | * @hdd_ctx: HDD Context |
| 12714 | * |
| 12715 | * Return: 0 for success/errno for failure |
| 12716 | */ |
| 12717 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12718 | { |
| 12719 | struct cdp_config_params params; |
| 12720 | QDF_STATUS status; |
| 12721 | |
| 12722 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12723 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12724 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12725 | params.tx_flow_stop_queue_threshold = |
| 12726 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12727 | params.tx_flow_start_queue_offset = |
| 12728 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12729 | #endif |
| 12730 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12731 | params.napi_enable = hdd_ctx->napi_enable; |
| 12732 | params.tcp_udp_checksumoffload = |
| 12733 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12734 | |
| 12735 | status = cdp_update_config_parameters( |
| 12736 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12737 | ¶ms); |
| 12738 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12739 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12740 | return status; |
| 12741 | } |
| 12742 | |
| 12743 | return 0; |
| 12744 | } |
| 12745 | |
| 12746 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12747 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12748 | * @hdd_ctx: HDD Context |
| 12749 | * |
| 12750 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12751 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12752 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12753 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12754 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12755 | int ret; |
| 12756 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12757 | hdd_update_ol_config(hdd_ctx); |
| 12758 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12759 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12760 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12761 | else |
| 12762 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12763 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12764 | |
| 12765 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12766 | } |
| 12767 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12768 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12769 | /** |
| 12770 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12771 | * @psoc_cfg: pmo psoc Configuration |
| 12772 | * @hdd_ctx: Pointer to hdd context |
| 12773 | * |
| 12774 | * Return: none |
| 12775 | */ |
| 12776 | static inline void hdd_ra_populate_pmo_config( |
| 12777 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12778 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12779 | { |
| 12780 | psoc_cfg->ra_ratelimit_interval = |
| 12781 | hdd_ctx->config->RArateLimitInterval; |
| 12782 | psoc_cfg->ra_ratelimit_enable = |
| 12783 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12784 | } |
| 12785 | #else |
| 12786 | static inline void hdd_ra_populate_pmo_config( |
| 12787 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12788 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12789 | { |
| 12790 | } |
| 12791 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12792 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12793 | /** |
| 12794 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12795 | * @hdd_ctx: HDD context |
| 12796 | * |
| 12797 | * Return: void |
| 12798 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12799 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12800 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12801 | struct pmo_psoc_cfg psoc_cfg; |
| 12802 | QDF_STATUS status; |
| 12803 | |
| 12804 | /* |
| 12805 | * Value of hdd_ctx->wowEnable can be, |
| 12806 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12807 | * 1 - Enable magic pattern match on all interfaces. |
| 12808 | * 2 - Enable pattern byte match on all interfaces. |
| 12809 | * 3 - Enable both magic patter and pattern byte match on |
| 12810 | * all interfaces. |
| 12811 | */ |
| 12812 | psoc_cfg.magic_ptrn_enable = |
| 12813 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12814 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12815 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12816 | psoc_cfg.ptrn_id_per_vdev = |
| 12817 | wma_is_service_enabled(wmi_service_unified_wow_capability); |
| 12818 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12819 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12820 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12821 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12822 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12823 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12824 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12825 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12826 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12827 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12828 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12829 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12830 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12831 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12832 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12833 | psoc_cfg.auto_power_save_fail_mode = |
| 12834 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12835 | |
| 12836 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12837 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12838 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12839 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12840 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 12841 | if (QDF_IS_STATUS_ERROR(status)) |
| 12842 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 12843 | |
| 12844 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12845 | } |
| 12846 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12847 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12848 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12849 | struct hdd_config *cfg) |
| 12850 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12851 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12852 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12853 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12854 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12855 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12856 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12857 | pno_cfg->channel_prediction_full_scan = |
| 12858 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12859 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12860 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12861 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12862 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12863 | } |
| 12864 | #else |
| 12865 | static inline void |
| 12866 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12867 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12868 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12869 | } |
| 12870 | #endif |
| 12871 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12872 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12873 | struct hdd_config *cfg) |
| 12874 | { |
| 12875 | uint8_t i = 0; |
| 12876 | |
| 12877 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12878 | if (!ie_whitelist->white_list) |
| 12879 | return; |
| 12880 | |
| 12881 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12882 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12883 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12884 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12885 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12886 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12887 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12888 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12889 | |
| 12890 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12891 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12892 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12893 | } |
| 12894 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12895 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12896 | { |
| 12897 | uint8_t i, score; |
| 12898 | |
| 12899 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 12900 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 12901 | if (score > MAX_INDEX_SCORE) |
| 12902 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 12903 | MAX_INDEX_SCORE, i); |
| 12904 | } |
| 12905 | |
| 12906 | return per_index_score; |
| 12907 | } |
| 12908 | |
| 12909 | /** |
| 12910 | * hdd_update_score_config - API to update candidate scoring related params |
| 12911 | * configuration parameters |
| 12912 | * @score_config: score config to update |
| 12913 | * @cfg: config params |
| 12914 | * |
| 12915 | * Return: 0 if success else err |
| 12916 | */ |
| 12917 | static void hdd_update_score_config( |
| 12918 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 12919 | { |
| 12920 | int total_weight; |
| 12921 | |
| 12922 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 12923 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 12924 | score_config->weight_cfg.vht_caps_weightage = |
| 12925 | cfg->vht_caps_weightage; |
| 12926 | score_config->weight_cfg.he_caps_weightage = |
| 12927 | cfg->he_caps_weightage; |
| 12928 | score_config->weight_cfg.chan_width_weightage = |
| 12929 | cfg->chan_width_weightage; |
| 12930 | score_config->weight_cfg.chan_band_weightage = |
| 12931 | cfg->chan_band_weightage; |
| 12932 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 12933 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12934 | cfg->beamforming_cap_weightage; |
| 12935 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 12936 | score_config->weight_cfg.channel_congestion_weightage = |
| 12937 | cfg->channel_congestion_weightage; |
| 12938 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 12939 | |
| 12940 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 12941 | score_config->weight_cfg.ht_caps_weightage + |
| 12942 | score_config->weight_cfg.vht_caps_weightage + |
| 12943 | score_config->weight_cfg.he_caps_weightage + |
| 12944 | score_config->weight_cfg.chan_width_weightage + |
| 12945 | score_config->weight_cfg.chan_band_weightage + |
| 12946 | score_config->weight_cfg.nss_weightage + |
| 12947 | score_config->weight_cfg.beamforming_cap_weightage + |
| 12948 | score_config->weight_cfg.pcl_weightage + |
| 12949 | score_config->weight_cfg.channel_congestion_weightage + |
| 12950 | score_config->weight_cfg.oce_wan_weightage; |
| 12951 | |
| 12952 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 12953 | hdd_err("total weight is greater than %d fallback to default values", |
| 12954 | BEST_CANDIDATE_MAX_WEIGHT); |
| 12955 | |
| 12956 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 12957 | score_config->weight_cfg.ht_caps_weightage = |
| 12958 | HT_CAPABILITY_WEIGHTAGE; |
| 12959 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 12960 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 12961 | score_config->weight_cfg.chan_width_weightage = |
| 12962 | CHAN_WIDTH_WEIGHTAGE; |
| 12963 | score_config->weight_cfg.chan_band_weightage = |
| 12964 | CHAN_BAND_WEIGHTAGE; |
| 12965 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 12966 | score_config->weight_cfg.beamforming_cap_weightage = |
| 12967 | BEAMFORMING_CAP_WEIGHTAGE; |
| 12968 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 12969 | score_config->weight_cfg.channel_congestion_weightage = |
| 12970 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 12971 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 12972 | } |
| 12973 | |
| 12974 | score_config->bandwidth_weight_per_index = |
| 12975 | hdd_limit_max_per_index_score( |
| 12976 | cfg->bandwidth_weight_per_index); |
| 12977 | score_config->nss_weight_per_index = |
| 12978 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 12979 | score_config->band_weight_per_index = |
| 12980 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 12981 | |
| 12982 | score_config->rssi_score.best_rssi_threshold = |
| 12983 | cfg->best_rssi_threshold; |
| 12984 | score_config->rssi_score.good_rssi_threshold = |
| 12985 | cfg->good_rssi_threshold; |
| 12986 | score_config->rssi_score.bad_rssi_threshold = |
| 12987 | cfg->bad_rssi_threshold; |
| 12988 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 12989 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 12990 | score_config->rssi_score.good_rssi_bucket_size = |
| 12991 | cfg->good_rssi_bucket_size; |
| 12992 | score_config->rssi_score.bad_rssi_bucket_size = |
| 12993 | cfg->bad_rssi_bucket_size; |
| 12994 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 12995 | cfg->rssi_pref_5g_rssi_thresh; |
| 12996 | |
| 12997 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 12998 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 12999 | hdd_limit_max_per_index_score( |
| 13000 | cfg->esp_qbss_score_slots3_to_0); |
| 13001 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13002 | hdd_limit_max_per_index_score( |
| 13003 | cfg->esp_qbss_score_slots7_to_4); |
| 13004 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13005 | hdd_limit_max_per_index_score( |
| 13006 | cfg->esp_qbss_score_slots11_to_8); |
| 13007 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13008 | hdd_limit_max_per_index_score( |
| 13009 | cfg->esp_qbss_score_slots15_to_12); |
| 13010 | |
| 13011 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13012 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13013 | hdd_limit_max_per_index_score( |
| 13014 | cfg->oce_wan_score_slots3_to_0); |
| 13015 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13016 | hdd_limit_max_per_index_score( |
| 13017 | cfg->oce_wan_score_slots7_to_4); |
| 13018 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13019 | hdd_limit_max_per_index_score( |
| 13020 | cfg->oce_wan_score_slots11_to_8); |
| 13021 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13022 | hdd_limit_max_per_index_score( |
| 13023 | cfg->oce_wan_score_slots15_to_12); |
| 13024 | |
| 13025 | |
| 13026 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13027 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13028 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13029 | |
| 13030 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13031 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13032 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13033 | score_config->he_cap = 1; |
| 13034 | |
| 13035 | if (score_config->he_cap || |
| 13036 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13037 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13038 | score_config->vht_cap = 1; |
| 13039 | |
| 13040 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13041 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13042 | score_config->ht_cap = 1; |
| 13043 | |
| 13044 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13045 | score_config->vht_24G_cap = 1; |
| 13046 | |
| 13047 | if (cfg->enableTxBF) |
| 13048 | score_config->beamformee_cap = 1; |
| 13049 | |
| 13050 | } |
| 13051 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13052 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13053 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13054 | * @hdd_ctx: HDD context |
| 13055 | * |
| 13056 | * Return: 0 if success else err |
| 13057 | */ |
| 13058 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13059 | { |
| 13060 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13061 | struct hdd_config *cfg = hdd_ctx->config; |
| 13062 | struct dfs_user_config dfs_cfg; |
| 13063 | QDF_STATUS status; |
| 13064 | |
| 13065 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13066 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13067 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13068 | hdd_err("failed dfs psoc configuration"); |
| 13069 | return -EINVAL; |
| 13070 | } |
| 13071 | |
| 13072 | return 0; |
| 13073 | } |
| 13074 | |
| 13075 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13076 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13077 | * @hdd_ctx: HDD context |
| 13078 | * |
| 13079 | * Return: 0 if success else err |
| 13080 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13081 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13082 | { |
| 13083 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13084 | struct scan_user_cfg scan_cfg; |
| 13085 | struct hdd_config *cfg = hdd_ctx->config; |
| 13086 | QDF_STATUS status; |
| 13087 | |
| 13088 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13089 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13090 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13091 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13092 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13093 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13094 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13095 | /* convert to ms */ |
| 13096 | scan_cfg.scan_cache_aging_time = |
| 13097 | cfg->scanAgingTimeout * 1000; |
| 13098 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13099 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13100 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13101 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13102 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13103 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13104 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13105 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13106 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13107 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13108 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13109 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13110 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13111 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13112 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13113 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13114 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13115 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13116 | if (status != QDF_STATUS_SUCCESS) { |
| 13117 | hdd_err("failed pmo psoc configuration"); |
| 13118 | return -EINVAL; |
| 13119 | } |
| 13120 | |
| 13121 | return 0; |
| 13122 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13123 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13124 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13125 | { |
| 13126 | int ret; |
| 13127 | |
| 13128 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13129 | if (ret) |
| 13130 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13131 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13132 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13133 | if (ret) |
| 13134 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13135 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13136 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13137 | if (ret) |
| 13138 | return ret; |
| 13139 | |
| 13140 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13141 | if (ret) |
| 13142 | return ret; |
| 13143 | |
| 13144 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13145 | |
| 13146 | return ret; |
| 13147 | } |
| 13148 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13149 | /** |
| 13150 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13151 | * @mode : cfg80211 DFS mode |
| 13152 | * |
| 13153 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13154 | */ |
| 13155 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13156 | { |
| 13157 | switch (mode) { |
| 13158 | case DFS_MODE_ENABLE: |
| 13159 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13160 | case DFS_MODE_DISABLE: |
| 13161 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13162 | case DFS_MODE_DEPRIORITIZE: |
| 13163 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13164 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13165 | hdd_debug("ACS dfs mode is NONE"); |
| 13166 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13167 | } |
| 13168 | } |
| 13169 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13170 | /** |
| 13171 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13172 | * @hddctx: pointer to hdd context |
| 13173 | * @set_value: enable/disable |
| 13174 | * |
| 13175 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13176 | * Host(even though it is duplicate). When Host send vendor command |
| 13177 | * disable,FW doesn't perform any action. Whenever any change in |
| 13178 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13179 | * |
| 13180 | * return - 0 on success, appropriate error values on failure. |
| 13181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13182 | 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] | 13183 | { |
| 13184 | QDF_STATUS status; |
| 13185 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13186 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13187 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13188 | |
| 13189 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13190 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13191 | return -EINVAL; |
| 13192 | } |
| 13193 | |
| 13194 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13195 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13196 | hdd_err("Failed to send chan avoid command to SME"); |
| 13197 | return -EINVAL; |
| 13198 | } |
| 13199 | return 0; |
| 13200 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13201 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13202 | /** |
| 13203 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13204 | * @value: value to set |
| 13205 | * |
| 13206 | * This function will set the passed value to roaming in progress flag. |
| 13207 | * |
| 13208 | * Return: None |
| 13209 | */ |
| 13210 | void hdd_set_roaming_in_progress(bool value) |
| 13211 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13212 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13213 | |
| 13214 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13215 | if (!hdd_ctx) { |
| 13216 | hdd_err("HDD context is NULL"); |
| 13217 | return; |
| 13218 | } |
| 13219 | |
| 13220 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13221 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13222 | } |
| 13223 | |
| 13224 | /** |
| 13225 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13226 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13227 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13228 | * 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] | 13229 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13230 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13231 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13232 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13233 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13234 | |
| 13235 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13236 | if (!hdd_ctx) { |
| 13237 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13238 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13239 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13240 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13241 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13242 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13243 | hdd_ctx->roaming_in_progress); |
| 13244 | |
| 13245 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13246 | } |
| 13247 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13248 | /** |
| 13249 | * hdd_is_connection_in_progress() - check if connection is in |
| 13250 | * progress |
| 13251 | * @session_id: session id |
| 13252 | * @reason: scan reject reason |
| 13253 | * |
| 13254 | * Go through each adapter and check if Connection is in progress |
| 13255 | * |
| 13256 | * Return: true if connection is in progress else false |
| 13257 | */ |
| 13258 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13259 | enum scan_reject_states *reason) |
| 13260 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13261 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13262 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13263 | uint8_t sta_id = 0; |
| 13264 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13265 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13266 | |
| 13267 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13268 | if (!hdd_ctx) { |
| 13269 | hdd_err("HDD context is NULL"); |
| 13270 | return false; |
| 13271 | } |
| 13272 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13273 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13274 | hdd_info("Adapter with device mode %s(%d) exists", |
| 13275 | hdd_device_mode_to_string(adapter->device_mode), |
| 13276 | adapter->device_mode); |
| 13277 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13278 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13279 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13280 | && (eConnectionState_Connecting == |
| 13281 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13282 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13283 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13284 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13285 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13286 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13287 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13288 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13289 | } |
| 13290 | return true; |
| 13291 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13292 | /* |
| 13293 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13294 | * hdd_is_roaming_in_progress is for LFR3 |
| 13295 | */ |
| 13296 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13297 | sme_neighbor_middle_of_roaming( |
| 13298 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13299 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13300 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13301 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13302 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13303 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13304 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13305 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13306 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13307 | } |
| 13308 | return true; |
| 13309 | } |
| 13310 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13311 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13312 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13313 | hdd_sta_ctx = |
| 13314 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13315 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13316 | hdd_sta_ctx->conn_info.connState) |
| 13317 | && sme_is_sta_key_exchange_in_progress( |
| 13318 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13319 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13320 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13321 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13322 | " is in middle of WPS/EAPOL exchange.", |
| 13323 | MAC_ADDR_ARRAY(sta_mac)); |
| 13324 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13325 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13326 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13327 | } |
| 13328 | return true; |
| 13329 | } |
| 13330 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13331 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13332 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13333 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13334 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13335 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13336 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13337 | continue; |
| 13338 | |
| 13339 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13340 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13341 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13342 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13343 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13344 | MAC_ADDR_ARRAY(sta_mac)); |
| 13345 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13346 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13347 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13348 | } |
| 13349 | return true; |
| 13350 | } |
| 13351 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13352 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13353 | return true; |
| 13354 | } |
| 13355 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13356 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13357 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13358 | return false; |
| 13359 | } |
| 13360 | |
| 13361 | /** |
| 13362 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13363 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13364 | * |
| 13365 | * Return: None |
| 13366 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13367 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13368 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13369 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13370 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13371 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13372 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13373 | tsap_Config_t *sap_config; |
| 13374 | void *sap_ctx; |
| 13375 | |
| 13376 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13377 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13378 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13379 | |
| 13380 | mutex_lock(&hdd_ctx->sap_lock); |
| 13381 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13382 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13383 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13384 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13385 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13386 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13387 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13388 | qdf_stop_bss_event, |
| 13389 | SME_CMD_TIMEOUT_VALUE); |
| 13390 | |
| 13391 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13392 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13393 | goto end; |
| 13394 | } |
| 13395 | } |
| 13396 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13397 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13398 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13399 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13400 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13401 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13402 | |
| 13403 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13404 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13405 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13406 | eUPDATE_IE_ALL); |
| 13407 | goto end; |
| 13408 | } |
| 13409 | |
| 13410 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13411 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13412 | sap_config, |
| 13413 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13414 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13415 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13416 | eUPDATE_IE_ALL); |
| 13417 | goto end; |
| 13418 | } |
| 13419 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13420 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13421 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13422 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13423 | SME_CMD_TIMEOUT_VALUE); |
| 13424 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13425 | eUPDATE_IE_ALL); |
| 13426 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13427 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13428 | goto end; |
| 13429 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13430 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13431 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13432 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13433 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13434 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13435 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13436 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13437 | ap_adapter->device_mode, |
| 13438 | true); |
| 13439 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13440 | } |
| 13441 | end: |
| 13442 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13443 | } |
| 13444 | |
| 13445 | /** |
| 13446 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13447 | * with non dfs acs |
| 13448 | * |
| 13449 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13450 | * |
| 13451 | * Return: None |
| 13452 | */ |
| 13453 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13454 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13455 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13456 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13457 | cds_context_type *cds_ctx; |
| 13458 | |
| 13459 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13460 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13461 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13462 | return; |
| 13463 | } |
| 13464 | |
| 13465 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13466 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13467 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13468 | return; |
| 13469 | } |
| 13470 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13471 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13472 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13473 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13474 | return; |
| 13475 | } |
| 13476 | |
| 13477 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13478 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13479 | &ap_adapter->event_flags) && |
| 13480 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13481 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13482 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13483 | 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] | 13484 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13485 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13486 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13487 | acs_cfg.acs_mode = true; |
| 13488 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13489 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13490 | } |
| 13491 | } |
| 13492 | |
| 13493 | /** |
| 13494 | * hdd_set_connection_in_progress() - to set the connection in |
| 13495 | * progress flag |
| 13496 | * @value: value to set |
| 13497 | * |
| 13498 | * This function will set the passed value to connection in progress flag. |
| 13499 | * If value is previously being set to true then no need to set it again. |
| 13500 | * |
| 13501 | * Return: true if value is being set correctly and false otherwise. |
| 13502 | */ |
| 13503 | bool hdd_set_connection_in_progress(bool value) |
| 13504 | { |
| 13505 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13506 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13507 | |
| 13508 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13509 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13510 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13511 | return false; |
| 13512 | } |
| 13513 | |
| 13514 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13515 | /* |
| 13516 | * if the value is set to true previously and if someone is |
| 13517 | * trying to make it true again then it could be some race |
| 13518 | * condition being triggered. Avoid this situation by returning |
| 13519 | * false |
| 13520 | */ |
| 13521 | if (hdd_ctx->connection_in_progress && value) |
| 13522 | status = false; |
| 13523 | else |
| 13524 | hdd_ctx->connection_in_progress = value; |
| 13525 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13526 | return status; |
| 13527 | } |
| 13528 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13529 | 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] | 13530 | { |
| 13531 | if (!adapter) { |
| 13532 | hdd_err("Invalid adapter"); |
| 13533 | return -EINVAL; |
| 13534 | } |
| 13535 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13536 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13537 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13538 | set_value, VDEV_CMD); |
| 13539 | return 0; |
| 13540 | |
| 13541 | } |
| 13542 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13543 | 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] | 13544 | { |
| 13545 | if (!adapter) { |
| 13546 | hdd_err("Invalid adapter"); |
| 13547 | return -EINVAL; |
| 13548 | } |
| 13549 | |
| 13550 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13551 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13552 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13553 | set_value, VDEV_CMD); |
| 13554 | return 0; |
| 13555 | } |
| 13556 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13557 | 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] | 13558 | *psoc, uint8_t vdev_id) |
| 13559 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13560 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13561 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13562 | |
| 13563 | /* |
| 13564 | * Currently PSOC is not being used. But this logic will |
| 13565 | * change once we have the converged implementation of |
| 13566 | * HDD context per PSOC in place. This would break if |
| 13567 | * multiple vdev objects reuse the vdev id. |
| 13568 | */ |
| 13569 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13570 | if (!adapter) |
| 13571 | hdd_err("Get adapter by vdev id failed"); |
| 13572 | |
| 13573 | return adapter; |
| 13574 | } |
| 13575 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13576 | 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] | 13577 | int8_t *rssi, int8_t *snr) |
| 13578 | { |
| 13579 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13580 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13581 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13582 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13583 | status = sme_get_rssi_snr_by_bssid(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13584 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13585 | if (QDF_STATUS_SUCCESS != status) { |
| 13586 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13587 | return -EINVAL; |
| 13588 | } |
| 13589 | |
| 13590 | return 0; |
| 13591 | } |
| 13592 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13593 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13594 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13595 | * @adapter - HDD adapter |
| 13596 | * @tos - type of service |
| 13597 | * @status - status of the traffic |
| 13598 | * |
| 13599 | * Return: 0 on success and non zero value on failure |
| 13600 | */ |
| 13601 | |
| 13602 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13603 | bool is_tos_active) |
| 13604 | { |
| 13605 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13606 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13607 | uint32_t max_off_chan_time = 0; |
| 13608 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13609 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13610 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13611 | |
| 13612 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13613 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13614 | |
| 13615 | if (ret < 0) { |
| 13616 | hdd_err("failed to set limit off chan params"); |
| 13617 | return ret; |
| 13618 | } |
| 13619 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13620 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13621 | |
| 13622 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13623 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13624 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13625 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13626 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13627 | if (adapter->active_ac) { |
| 13628 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13629 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13630 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13631 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13632 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13633 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13634 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13635 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13636 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13637 | PM_LATENCY); |
| 13638 | } else { |
| 13639 | /*ignore this command if only BE/BK is active */ |
| 13640 | is_tos_active = false; |
| 13641 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13642 | hdd_ctx->config->conc_system_pref); |
| 13643 | } |
| 13644 | } else { |
| 13645 | /* No active tos */ |
| 13646 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13647 | hdd_ctx->config->conc_system_pref); |
| 13648 | } |
| 13649 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13650 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13651 | is_tos_active, max_off_chan_time, |
| 13652 | hdd_ctx->config->nRestTimeConc, true); |
| 13653 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13654 | hdd_err("failed to set limit off chan params"); |
| 13655 | ret = -EINVAL; |
| 13656 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13657 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13658 | return ret; |
| 13659 | } |
| 13660 | |
| 13661 | /** |
| 13662 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13663 | * @adapter - HDD adapter |
| 13664 | * |
| 13665 | * Return: 0 on success and non zero value on failure |
| 13666 | */ |
| 13667 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13668 | { |
| 13669 | struct hdd_context *hdd_ctx; |
| 13670 | int ret; |
| 13671 | QDF_STATUS status; |
| 13672 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13673 | |
| 13674 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13675 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13676 | if (ret < 0) |
| 13677 | return ret; |
| 13678 | |
| 13679 | /* set the system preferece to default */ |
| 13680 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13681 | hdd_ctx->config->conc_system_pref); |
| 13682 | |
| 13683 | /* clear the bitmap */ |
| 13684 | adapter->active_ac = 0; |
| 13685 | |
| 13686 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13687 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13688 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13689 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13690 | false, 0, 0, false); |
| 13691 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13692 | hdd_err("failed to reset limit off chan params"); |
| 13693 | ret = -EINVAL; |
| 13694 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13695 | |
| 13696 | return ret; |
| 13697 | } |
| 13698 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13699 | /** |
| 13700 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13701 | * @drv_op: Enum indicating driver op |
| 13702 | * |
| 13703 | * Return: none |
| 13704 | */ |
| 13705 | void hdd_start_driver_ops_timer(int drv_op) |
| 13706 | { |
| 13707 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13708 | switch (drv_op) { |
| 13709 | case eHDD_DRV_OP_PROBE: |
| 13710 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13711 | break; |
| 13712 | case eHDD_DRV_OP_REMOVE: |
| 13713 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13714 | break; |
| 13715 | case eHDD_DRV_OP_SHUTDOWN: |
| 13716 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13717 | break; |
| 13718 | case eHDD_DRV_OP_REINIT: |
| 13719 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13720 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13721 | case eHDD_DRV_OP_IFF_UP: |
| 13722 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13723 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13724 | } |
| 13725 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13726 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13727 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13728 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13729 | } |
| 13730 | |
| 13731 | /** |
| 13732 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13733 | * |
| 13734 | * Return: none |
| 13735 | */ |
| 13736 | void hdd_stop_driver_ops_timer(void) |
| 13737 | { |
| 13738 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13739 | } |
| 13740 | |
| 13741 | /** |
| 13742 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13743 | * inactivity timer |
| 13744 | * |
| 13745 | * Return: None |
| 13746 | */ |
| 13747 | void hdd_drv_ops_inactivity_handler(void) |
| 13748 | { |
| 13749 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13750 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13751 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13752 | if (hdd_drv_ops_task) { |
| 13753 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13754 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13755 | } else { |
| 13756 | hdd_err("hdd_drv_ops_task is null"); |
| 13757 | } |
| 13758 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13759 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13760 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13761 | sizeof("shutdown"))) |
| 13762 | QDF_BUG(0); |
| 13763 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13764 | if (cds_is_fw_down()) { |
| 13765 | hdd_err("FW is down"); |
| 13766 | return; |
| 13767 | } |
| 13768 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13769 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13770 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13771 | else |
| 13772 | QDF_BUG(0); |
| 13773 | } |
| 13774 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13775 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13776 | { |
| 13777 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13778 | |
| 13779 | if (!hdd_ctx) |
| 13780 | return; |
| 13781 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13782 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13783 | } |
| 13784 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13785 | /** |
| 13786 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13787 | * @struct hdd_context *hdd_ctx |
| 13788 | * @struct hdd_adapter *padapter |
| 13789 | * @bool enble |
| 13790 | * |
| 13791 | * Return: none |
| 13792 | */ |
| 13793 | void hdd_set_rx_mode_rps(bool enable) |
| 13794 | { |
| 13795 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
| 13796 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13797 | struct hdd_adapter *adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13798 | |
| 13799 | if (adapter && hdd_ctx && |
| 13800 | !hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
| 13801 | if (enable && !cds_cfg->rps_enabled) |
| 13802 | hdd_send_rps_ind(adapter); |
| 13803 | else if (!enable && cds_cfg->rps_enabled) |
| 13804 | hdd_send_rps_disable_ind(adapter); |
| 13805 | } |
| 13806 | } |
| 13807 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13808 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13809 | { |
| 13810 | struct hdd_adapter *adapter = NULL; |
| 13811 | |
| 13812 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 13813 | if ((adapter->device_mode == QDF_STA_MODE || |
| 13814 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 13815 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 13816 | &adapter->event_flags)){ |
| 13817 | return true; |
| 13818 | } |
| 13819 | } |
| 13820 | |
| 13821 | return false; |
| 13822 | } |
| 13823 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13824 | /* Register the module init/exit functions */ |
| 13825 | module_init(hdd_module_init); |
| 13826 | module_exit(hdd_module_exit); |
| 13827 | |
| 13828 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13829 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13830 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13831 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13832 | static const struct kernel_param_ops con_mode_ops = { |
| 13833 | .set = con_mode_handler, |
| 13834 | .get = param_get_int, |
| 13835 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13836 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13837 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 13838 | .set = con_mode_handler_ftm, |
| 13839 | .get = param_get_int, |
| 13840 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13841 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13842 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 13843 | .set = con_mode_handler_monitor, |
| 13844 | .get = param_get_int, |
| 13845 | }; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13846 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13847 | static const struct kernel_param_ops fwpath_ops = { |
| 13848 | .set = fwpath_changed_handler, |
| 13849 | .get = param_get_string, |
| 13850 | }; |
| 13851 | |
| 13852 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 13853 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13854 | |
| 13855 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 13856 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13857 | |
| 13858 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 13859 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13860 | |
| 13861 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 13862 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13863 | |
| 13864 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13865 | |
| 13866 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13867 | |
| 13868 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |