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 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | /** |
| 20 | * DOC: wlan_hdd_main.c |
| 21 | * |
| 22 | * WLAN Host Device Driver implementation |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* Include Files */ |
| 27 | #include <wlan_hdd_includes.h> |
| 28 | #include <cds_api.h> |
| 29 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 30 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 31 | #include <linux/etherdevice.h> |
| 32 | #include <linux/firmware.h> |
| 33 | #include <wlan_hdd_tx_rx.h> |
| 34 | #include <wni_api.h> |
| 35 | #include <wlan_hdd_cfg.h> |
| 36 | #include <wlan_ptt_sock_svc.h> |
| 37 | #include <dbglog_host.h> |
| 38 | #include <wlan_logging_sock_svc.h> |
| 39 | #include <wlan_hdd_wowl.h> |
| 40 | #include <wlan_hdd_misc.h> |
| 41 | #include <wlan_hdd_wext.h> |
| 42 | #include "wlan_hdd_trace.h" |
| 43 | #include "wlan_hdd_ioctl.h" |
| 44 | #include "wlan_hdd_ftm.h" |
| 45 | #include "wlan_hdd_power.h" |
| 46 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 47 | #include "wlan_hdd_scan.h" |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 48 | #include "wlan_hdd_request_manager.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 49 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 50 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 51 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 52 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 53 | #include "qdf_str.h" |
| 54 | #include "qdf_trace.h" |
| 55 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 56 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 57 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 58 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 59 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 60 | |
| 61 | #include <net/addrconf.h> |
| 62 | #include <linux/wireless.h> |
| 63 | #include <net/cfg80211.h> |
| 64 | #include <linux/inetdevice.h> |
| 65 | #include <net/addrconf.h> |
| 66 | #include "wlan_hdd_cfg80211.h" |
| 67 | #include "wlan_hdd_ext_scan.h" |
| 68 | #include "wlan_hdd_p2p.h" |
| 69 | #include <linux/rtnetlink.h> |
| 70 | #include "sap_api.h" |
| 71 | #include <linux/semaphore.h> |
| 72 | #include <linux/ctype.h> |
| 73 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 74 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 75 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | #include <soc/qcom/subsystem_restart.h> |
| 77 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 78 | #include <wlan_hdd_hostapd.h> |
| 79 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 80 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 81 | #include "cfg_api.h" |
| 82 | #include "qwlan_version.h" |
| 83 | #include "wma_types.h" |
| 84 | #include "wlan_hdd_tdls.h" |
| 85 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 86 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 87 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 88 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 89 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 90 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #include "wlan_hdd_nan.h" |
| 92 | #include "wlan_hdd_debugfs.h" |
| 93 | #include "wlan_hdd_driver_ops.h" |
| 94 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 95 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 96 | |
| 97 | #include <wlan_hdd_ipa.h> |
| 98 | #include "hif.h" |
| 99 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 100 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 101 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 102 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 103 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 104 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 105 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 106 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 107 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 108 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 109 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 110 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 111 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 112 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 113 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 114 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 115 | #include "os_if_wifi_pos.h" |
| 116 | #include "wifi_pos_api.h" |
| 117 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 118 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 119 | #include "os_if_nan.h" |
| 120 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 121 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 122 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 123 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 124 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 125 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 126 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 127 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 128 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 129 | #include "wlan_disa_obj_mgmt_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 130 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 131 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 132 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 133 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 134 | #ifdef CNSS_GENL |
| 135 | #include <net/cnss_nl.h> |
| 136 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 137 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 138 | #include "wlan_ocb_ucfg_api.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 139 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 140 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 141 | #ifdef MODULE |
| 142 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 143 | #else |
| 144 | #define WLAN_MODULE_NAME "wlan" |
| 145 | #endif |
| 146 | |
| 147 | #ifdef TIMER_MANAGER |
| 148 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 149 | #else |
| 150 | #define TIMER_MANAGER_STR "" |
| 151 | #endif |
| 152 | |
| 153 | #ifdef MEMORY_DEBUG |
| 154 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 155 | #else |
| 156 | #define MEMORY_DEBUG_STR "" |
| 157 | #endif |
| 158 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 159 | #ifdef PANIC_ON_BUG |
| 160 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 161 | #else |
| 162 | #define PANIC_ON_BUG_STR "" |
| 163 | #endif |
| 164 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 165 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 166 | int wlan_start_ret_val; |
| 167 | static DECLARE_COMPLETION(wlan_start_comp); |
| 168 | static unsigned int dev_num = 1; |
| 169 | static struct cdev wlan_hdd_state_cdev; |
| 170 | static struct class *class; |
| 171 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 172 | #ifndef MODULE |
| 173 | static struct gwlan_loader *wlan_loader; |
| 174 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 175 | struct kobj_attribute *attr, |
| 176 | const char *buf, size_t count); |
| 177 | struct gwlan_loader { |
| 178 | bool loaded_state; |
| 179 | struct kobject *boot_wlan_obj; |
| 180 | struct attribute_group *attr_group; |
| 181 | }; |
| 182 | |
| 183 | static struct kobj_attribute wlan_boot_attribute = |
| 184 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 185 | |
| 186 | static struct attribute *attrs[] = { |
| 187 | &wlan_boot_attribute.attr, |
| 188 | NULL, |
| 189 | }; |
| 190 | |
| 191 | #define MODULE_INITIALIZED 1 |
| 192 | #endif |
| 193 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 194 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 195 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 196 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 197 | |
| 198 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 199 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 200 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 201 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 202 | /* the Android framework expects this param even though we don't use it */ |
| 203 | #define BUF_LEN 20 |
| 204 | static char fwpath_buffer[BUF_LEN]; |
| 205 | static struct kparam_string fwpath = { |
| 206 | .string = fwpath_buffer, |
| 207 | .maxlen = BUF_LEN, |
| 208 | }; |
| 209 | |
| 210 | static char *country_code; |
| 211 | static int enable_11d = -1; |
| 212 | static int enable_dfs_chan_scan = -1; |
| 213 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 214 | /* |
| 215 | * spinlock for synchronizing asynchronous request/response |
| 216 | * (full description of use in wlan_hdd_main.h) |
| 217 | */ |
| 218 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 219 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 220 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 221 | #define WLAN_NLINK_CESIUM 30 |
| 222 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 223 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 224 | |
| 225 | #define WOW_MAX_FILTER_LISTS 1 |
| 226 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 227 | #define WOW_MIN_PATTERN_SIZE 6 |
| 228 | #define WOW_MAX_PATTERN_SIZE 64 |
| 229 | |
| 230 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 231 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 232 | .flags = WIPHY_WOWLAN_ANY | |
| 233 | WIPHY_WOWLAN_MAGIC_PKT | |
| 234 | WIPHY_WOWLAN_DISCONNECT | |
| 235 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 236 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 237 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 238 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 239 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 240 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 241 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 242 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 243 | }; |
| 244 | #endif |
| 245 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 246 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 247 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 259 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 260 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 261 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 262 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 263 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 281 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 282 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 283 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 284 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 285 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 286 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 287 | }; |
| 288 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 289 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 290 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 291 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 292 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 293 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 294 | }; |
| 295 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 296 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 297 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 298 | |
| 299 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 300 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 301 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 302 | #endif |
| 303 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 304 | void hdd_start_complete(int ret) |
| 305 | { |
| 306 | wlan_start_ret_val = ret; |
| 307 | |
| 308 | complete(&wlan_start_comp); |
| 309 | } |
| 310 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 311 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 312 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 313 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 314 | * |
| 315 | * Return: none |
| 316 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 317 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 318 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 319 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 320 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 321 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 322 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 327 | * @vdev_id: vdev_id |
| 328 | * @action: action type |
| 329 | * @reason: reason type |
| 330 | * |
| 331 | * Return: none |
| 332 | */ |
| 333 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 334 | enum netif_action_type action, enum netif_reason_type reason) |
| 335 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 336 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 337 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 338 | |
| 339 | if (!hdd_ctx) { |
| 340 | hdd_err("hdd ctx is NULL"); |
| 341 | return; |
| 342 | } |
| 343 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 344 | |
| 345 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 349 | * Store WLAN driver version and timestamp info in global variables such that |
| 350 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 351 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 352 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 353 | #ifdef BUILD_TAG |
| 354 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 355 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 356 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 357 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 358 | |
| 359 | /** |
| 360 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 361 | * @device_mode: device mode |
| 362 | * |
| 363 | * This utility function helps log string conversion of device mode. |
| 364 | * |
| 365 | * Return: string conversion of device mode, if match found; |
| 366 | * "Unknown" otherwise. |
| 367 | */ |
| 368 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 369 | { |
| 370 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 371 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 372 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 373 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 374 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 375 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 376 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 377 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 378 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 379 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 380 | default: |
| 381 | return "Unknown"; |
| 382 | } |
| 383 | } |
| 384 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 385 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 386 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 387 | * @hdd_ctx: HDD context |
| 388 | * @chan_list: buf hold returned chan list |
| 389 | * @chan_num: input buf size and output returned chan num |
| 390 | * |
| 391 | * This function helps get current available chan list from regulatory |
| 392 | * module. It excludes the "disabled" and "invalid" channels. |
| 393 | * |
| 394 | * Return: 0 for success. |
| 395 | */ |
| 396 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 397 | uint8_t *chan_list, |
| 398 | uint32_t *chan_num) |
| 399 | { |
| 400 | int i = 0, j = 0; |
| 401 | struct regulatory_channel *cur_chan_list; |
| 402 | struct wlan_objmgr_pdev *pdev; |
| 403 | |
| 404 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 405 | return -EINVAL; |
| 406 | |
| 407 | pdev = hdd_ctx->hdd_pdev; |
| 408 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 409 | sizeof(struct regulatory_channel)); |
| 410 | if (!cur_chan_list) |
| 411 | return -ENOMEM; |
| 412 | |
| 413 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 414 | QDF_STATUS_SUCCESS) { |
| 415 | qdf_mem_free(cur_chan_list); |
| 416 | return -EINVAL; |
| 417 | } |
| 418 | |
| 419 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 420 | uint32_t ch = cur_chan_list[i].chan_num; |
| 421 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 422 | ch); |
| 423 | |
| 424 | if (state != CHANNEL_STATE_DISABLE && |
| 425 | state != CHANNEL_STATE_INVALID && |
| 426 | j < *chan_num) { |
| 427 | chan_list[j] = (uint8_t)ch; |
| 428 | j++; |
| 429 | } |
| 430 | } |
| 431 | *chan_num = j; |
| 432 | qdf_mem_free(cur_chan_list); |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 437 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 438 | * @adapter: HDD adapter |
| 439 | * @chan_number: Channel number |
| 440 | * @chan_bw: Bandwidth |
| 441 | * |
| 442 | * Checks if the given bandwidth is valid for the given channel number. |
| 443 | * |
| 444 | * Return: 0 for success, non-zero for failure |
| 445 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 446 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 447 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 448 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 449 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 450 | uint8_t chan[NUM_CHANNELS]; |
| 451 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 452 | bool found = false; |
| 453 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 454 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 455 | |
| 456 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 457 | if (!hal) { |
| 458 | hdd_err("Invalid HAL context"); |
| 459 | return -EINVAL; |
| 460 | } |
| 461 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 462 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 463 | &len); |
| 464 | if (ret) { |
| 465 | hdd_err("error %d in getting valid channel list", ret); |
| 466 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | for (i = 0; i < len; i++) { |
| 470 | if (chan[i] == chan_number) { |
| 471 | found = true; |
| 472 | break; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | if (found == false) { |
| 477 | hdd_err("Channel not in driver's valid channel list"); |
| 478 | return -EOPNOTSUPP; |
| 479 | } |
| 480 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 481 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 482 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 483 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 484 | return -EINVAL; |
| 485 | } |
| 486 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 487 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 488 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 489 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 490 | return -EINVAL; |
| 491 | } |
| 492 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 493 | (chan_bw != CH_WIDTH_MAX)) { |
| 494 | hdd_err("Only BW20 possible on channel 14"); |
| 495 | return -EINVAL; |
| 496 | } |
| 497 | } |
| 498 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 499 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 500 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 501 | (chan_bw != CH_WIDTH_MAX)) { |
| 502 | hdd_err("Only BW20 possible on channel 165"); |
| 503 | return -EINVAL; |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 510 | /** |
| 511 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 512 | * |
| 513 | * Block the unloading of the driver (or) interface up until the |
| 514 | * cds recovery is completed |
| 515 | * |
| 516 | * Return: true for recovery completion else false |
| 517 | */ |
| 518 | static bool hdd_wait_for_recovery_completion(void) |
| 519 | { |
| 520 | int retry = 0; |
| 521 | |
| 522 | /* Wait for recovery to complete */ |
| 523 | while (cds_is_driver_recovering()) { |
| 524 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 525 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 526 | |
| 527 | if (g_is_system_reboot_triggered) { |
| 528 | hdd_info("System Reboot happening ignore unload!!"); |
| 529 | return false; |
| 530 | } |
| 531 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 532 | msleep(1000); |
| 533 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 534 | hdd_err("SSR never completed, error"); |
| 535 | /* |
| 536 | * Trigger the bug_on in the internal builds, in the |
| 537 | * customer builds self-recovery will be enabled |
| 538 | * in those cases just return error. |
| 539 | */ |
| 540 | if (cds_is_self_recovery_enabled()) |
| 541 | return false; |
| 542 | QDF_BUG(0); |
| 543 | } |
| 544 | } |
| 545 | |
| 546 | hdd_info("Recovery completed successfully!"); |
| 547 | return true; |
| 548 | } |
| 549 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 550 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 551 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 552 | unsigned long state, void *data) |
| 553 | { |
| 554 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 555 | struct netdev_notifier_info *dev_notif_info = data; |
| 556 | struct net_device *dev = dev_notif_info->dev; |
| 557 | #else |
| 558 | struct net_device *dev = data; |
| 559 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 560 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 561 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 562 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 563 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 564 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 565 | /* Make sure that this callback corresponds to our device. */ |
| 566 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 567 | return NOTIFY_DONE; |
| 568 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 569 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 571 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 572 | return NOTIFY_DONE; |
| 573 | } |
| 574 | |
| 575 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 576 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | return NOTIFY_DONE; |
| 578 | } |
| 579 | |
| 580 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 581 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 582 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 583 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | return NOTIFY_DONE; |
| 585 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 586 | |
| 587 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 588 | hdd_err("%s: Driver module is closed", __func__); |
| 589 | return NOTIFY_DONE; |
| 590 | } |
| 591 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 592 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 593 | return NOTIFY_DONE; |
| 594 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 595 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 596 | dev->name, state); |
| 597 | |
| 598 | switch (state) { |
| 599 | case NETDEV_REGISTER: |
| 600 | break; |
| 601 | |
| 602 | case NETDEV_UNREGISTER: |
| 603 | break; |
| 604 | |
| 605 | case NETDEV_UP: |
| 606 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 607 | break; |
| 608 | |
| 609 | case NETDEV_DOWN: |
| 610 | break; |
| 611 | |
| 612 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 613 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 614 | complete(&adapter->linkup_event_var); |
| 615 | break; |
| 616 | |
| 617 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 618 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 619 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 620 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 621 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 622 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 623 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 624 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 625 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 626 | /* |
| 627 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 628 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 629 | * flag after which driver does not send the cfg80211_scan_done. |
| 630 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 631 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 632 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 633 | break; |
| 634 | |
| 635 | default: |
| 636 | break; |
| 637 | } |
| 638 | |
| 639 | return NOTIFY_DONE; |
| 640 | } |
| 641 | |
| 642 | /** |
| 643 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 644 | * @nb: pointer to notifier block |
| 645 | * @state: state |
| 646 | * @ndev: ndev pointer |
| 647 | * |
| 648 | * Return: 0 on success, error number otherwise. |
| 649 | */ |
| 650 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 651 | unsigned long state, |
| 652 | void *ndev) |
| 653 | { |
| 654 | int ret; |
| 655 | |
| 656 | cds_ssr_protect(__func__); |
| 657 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 658 | cds_ssr_unprotect(__func__); |
| 659 | |
| 660 | return ret; |
| 661 | } |
| 662 | |
| 663 | struct notifier_block hdd_netdev_notifier = { |
| 664 | .notifier_call = hdd_netdev_notifier_call, |
| 665 | }; |
| 666 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 667 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 668 | unsigned long msg_type, void *_unused) |
| 669 | { |
| 670 | switch (msg_type) { |
| 671 | case SYS_DOWN: |
| 672 | case SYS_HALT: |
| 673 | case SYS_POWER_OFF: |
| 674 | g_is_system_reboot_triggered = true; |
| 675 | hdd_info("reboot, reason: %ld", msg_type); |
| 676 | break; |
| 677 | default: |
| 678 | break; |
| 679 | } |
| 680 | |
| 681 | return NOTIFY_OK; |
| 682 | } |
| 683 | |
| 684 | struct notifier_block system_reboot_notifier = { |
| 685 | .notifier_call = system_reboot_notifier_call, |
| 686 | }; |
| 687 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 688 | /* variable to hold the insmod parameters */ |
| 689 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 690 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 691 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 692 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 693 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 694 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 695 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 696 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 697 | /** |
| 698 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 699 | * @ch_width: NL channel width |
| 700 | * |
| 701 | * Converts the NL channel width to the driver's internal representation |
| 702 | * |
| 703 | * Return: Converted channel width. In case of non matching NL channel width, |
| 704 | * CH_WIDTH_MAX will be returned. |
| 705 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 706 | 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] | 707 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 708 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 709 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 710 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 711 | switch (ch_width) { |
| 712 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 713 | case NL80211_CHAN_WIDTH_20: |
| 714 | return CH_WIDTH_20MHZ; |
| 715 | case NL80211_CHAN_WIDTH_40: |
| 716 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 717 | case NL80211_CHAN_WIDTH_80: |
| 718 | return CH_WIDTH_80MHZ; |
| 719 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 720 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 721 | return CH_WIDTH_80P80MHZ; |
| 722 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 723 | return CH_WIDTH_160MHZ; |
| 724 | else |
| 725 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 726 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 727 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 728 | return CH_WIDTH_160MHZ; |
| 729 | else |
| 730 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 731 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 732 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 733 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 734 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 735 | default: |
| 736 | hdd_err("Invalid channel width %d, setting to default", |
| 737 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 738 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 739 | } |
| 740 | } |
| 741 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 742 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 743 | * @hal: handler to HAL |
| 744 | * @channel: channel id |
| 745 | * @bw_offset: bandwidth offset |
| 746 | * |
| 747 | * Function invokes sme api to find the operating class |
| 748 | * |
| 749 | * Return: operating class |
| 750 | */ |
| 751 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 752 | uint8_t bw_offset) |
| 753 | { |
| 754 | uint8_t opclass = 0; |
| 755 | |
| 756 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 757 | return opclass; |
| 758 | } |
| 759 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 760 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 761 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 762 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 763 | * @bitmask: Bitmask of log levels to be enabled |
| 764 | * |
| 765 | * Called immediately after the cfg.ini is read in order to configure |
| 766 | * the desired trace levels. |
| 767 | * |
| 768 | * Return: None |
| 769 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 770 | 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] | 771 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 772 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 773 | int qdf_print_idx = -1; |
| 774 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 775 | /* |
| 776 | * if the bitmask is the default value, then a bitmask was not |
| 777 | * specified in cfg.ini, so leave the logging level alone (it |
| 778 | * will remain at the "compiled in" default value) |
| 779 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 780 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 781 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 782 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 783 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 785 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 786 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 787 | QDF_TRACE_LEVEL_NONE, 0); |
| 788 | |
| 789 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 790 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 791 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 792 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | while (0 != bitmask) { |
| 794 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 795 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 796 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 797 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 798 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 799 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 800 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 801 | level++; |
| 802 | bitmask >>= 1; |
| 803 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 804 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 808 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 809 | * @hdd_ctx: HDD context pointer |
| 810 | * |
| 811 | * Return: 0 if the context is valid. Error code otherwise |
| 812 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 813 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 814 | { |
| 815 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 816 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 817 | return -ENODEV; |
| 818 | } |
| 819 | |
| 820 | if (cds_is_driver_recovering()) { |
| 821 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 822 | (void *)_RET_IP_, cds_get_driver_state()); |
| 823 | return -EAGAIN; |
| 824 | } |
| 825 | |
| 826 | if (hdd_ctx->start_modules_in_progress || |
| 827 | hdd_ctx->stop_modules_in_progress) { |
| 828 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 829 | (void *)_RET_IP_); |
| 830 | return -EAGAIN; |
| 831 | } |
| 832 | |
| 833 | return 0; |
| 834 | } |
| 835 | |
| 836 | |
| 837 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 838 | * wlan_hdd_validate_context() - check the HDD context |
| 839 | * @hdd_ctx: HDD context pointer |
| 840 | * |
| 841 | * Return: 0 if the context is valid. Error code otherwise |
| 842 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 843 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 845 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 846 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 847 | return -ENODEV; |
| 848 | } |
| 849 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 850 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 851 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 852 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 853 | return -EAGAIN; |
| 854 | } |
| 855 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 856 | if (cds_is_load_or_unload_in_progress()) { |
| 857 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 858 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 860 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 861 | |
| 862 | if (hdd_ctx->start_modules_in_progress || |
| 863 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 864 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 865 | (void *)_RET_IP_); |
| 866 | return -EAGAIN; |
| 867 | } |
| 868 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 869 | if (cds_is_driver_in_bad_state()) { |
| 870 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 871 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 872 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 873 | } |
| 874 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 875 | if (cds_is_fw_down()) { |
| 876 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 877 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 878 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 879 | } |
| 880 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 881 | return 0; |
| 882 | } |
| 883 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 884 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 885 | { |
| 886 | if (!adapter) { |
| 887 | hdd_err("adapter is null"); |
| 888 | return -EINVAL; |
| 889 | } |
| 890 | |
| 891 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 892 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 893 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 894 | return -EINVAL; |
| 895 | } |
| 896 | |
| 897 | if (!adapter->dev) { |
| 898 | hdd_err("adapter net_device is null"); |
| 899 | return -EINVAL; |
| 900 | } |
| 901 | |
| 902 | if (!(adapter->dev->flags & IFF_UP)) { |
| 903 | hdd_info("adapter net_device is not up"); |
| 904 | return -EAGAIN; |
| 905 | } |
| 906 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 907 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 908 | hdd_info("adapter session is not open"); |
| 909 | return -EAGAIN; |
| 910 | } |
| 911 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 912 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 913 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 914 | return -EINVAL; |
| 915 | } |
| 916 | |
| 917 | return 0; |
| 918 | } |
| 919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 920 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 921 | * wlan_hdd_validate_modules_state() - Check modules status |
| 922 | * @hdd_ctx: HDD context pointer |
| 923 | * |
| 924 | * Check's the driver module's state and returns true if the |
| 925 | * modules are enabled returns false if modules are closed. |
| 926 | * |
| 927 | * Return: True if modules are enabled or false. |
| 928 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 929 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 930 | { |
| 931 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 932 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 933 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 934 | hdd_info("Modules not enabled, Present status: %d", |
| 935 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 936 | return false; |
| 937 | } |
| 938 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 939 | return true; |
| 940 | } |
| 941 | |
| 942 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 943 | * 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] | 944 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | * |
| 946 | * This function sets the IBSS power save config parameters to WMA |
| 947 | * which will send it to firmware if FW supports IBSS power save |
| 948 | * before vdev start. |
| 949 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 950 | * 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] | 951 | * on failure. |
| 952 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 953 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 954 | { |
| 955 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 956 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 957 | |
| 958 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 959 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 960 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 961 | } |
| 962 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 963 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 964 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 965 | hdd_ctx->config->ibssATIMWinSize, |
| 966 | VDEV_CMD); |
| 967 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 968 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 969 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | } |
| 971 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 972 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 973 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 974 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 975 | VDEV_CMD); |
| 976 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 977 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 978 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 979 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 980 | } |
| 981 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 982 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 983 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 984 | hdd_ctx->config-> |
| 985 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 986 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 987 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 988 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 989 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | } |
| 991 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 992 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 994 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 995 | VDEV_CMD); |
| 996 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 997 | 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] | 998 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | } |
| 1000 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1001 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1003 | hdd_ctx->config->ibssInactivityCount, |
| 1004 | VDEV_CMD); |
| 1005 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1006 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1007 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | } |
| 1009 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1010 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1012 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1013 | VDEV_CMD); |
| 1014 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1015 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1016 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1017 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | } |
| 1019 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1020 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1021 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1022 | hdd_ctx->config->ibssPsWarmupTime, |
| 1023 | VDEV_CMD); |
| 1024 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1025 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1026 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1027 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | } |
| 1029 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1030 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1031 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1032 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1033 | VDEV_CMD); |
| 1034 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1035 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1036 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1037 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | } |
| 1039 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1040 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1041 | } |
| 1042 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1043 | #ifdef FEATURE_RUNTIME_PM |
| 1044 | /** |
| 1045 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1046 | * @hdd_ctx: HDD context |
| 1047 | * |
| 1048 | * Return: None |
| 1049 | */ |
| 1050 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1051 | { |
| 1052 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1053 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1054 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1055 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1056 | |
| 1057 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1058 | } |
| 1059 | |
| 1060 | /** |
| 1061 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1062 | * @hdd_ctx: HDD Context |
| 1063 | * |
| 1064 | * Return: None |
| 1065 | */ |
| 1066 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1067 | { |
| 1068 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1069 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1070 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1071 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1072 | |
| 1073 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1074 | } |
| 1075 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1076 | #else /* FEATURE_RUNTIME_PM */ |
| 1077 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1078 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1079 | #endif /* FEATURE_RUNTIME_PM */ |
| 1080 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1081 | #define INTF_MACADDR_MASK 0x7 |
| 1082 | |
| 1083 | /** |
| 1084 | * hdd_update_macaddr() - update mac address |
| 1085 | * @config: hdd configuration |
| 1086 | * @hw_macaddr: mac address |
| 1087 | * |
| 1088 | * Mac address for multiple virtual interface is found as following |
| 1089 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1090 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1091 | * define the mac address for the remaining interfaces and locally |
| 1092 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1093 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1094 | * interface). |
| 1095 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1096 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1097 | * |
| 1098 | * Return: None |
| 1099 | */ |
| 1100 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1101 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1102 | { |
| 1103 | int8_t i; |
| 1104 | uint8_t macaddr_b3, tmp_br3; |
| 1105 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1106 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1107 | QDF_MAC_ADDR_SIZE); |
| 1108 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1109 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1110 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1111 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1112 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1113 | INTF_MACADDR_MASK; |
| 1114 | macaddr_b3 += tmp_br3; |
| 1115 | |
| 1116 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1117 | * mac address range before collision |
| 1118 | */ |
| 1119 | macaddr_b3 ^= (1 << 7); |
| 1120 | |
| 1121 | /* Set locally administered bit */ |
| 1122 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1123 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1124 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1125 | MAC_ADDRESS_STR, i, |
| 1126 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1127 | } |
| 1128 | } |
| 1129 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1130 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1131 | { |
| 1132 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1133 | struct tdls_start_params tdls_cfg; |
| 1134 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1135 | struct hdd_config *cfg = hdd_ctx->config; |
| 1136 | QDF_STATUS status; |
| 1137 | |
| 1138 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1139 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1140 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1141 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1142 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1143 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1144 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1145 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1146 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1147 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1148 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1149 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1150 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1151 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1152 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1153 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1154 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1155 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1156 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1157 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1158 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1159 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1160 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1161 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1162 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1163 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1164 | (cfg->fTDLSExternalControl ? |
| 1165 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1166 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1167 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1168 | |
| 1169 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1170 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1171 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1172 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1173 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1174 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1175 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1176 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1177 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1178 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1179 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1180 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1181 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1182 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1183 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1184 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1185 | |
| 1186 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1187 | if (status != QDF_STATUS_SUCCESS) { |
| 1188 | hdd_err("failed pmo psoc configuration"); |
| 1189 | return -EINVAL; |
| 1190 | } |
| 1191 | |
| 1192 | hdd_ctx->tdls_umac_comp_active = true; |
| 1193 | /* enable napier specific tdls data path */ |
| 1194 | hdd_ctx->tdls_nap_active = true; |
| 1195 | |
| 1196 | return 0; |
| 1197 | } |
| 1198 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1199 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1200 | struct wma_tgt_services *cfg) |
| 1201 | { |
| 1202 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1203 | |
| 1204 | /* Set up UAPSD */ |
| 1205 | config->apUapsdEnabled &= cfg->uapsd; |
| 1206 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1207 | /* 11AX mode support */ |
| 1208 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1209 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1210 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1211 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1212 | /* 11AC mode support */ |
| 1213 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1214 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1215 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | |
| 1217 | /* ARP offload: override user setting if invalid */ |
| 1218 | config->fhostArpOffload &= cfg->arp_offload; |
| 1219 | |
| 1220 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1221 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1222 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1223 | if (cfg->pno_offload) |
| 1224 | config->PnoOffload = true; |
| 1225 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1226 | #ifdef FEATURE_WLAN_TDLS |
| 1227 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1228 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1229 | cfg->en_tdls_offchan; |
| 1230 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1231 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1232 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1233 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1234 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1235 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1236 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1238 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1239 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1240 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1241 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1242 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1243 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1244 | |
| 1245 | } |
| 1246 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1247 | /** |
| 1248 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1249 | * @hdd_ctx: HDD context |
| 1250 | * |
| 1251 | * Sets the Nss per vdev type based on INI |
| 1252 | * |
| 1253 | * Return: None |
| 1254 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1255 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1256 | { |
| 1257 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1258 | uint8_t max_supp_nss = 1; |
| 1259 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1260 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1261 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1262 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1263 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1264 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1265 | |
| 1266 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1267 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1268 | |
| 1269 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1270 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1273 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1274 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1275 | * @hdd_ctx: HDD context |
| 1276 | * |
| 1277 | * Updates wiphy vhtcap fields |
| 1278 | * |
| 1279 | * Return: None |
| 1280 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1281 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1282 | { |
| 1283 | struct ieee80211_supported_band *band_5g = |
| 1284 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1285 | uint32_t val; |
| 1286 | |
| 1287 | if (!band_5g) { |
| 1288 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1289 | return; |
| 1290 | } |
| 1291 | |
| 1292 | val = hdd_ctx->config->txBFCsnValue; |
| 1293 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1294 | |
| 1295 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1296 | band_5g->vht_cap.cap |= |
| 1297 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1298 | |
| 1299 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1300 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1301 | } |
| 1302 | |
| 1303 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1304 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1305 | * @hdd_ctx: HDD context |
| 1306 | * |
| 1307 | * Sets the DBS capability as per INI and firmware capability |
| 1308 | * |
| 1309 | * Return: None |
| 1310 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1311 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1312 | { |
| 1313 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1314 | uint8_t hw_dbs_capable = 0; |
| 1315 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1316 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1317 | ((cfg_ini->dual_mac_feature_disable == |
| 1318 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1319 | (cfg_ini->dual_mac_feature_disable == |
| 1320 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1321 | hw_dbs_capable = 1; |
| 1322 | |
| 1323 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1324 | } |
| 1325 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1326 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1327 | struct wma_tgt_ht_cap *cfg) |
| 1328 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1329 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | uint32_t value, val32; |
| 1331 | uint16_t val16; |
| 1332 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1333 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1334 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1335 | uint8_t enable_tx_stbc; |
| 1336 | |
| 1337 | /* check and update RX STBC */ |
| 1338 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1339 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1340 | |
| 1341 | /* get the MPDU density */ |
| 1342 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1343 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1344 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1345 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1346 | value = 0; |
| 1347 | } |
| 1348 | |
| 1349 | /* |
| 1350 | * MPDU density: |
| 1351 | * override user's setting if value is larger |
| 1352 | * than the one supported by target |
| 1353 | */ |
| 1354 | if (value > cfg->mpdu_density) { |
| 1355 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1356 | cfg->mpdu_density); |
| 1357 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1358 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1359 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1360 | } |
| 1361 | |
| 1362 | /* get the HT capability info */ |
| 1363 | 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] | 1364 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1365 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | return; |
| 1367 | } |
| 1368 | val16 = (uint16_t) val32; |
| 1369 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1370 | |
| 1371 | /* Set the LDPC capability */ |
| 1372 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1373 | |
| 1374 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1375 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1376 | |
| 1377 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1378 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1379 | |
| 1380 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1381 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1382 | |
| 1383 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1384 | |
| 1385 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1386 | pconfig->enable2x2 = 1; |
| 1387 | } else { |
| 1388 | pconfig->enable2x2 = 0; |
| 1389 | enable_tx_stbc = 0; |
| 1390 | |
| 1391 | /* 1x1 */ |
| 1392 | /* Update Rx Highest Long GI data Rate */ |
| 1393 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1394 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1395 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1396 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1397 | 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] | 1398 | } |
| 1399 | |
| 1400 | /* Update Tx Highest Long GI data Rate */ |
| 1401 | if (sme_cfg_set_int |
| 1402 | (hdd_ctx->hHal, |
| 1403 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1404 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1405 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1406 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1407 | } |
| 1408 | } |
| 1409 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1410 | enable_tx_stbc = 0; |
| 1411 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1412 | |
| 1413 | val32 = val16; |
| 1414 | 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] | 1415 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1416 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1417 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1418 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1419 | 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] | 1420 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1421 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1422 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1423 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1424 | if (pconfig->enable2x2) { |
| 1425 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1426 | mcs_set[value] = |
| 1427 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1428 | |
| 1429 | status = |
| 1430 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1431 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1432 | mcs_set, |
| 1433 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1434 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1435 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | } |
| 1437 | } |
| 1438 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1439 | } |
| 1440 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1441 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1442 | struct wma_tgt_vht_cap *cfg) |
| 1443 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1444 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1445 | uint32_t value = 0; |
| 1446 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1447 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1448 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1449 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1450 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1451 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1452 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1453 | struct wma_caps_per_phy caps_per_phy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1455 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1456 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1457 | return; |
| 1458 | } |
| 1459 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | /* Get the current MPDU length */ |
| 1461 | status = |
| 1462 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1463 | &value); |
| 1464 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1465 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1466 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1467 | value = 0; |
| 1468 | } |
| 1469 | |
| 1470 | /* |
| 1471 | * VHT max MPDU length: |
| 1472 | * override if user configured value is too high |
| 1473 | * that the target cannot support |
| 1474 | */ |
| 1475 | if (value > cfg->vht_max_mpdu) { |
| 1476 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1477 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1478 | cfg->vht_max_mpdu); |
| 1479 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1480 | if (status == QDF_STATUS_E_FAILURE) |
| 1481 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1482 | } |
| 1483 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1484 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1485 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1486 | |
| 1487 | if (pconfig->enable2x2) |
| 1488 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1489 | |
| 1490 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1491 | QDF_STATUS_E_FAILURE) { |
| 1492 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1493 | } |
| 1494 | |
| 1495 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1496 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1497 | if (pconfig->enable2x2) |
| 1498 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1499 | |
| 1500 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1501 | QDF_STATUS_E_FAILURE) { |
| 1502 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1503 | } |
| 1504 | |
| 1505 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1506 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1507 | if (pconfig->enable2x2) |
| 1508 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1509 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1510 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1511 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1512 | |
| 1513 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1514 | QDF_STATUS_E_FAILURE) { |
| 1515 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1516 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1517 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1518 | 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] | 1519 | &value); |
| 1520 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1521 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1522 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1523 | value = 0; |
| 1524 | } |
| 1525 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1526 | /* Set HW RX LDPC capability */ |
| 1527 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1528 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1529 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1530 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1531 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1532 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1533 | if (status == QDF_STATUS_E_FAILURE) |
| 1534 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1535 | } |
| 1536 | |
| 1537 | /* Get current GI 80 value */ |
| 1538 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1539 | &value); |
| 1540 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1541 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1542 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1543 | value = 0; |
| 1544 | } |
| 1545 | |
| 1546 | /* set the Guard interval 80MHz */ |
| 1547 | if (value && !cfg->vht_short_gi_80) { |
| 1548 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1549 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1550 | cfg->vht_short_gi_80); |
| 1551 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1552 | if (status == QDF_STATUS_E_FAILURE) |
| 1553 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1554 | } |
| 1555 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1556 | /* Get VHT TX STBC cap */ |
| 1557 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1558 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1559 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1560 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1561 | value = 0; |
| 1562 | } |
| 1563 | |
| 1564 | /* VHT TX STBC cap */ |
| 1565 | if (value && !cfg->vht_tx_stbc) { |
| 1566 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1567 | cfg->vht_tx_stbc); |
| 1568 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1569 | if (status == QDF_STATUS_E_FAILURE) |
| 1570 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1571 | } |
| 1572 | |
| 1573 | /* Get VHT RX STBC cap */ |
| 1574 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1575 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1576 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1577 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1578 | value = 0; |
| 1579 | } |
| 1580 | |
| 1581 | /* VHT RX STBC cap */ |
| 1582 | if (value && !cfg->vht_rx_stbc) { |
| 1583 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1584 | cfg->vht_rx_stbc); |
| 1585 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1586 | if (status == QDF_STATUS_E_FAILURE) |
| 1587 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1588 | } |
| 1589 | |
| 1590 | /* Get VHT SU Beamformer cap */ |
| 1591 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1592 | &value); |
| 1593 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1594 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1595 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1596 | value = 0; |
| 1597 | } |
| 1598 | |
| 1599 | /* set VHT SU Beamformer cap */ |
| 1600 | if (value && !cfg->vht_su_bformer) { |
| 1601 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1602 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1603 | cfg->vht_su_bformer); |
| 1604 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1605 | if (status == QDF_STATUS_E_FAILURE) |
| 1606 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1607 | } |
| 1608 | |
| 1609 | /* check and update SU BEAMFORMEE capabality */ |
| 1610 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1611 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1612 | |
| 1613 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1614 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1615 | pconfig->enableTxBF); |
| 1616 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1617 | if (status == QDF_STATUS_E_FAILURE) |
| 1618 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | |
| 1620 | /* Get VHT MU Beamformer cap */ |
| 1621 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1622 | &value); |
| 1623 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1624 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1625 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1626 | value = 0; |
| 1627 | } |
| 1628 | |
| 1629 | /* set VHT MU Beamformer cap */ |
| 1630 | if (value && !cfg->vht_mu_bformer) { |
| 1631 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1632 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1633 | cfg->vht_mu_bformer); |
| 1634 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1635 | if (status == QDF_STATUS_E_FAILURE) |
| 1636 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | } |
| 1638 | |
| 1639 | /* Get VHT MU Beamformee cap */ |
| 1640 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1641 | &value); |
| 1642 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1643 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1644 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1645 | value = 0; |
| 1646 | } |
| 1647 | |
| 1648 | /* set VHT MU Beamformee cap */ |
| 1649 | if (value && !cfg->vht_mu_bformee) { |
| 1650 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1651 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1652 | cfg->vht_mu_bformee); |
| 1653 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1654 | if (status == QDF_STATUS_E_FAILURE) |
| 1655 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | /* Get VHT MAX AMPDU Len exp */ |
| 1659 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1660 | &value); |
| 1661 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1662 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1663 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1664 | value = 0; |
| 1665 | } |
| 1666 | |
| 1667 | /* |
| 1668 | * VHT max AMPDU len exp: |
| 1669 | * override if user configured value is too high |
| 1670 | * that the target cannot support. |
| 1671 | * Even though Rome publish ampdu_len=7, it can |
| 1672 | * only support 4 because of some h/w bug. |
| 1673 | */ |
| 1674 | |
| 1675 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1676 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1677 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1678 | cfg->vht_max_ampdu_len_exp); |
| 1679 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1680 | if (status == QDF_STATUS_E_FAILURE) |
| 1681 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1682 | } |
| 1683 | |
| 1684 | /* Get VHT TXOP PS CAP */ |
| 1685 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1686 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1687 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1688 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1689 | value = 0; |
| 1690 | } |
| 1691 | |
| 1692 | /* set VHT TXOP PS cap */ |
| 1693 | if (value && !cfg->vht_txop_ps) { |
| 1694 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1695 | cfg->vht_txop_ps); |
| 1696 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1697 | if (status == QDF_STATUS_E_FAILURE) |
| 1698 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1699 | } |
| 1700 | |
| 1701 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1702 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1703 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1704 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1705 | else |
| 1706 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1707 | |
| 1708 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1709 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1710 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1711 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1712 | VHT_CAP_160_AND_80P80_SUPP); |
| 1713 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1714 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1715 | band_5g->vht_cap.cap |= |
| 1716 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1717 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1718 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1719 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1720 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1721 | VHT_CAP_160_SUPP); |
| 1722 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1723 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1724 | band_5g->vht_cap.cap |= |
| 1725 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1726 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1727 | } |
| 1728 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1729 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1730 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1731 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1732 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1733 | &value); |
| 1734 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1735 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1736 | value = 0; |
| 1737 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1738 | /* set the Guard interval 160MHz */ |
| 1739 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1740 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1741 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1742 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1743 | |
| 1744 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1745 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1746 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1747 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1748 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1749 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1750 | hdd_debug("VHT RxLDPC capability is set"); |
| 1751 | } else { |
| 1752 | /* |
| 1753 | * Get the RX LDPC capability for the NON DBS |
| 1754 | * hardware mode for 5G band |
| 1755 | */ |
| 1756 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1757 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1758 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1759 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1760 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1761 | hdd_debug("VHT RX LDPC capability is set"); |
| 1762 | } |
| 1763 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1764 | |
| 1765 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1766 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1767 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1768 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1769 | |
| 1770 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1771 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1772 | |
| 1773 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1774 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1775 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1776 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1777 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1778 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1779 | |
| 1780 | band_5g->vht_cap.cap |= |
| 1781 | (cfg->vht_max_ampdu_len_exp << |
| 1782 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1783 | |
| 1784 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1785 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1786 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1787 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1788 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1789 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1790 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1791 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1792 | |
| 1793 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1794 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1795 | |
| 1796 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1797 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1798 | /** |
| 1799 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1800 | * @hdd_ctx: Pointer to the HDD context |
| 1801 | * |
| 1802 | * Auto-generate mac address using device serial number. |
| 1803 | * Keep the first 3 bytes of OUI as before and replace |
| 1804 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1805 | * |
| 1806 | * Return: 0 for success |
| 1807 | * Non zero failure code for errors |
| 1808 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1809 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1810 | { |
| 1811 | unsigned int serialno = 0; |
| 1812 | struct qdf_mac_addr mac_addr = { |
| 1813 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1814 | }; |
| 1815 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1816 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1817 | if (serialno == 0) |
| 1818 | return -EINVAL; |
| 1819 | |
| 1820 | serialno &= 0x00ffffff; |
| 1821 | |
| 1822 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1823 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1824 | mac_addr.bytes[5] = serialno & 0xff; |
| 1825 | |
| 1826 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1827 | return 0; |
| 1828 | } |
| 1829 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1830 | /** |
| 1831 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1832 | * configuration to cfg_ini in HDD |
| 1833 | * @hdd_ctx: Pointer to hdd_ctx |
| 1834 | * @cfg: target configuration |
| 1835 | * |
| 1836 | * Return: None |
| 1837 | */ |
| 1838 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1839 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1840 | struct wma_tgt_cfg *cfg) |
| 1841 | { |
| 1842 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1843 | } |
| 1844 | #else |
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 | } |
| 1849 | #endif |
| 1850 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1851 | void hdd_update_tgt_cfg(void *context, void *param) |
| 1852 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1853 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1854 | struct hdd_context *hdd_ctx = (struct hdd_context *) context; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1855 | struct wma_tgt_cfg *cfg = param; |
| 1856 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1857 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1858 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1859 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1860 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1861 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1862 | if (ret) { |
| 1863 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1864 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1865 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1866 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1867 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1868 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1869 | hdd_err("dispatcher pdev open failed"); |
| 1870 | QDF_BUG(0); |
| 1871 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1872 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1873 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1874 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1875 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1876 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1877 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1878 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1879 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1880 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1881 | hdd_softap_hard_start_xmit); |
| 1882 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1883 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1884 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1885 | if (cds_cfg) { |
| 1886 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1887 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1888 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1889 | cds_cfg->sub_20_channel_width = |
| 1890 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1891 | } else { |
| 1892 | cds_cfg->sub_20_channel_width = |
| 1893 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1894 | } |
| 1895 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1896 | |
| 1897 | /* first store the INI band capability */ |
| 1898 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1899 | |
| 1900 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1901 | hdd_ctx->is_fils_roaming_supported = |
| 1902 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1903 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1904 | hdd_ctx->config->is_11k_offload_supported = |
| 1905 | cfg->services.is_11k_offload_supported; |
| 1906 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1907 | /* |
| 1908 | * now overwrite the target band capability with INI |
| 1909 | * setting if INI setting is a subset |
| 1910 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1911 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1912 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1913 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1915 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1916 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1917 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1918 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1919 | } |
| 1920 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1921 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1922 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1923 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1924 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1925 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1926 | } |
| 1927 | |
| 1928 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1929 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1930 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1931 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1932 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1933 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1934 | static struct qdf_mac_addr default_mac_addr = { |
| 1935 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1936 | }; |
| 1937 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1938 | &default_mac_addr)) { |
| 1939 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1940 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1941 | MAC_ADDRESS_STR, |
| 1942 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1943 | intfMacAddr[0].bytes)); |
| 1944 | } else { |
| 1945 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1946 | MAC_ADDRESS_STR, |
| 1947 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1948 | intfMacAddr[0].bytes)); |
| 1949 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1950 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1951 | } |
| 1952 | |
| 1953 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1954 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1955 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1956 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1957 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1958 | sizeof(cfg->hw_bd_info)); |
| 1959 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1960 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1961 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1962 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1963 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1964 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1965 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1966 | |
| 1967 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1968 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1969 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1970 | if (cfg->services.en_11ax) { |
| 1971 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1972 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1973 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1974 | |
| 1975 | hdd_update_vdev_nss(hdd_ctx); |
| 1976 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1977 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1978 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1979 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1980 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1981 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1982 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1983 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1984 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1985 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1986 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1987 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1988 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1989 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1990 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1991 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1992 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1993 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1994 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1995 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1996 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 1997 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1998 | hdd_ctx->config->txBFCsnValue = |
| 1999 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2000 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2001 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2002 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2003 | hdd_ctx->config->txBFCsnValue); |
| 2004 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2005 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2006 | |
| 2007 | |
| 2008 | 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] | 2009 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 2010 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2011 | |
| 2012 | /* |
| 2013 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2014 | */ |
| 2015 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2016 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2017 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2018 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2019 | /* |
| 2020 | * This needs to be done after HDD pdev is created and stored since |
| 2021 | * it will access the HDD pdev object lock. |
| 2022 | */ |
| 2023 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2024 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2025 | /* Configure NAN datapath features */ |
| 2026 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2027 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2028 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2029 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2030 | cfg->obss_detection_offloaded); |
| 2031 | if (QDF_IS_STATUS_ERROR(status)) |
| 2032 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2033 | |
| 2034 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2035 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2036 | cfg->obss_color_collision_offloaded); |
| 2037 | if (QDF_IS_STATUS_ERROR(status)) |
| 2038 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2039 | } |
| 2040 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2041 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2043 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2044 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2045 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2046 | if (!hdd_ctx) { |
| 2047 | hdd_info("Couldn't get hdd_ctx"); |
| 2048 | return true; |
| 2049 | } |
| 2050 | |
| 2051 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2052 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2053 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2054 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2055 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2056 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2057 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2058 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2059 | |
| 2060 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2061 | QDF_P2P_GO_MODE == adapter->device_mode) && |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2062 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2063 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2064 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2065 | true; |
| 2066 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2067 | adapter->session_id); |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2068 | cdp_fc_vdev_flush(cds_get_context(QDF_MODULE_ID_SOC), |
| 2069 | adapter->txrx_vdev); |
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) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2156 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 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 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2305 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2306 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2307 | if (ret < 0) { |
| 2308 | hdd_err("Failed to register frames - ret %d", ret); |
| 2309 | goto err_start_adapter; |
| 2310 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2311 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2312 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2313 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2314 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2315 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2316 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2317 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2318 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2319 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2320 | err_start_adapter: |
| 2321 | return -EINVAL; |
| 2322 | } |
| 2323 | |
| 2324 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2325 | * hdd_enable_power_management() - API to Enable Power Management |
| 2326 | * |
| 2327 | * API invokes Bus Interface Layer power management functionality |
| 2328 | * |
| 2329 | * Return: None |
| 2330 | */ |
| 2331 | static void hdd_enable_power_management(void) |
| 2332 | { |
| 2333 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2334 | |
| 2335 | if (!hif_ctx) { |
| 2336 | hdd_err("Bus Interface Context is Invalid"); |
| 2337 | return; |
| 2338 | } |
| 2339 | |
| 2340 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2341 | } |
| 2342 | |
| 2343 | /** |
| 2344 | * hdd_disable_power_management() - API to disable Power Management |
| 2345 | * |
| 2346 | * API disable Bus Interface Layer Power management functionality |
| 2347 | * |
| 2348 | * Return: None |
| 2349 | */ |
| 2350 | static void hdd_disable_power_management(void) |
| 2351 | { |
| 2352 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2353 | |
| 2354 | if (!hif_ctx) { |
| 2355 | hdd_err("Bus Interface Context is Invalid"); |
| 2356 | return; |
| 2357 | } |
| 2358 | |
| 2359 | hif_disable_power_management(hif_ctx); |
| 2360 | } |
| 2361 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2362 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2363 | { |
| 2364 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2365 | size_t target_hw_name_len; |
| 2366 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2367 | uint8_t *buf; |
| 2368 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2369 | |
| 2370 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2371 | if (!hif_sc) { |
| 2372 | hdd_err("HIF context is NULL"); |
| 2373 | return; |
| 2374 | } |
| 2375 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2376 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2377 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2378 | &target_hw_name); |
| 2379 | |
| 2380 | if (hdd_ctx->target_hw_name) |
| 2381 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2382 | |
| 2383 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2384 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2385 | if (hdd_ctx->target_hw_name) |
| 2386 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2387 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2388 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2389 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2390 | if (buf) { |
| 2391 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2392 | hdd_info("%s", buf); |
| 2393 | qdf_mem_free(buf); |
| 2394 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2395 | } |
| 2396 | |
| 2397 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2398 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2399 | * @hdd_ctx: Pointer to hdd context |
| 2400 | * |
| 2401 | * Return: none |
| 2402 | */ |
| 2403 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2404 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2405 | { |
| 2406 | uint8_t num_entries = 0; |
| 2407 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2408 | uint8_t *tx_sched_wrr_ac; |
| 2409 | int i; |
| 2410 | cds_context_type *cds_ctx; |
| 2411 | |
| 2412 | if (NULL == hdd_ctx) |
| 2413 | return; |
| 2414 | |
| 2415 | if (NULL == hdd_ctx->config) { |
| 2416 | /* Do nothing if hdd_ctx is invalid */ |
| 2417 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2418 | return; |
| 2419 | } |
| 2420 | |
| 2421 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2422 | |
| 2423 | if (!cds_ctx) { |
| 2424 | hdd_err("Invalid CDS Context"); |
| 2425 | return; |
| 2426 | } |
| 2427 | |
| 2428 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2429 | switch (i) { |
| 2430 | case OL_TX_WMM_AC_BE: |
| 2431 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2432 | break; |
| 2433 | case OL_TX_WMM_AC_BK: |
| 2434 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2435 | break; |
| 2436 | case OL_TX_WMM_AC_VI: |
| 2437 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2438 | break; |
| 2439 | case OL_TX_WMM_AC_VO: |
| 2440 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2441 | break; |
| 2442 | default: |
| 2443 | tx_sched_wrr_ac = NULL; |
| 2444 | break; |
| 2445 | } |
| 2446 | |
| 2447 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2448 | tx_sched_wrr_param, |
| 2449 | &num_entries, |
| 2450 | sizeof(tx_sched_wrr_param)); |
| 2451 | |
| 2452 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2453 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2454 | tx_sched_wrr_param[0]; |
| 2455 | cds_ctx->ac_specs[i].credit_threshold = |
| 2456 | tx_sched_wrr_param[1]; |
| 2457 | cds_ctx->ac_specs[i].send_limit = |
| 2458 | tx_sched_wrr_param[2]; |
| 2459 | cds_ctx->ac_specs[i].credit_reserve = |
| 2460 | tx_sched_wrr_param[3]; |
| 2461 | cds_ctx->ac_specs[i].discard_weight = |
| 2462 | tx_sched_wrr_param[4]; |
| 2463 | } |
| 2464 | |
| 2465 | num_entries = 0; |
| 2466 | } |
| 2467 | } |
| 2468 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2469 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2470 | const size_t version_len, uint8_t *version) |
| 2471 | { |
| 2472 | uint32_t size; |
| 2473 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2474 | |
| 2475 | if (!hdd_ctx) { |
| 2476 | hdd_err("Invalid context, HDD context is null"); |
| 2477 | return 0; |
| 2478 | } |
| 2479 | |
| 2480 | if (!version && version_len == 0) { |
| 2481 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2482 | return 0; |
| 2483 | } |
| 2484 | |
| 2485 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2486 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2487 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2488 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2489 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2490 | |
| 2491 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2492 | "Host SW:%s, FW:%d.%d.%d.%d.%d, HW:%s, Board ver: %x Ref design id: %x, Customer id: %x, Project id: %x, Board Data Rev: %x", |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2493 | QWLAN_VERSIONSTR, |
| 2494 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2495 | hdd_ctx->target_hw_name, |
| 2496 | hdd_ctx->hw_bd_info.bdf_version, |
| 2497 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2498 | hdd_ctx->hw_bd_info.customer_id, |
| 2499 | hdd_ctx->hw_bd_info.project_id, |
| 2500 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2501 | |
| 2502 | return size; |
| 2503 | } |
| 2504 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2505 | #ifdef IPA_OFFLOAD |
| 2506 | /** |
| 2507 | * hdd_update_ipa_component_config() - update ipa config |
| 2508 | * @hdd_ctx: Pointer to hdd context |
| 2509 | * |
| 2510 | * Return: none |
| 2511 | */ |
| 2512 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2513 | { |
| 2514 | struct hdd_config *cfg = hdd_ctx->config; |
| 2515 | struct wlan_ipa_config ipa_cfg; |
| 2516 | |
| 2517 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2518 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2519 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2520 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2521 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2522 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2523 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2524 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2525 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2526 | |
| 2527 | ucfg_ipa_update_config(&ipa_cfg); |
| 2528 | } |
| 2529 | #else |
| 2530 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2531 | { |
| 2532 | } |
| 2533 | #endif |
| 2534 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2535 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2536 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2537 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2538 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2539 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2540 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2541 | |
| 2542 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2543 | if (!adapter) { |
| 2544 | hdd_err("Adapter is NULL"); |
| 2545 | return PM_MAX_NUM_OF_MODE; |
| 2546 | } |
| 2547 | |
| 2548 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2549 | adapter->device_mode); |
| 2550 | } |
| 2551 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2552 | static void hdd_register_policy_manager_callback( |
| 2553 | struct wlan_objmgr_psoc *psoc) |
| 2554 | { |
| 2555 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2556 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2557 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2558 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2559 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2560 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2561 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2562 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2563 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2564 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2565 | if (QDF_STATUS_SUCCESS != |
| 2566 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2567 | hdd_err("HDD callback registration with policy manager failed"); |
| 2568 | } |
| 2569 | } |
| 2570 | #else |
| 2571 | static void hdd_register_policy_manager_callback( |
| 2572 | struct wlan_objmgr_psoc *psoc) |
| 2573 | { |
| 2574 | } |
| 2575 | #endif |
| 2576 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2577 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2578 | { |
| 2579 | struct nan_callbacks cb_obj = {0}; |
| 2580 | |
| 2581 | cb_obj.ndi_open = hdd_ndi_open; |
| 2582 | cb_obj.ndi_close = hdd_ndi_close; |
| 2583 | cb_obj.ndi_start = hdd_ndi_start; |
| 2584 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2585 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2586 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2587 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2588 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2589 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2590 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2591 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2592 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2593 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2594 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2595 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2596 | /** |
| 2597 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2598 | * |
| 2599 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2600 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2601 | * |
| 2602 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2603 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2604 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2605 | * fixed. |
| 2606 | * |
| 2607 | * Return: None |
| 2608 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2609 | static void hdd_check_for_leaks(void) |
| 2610 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2611 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2612 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2613 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2614 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2615 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2616 | } |
| 2617 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2618 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2619 | #else |
| 2620 | static inline void hdd_check_for_leaks(void) {} |
| 2621 | |
| 2622 | #define hdd_debug_domain_set(domain) |
| 2623 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2624 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2625 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2626 | * hdd_update_country_code - Update country code |
| 2627 | * @hdd_ctx: HDD context |
| 2628 | * |
| 2629 | * Update country code based on module parameter country_code |
| 2630 | * |
| 2631 | * Return: 0 on success and errno on failure |
| 2632 | */ |
| 2633 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2634 | { |
| 2635 | if (!country_code) |
| 2636 | return 0; |
| 2637 | |
| 2638 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2639 | } |
| 2640 | |
| 2641 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2642 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2643 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2644 | * @reinit: flag to indicate from SSR or normal path |
| 2645 | * |
| 2646 | * This function maintains the driver state machine it will be invoked from |
| 2647 | * startup, reinit and change interface. Depending on the driver state shall |
| 2648 | * perform the opening of the modules. |
| 2649 | * |
| 2650 | * Return: 0 for success; non-zero for failure |
| 2651 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2652 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2653 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2654 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2655 | qdf_device_t qdf_dev; |
| 2656 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2657 | bool unint = false; |
| 2658 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2659 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2660 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2661 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2662 | |
| 2663 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2664 | if (!qdf_dev) { |
| 2665 | hdd_err("QDF Device Context is Invalid return"); |
| 2666 | return -EINVAL; |
| 2667 | } |
| 2668 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2669 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2670 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2671 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2672 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2673 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2674 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2675 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2676 | return 0; |
| 2677 | } |
| 2678 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2679 | hdd_ctx->start_modules_in_progress = true; |
| 2680 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2681 | switch (hdd_ctx->driver_status) { |
| 2682 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2683 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2684 | unint = true; |
| 2685 | /* Fall through dont add break here */ |
| 2686 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2687 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2688 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2689 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2690 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2691 | if (!reinit && !unint) { |
| 2692 | ret = pld_power_on(qdf_dev->dev); |
| 2693 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2694 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2695 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2696 | goto release_lock; |
| 2697 | } |
| 2698 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2699 | |
| 2700 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2701 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2702 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2703 | qdf_dev->bus_type, |
| 2704 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2705 | HIF_ENABLE_TYPE_PROBE); |
| 2706 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2707 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2708 | goto power_down; |
| 2709 | } |
| 2710 | |
| 2711 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2712 | if (!hif_ctx) { |
| 2713 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2714 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2715 | goto power_down; |
| 2716 | } |
| 2717 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2718 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2719 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2720 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2721 | status); |
| 2722 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2723 | goto hif_close; |
| 2724 | } |
| 2725 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2726 | hdd_update_ipa_component_config(hdd_ctx); |
| 2727 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2728 | ret = hdd_update_config(hdd_ctx); |
| 2729 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2730 | hdd_err("Failed to update configuration; errno: %d", |
| 2731 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2732 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2733 | } |
| 2734 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2735 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2736 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2737 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2738 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2739 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2740 | ret = qdf_status_to_os_return(status); |
| 2741 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2742 | } |
| 2743 | |
Jeff Johnson | 79e3688 | 2018-05-06 17:15:33 -0700 | [diff] [blame] | 2744 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2745 | ret = hdd_update_components_config(hdd_ctx); |
| 2746 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2747 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2748 | ret); |
| 2749 | goto close; |
| 2750 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2751 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2752 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2753 | hdd_err("Failed to Open cds post open; status: %d", |
| 2754 | status); |
| 2755 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2756 | goto close; |
| 2757 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2758 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2759 | /* |
| 2760 | * NAN compoenet requires certian operations like, open adapter, |
| 2761 | * close adapter, etc. to be initiated by HDD, for those |
| 2762 | * register HDD callbacks with UMAC's NAN componenet. |
| 2763 | */ |
| 2764 | hdd_nan_register_callbacks(hdd_ctx); |
| 2765 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2766 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2767 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2768 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2769 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2770 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2771 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2772 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2773 | } |
| 2774 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2775 | hdd_register_policy_manager_callback( |
| 2776 | hdd_ctx->hdd_psoc); |
| 2777 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2778 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2779 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2780 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2781 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2782 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2783 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2784 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2785 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2786 | break; |
| 2787 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2788 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | /* Fall through dont add break here */ |
| 2790 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2791 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2792 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2793 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2794 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2795 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2796 | break; |
| 2797 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2798 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2799 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2800 | if (ret) { |
| 2801 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2802 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2803 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2804 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2805 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2806 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2807 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2808 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2809 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2810 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2811 | default: |
| 2812 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2813 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2814 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | goto release_lock; |
| 2816 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2817 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2818 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2819 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2820 | ret = hdd_update_country_code(hdd_ctx); |
| 2821 | if (ret) |
| 2822 | hdd_err("Failed to update command line country code!"); |
| 2823 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2824 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2825 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2826 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2827 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2828 | return 0; |
| 2829 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2830 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2831 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2832 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2833 | cds_txrx_free: |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2834 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 2835 | |
| 2836 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2837 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 2838 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
| 2839 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2840 | } |
| 2841 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2842 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2843 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2844 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2845 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2846 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2847 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2848 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2849 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2850 | deinit_config: |
| 2851 | cds_deinit_ini_config(); |
| 2852 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2853 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2854 | ol_cds_free(); |
| 2855 | |
| 2856 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2857 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2858 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2859 | power_down: |
| 2860 | if (!reinit && !unint) |
| 2861 | pld_power_off(qdf_dev->dev); |
| 2862 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2863 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2864 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2865 | |
| 2866 | /* many adapter resources are not freed by design in SSR case */ |
| 2867 | if (!reinit) |
| 2868 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2869 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2870 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2871 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2872 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2873 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2874 | } |
| 2875 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2876 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2877 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2878 | { |
| 2879 | int ret = os_if_wifi_pos_register_nl(); |
| 2880 | |
| 2881 | if (ret) |
| 2882 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2883 | |
| 2884 | return ret; |
| 2885 | } |
| 2886 | |
| 2887 | static int hdd_deactivate_wifi_pos(void) |
| 2888 | { |
| 2889 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2890 | |
| 2891 | if (ret) |
| 2892 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2893 | |
| 2894 | return ret; |
| 2895 | } |
| 2896 | |
| 2897 | /** |
| 2898 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2899 | * @hdd_ctx: hdd context |
| 2900 | * |
| 2901 | * Return: status of operation |
| 2902 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2903 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2904 | { |
| 2905 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2906 | struct hdd_config *cfg = hdd_ctx->config; |
| 2907 | |
| 2908 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2909 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2910 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2911 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2912 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2913 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2914 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2915 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2916 | } |
| 2917 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2918 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2919 | { |
| 2920 | return oem_activate_service(hdd_ctx); |
| 2921 | } |
| 2922 | |
| 2923 | static int hdd_deactivate_wifi_pos(void) |
| 2924 | { |
| 2925 | return 0; |
| 2926 | } |
| 2927 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2928 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2929 | { |
| 2930 | } |
| 2931 | #endif |
| 2932 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2933 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2934 | * __hdd_open() - HDD Open function |
| 2935 | * @dev: Pointer to net_device structure |
| 2936 | * |
| 2937 | * This is called in response to ifconfig up |
| 2938 | * |
| 2939 | * Return: 0 for success; non-zero for failure |
| 2940 | */ |
| 2941 | static int __hdd_open(struct net_device *dev) |
| 2942 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2943 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2944 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2945 | int ret; |
| 2946 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2947 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2948 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2949 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2950 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2951 | /* Nothing to be done if device is unloading */ |
| 2952 | if (cds_is_driver_unloading()) { |
| 2953 | hdd_err("Driver is unloading can not open the hdd"); |
| 2954 | return -EBUSY; |
| 2955 | } |
| 2956 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2957 | if (cds_is_driver_recovering()) { |
| 2958 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2959 | return -EBUSY; |
| 2960 | } |
| 2961 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2962 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 2963 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 2964 | return -EBUSY; |
| 2965 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2966 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2967 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2968 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2969 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2970 | /* |
| 2971 | * This scenario can be hit in cases where in the wlan driver after |
| 2972 | * registering the netdevices and there is a failure in driver |
| 2973 | * initialization. So return error gracefully because the netdevices |
| 2974 | * will be de-registered as part of the load failure. |
| 2975 | */ |
| 2976 | |
| 2977 | if (!cds_is_driver_loaded()) { |
| 2978 | hdd_err("Failed to start the wlan driver!!"); |
| 2979 | ret = -EIO; |
| 2980 | goto err_hdd_hdd_init_deinit_lock; |
| 2981 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2982 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2983 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2984 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2985 | if (ret) { |
| 2986 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2987 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2988 | } |
| 2989 | |
| 2990 | |
| 2991 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2992 | ret = hdd_start_adapter(adapter); |
| 2993 | if (ret) { |
| 2994 | hdd_err("Failed to start adapter :%d", |
| 2995 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2996 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2997 | } |
| 2998 | } |
| 2999 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3000 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3001 | 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] | 3002 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3003 | /* Enable TX queues only when we are connected */ |
| 3004 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3005 | WLAN_START_ALL_NETIF_QUEUE, |
| 3006 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3007 | } |
| 3008 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3009 | /* Enable carrier and transmit queues for NDI */ |
| 3010 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3011 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3012 | wlan_hdd_netif_queue_control(adapter, |
| 3013 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3014 | WLAN_CONTROL_PATH); |
| 3015 | } |
| 3016 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3017 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3018 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3019 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3020 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3021 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3022 | return ret; |
| 3023 | } |
| 3024 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3025 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3026 | /** |
| 3027 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3028 | * @dev: Pointer to net_device structure |
| 3029 | * |
| 3030 | * This is called in response to ifconfig up |
| 3031 | * |
| 3032 | * Return: 0 for success; non-zero for failure |
| 3033 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3034 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3035 | { |
| 3036 | int ret; |
| 3037 | |
| 3038 | cds_ssr_protect(__func__); |
| 3039 | ret = __hdd_open(dev); |
| 3040 | cds_ssr_unprotect(__func__); |
| 3041 | |
| 3042 | return ret; |
| 3043 | } |
| 3044 | |
| 3045 | /** |
| 3046 | * __hdd_stop() - HDD stop function |
| 3047 | * @dev: Pointer to net_device structure |
| 3048 | * |
| 3049 | * This is called in response to ifconfig down |
| 3050 | * |
| 3051 | * Return: 0 for success; non-zero for failure |
| 3052 | */ |
| 3053 | static int __hdd_stop(struct net_device *dev) |
| 3054 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3055 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3056 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3057 | int ret; |
| 3058 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3059 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3060 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3061 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3062 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | |
| 3064 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3065 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3066 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3067 | |
| 3068 | /* Nothing to be done if the interface is not opened */ |
| 3069 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3070 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3071 | return -ENODEV; |
| 3072 | } |
| 3073 | |
| 3074 | /* Make sure the interface is marked as closed */ |
| 3075 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3076 | |
| 3077 | hdd_debug("Disabling Auto Power save timer"); |
| 3078 | sme_ps_disable_auto_ps_timer( |
| 3079 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3080 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3081 | |
| 3082 | /* |
| 3083 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3084 | * be called on that interface |
| 3085 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3086 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3087 | hdd_device_mode_to_string(adapter->device_mode), |
| 3088 | adapter->device_mode); |
| 3089 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3090 | wlan_hdd_netif_queue_control(adapter, |
| 3091 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3092 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3093 | |
| 3094 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3095 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3096 | * bursty in nature and depends on the need to transfer. The service |
| 3097 | * layer may down the interface after the usage and up again when |
| 3098 | * required. In some sense, the NDI is expected to be available |
| 3099 | * (like SAP) iface until NDI delete request is issued by the service |
| 3100 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3101 | * interface (NDI). |
| 3102 | */ |
| 3103 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3104 | return 0; |
| 3105 | |
| 3106 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3107 | * The interface is marked as down for outside world (aka kernel) |
| 3108 | * But the driver is pretty much alive inside. The driver needs to |
| 3109 | * tear down the existing connection on the netdev (session) |
| 3110 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3111 | * for this interface. The call also needs to wait until the above |
| 3112 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3113 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3114 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3115 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3116 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3117 | |
| 3118 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3119 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3120 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3121 | |
| 3122 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3123 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3124 | * this is the last cli iface, flush the scan database. |
| 3125 | */ |
| 3126 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3127 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3128 | |
| 3129 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3130 | * Find if any iface is up. If any iface is up then can't put device to |
| 3131 | * sleep/power save mode |
| 3132 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3133 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3134 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3135 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3136 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3137 | hdd_prevent_suspend_timeout( |
| 3138 | hdd_ctx->config->iface_change_wait_time, |
| 3139 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3140 | } |
| 3141 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3142 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3143 | return 0; |
| 3144 | } |
| 3145 | |
| 3146 | /** |
| 3147 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3148 | * @dev: pointer to net_device structure |
| 3149 | * |
| 3150 | * This is called in response to ifconfig down |
| 3151 | * |
| 3152 | * Return: 0 for success and error number for failure |
| 3153 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3154 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3155 | { |
| 3156 | int ret; |
| 3157 | |
| 3158 | cds_ssr_protect(__func__); |
| 3159 | ret = __hdd_stop(dev); |
| 3160 | cds_ssr_unprotect(__func__); |
| 3161 | |
| 3162 | return ret; |
| 3163 | } |
| 3164 | |
| 3165 | /** |
| 3166 | * __hdd_uninit() - HDD uninit function |
| 3167 | * @dev: Pointer to net_device structure |
| 3168 | * |
| 3169 | * This is called during the netdev unregister to uninitialize all data |
| 3170 | * associated with the device |
| 3171 | * |
| 3172 | * Return: None |
| 3173 | */ |
| 3174 | static void __hdd_uninit(struct net_device *dev) |
| 3175 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3176 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3177 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3178 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3179 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3180 | |
| 3181 | do { |
| 3182 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3183 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | break; |
| 3185 | } |
| 3186 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3187 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3188 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3189 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3190 | break; |
| 3191 | } |
| 3192 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3193 | if (dev != adapter->dev) |
| 3194 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3195 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3196 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3197 | |
| 3198 | /* after uninit our adapter structure will no longer be valid */ |
| 3199 | adapter->dev = NULL; |
| 3200 | adapter->magic = 0; |
| 3201 | } while (0); |
| 3202 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3203 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3204 | } |
| 3205 | |
| 3206 | /** |
| 3207 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3208 | * @dev: pointer to net_device structure |
| 3209 | * |
| 3210 | * This is called during the netdev unregister to uninitialize all data |
| 3211 | * associated with the device |
| 3212 | * |
| 3213 | * Return: none |
| 3214 | */ |
| 3215 | static void hdd_uninit(struct net_device *dev) |
| 3216 | { |
| 3217 | cds_ssr_protect(__func__); |
| 3218 | __hdd_uninit(dev); |
| 3219 | cds_ssr_unprotect(__func__); |
| 3220 | } |
| 3221 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3222 | static int hdd_open_cesium_nl_sock(void) |
| 3223 | { |
| 3224 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3225 | struct netlink_kernel_cfg cfg = { |
| 3226 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3227 | .input = NULL |
| 3228 | }; |
| 3229 | #endif |
| 3230 | int ret = 0; |
| 3231 | |
| 3232 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3233 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3234 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3235 | THIS_MODULE, |
| 3236 | #endif |
| 3237 | &cfg); |
| 3238 | #else |
| 3239 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3240 | WLAN_NLINK_MCAST_GRP_ID, |
| 3241 | NULL, NULL, THIS_MODULE); |
| 3242 | #endif |
| 3243 | |
| 3244 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3245 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3246 | ret = -ECONNREFUSED; |
| 3247 | } |
| 3248 | |
| 3249 | return ret; |
| 3250 | } |
| 3251 | |
| 3252 | static void hdd_close_cesium_nl_sock(void) |
| 3253 | { |
| 3254 | if (NULL != cesium_nl_srv_sock) { |
| 3255 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3256 | cesium_nl_srv_sock = NULL; |
| 3257 | } |
| 3258 | } |
| 3259 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3260 | /** |
| 3261 | * __hdd_set_mac_address() - set the user specified mac address |
| 3262 | * @dev: Pointer to the net device. |
| 3263 | * @addr: Pointer to the sockaddr. |
| 3264 | * |
| 3265 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3266 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3267 | * |
| 3268 | * Return: 0 for success, non zero for failure |
| 3269 | */ |
| 3270 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3271 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3272 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3273 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3274 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3275 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3276 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3277 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3279 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3280 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3281 | if (netif_running(dev)) { |
| 3282 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3283 | return -EBUSY; |
| 3284 | } |
| 3285 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3287 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3288 | if (0 != ret) |
| 3289 | return ret; |
| 3290 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3291 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3292 | |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3293 | if (hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes)) { |
| 3294 | hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, |
| 3295 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3296 | return -EINVAL; |
| 3297 | } |
| 3298 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3299 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3300 | hdd_err("MAC is all zero"); |
| 3301 | return -EINVAL; |
| 3302 | } |
| 3303 | |
| 3304 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3305 | hdd_err("MAC is Broadcast"); |
| 3306 | return -EINVAL; |
| 3307 | } |
| 3308 | |
| 3309 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3310 | hdd_err("MAC is Multicast"); |
| 3311 | return -EINVAL; |
| 3312 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3313 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3314 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3315 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3316 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3317 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3318 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3319 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3320 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3321 | } |
| 3322 | |
| 3323 | /** |
| 3324 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3325 | * function from SSR |
| 3326 | * @dev: pointer to net_device structure |
| 3327 | * @addr: Pointer to the sockaddr |
| 3328 | * |
| 3329 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3330 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3331 | * |
| 3332 | * Return: 0 for success. |
| 3333 | */ |
| 3334 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3335 | { |
| 3336 | int ret; |
| 3337 | |
| 3338 | cds_ssr_protect(__func__); |
| 3339 | ret = __hdd_set_mac_address(dev, addr); |
| 3340 | cds_ssr_unprotect(__func__); |
| 3341 | |
| 3342 | return ret; |
| 3343 | } |
| 3344 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3345 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3346 | { |
| 3347 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3348 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3349 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3350 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3351 | break; |
| 3352 | } |
| 3353 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3354 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | return NULL; |
| 3356 | |
| 3357 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3358 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3359 | } |
| 3360 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3361 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3362 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3363 | { |
| 3364 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3365 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3366 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3367 | if (!memcmp(releaseAddr, |
| 3368 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3369 | 6)) { |
| 3370 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3371 | break; |
| 3372 | } |
| 3373 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3374 | } |
| 3375 | |
| 3376 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3377 | /** |
| 3378 | * __hdd_set_multicast_list() - set the multicast address list |
| 3379 | * @dev: Pointer to the WLAN device. |
| 3380 | * @skb: Pointer to OS packet (sk_buff). |
| 3381 | * |
| 3382 | * This funciton sets the multicast address list. |
| 3383 | * |
| 3384 | * Return: None |
| 3385 | */ |
| 3386 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3387 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3388 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3389 | int i = 0, status; |
| 3390 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3391 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3392 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3393 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3394 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3396 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3397 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3398 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3399 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3400 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3401 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3402 | goto out; |
| 3403 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3404 | status = hdd_validate_adapter(adapter); |
| 3405 | if (status) |
| 3406 | goto out; |
| 3407 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3408 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3409 | hdd_err("%s: Driver module is closed", __func__); |
| 3410 | return; |
| 3411 | } |
| 3412 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3413 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3414 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3415 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3416 | goto out; |
| 3417 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3418 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3419 | /* Delete already configured multicast address list */ |
| 3420 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3421 | hdd_info("clear previously configured MC address list"); |
| 3422 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3423 | pmo_mc_list_change_notify); |
| 3424 | } |
| 3425 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3426 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3427 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3428 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3429 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3430 | } else { |
| 3431 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3432 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3433 | 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] | 3434 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3435 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3436 | pmo_mc_list_change_notify); |
| 3437 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3438 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3439 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3440 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3441 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | if (i == mc_count) |
| 3443 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3444 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3445 | 0, ETH_ALEN); |
| 3446 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3447 | ha->addr, ETH_ALEN); |
| 3448 | hdd_info("mlist[%d] = %pM", i, |
| 3449 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3450 | i++; |
| 3451 | } |
| 3452 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3453 | |
| 3454 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3455 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3456 | mc_list_request->count = mc_count; |
| 3457 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3458 | if (status == 0) { |
| 3459 | hdd_enable_mc_addr_filtering(adapter, |
| 3460 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3461 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3462 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3463 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3464 | out: |
| 3465 | if (mc_list_request) |
| 3466 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3467 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3468 | } |
| 3469 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3470 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3471 | /** |
| 3472 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3473 | * @dev: pointer to net_device |
| 3474 | * |
| 3475 | * Return: none |
| 3476 | */ |
| 3477 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3478 | { |
| 3479 | cds_ssr_protect(__func__); |
| 3480 | __hdd_set_multicast_list(dev); |
| 3481 | cds_ssr_unprotect(__func__); |
| 3482 | } |
| 3483 | #endif |
| 3484 | |
| 3485 | /** |
| 3486 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3487 | * @dev: Pointer to the WLAN device. |
| 3488 | * @skb: Pointer to OS packet (sk_buff). |
| 3489 | * |
| 3490 | * This function is registered with the Linux OS for network |
| 3491 | * core to decide which queue to use first. |
| 3492 | * |
| 3493 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3494 | */ |
| 3495 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3496 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3497 | , void *accel_priv |
| 3498 | #endif |
| 3499 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3500 | , select_queue_fallback_t fallback |
| 3501 | #endif |
| 3502 | ) |
| 3503 | { |
| 3504 | return hdd_wmm_select_queue(dev, skb); |
| 3505 | } |
| 3506 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3507 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3508 | .ndo_open = hdd_open, |
| 3509 | .ndo_stop = hdd_stop, |
| 3510 | .ndo_uninit = hdd_uninit, |
| 3511 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3512 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3513 | .ndo_get_stats = hdd_get_stats, |
| 3514 | .ndo_do_ioctl = hdd_ioctl, |
| 3515 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3516 | .ndo_select_queue = hdd_select_queue, |
| 3517 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3519 | #endif |
| 3520 | }; |
| 3521 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3522 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3523 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3524 | .ndo_open = hdd_mon_open, |
| 3525 | .ndo_stop = hdd_stop, |
| 3526 | .ndo_get_stats = hdd_get_stats, |
| 3527 | }; |
| 3528 | |
| 3529 | /** |
| 3530 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3531 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3532 | * Return: None |
| 3533 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3534 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3535 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3536 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3537 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3538 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3539 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3540 | } |
| 3541 | |
| 3542 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3543 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3544 | * @hdd_ctx: global hdd context |
| 3545 | * @macAddr: mac address to assign to the interface |
| 3546 | * @name: User-visible name of the interface |
| 3547 | * |
| 3548 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3549 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3550 | * |
| 3551 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3552 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3553 | 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] | 3554 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3555 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3556 | const char *name) |
| 3557 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3558 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3559 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3560 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3561 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | /* |
| 3563 | * cfg80211 initialization and registration.... |
| 3564 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3565 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3566 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3567 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3568 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3569 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3570 | hdd_mon_mode_ether_setup : ether_setup), |
| 3571 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3572 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3573 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | |
| 3575 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3576 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3577 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3578 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3579 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3580 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3581 | sizeof(sta_ctx->conn_info.staId), |
| 3582 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3583 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3584 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3585 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3586 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3588 | qdf_status = qdf_event_create( |
| 3589 | &adapter->qdf_session_open_event); |
| 3590 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3591 | hdd_err("Session open QDF event init failed!"); |
| 3592 | free_netdev(adapter->dev); |
| 3593 | return NULL; |
| 3594 | } |
| 3595 | |
| 3596 | qdf_status = qdf_event_create( |
| 3597 | &adapter->qdf_session_close_event); |
| 3598 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3599 | hdd_err("Session close QDF event init failed!"); |
| 3600 | free_netdev(adapter->dev); |
| 3601 | return NULL; |
| 3602 | } |
| 3603 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3604 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3605 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3606 | init_completion(&adapter->linkup_event_var); |
| 3607 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3608 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3609 | init_completion(&adapter->sta_authorized_event); |
| 3610 | init_completion(&adapter->offchannel_tx_event); |
| 3611 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3612 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3613 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3614 | |
| 3615 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3616 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3617 | adapter->disconnection_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3618 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3619 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3621 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3622 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3623 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3624 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3625 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | |
| 3627 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3628 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3629 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3630 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3632 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3633 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | hdd_set_station_ops(adapter->dev); |
| 3635 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3636 | hdd_dev_setup_destructor(dev); |
| 3637 | dev->ieee80211_ptr = &adapter->wdev; |
| 3638 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3639 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3640 | adapter->wdev.netdev = dev; |
| 3641 | /* set dev's parent to underlying device */ |
| 3642 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3643 | hdd_wmm_init(adapter); |
| 3644 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3645 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3646 | } |
| 3647 | |
| 3648 | return adapter; |
| 3649 | } |
| 3650 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3651 | 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] | 3652 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3653 | struct net_device *dev = adapter->dev; |
| 3654 | int ret; |
| 3655 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3656 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3657 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3658 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3659 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3660 | |
| 3661 | ret = dev_alloc_name(dev, dev->name); |
| 3662 | if (ret < 0) { |
| 3663 | hdd_err( |
| 3664 | "unable to get dev name: %s, err = 0x%x", |
| 3665 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3666 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3667 | } |
| 3668 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3669 | |
| 3670 | ret = register_netdevice(dev); |
| 3671 | if (ret) { |
| 3672 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3673 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3674 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3675 | } |
| 3676 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3677 | ret = register_netdev(dev); |
| 3678 | if (ret) { |
| 3679 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3680 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3681 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3682 | } |
| 3683 | } |
| 3684 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3685 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3686 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3687 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3688 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3689 | } |
| 3690 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3691 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3692 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3693 | struct hdd_adapter *adapter; |
| 3694 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3695 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3696 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3697 | if (!hdd_ctx) { |
| 3698 | hdd_err("Invalid HDD_CTX"); |
| 3699 | return QDF_STATUS_E_FAILURE; |
| 3700 | } |
| 3701 | |
| 3702 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3703 | if (NULL == adapter) { |
| 3704 | hdd_err("NULL adapter"); |
| 3705 | return QDF_STATUS_E_INVAL; |
| 3706 | } |
| 3707 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3708 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3709 | hdd_debug("session %d opened", adapter->session_id); |
| 3710 | |
| 3711 | return QDF_STATUS_SUCCESS; |
| 3712 | } |
| 3713 | |
| 3714 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3715 | { |
| 3716 | struct hdd_adapter *adapter; |
| 3717 | struct hdd_context *hdd_ctx; |
| 3718 | |
| 3719 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3720 | if (!hdd_ctx) { |
| 3721 | hdd_err("Invalid HDD_CTX"); |
| 3722 | return QDF_STATUS_E_FAILURE; |
| 3723 | } |
| 3724 | |
| 3725 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3726 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3727 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3728 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3729 | } |
| 3730 | |
| 3731 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3732 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3733 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3734 | } |
| 3735 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3736 | /* |
| 3737 | * For NAN Data interface, the close session results in the final |
| 3738 | * indication to the userspace |
| 3739 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3740 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3741 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3742 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3743 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3744 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3745 | /* |
| 3746 | * We can be blocked while waiting for scheduled work to be |
| 3747 | * flushed, and the adapter structure can potentially be freed, in |
| 3748 | * which case the magic will have been reset. So make sure the |
| 3749 | * magic is still good, and hence the adapter structure is still |
| 3750 | * valid, before signaling completion |
| 3751 | */ |
| 3752 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3753 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3754 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3755 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3756 | } |
| 3757 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3758 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3760 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3761 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3762 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3763 | if (QDF_IS_STATUS_ERROR(status)) |
| 3764 | return qdf_status_to_os_return(status); |
| 3765 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3766 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3767 | if (QDF_IS_STATUS_ERROR(status)) |
| 3768 | return qdf_status_to_os_return(status); |
| 3769 | |
| 3770 | if (wma_capability_enhanced_mcast_filter()) |
| 3771 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3772 | else |
| 3773 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3774 | |
| 3775 | return qdf_status_to_os_return(status); |
| 3776 | } |
| 3777 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3778 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3779 | { |
| 3780 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3781 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3782 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3783 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3784 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3785 | vdev_id = adapter->session_id; |
| 3786 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3787 | |
| 3788 | /* vdev created sanity check */ |
| 3789 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3790 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3791 | return -EINVAL; |
| 3792 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3793 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3794 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3795 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3796 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3797 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3798 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3799 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3800 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3801 | errno = qdf_status_to_os_return(status); |
| 3802 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3803 | } |
| 3804 | |
| 3805 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3806 | status = qdf_wait_for_event_completion( |
| 3807 | &adapter->qdf_session_close_event, |
| 3808 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3809 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3810 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3811 | hdd_ndp_session_end_handler(adapter); |
| 3812 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3813 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3814 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3815 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3816 | errno = -ETIMEDOUT; |
| 3817 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3818 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3819 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3820 | errno = -EINVAL; |
| 3821 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3822 | } else { |
| 3823 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3824 | errno = -EINVAL; |
| 3825 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3826 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3827 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3828 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3829 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3830 | /* |
| 3831 | * In SSR or driver unloading case, directly exit may cause objects |
| 3832 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3833 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3834 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3835 | return errno; |
| 3836 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3837 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3838 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3839 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3840 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3841 | return errno; |
| 3842 | } |
| 3843 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3844 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3845 | |
| 3846 | return 0; |
| 3847 | } |
| 3848 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3849 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3850 | struct sme_session_params *session_param, |
| 3851 | csr_roam_completeCallback callback, |
| 3852 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3853 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3854 | uint32_t type; |
| 3855 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3856 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3857 | |
| 3858 | /* determine vdev (sub)type */ |
| 3859 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3860 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3861 | hdd_err("failed to get vdev type: %d", status); |
| 3862 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3863 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3864 | session_param->sme_session_id = adapter->session_id; |
| 3865 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3866 | session_param->type_of_persona = type; |
| 3867 | session_param->subtype_of_persona = sub_type; |
| 3868 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3869 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3870 | session_param->callback = callback; |
| 3871 | session_param->callback_ctx = callback_ctx; |
| 3872 | |
| 3873 | return 0; |
| 3874 | } |
| 3875 | |
| 3876 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3877 | csr_roam_completeCallback callback, void *ctx) |
| 3878 | { |
| 3879 | QDF_STATUS status; |
| 3880 | int errno; |
| 3881 | struct hdd_context *hdd_ctx; |
| 3882 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3883 | |
| 3884 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3885 | |
| 3886 | /* do vdev create via objmgr */ |
| 3887 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3888 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3889 | if (errno) { |
| 3890 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3891 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3892 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3893 | |
| 3894 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3895 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3896 | if (QDF_STATUS_SUCCESS != status) { |
| 3897 | hdd_err("failed to reinit session open event"); |
| 3898 | return -EINVAL; |
| 3899 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3900 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3901 | callback, ctx); |
| 3902 | if (errno) { |
| 3903 | hdd_err("failed to populating SME params"); |
| 3904 | goto objmgr_vdev_destroy_procedure; |
| 3905 | } |
| 3906 | |
| 3907 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3908 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3909 | hdd_err("failed to open sme session: %d", status); |
| 3910 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3911 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3912 | } |
| 3913 | |
| 3914 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3915 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3916 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3917 | if (QDF_STATUS_SUCCESS != status) { |
| 3918 | if (adapter->qdf_session_open_event.force_set) { |
| 3919 | /* |
| 3920 | * SSR/PDR has caused shutdown, which has forcefully |
| 3921 | * set the event. Return without the closing session. |
| 3922 | */ |
| 3923 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3924 | hdd_err("Session open event forcefully set"); |
| 3925 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3926 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3927 | |
| 3928 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3929 | hdd_err("Session failed to open within timeout period"); |
| 3930 | else |
| 3931 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3932 | status); |
| 3933 | errno = -ETIMEDOUT; |
| 3934 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3935 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3936 | } |
| 3937 | |
| 3938 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3939 | errno = hdd_vdev_ready(adapter); |
| 3940 | if (errno) { |
| 3941 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3942 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3943 | } |
| 3944 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 3945 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3946 | hdd_debug("setting RTT mac randomization param: %d", |
| 3947 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 3948 | errno = sme_cli_set_command(adapter->session_id, |
| 3949 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 3950 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 3951 | VDEV_CMD); |
| 3952 | if (0 != errno) |
| 3953 | hdd_err("RTT mac randomization param set failed %d", |
| 3954 | errno); |
| 3955 | } |
| 3956 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3957 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3958 | |
| 3959 | return 0; |
| 3960 | |
| 3961 | /* |
| 3962 | * Due to legacy constraints, we need to destroy in the same order as |
| 3963 | * create. So, split error handling into 2 cases to accommodate. |
| 3964 | */ |
| 3965 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3966 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3967 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3968 | |
| 3969 | return errno; |
| 3970 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3971 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3972 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3973 | |
| 3974 | return errno; |
| 3975 | } |
| 3976 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3977 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3978 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3979 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3980 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3981 | QDF_STATUS status; |
| 3982 | int ret_val; |
| 3983 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3984 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3985 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3986 | 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] | 3987 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3988 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 3989 | hdd_roam_profile_init(adapter); |
| 3990 | hdd_register_wext(adapter->dev); |
| 3991 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3992 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3993 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 3994 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3995 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 3996 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 3997 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3998 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 3999 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4000 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4001 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4002 | hdd_ctx->config->OperatingChannel; |
| 4003 | |
| 4004 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4005 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4006 | |
| 4007 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4008 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4009 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4010 | status, status); |
| 4011 | goto error_init_txrx; |
| 4012 | } |
| 4013 | |
| 4014 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4015 | |
| 4016 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4017 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4018 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4019 | status, status); |
| 4020 | goto error_wmm_init; |
| 4021 | } |
| 4022 | |
| 4023 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4024 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4025 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4026 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4027 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4028 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4029 | if (ret_val) |
| 4030 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4031 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4032 | /* |
| 4033 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4034 | * during that time, then as part of SSR init, do not enable |
| 4035 | * the LRO again. Keep the LRO state same as before SSR. |
| 4036 | */ |
| 4037 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4038 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4039 | |
| 4040 | /* rcpi info initialization */ |
| 4041 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4042 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4043 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4044 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4045 | error_wmm_init: |
| 4046 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4047 | hdd_deinit_tx_rx(adapter); |
| 4048 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4049 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4050 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4051 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4052 | return status; |
| 4053 | } |
| 4054 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4055 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4056 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4057 | * @hdd_ctx: global hdd context |
| 4058 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4059 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4060 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4061 | * |
| 4062 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4063 | * |
| 4064 | * Return: None. |
| 4065 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4066 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4067 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4068 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4069 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4070 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4071 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4072 | if (adapter->dev) { |
| 4073 | if (rtnl_held) |
| 4074 | adapter->dev->wireless_handlers = NULL; |
| 4075 | else { |
| 4076 | rtnl_lock(); |
| 4077 | adapter->dev->wireless_handlers = NULL; |
| 4078 | rtnl_unlock(); |
| 4079 | } |
| 4080 | } |
| 4081 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4082 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4083 | hdd_deinit_tx_rx(adapter); |
| 4084 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4085 | } |
| 4086 | |
| 4087 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4088 | hdd_wmm_adapter_close(adapter); |
| 4089 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4090 | } |
| 4091 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4092 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4093 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4094 | } |
| 4095 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4096 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4097 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4098 | bool rtnl_held) |
| 4099 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4100 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4101 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4102 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4103 | case QDF_STA_MODE: |
| 4104 | case QDF_P2P_CLIENT_MODE: |
| 4105 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4106 | case QDF_IBSS_MODE: |
| 4107 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4108 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4109 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4110 | break; |
| 4111 | } |
| 4112 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4113 | case QDF_SAP_MODE: |
| 4114 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4115 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4116 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4117 | break; |
| 4118 | } |
| 4119 | |
| 4120 | default: |
| 4121 | break; |
| 4122 | } |
| 4123 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4124 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4125 | } |
| 4126 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4127 | 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] | 4128 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4129 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4130 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4131 | |
| 4132 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4133 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4135 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4136 | return; |
| 4137 | } |
| 4138 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4139 | hdd_nud_deinit_tracking(adapter); |
| 4140 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4141 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4142 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4143 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4144 | /* |
| 4145 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4146 | * the driver is almost closed and cannot handle either control |
| 4147 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4148 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4149 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4150 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4151 | * the interface is closed and restricts any operations on that |
| 4152 | */ |
| 4153 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4154 | |
| 4155 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4156 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4157 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4158 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4159 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4160 | /* |
| 4161 | * Note that the adapter is no longer valid at this point |
| 4162 | * since the memory has been reclaimed |
| 4163 | */ |
| 4164 | } |
| 4165 | } |
| 4166 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4167 | 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] | 4168 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4169 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4170 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4171 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4172 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4173 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4174 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4175 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4176 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4177 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4178 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4179 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4180 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4181 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4182 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4183 | /** |
| 4184 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4185 | * @hdd_ctx: HDD Context |
| 4186 | * @adapter: HDD Adapter |
| 4187 | * |
| 4188 | * This function set the FW Debug log level based on the INI. |
| 4189 | * |
| 4190 | * Return: None |
| 4191 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4192 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4193 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4194 | { |
| 4195 | uint8_t count = 0, numentries = 0, |
| 4196 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4197 | uint32_t value = 0; |
| 4198 | int ret; |
| 4199 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4200 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4201 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4202 | 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] | 4203 | return; |
| 4204 | } |
| 4205 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4206 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4207 | hdd_ctx->fw_log_settings.dl_type = |
| 4208 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4209 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4210 | WMI_DBGLOG_TYPE, |
| 4211 | hdd_ctx->config->enableFwLogType, |
| 4212 | DBG_CMD); |
| 4213 | if (ret != 0) |
| 4214 | hdd_err("Failed to enable FW log type ret %d", |
| 4215 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4216 | |
| 4217 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4218 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4219 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4220 | WMI_DBGLOG_LOG_LEVEL, |
| 4221 | hdd_ctx->config->enableFwLogLevel, |
| 4222 | DBG_CMD); |
| 4223 | if (ret != 0) |
| 4224 | hdd_err("Failed to enable FW log level ret %d", |
| 4225 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4226 | |
| 4227 | hdd_string_to_u8_array( |
| 4228 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4229 | moduleloglevel, |
| 4230 | &numentries, |
| 4231 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4232 | |
| 4233 | while (count < numentries) { |
| 4234 | /* |
| 4235 | * FW module log level input string looks like |
| 4236 | * below: |
| 4237 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4238 | * <Log Level>,... |
| 4239 | * For example: |
| 4240 | * gFwDebugModuleLoglevel= |
| 4241 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4242 | * Above input string means : |
| 4243 | * For FW module ID 1 enable log level 0 |
| 4244 | * For FW module ID 2 enable log level 1 |
| 4245 | * For FW module ID 3 enable log level 2 |
| 4246 | * For FW module ID 4 enable log level 3 |
| 4247 | * For FW module ID 5 enable log level 4 |
| 4248 | * For FW module ID 6 enable log level 5 |
| 4249 | * For FW module ID 7 enable log level 6 |
| 4250 | */ |
| 4251 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4252 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4253 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4254 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4255 | moduleloglevel[count], |
| 4256 | moduleloglevel[count + 1]); |
| 4257 | return; |
| 4258 | } |
| 4259 | |
| 4260 | value = moduleloglevel[count] << 16; |
| 4261 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4262 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4263 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4264 | value, DBG_CMD); |
| 4265 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4266 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4267 | value, ret); |
| 4268 | |
| 4269 | count += 2; |
| 4270 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4271 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4272 | } |
| 4273 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4274 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4275 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4276 | { |
| 4277 | } |
| 4278 | |
| 4279 | #endif |
| 4280 | |
| 4281 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4282 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4283 | * @adapter: HDD adapter |
| 4284 | * |
| 4285 | * Return: 0 on success or errno on failure |
| 4286 | */ |
| 4287 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4288 | { |
| 4289 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4290 | QDF_STATUS status; |
| 4291 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4292 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4293 | |
| 4294 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4295 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4296 | hdd_ctx->config->txchainmask1x1, |
| 4297 | hdd_ctx->config->rxchainmask1x1); |
| 4298 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4299 | hdd_ctx->config->dual_mac_feature_disable, |
| 4300 | hdd_ctx->config->tx_chain_mask_2g, |
| 4301 | hdd_ctx->config->rx_chain_mask_2g); |
| 4302 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4303 | hdd_ctx->config->tx_chain_mask_5g, |
| 4304 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4305 | hdd_debug("enable_bt_chain_separation %d", |
| 4306 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4307 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4308 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4309 | HW_MODE_DBS_NONE, |
| 4310 | CDS_BAND_ALL); |
| 4311 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4312 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4313 | return qdf_status_to_os_return(status); |
| 4314 | } |
| 4315 | |
| 4316 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4317 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4318 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4319 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
| 4320 | hdd_info("firmware not capable. skip chain mask programming"); |
| 4321 | return 0; |
| 4322 | } |
| 4323 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4324 | if (hdd_ctx->config->enable2x2 && |
| 4325 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4326 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4327 | return 0; |
| 4328 | } |
| 4329 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4330 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4331 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4332 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4333 | hdd_ctx->config->dual_mac_feature_disable); |
| 4334 | return 0; |
| 4335 | } |
| 4336 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4337 | if (hdd_ctx->lte_coex_ant_share) { |
| 4338 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4339 | return 0; |
| 4340 | } |
| 4341 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4342 | if (hdd_ctx->config->txchainmask1x1) { |
| 4343 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4344 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4345 | hdd_ctx->config->txchainmask1x1, |
| 4346 | PDEV_CMD); |
| 4347 | if (ret_val) |
| 4348 | goto error; |
| 4349 | } |
| 4350 | |
| 4351 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4352 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4353 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4354 | hdd_ctx->config->rxchainmask1x1, |
| 4355 | PDEV_CMD); |
| 4356 | if (ret_val) |
| 4357 | goto error; |
| 4358 | } |
| 4359 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4360 | if (hdd_ctx->config->txchainmask1x1 || |
| 4361 | hdd_ctx->config->rxchainmask1x1) { |
| 4362 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4363 | return 0; |
| 4364 | } |
| 4365 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4366 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4367 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4368 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4369 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4370 | if (0 != ret_val) |
| 4371 | goto error; |
| 4372 | } |
| 4373 | |
| 4374 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4375 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4376 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4377 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4378 | if (0 != ret_val) |
| 4379 | goto error; |
| 4380 | } |
| 4381 | |
| 4382 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4383 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4384 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4385 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4386 | if (0 != ret_val) |
| 4387 | goto error; |
| 4388 | } |
| 4389 | |
| 4390 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4391 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4392 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4393 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4394 | if (0 != ret_val) |
| 4395 | goto error; |
| 4396 | } |
| 4397 | |
| 4398 | return 0; |
| 4399 | |
| 4400 | error: |
| 4401 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4402 | return -EINVAL; |
| 4403 | } |
| 4404 | |
| 4405 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4406 | * hdd_set_fw_params() - Set parameters to firmware |
| 4407 | * @adapter: HDD adapter |
| 4408 | * |
| 4409 | * This function Sets various parameters to fw once the |
| 4410 | * adapter is started. |
| 4411 | * |
| 4412 | * Return: 0 on success or errno on failure |
| 4413 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4414 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4415 | { |
| 4416 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4417 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4418 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4419 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4420 | |
| 4421 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4422 | if (!hdd_ctx) |
| 4423 | return -EINVAL; |
| 4424 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4425 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4426 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4427 | return 0; |
| 4428 | } |
| 4429 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4430 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4431 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4432 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4433 | if (ret) { |
| 4434 | hdd_err("Failed to set LPRx"); |
| 4435 | goto error; |
| 4436 | } |
| 4437 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4438 | |
| 4439 | ret = sme_cli_set_command( |
| 4440 | adapter->session_id, |
| 4441 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4442 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4443 | PDEV_CMD); |
| 4444 | if (ret) { |
| 4445 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4446 | goto error; |
| 4447 | } |
| 4448 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4449 | ret = sme_cli_set_command( |
| 4450 | adapter->session_id, |
| 4451 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4452 | hdd_ctx->config->enable_tx_sch_delay, |
| 4453 | PDEV_CMD); |
| 4454 | if (ret) { |
| 4455 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4456 | goto error; |
| 4457 | } |
| 4458 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4459 | ret = sme_cli_set_command( |
| 4460 | adapter->session_id, |
| 4461 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4462 | hdd_ctx->config->enable_secondary_rate, |
| 4463 | PDEV_CMD); |
| 4464 | if (ret) { |
| 4465 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4466 | goto error; |
| 4467 | } |
| 4468 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4469 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4470 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4471 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4472 | hdd_ctx->config->upper_brssi_thresh); |
| 4473 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4474 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4475 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4476 | hdd_ctx->config->lower_brssi_thresh); |
| 4477 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4478 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4479 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4480 | hdd_ctx->config->enable_dtim_1chrx); |
| 4481 | } |
| 4482 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4483 | if (hdd_ctx->config->enable2x2) { |
| 4484 | hdd_debug("configuring 2x2 mode fw params"); |
| 4485 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4486 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4487 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4488 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4489 | PDEV_CMD); |
| 4490 | if (ret) { |
| 4491 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4492 | ret); |
| 4493 | goto error; |
| 4494 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4495 | |
| 4496 | if (hdd_configure_chain_mask(adapter)) |
| 4497 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4498 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4499 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4500 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4501 | hdd_debug("configuring 1x1 mode fw params"); |
| 4502 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4503 | /* |
| 4504 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4505 | * we are passing two value |
| 4506 | * as param_id << 29 | param_value. |
| 4507 | * Below param_value = 0(disable) |
| 4508 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4509 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4510 | WMI_STA_SMPS_PARAM_CMDID, |
| 4511 | HDD_DTIM_1CHAIN_RX_ID << |
| 4512 | HDD_SMPS_PARAM_VALUE_S, |
| 4513 | VDEV_CMD); |
| 4514 | if (ret) { |
| 4515 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4516 | goto error; |
| 4517 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4518 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4519 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4520 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4521 | |
| 4522 | if (hdd_configure_chain_mask(adapter)) |
| 4523 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4524 | } |
| 4525 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4526 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4527 | WMI_PDEV_PARAM_HYST_EN, |
| 4528 | hdd_ctx->config->enableMemDeepSleep, |
| 4529 | PDEV_CMD); |
| 4530 | if (ret) { |
| 4531 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4532 | goto error; |
| 4533 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4534 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4535 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4536 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4537 | hdd_ctx->config->rts_profile, |
| 4538 | VDEV_CMD); |
| 4539 | if (ret) { |
| 4540 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4541 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4542 | } |
| 4543 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4544 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4545 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4546 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4547 | GEN_VDEV_PARAM_AMSDU, |
| 4548 | hdd_ctx->config->max_amsdu_num, |
| 4549 | GEN_CMD); |
| 4550 | if (ret != 0) { |
| 4551 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4552 | goto error; |
| 4553 | } |
| 4554 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4555 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4556 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4557 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4558 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4559 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4560 | error: |
| 4561 | return -EINVAL; |
| 4562 | } |
| 4563 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4564 | /** |
| 4565 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4566 | * @hdd_ctx: global hdd context |
| 4567 | * @session_type: type of the interface to be created |
| 4568 | * @iface_name: User-visible name of the interface |
| 4569 | * @macAddr: MAC address to assign to the interface |
| 4570 | * @name_assign_type: the name of assign type of the netdev |
| 4571 | * @rtnl_held: the rtnl lock hold flag |
| 4572 | * |
| 4573 | * This function open and setup the hdd adpater according to the device |
| 4574 | * type request, assign the name, the mac address assigned, and then prepared |
| 4575 | * the hdd related parameters, queue, lock and ready to start. |
| 4576 | * |
| 4577 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4578 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4579 | 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] | 4580 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4581 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4582 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4583 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4584 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4585 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4586 | |
| 4587 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4588 | /* |
| 4589 | * Max limit reached on the number of vdevs configured by the |
| 4590 | * host. Return error |
| 4591 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4592 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4593 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4594 | return NULL; |
| 4595 | } |
| 4596 | |
| 4597 | if (macAddr == NULL) { |
| 4598 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4599 | 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] | 4600 | return NULL; |
| 4601 | } |
| 4602 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4603 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4604 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4605 | " already exists", |
| 4606 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4607 | return NULL; |
| 4608 | } |
| 4609 | |
| 4610 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4611 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4612 | /* Reset locally administered bit if the device mode is STA */ |
| 4613 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4614 | hdd_info("locally administered bit reset in sta mode: " |
| 4615 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4616 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4617 | case QDF_P2P_CLIENT_MODE: |
| 4618 | case QDF_P2P_DEVICE_MODE: |
| 4619 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4620 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4621 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4622 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4623 | name_assign_type, |
| 4624 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4625 | |
| 4626 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4627 | hdd_err("failed to allocate adapter for session %d", |
| 4628 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4629 | return NULL; |
| 4630 | } |
| 4631 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4632 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4633 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4634 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4635 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4636 | else if (QDF_MONITOR_MODE == session_type) |
| 4637 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4638 | else |
| 4639 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4640 | |
| 4641 | adapter->device_mode = session_type; |
| 4642 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4643 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4644 | /* |
| 4645 | * Workqueue which gets scheduled in IPv4 notification |
| 4646 | * callback |
| 4647 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4648 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4650 | |
| 4651 | #ifdef WLAN_NS_OFFLOAD |
| 4652 | /* |
| 4653 | * Workqueue which gets scheduled in IPv6 |
| 4654 | * notification callback. |
| 4655 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4656 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4657 | hdd_ipv6_notifier_work_queue); |
| 4658 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4659 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4660 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4661 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4662 | |
| 4663 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4664 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4665 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4666 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4667 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4668 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4669 | /* Initialize NAN Data Interface */ |
| 4670 | if (QDF_NDI_MODE == session_type) { |
| 4671 | status = hdd_init_nan_data_mode(adapter); |
| 4672 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4673 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4674 | } |
| 4675 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4676 | hdd_nud_init_tracking(adapter); |
| 4677 | |
| 4678 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4679 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4680 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4681 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4682 | case QDF_P2P_GO_MODE: |
| 4683 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4684 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4685 | name_assign_type, |
| 4686 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4687 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4688 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4689 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4690 | return NULL; |
| 4691 | } |
| 4692 | |
| 4693 | adapter->wdev.iftype = |
| 4694 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4695 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | NL80211_IFTYPE_P2P_GO; |
| 4697 | adapter->device_mode = session_type; |
| 4698 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4699 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4700 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4701 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4702 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4703 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4704 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4705 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4706 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4707 | |
| 4708 | /* |
| 4709 | * Workqueue which gets scheduled in IPv4 notification |
| 4710 | * callback |
| 4711 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4712 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4713 | hdd_ipv4_notifier_work_queue); |
| 4714 | |
| 4715 | #ifdef WLAN_NS_OFFLOAD |
| 4716 | /* |
| 4717 | * Workqueue which gets scheduled in IPv6 |
| 4718 | * notification callback. |
| 4719 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4720 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4721 | hdd_ipv6_notifier_work_queue); |
| 4722 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4723 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4724 | case QDF_FTM_MODE: |
| 4725 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4726 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4727 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4728 | if (NULL == adapter) { |
| 4729 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4730 | return NULL; |
| 4731 | } |
| 4732 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4733 | adapter->device_mode = session_type; |
| 4734 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4735 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4736 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4737 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4738 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4739 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4740 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4741 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4742 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4743 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4744 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4745 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4746 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4747 | return NULL; |
| 4748 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4749 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4750 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4751 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4752 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4754 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | } |
| 4756 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4757 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4758 | if (NULL != adapter) { |
| 4759 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4760 | adapter = NULL; |
| 4761 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4762 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4763 | return NULL; |
| 4764 | } |
| 4765 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4766 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4767 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4768 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4770 | /* Adapter successfully added. Increment the vdev count */ |
| 4771 | hdd_ctx->current_intf_count++; |
| 4772 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4773 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4774 | hdd_ctx->current_intf_count); |
| 4775 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4776 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | } |
| 4778 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4779 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4780 | hdd_err("Interface %s wow debug_fs init failed", |
| 4781 | netdev_name(adapter->dev)); |
| 4782 | |
| 4783 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4784 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | |
| 4786 | return adapter; |
| 4787 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4788 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4789 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4790 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | |
| 4792 | return NULL; |
| 4793 | } |
| 4794 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4795 | #ifdef MSM_PLATFORM |
| 4796 | static inline |
| 4797 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4798 | { |
| 4799 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4800 | } |
| 4801 | #else |
| 4802 | static inline |
| 4803 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4804 | { |
| 4805 | } |
| 4806 | #endif |
| 4807 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4808 | 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] | 4809 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4810 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4811 | /* |
| 4812 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4813 | * |
| 4814 | * The reason is to fix one race condition between |
| 4815 | * bus bandwidth work and cleaning up an adapter. |
| 4816 | * Under some conditions, it is possible for the bus bandwidth |
| 4817 | * work to access a particularly destroyed adapter, leading to |
| 4818 | * use-after-free. |
| 4819 | */ |
| 4820 | hdd_debug("wait for bus bw work to flush"); |
| 4821 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4822 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4823 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4824 | /* cleanup adapter */ |
| 4825 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4826 | adapter->device_mode); |
| 4827 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4828 | hdd_remove_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4830 | /* conditionally restart the bw timer */ |
| 4831 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4833 | /* Adapter removed. Decrement vdev count */ |
| 4834 | if (hdd_ctx->current_intf_count != 0) |
| 4835 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4836 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4837 | /* Fw will take care incase of concurrency */ |
| 4838 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4839 | } |
| 4840 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4841 | /** |
| 4842 | * hdd_close_all_adapters - Close all open adapters |
| 4843 | * @hdd_ctx: Hdd context |
| 4844 | * rtnl_held: True if RTNL lock held |
| 4845 | * |
| 4846 | * Close all open adapters. |
| 4847 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4848 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4849 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4850 | 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] | 4851 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4852 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4853 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4854 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4855 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4856 | |
| 4857 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4858 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4859 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4860 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4861 | adapter->mac_addr.bytes); |
| 4862 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4863 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4864 | /* Adapter removed. Decrement vdev count */ |
| 4865 | if (hdd_ctx->current_intf_count != 0) |
| 4866 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4867 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4868 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4869 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4870 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4871 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4872 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | } |
| 4874 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4875 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4877 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4878 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4879 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4880 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4881 | case QDF_STA_MODE: |
| 4882 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4883 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4884 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4885 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4886 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4887 | break; |
| 4888 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4889 | case QDF_SAP_MODE: |
| 4890 | case QDF_P2P_GO_MODE: |
| 4891 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4893 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4894 | break; |
| 4895 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4896 | case QDF_FTM_MODE: |
| 4897 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | default: |
| 4899 | /* |
| 4900 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4901 | * for these kind of devices |
| 4902 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4903 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4904 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4905 | return; |
| 4906 | } |
| 4907 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4908 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4909 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | updateIE.ieBufferlength = 0; |
| 4911 | updateIE.pAdditionIEBuffer = NULL; |
| 4912 | updateIE.append = true; |
| 4913 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4914 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4915 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4916 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4917 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | } |
| 4919 | } |
| 4920 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4921 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4922 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4924 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4925 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4926 | union iwreq_data wrqu; |
| 4927 | tSirUpdateIE updateIE; |
| 4928 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 4929 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4930 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4931 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4932 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 4933 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 4934 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4935 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4936 | hdd_nud_ignore_tracking(adapter, true); |
| 4937 | hdd_nud_reset_tracking(adapter); |
| 4938 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4939 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4940 | wlan_hdd_netif_queue_control(adapter, |
| 4941 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4942 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4943 | /* |
| 4944 | * if this is the last active connection check & stop the |
| 4945 | * opportunistic timer first |
| 4946 | */ |
| 4947 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4948 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4949 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4950 | adapter->device_mode), NULL) == 1)) || |
| 4951 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4952 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4953 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4954 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4955 | case QDF_STA_MODE: |
| 4956 | case QDF_P2P_CLIENT_MODE: |
| 4957 | case QDF_IBSS_MODE: |
| 4958 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4959 | case QDF_NDI_MODE: |
| 4960 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4961 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4962 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4963 | hdd_is_connecting( |
| 4964 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4965 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4966 | roam_profile = hdd_roam_profile(adapter); |
| 4967 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4968 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4969 | qdf_ret_status = sme_roam_disconnect( |
| 4970 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4971 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4972 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4973 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4974 | eCSR_BSS_TYPE_START_IBSS) |
| 4975 | qdf_ret_status = sme_roam_disconnect( |
| 4976 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4977 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4978 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4979 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4980 | qdf_ret_status = |
| 4981 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4982 | hdd_debug("Send disconnected event to userspace"); |
| 4983 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4984 | adapter->dev, true, |
| 4985 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 4986 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4987 | qdf_ret_status = sme_roam_disconnect( |
| 4988 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4989 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4990 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4991 | /* success implies disconnect command got |
| 4992 | * queued up successfully |
| 4993 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4994 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 4995 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | rc = wait_for_completion_timeout( |
| 4997 | &adapter->disconnect_comp_var, |
| 4998 | msecs_to_jiffies |
| 4999 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5000 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5001 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5003 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5004 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5006 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5007 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5008 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5009 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5010 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5011 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5012 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5013 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5014 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5015 | |
| 5016 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5017 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | #endif |
| 5019 | |
| 5020 | hdd_deregister_tx_flow_control(adapter); |
| 5021 | |
| 5022 | #ifdef WLAN_NS_OFFLOAD |
| 5023 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5024 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5025 | #endif |
| 5026 | #endif |
| 5027 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5028 | if (adapter->device_mode == QDF_STA_MODE) |
| 5029 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5030 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5031 | |
| 5032 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5033 | hdd_err("Error: Can't disconnect adapter"); |
| 5034 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5035 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5036 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5037 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | break; |
| 5039 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5040 | case QDF_MONITOR_MODE: |
| 5041 | wlan_hdd_scan_abort(adapter); |
| 5042 | hdd_deregister_tx_flow_control(adapter); |
| 5043 | hdd_vdev_destroy(adapter); |
| 5044 | break; |
| 5045 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5046 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5047 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5048 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5049 | sap_config = &adapter->session.ap.sap_config; |
| 5050 | if (sap_config) |
| 5051 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5052 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5053 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 5054 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5055 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5056 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5057 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5058 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5059 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5060 | cds_flush_delayed_work( |
| 5061 | &adapter->acs_pending_work); |
| 5062 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5063 | } |
| 5064 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5065 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5066 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5067 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5068 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5069 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5070 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5072 | |
| 5073 | hdd_deregister_tx_flow_control(adapter); |
| 5074 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5075 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5076 | mutex_lock(&hdd_ctx->sap_lock); |
| 5077 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5078 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5079 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5080 | |
| 5081 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5082 | status = wlansap_stop_bss( |
| 5083 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5084 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5085 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5086 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5087 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5088 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5089 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5090 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5091 | qdf_wait_for_event_completion( |
| 5092 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5093 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5095 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5096 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5097 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | } |
| 5099 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5100 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | } |
| 5102 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5103 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5104 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5105 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5106 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5107 | adapter->device_mode, |
| 5108 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5109 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5110 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5111 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5112 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5113 | updateIE.ieBufferlength = 0; |
| 5114 | updateIE.pAdditionIEBuffer = NULL; |
| 5115 | updateIE.append = false; |
| 5116 | updateIE.notify = false; |
| 5117 | /* Probe bcn reset */ |
| 5118 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5119 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5120 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5121 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5122 | } |
| 5123 | /* Assoc resp reset */ |
| 5124 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5125 | &updateIE, |
| 5126 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5127 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5128 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5129 | } |
| 5130 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5131 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5132 | } |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5133 | qdf_mem_free(adapter->session.ap.beacon); |
| 5134 | adapter->session.ap.beacon = NULL; |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5135 | /* |
| 5136 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5137 | */ |
| 5138 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5139 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5140 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5141 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5142 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5143 | #endif |
| 5144 | |
| 5145 | #ifdef WLAN_NS_OFFLOAD |
| 5146 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5147 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5148 | #endif |
| 5149 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5150 | |
| 5151 | hdd_vdev_destroy(adapter); |
| 5152 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5153 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5154 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5155 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5156 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5157 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5158 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5159 | hdd_deregister_tx_flow_control(adapter); |
| 5160 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5161 | break; |
| 5162 | default: |
| 5163 | break; |
| 5164 | } |
| 5165 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5166 | if (adapter->scan_info.default_scan_ies) { |
| 5167 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5168 | adapter->scan_info.default_scan_ies = NULL; |
| 5169 | } |
| 5170 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5171 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5172 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5173 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5174 | } |
| 5175 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5176 | /** |
| 5177 | * hdd_deinit_all_adapters - deinit all adapters |
| 5178 | * @hdd_ctx: HDD context |
| 5179 | * @rtnl_held: True if RTNL lock held |
| 5180 | * |
| 5181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5182 | 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] | 5183 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5184 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5185 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5186 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5187 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5188 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5189 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5190 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5191 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5192 | } |
| 5193 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5194 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5195 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5196 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5197 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5198 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5199 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5200 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5201 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5202 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5203 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5205 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5206 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5207 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5208 | } |
| 5209 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5210 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5211 | struct hdd_adapter *adapter) |
| 5212 | { |
| 5213 | switch (adapter->device_mode) { |
| 5214 | case QDF_STA_MODE: |
| 5215 | case QDF_P2P_CLIENT_MODE: |
| 5216 | case QDF_IBSS_MODE: |
| 5217 | case QDF_P2P_DEVICE_MODE: |
| 5218 | case QDF_NDI_MODE: |
| 5219 | wlan_hdd_scan_abort(adapter); |
| 5220 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5221 | if (adapter->device_mode == QDF_STA_MODE) |
| 5222 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5223 | adapter->dev); |
| 5224 | break; |
| 5225 | case QDF_P2P_GO_MODE: |
| 5226 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5227 | break; |
| 5228 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5229 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5230 | wlan_hdd_undo_acs(adapter); |
| 5231 | break; |
| 5232 | default: |
| 5233 | break; |
| 5234 | } |
| 5235 | } |
| 5236 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5237 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5238 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5239 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5240 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5241 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5242 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5243 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5244 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5245 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5246 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5247 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5248 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5249 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5250 | hdd_device_mode_to_string(adapter->device_mode), |
| 5251 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5252 | |
| 5253 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5254 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5255 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5256 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5257 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5258 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5259 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5260 | if (hdd_ctx->config->sap_internal_restart && |
| 5261 | adapter->device_mode == QDF_SAP_MODE) { |
| 5262 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5263 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5264 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5265 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5266 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5267 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5268 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5269 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5270 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5271 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5273 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5274 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5275 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5276 | |
| 5277 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5278 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5279 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5280 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5281 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5282 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5283 | hdd_wmm_adapter_close(adapter); |
| 5284 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5285 | } |
| 5286 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5287 | if (adapter->device_mode == QDF_STA_MODE) |
| 5288 | hdd_clear_fils_connection_info(adapter); |
| 5289 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5290 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5291 | /* |
| 5292 | * If adapter is SAP, set session ID to invalid |
| 5293 | * since SAP session will be cleanup during SSR. |
| 5294 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5295 | wlansap_set_invalid_session( |
| 5296 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5297 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5298 | wlansap_cleanup_cac_timer( |
| 5299 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5300 | } |
| 5301 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5302 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5303 | if (adapter->device_mode == QDF_STA_MODE || |
| 5304 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5305 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5306 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5307 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5308 | |
| 5309 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5310 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5311 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
| 5312 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5313 | if (adapter->sta_info[sta_id].in_use) { |
| 5314 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5315 | sta_id); |
| 5316 | hdd_softap_deregister_sta(adapter, |
| 5317 | sta_id); |
| 5318 | adapter->sta_info[sta_id].in_use = 0; |
| 5319 | } |
| 5320 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5321 | } |
| 5322 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5323 | hdd_nud_reset_tracking(adapter); |
| 5324 | hdd_nud_ignore_tracking(adapter, true); |
| 5325 | hdd_set_disconnect_status(adapter, false); |
| 5326 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5327 | hdd_softap_deinit_tx_rx(adapter); |
| 5328 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5329 | /* Destroy vdev which will be recreated during reinit. */ |
| 5330 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5331 | } |
| 5332 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5333 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5334 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5335 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5336 | } |
| 5337 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5338 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5339 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5340 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5341 | bool close_modules = true; |
| 5342 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5343 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5344 | hdd_info("FTM mode, don't close the module"); |
| 5345 | return false; |
| 5346 | } |
| 5347 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5348 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5349 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5350 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5351 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5352 | close_modules = false; |
| 5353 | break; |
| 5354 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5355 | } |
| 5356 | |
| 5357 | return close_modules; |
| 5358 | } |
| 5359 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5360 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5361 | { |
| 5362 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5363 | return true; |
| 5364 | else |
| 5365 | return false; |
| 5366 | } |
| 5367 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5368 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5369 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5370 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5371 | struct ieee80211_channel *channel, |
| 5372 | const u8 *bssid, const u8 *ssid, |
| 5373 | size_t ssid_len) |
| 5374 | { |
| 5375 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5376 | ssid, ssid_len, |
| 5377 | WLAN_CAPABILITY_ESS, |
| 5378 | WLAN_CAPABILITY_ESS); |
| 5379 | } |
| 5380 | #else |
| 5381 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5382 | struct ieee80211_channel *channel, |
| 5383 | const u8 *bssid, const u8 *ssid, |
| 5384 | size_t ssid_len) |
| 5385 | { |
| 5386 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5387 | ssid, ssid_len, |
| 5388 | IEEE80211_BSS_TYPE_ESS, |
| 5389 | IEEE80211_PRIVACY_ANY); |
| 5390 | } |
| 5391 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5392 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5393 | #if defined CFG80211_CONNECT_BSS || \ |
| 5394 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5395 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5396 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5397 | /** |
| 5398 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5399 | * @timeout_reason: reason for connect timeout |
| 5400 | * |
| 5401 | * This function is used to convert host timeout |
| 5402 | * reason enum to kernel specific enum. |
| 5403 | * |
| 5404 | * Return: nl timeout enum |
| 5405 | */ |
| 5406 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5407 | tSirResultCodes timeout_reason) |
| 5408 | { |
| 5409 | switch (timeout_reason) { |
| 5410 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5411 | return NL80211_TIMEOUT_SCAN; |
| 5412 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5413 | return NL80211_TIMEOUT_AUTH; |
| 5414 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5415 | return NL80211_TIMEOUT_ASSOC; |
| 5416 | default: |
| 5417 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5418 | } |
| 5419 | } |
| 5420 | |
| 5421 | /** |
| 5422 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5423 | * @dev: network device |
| 5424 | * @bssid: bssid to which we want to associate |
| 5425 | * @timeout_reason: reason for connect timeout |
| 5426 | * |
| 5427 | * This API is used to send connection timeout reason to supplicant |
| 5428 | * |
| 5429 | * Return: void |
| 5430 | */ |
| 5431 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5432 | const u8 *bssid, |
| 5433 | tSirResultCodes timeout_reason) |
| 5434 | { |
| 5435 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5436 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5437 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5438 | |
| 5439 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5440 | nl_timeout_reason); |
| 5441 | } |
| 5442 | |
| 5443 | /** |
| 5444 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5445 | * @dev: network device |
| 5446 | * @bssid: bssid to which we want to associate |
| 5447 | * @req_ie: Request Information Element |
| 5448 | * @req_ie_len: len of the req IE |
| 5449 | * @resp_ie: Response IE |
| 5450 | * @resp_ie_len: len of ht response IE |
| 5451 | * @status: status |
| 5452 | * @gfp: Kernel Flag |
| 5453 | * @timeout_reason: reason for connect timeout |
| 5454 | * |
| 5455 | * Return: void |
| 5456 | */ |
| 5457 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5458 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5459 | size_t req_ie_len, const u8 *resp_ie, |
| 5460 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5461 | tSirResultCodes timeout_reason) |
| 5462 | { |
| 5463 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5464 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5465 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5466 | |
| 5467 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5468 | resp_ie, resp_ie_len, status, gfp, |
| 5469 | nl_timeout_reason); |
| 5470 | } |
| 5471 | #else |
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)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5474 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5475 | const u8 *bssid, |
| 5476 | tSirResultCodes timeout_reason) |
| 5477 | { |
| 5478 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5479 | } |
| 5480 | #endif |
| 5481 | |
| 5482 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5483 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5484 | size_t req_ie_len, const u8 *resp_ie, |
| 5485 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5486 | tSirResultCodes timeout_reason) |
| 5487 | { |
| 5488 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5489 | resp_ie, resp_ie_len, status, gfp); |
| 5490 | } |
| 5491 | #endif |
| 5492 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5493 | /** |
| 5494 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5495 | * @dev: network device |
| 5496 | * @bssid: bssid to which we want to associate |
| 5497 | * @req_ie: Request Information Element |
| 5498 | * @req_ie_len: len of the req IE |
| 5499 | * @resp_ie: Response IE |
| 5500 | * @resp_ie_len: len of ht response IE |
| 5501 | * @status: status |
| 5502 | * @gfp: Kernel Flag |
| 5503 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5504 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5505 | * |
| 5506 | * The API is a wrapper to send connection status to supplicant |
| 5507 | * |
| 5508 | * Return: Void |
| 5509 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5510 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5511 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5512 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5513 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5514 | size_t req_ie_len, const u8 *resp_ie, |
| 5515 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5516 | bool connect_timeout, |
| 5517 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5518 | { |
| 5519 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5520 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5521 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5522 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5523 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5524 | } |
| 5525 | #else |
| 5526 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5527 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5528 | size_t req_ie_len, const u8 *resp_ie, |
| 5529 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5530 | bool connect_timeout, |
| 5531 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5532 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5533 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5534 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5535 | } |
| 5536 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5537 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5538 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5539 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5540 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5541 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5542 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5543 | /** |
| 5544 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5545 | * @fils_params: connect response to supplicant |
| 5546 | * @fils_kek: FILS kek |
| 5547 | * @fils_kek_len: FILS kek length |
| 5548 | * @pmk: FILS PMK |
| 5549 | * @pmk_len: FILS PMK length |
| 5550 | * @pmkid: PMKID |
| 5551 | * @fils_seq_num: FILS Seq number |
| 5552 | * |
| 5553 | * Return: None |
| 5554 | */ |
| 5555 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5556 | *fils_params, const uint8_t *fils_kek, |
| 5557 | size_t fils_kek_len, const uint8_t *pmk, |
| 5558 | size_t pmk_len, const uint8_t *pmkid, |
| 5559 | uint16_t fils_seq_num) |
| 5560 | { |
| 5561 | /* Increament seq number to be used for next FILS */ |
| 5562 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5563 | fils_params->update_erp_next_seq_num = true; |
| 5564 | fils_params->fils_kek = fils_kek; |
| 5565 | fils_params->fils_kek_len = fils_kek_len; |
| 5566 | fils_params->pmk = pmk; |
| 5567 | fils_params->pmk_len = pmk_len; |
| 5568 | fils_params->pmkid = pmkid; |
| 5569 | } |
| 5570 | #else |
| 5571 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5572 | *fils_params, const uint8_t |
| 5573 | *fils_kek, size_t fils_kek_len, |
| 5574 | const uint8_t *pmk, size_t pmk_len, |
| 5575 | const uint8_t *pmkid, |
| 5576 | uint16_t fils_seq_num) |
| 5577 | { } |
| 5578 | #endif |
| 5579 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5580 | void hdd_update_hlp_info(struct net_device *dev, |
| 5581 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5582 | { |
| 5583 | struct sk_buff *skb; |
| 5584 | uint16_t skb_len; |
| 5585 | struct llc_snap_hdr_t *llc_hdr; |
| 5586 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5587 | uint8_t *hlp_data; |
| 5588 | uint16_t hlp_data_len; |
| 5589 | struct fils_join_rsp_params *roam_fils_params |
| 5590 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5591 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5592 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5593 | if (!roam_fils_params) { |
| 5594 | hdd_err("FILS Roam Param NULL"); |
| 5595 | return; |
| 5596 | } |
| 5597 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5598 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5599 | hdd_err("FILS HLP Data NULL, len %d", |
| 5600 | roam_fils_params->hlp_data_len); |
| 5601 | return; |
| 5602 | } |
| 5603 | |
| 5604 | hlp_data = roam_fils_params->hlp_data; |
| 5605 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5606 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5607 | /* Calculate skb length */ |
| 5608 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5609 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5610 | if (skb == NULL) { |
| 5611 | hdd_err("HLP packet nbuf alloc fails"); |
| 5612 | return; |
| 5613 | } |
| 5614 | |
| 5615 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5616 | QDF_MAC_ADDR_SIZE); |
| 5617 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5618 | QDF_MAC_ADDR_SIZE); |
| 5619 | |
| 5620 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5621 | if (IS_SNAP(llc_hdr)) { |
| 5622 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5623 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5624 | } |
| 5625 | |
| 5626 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5627 | |
| 5628 | /* |
| 5629 | * This HLP packet is formed from HLP info encapsulated |
| 5630 | * in assoc response frame which is AEAD encrypted. |
| 5631 | * Hence, this checksum validation can be set unnecessary. |
| 5632 | * i.e. network layer need not worry about checksum. |
| 5633 | */ |
| 5634 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5635 | |
| 5636 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5637 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5638 | hdd_err("Sending HLP packet fails"); |
| 5639 | return; |
| 5640 | } |
| 5641 | hdd_debug("send HLP packet to netif successfully"); |
| 5642 | } |
| 5643 | |
| 5644 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5645 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5646 | * @dev: network device |
| 5647 | * @bssid: bssid to which we want to associate |
| 5648 | * @bss: cfg80211 bss info |
| 5649 | * @roam_info: information about connected bss |
| 5650 | * @req_ie: Request Information Element |
| 5651 | * @req_ie_len: len of the req IE |
| 5652 | * @resp_ie: Response IE |
| 5653 | * @resp_ie_len: len of ht response IE |
| 5654 | * @status: status |
| 5655 | * @gfp: allocation flags |
| 5656 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5657 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5658 | * |
| 5659 | * This API is used as wrapper to send FILS key/sequence number |
| 5660 | * params etc. to supplicant in case of FILS connection |
| 5661 | * |
| 5662 | * Return: None |
| 5663 | */ |
| 5664 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5665 | struct cfg80211_bss *bss, |
| 5666 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5667 | const u8 *req_ie, size_t req_ie_len, |
| 5668 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5669 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5670 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5671 | { |
| 5672 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5673 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5674 | struct fils_join_rsp_params *roam_fils_params = |
| 5675 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5676 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5677 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5678 | |
| 5679 | if (!roam_fils_params) { |
| 5680 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5681 | } else { |
| 5682 | fils_params.status = status; |
| 5683 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5684 | fils_params.timeout_reason = |
| 5685 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5686 | fils_params.req_ie = req_ie; |
| 5687 | fils_params.req_ie_len = req_ie_len; |
| 5688 | fils_params.resp_ie = resp_ie; |
| 5689 | fils_params.resp_ie_len = resp_ie_len; |
| 5690 | fils_params.bss = bss; |
| 5691 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5692 | roam_fils_params->kek_len, |
| 5693 | roam_fils_params->fils_pmk, |
| 5694 | roam_fils_params->fils_pmk_len, |
| 5695 | roam_fils_params->fils_pmkid, |
| 5696 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5697 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5698 | } |
| 5699 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5700 | fils_params.status, |
| 5701 | fils_params.fils_erp_next_seq_num); |
| 5702 | |
| 5703 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5704 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5705 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5706 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5707 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5708 | /* Clear all the FILS key info */ |
| 5709 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5710 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5711 | if (roam_fils_params) |
| 5712 | qdf_mem_free(roam_fils_params); |
| 5713 | roam_info->fils_join_rsp = NULL; |
| 5714 | } |
| 5715 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5716 | static inline void |
| 5717 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5718 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5719 | const u8 *req_ie, size_t req_ie_len, |
| 5720 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5721 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5722 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5723 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5724 | #endif |
| 5725 | #endif |
| 5726 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5727 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5728 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5729 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5730 | /** |
| 5731 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5732 | * supplicant. |
| 5733 | * @dev: network device |
| 5734 | * @bssid: bssid to which we want to associate |
| 5735 | * @bss: cfg80211 bss info |
| 5736 | * @roam_info: information about connected bss |
| 5737 | * @req_ie: Request Information Element |
| 5738 | * @req_ie_len: len of the req IE |
| 5739 | * @resp_ie: Response IE |
| 5740 | * @resp_ie_len: len of ht response IE |
| 5741 | * @status: status |
| 5742 | * @gfp: allocation flags |
| 5743 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5744 | * @timeout_reason: reason for connect timeout |
| 5745 | * |
| 5746 | * The API is a wrapper to send connection status to supplicant |
| 5747 | * |
| 5748 | * Return: 0 if success else failure |
| 5749 | */ |
| 5750 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5751 | const u8 *bssid, |
| 5752 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5753 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5754 | size_t req_ie_len, const u8 *resp_ie, |
| 5755 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5756 | bool connect_timeout, |
| 5757 | tSirResultCodes timeout_reason) |
| 5758 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5759 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5760 | if (!roam_info || !roam_info->is_fils_connection) |
| 5761 | return -EINVAL; |
| 5762 | |
| 5763 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5764 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5765 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5766 | return 0; |
| 5767 | } |
| 5768 | #else |
| 5769 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5770 | const u8 *bssid, |
| 5771 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5772 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5773 | size_t req_ie_len, const u8 *resp_ie, |
| 5774 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5775 | bool connect_timeout, |
| 5776 | tSirResultCodes timeout_reason) |
| 5777 | { |
| 5778 | return -EINVAL; |
| 5779 | } |
| 5780 | #endif |
| 5781 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5782 | /** |
| 5783 | * hdd_connect_result() - API to send connection status to supplicant |
| 5784 | * @dev: network device |
| 5785 | * @bssid: bssid to which we want to associate |
| 5786 | * @roam_info: information about connected bss |
| 5787 | * @req_ie: Request Information Element |
| 5788 | * @req_ie_len: len of the req IE |
| 5789 | * @resp_ie: Response IE |
| 5790 | * @resp_ie_len: len of ht response IE |
| 5791 | * @status: status |
| 5792 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5793 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5794 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5795 | * |
| 5796 | * The API is a wrapper to send connection status to supplicant |
| 5797 | * and allow runtime suspend |
| 5798 | * |
| 5799 | * Return: Void |
| 5800 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5801 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5802 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5803 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5804 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5805 | bool connect_timeout, |
| 5806 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5807 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5808 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5809 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5810 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5811 | |
| 5812 | if (WLAN_STATUS_SUCCESS == status) { |
| 5813 | struct ieee80211_channel *chan; |
| 5814 | int freq; |
| 5815 | int chan_no = roam_info->pBssDesc->channelId; |
| 5816 | |
| 5817 | if (chan_no <= 14) |
| 5818 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5819 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5820 | else |
| 5821 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5822 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5823 | |
| 5824 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5825 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5826 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5827 | roam_info->u.pConnectedProfile->SSID.length); |
| 5828 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5829 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5830 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5831 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5832 | resp_ie_len, status, gfp, connect_timeout, |
| 5833 | timeout_reason) != 0) { |
| 5834 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5835 | req_ie_len, resp_ie, resp_ie_len, |
| 5836 | status, gfp, connect_timeout, timeout_reason); |
| 5837 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5838 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5839 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5840 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5841 | } |
| 5842 | #else |
| 5843 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5844 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5845 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5846 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5847 | bool connect_timeout, |
| 5848 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5849 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5850 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5851 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5852 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5853 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5854 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5855 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5856 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5857 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5858 | } |
| 5859 | #endif |
| 5860 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5861 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 5862 | uint32_t bandwidth) |
| 5863 | { |
| 5864 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5865 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5866 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 5867 | QDF_STATUS status; |
| 5868 | tHalHandle hal_hdl = hdd_ctx->hHal; |
| 5869 | struct qdf_mac_addr bssid; |
| 5870 | struct csr_roam_profile roam_profile; |
| 5871 | struct ch_params ch_params; |
| 5872 | |
| 5873 | if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) { |
| 5874 | hdd_err("Not supported, device is not in monitor mode"); |
| 5875 | return -EINVAL; |
| 5876 | } |
| 5877 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 5878 | /* Validate Channel */ |
| 5879 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 5880 | hdd_err("Channel %d Not supported", chan); |
| 5881 | return -EINVAL; |
| 5882 | } |
| 5883 | |
| 5884 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 5885 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 5886 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 5887 | return -EINVAL; |
| 5888 | } |
| 5889 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 5890 | (bandwidth != CH_WIDTH_MAX)) { |
| 5891 | hdd_err("Only BW20 possible on channel 14"); |
| 5892 | return -EINVAL; |
| 5893 | } |
| 5894 | } |
| 5895 | |
| 5896 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 5897 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 5898 | (bandwidth != CH_WIDTH_MAX)) { |
| 5899 | hdd_err("Only BW20 possible on channel 165"); |
| 5900 | return -EINVAL; |
| 5901 | } |
| 5902 | } |
| 5903 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5904 | hdd_debug("Set monitor mode Channel %d", chan); |
| 5905 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 5906 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 5907 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 5908 | roam_profile.phyMode = ch_info->phy_mode; |
| 5909 | roam_profile.ch_params.ch_width = bandwidth; |
| 5910 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
| 5911 | |
| 5912 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 5913 | QDF_MAC_ADDR_SIZE); |
| 5914 | |
| 5915 | ch_params.ch_width = bandwidth; |
| 5916 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 5917 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 5918 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 5919 | return -EINVAL; |
| 5920 | } |
| 5921 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 5922 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 5923 | hdd_err("Failed to change hw mode"); |
| 5924 | return -EINVAL; |
| 5925 | } |
| 5926 | |
| 5927 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 5928 | &roam_profile); |
| 5929 | if (status) { |
| 5930 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 5931 | status); |
| 5932 | } |
| 5933 | |
| 5934 | adapter->mon_chan = chan; |
| 5935 | adapter->mon_bandwidth = bandwidth; |
| 5936 | return qdf_status_to_os_return(status); |
| 5937 | } |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5938 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5939 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5941 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5942 | #ifndef MSM_PLATFORM |
Dustin Brown | ce5b3d3 | 2018-01-17 15:07:38 -0800 | [diff] [blame] | 5943 | struct qdf_mac_addr bcastMac = QDF_MAC_ADDR_BCAST_INIT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5944 | #endif |
| 5945 | eConnectionState connState; |
| 5946 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5947 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5948 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5949 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5950 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5951 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5952 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5953 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 5954 | hdd_device_mode_to_string(adapter->device_mode), |
| 5955 | adapter->device_mode); |
| 5956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5957 | hdd_wmm_init(adapter); |
| 5958 | |
| 5959 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5960 | case QDF_STA_MODE: |
| 5961 | case QDF_P2P_CLIENT_MODE: |
| 5962 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5963 | |
| 5964 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 5965 | ->conn_info.connState; |
| 5966 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5967 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5968 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 5969 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5970 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5971 | /* Indicate disconnect event to supplicant |
| 5972 | * if associated previously |
| 5973 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5974 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 5975 | eConnectionState_IbssConnected == connState || |
| 5976 | eConnectionState_NotConnected == connState || |
| 5977 | eConnectionState_IbssDisconnected == connState || |
| 5978 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5979 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5980 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5981 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5982 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5983 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5984 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 5985 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5986 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 5987 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5988 | |
| 5989 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 5990 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5991 | adapter->dev, false, |
| 5992 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5993 | } else if (eConnectionState_Connecting == connState) { |
| 5994 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5995 | * Indicate connect failure to supplicant if we |
| 5996 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5997 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5998 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5999 | NULL, 0, NULL, 0, |
| 6000 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6001 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6002 | } |
| 6003 | |
| 6004 | hdd_register_tx_flow_control(adapter, |
| 6005 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6006 | hdd_tx_resume_cb, |
| 6007 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6008 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6009 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6010 | break; |
| 6011 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6012 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6013 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6014 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6015 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6016 | break; |
| 6017 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6018 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6019 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6020 | hdd_debug("[SSR] send stop ap to supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6021 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6022 | #else |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6023 | hdd_debug("[SSR] send restart supplicant"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6024 | /* event supplicant to restart */ |
| 6025 | cfg80211_del_sta(adapter->dev, |
| 6026 | (const u8 *)&bcastMac.bytes[0], |
| 6027 | GFP_KERNEL); |
| 6028 | #endif |
| 6029 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6030 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6031 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6032 | hdd_set_mon_rx_cb(adapter->dev); |
| 6033 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6034 | adapter->mon_bandwidth); |
| 6035 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6036 | default: |
| 6037 | break; |
| 6038 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6039 | /* |
| 6040 | * Action frame registered in one adapter which will |
| 6041 | * applicable to all interfaces |
| 6042 | */ |
| 6043 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6044 | } |
| 6045 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6046 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6047 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6048 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6049 | } |
| 6050 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6051 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6052 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6053 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6054 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6055 | qdf_list_node_t *node; |
| 6056 | |
| 6057 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6058 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6059 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6060 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6061 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6062 | |
| 6063 | if (QDF_IS_STATUS_ERROR(status)) |
| 6064 | return status; |
| 6065 | |
| 6066 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6067 | |
| 6068 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6069 | } |
| 6070 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6071 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6072 | struct hdd_adapter *current_adapter, |
| 6073 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6074 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6075 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6076 | qdf_list_node_t *node; |
| 6077 | |
| 6078 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6079 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6080 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6081 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6082 | ¤t_adapter->node, |
| 6083 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6084 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6085 | |
| 6086 | if (QDF_IS_STATUS_ERROR(status)) |
| 6087 | return status; |
| 6088 | |
| 6089 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6090 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6091 | return status; |
| 6092 | } |
| 6093 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6094 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6095 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6096 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6097 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6098 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6099 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6100 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6101 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6102 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6103 | return status; |
| 6104 | } |
| 6105 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6106 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6107 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6108 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6109 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6110 | qdf_list_node_t *node; |
| 6111 | |
| 6112 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6113 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6114 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6115 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6116 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6117 | |
| 6118 | if (QDF_IS_STATUS_ERROR(status)) |
| 6119 | return status; |
| 6120 | |
| 6121 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6122 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6123 | return status; |
| 6124 | } |
| 6125 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6126 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6127 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6128 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6129 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6130 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6131 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6132 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6133 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6135 | return status; |
| 6136 | } |
| 6137 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6138 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6139 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6140 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6141 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6142 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6143 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6144 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6145 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | return status; |
| 6148 | } |
| 6149 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6150 | 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] | 6151 | tSirMacAddr macAddr) |
| 6152 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6153 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6154 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6155 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6156 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6157 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6158 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6159 | } |
| 6160 | |
| 6161 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6162 | } |
| 6163 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6164 | 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] | 6165 | uint32_t vdev_id) |
| 6166 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6167 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6168 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6169 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6170 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6171 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6172 | } |
| 6173 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6174 | return NULL; |
| 6175 | } |
| 6176 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6177 | /** |
| 6178 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6179 | * the sessionid |
| 6180 | * @hdd_ctx: hdd context. |
| 6181 | * @sme_session_id: sme session is for the adapter to get. |
| 6182 | * |
| 6183 | * This function is used to get the adapter with provided session id |
| 6184 | * |
| 6185 | * Return: adapter pointer if found |
| 6186 | * |
| 6187 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6188 | struct hdd_adapter * |
| 6189 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6190 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6191 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6192 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6193 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6194 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6195 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6196 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6197 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6198 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6199 | return NULL; |
| 6200 | } |
| 6201 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6202 | 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] | 6203 | const char *iface_name) |
| 6204 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6205 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6206 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6207 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6208 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6209 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6210 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6211 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6212 | return NULL; |
| 6213 | } |
| 6214 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6215 | /** |
| 6216 | * hdd_get_adapter() - to get adapter matching the mode |
| 6217 | * @hdd_ctx: hdd context |
| 6218 | * @mode: adapter mode |
| 6219 | * |
| 6220 | * This routine will return the pointer to adapter matching |
| 6221 | * with the passed mode. |
| 6222 | * |
| 6223 | * Return: pointer to adapter or null |
| 6224 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6225 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6226 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6227 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6228 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6229 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6230 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6231 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6232 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6233 | } |
| 6234 | |
| 6235 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6236 | } |
| 6237 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6238 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6239 | { |
| 6240 | struct hdd_context *hdd_ctx; |
| 6241 | struct hdd_adapter *adapter; |
| 6242 | |
| 6243 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6244 | if (!hdd_ctx) { |
| 6245 | hdd_err("Invalid HDD context"); |
| 6246 | return QDF_MAX_NO_OF_MODE; |
| 6247 | } |
| 6248 | |
| 6249 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6250 | if (!adapter) { |
| 6251 | hdd_err("Invalid HDD adapter"); |
| 6252 | return QDF_MAX_NO_OF_MODE; |
| 6253 | } |
| 6254 | |
| 6255 | return adapter->device_mode; |
| 6256 | } |
| 6257 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6258 | /** |
| 6259 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6260 | * @hdd_ctx: Pointer to the HDD context. |
| 6261 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6262 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6263 | * QDF_STA_MODE, |
| 6264 | * QDF_P2P_CLIENT_MODE, |
| 6265 | * QDF_SAP_MODE, |
| 6266 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | * |
| 6268 | * This API returns the operating channel of the requested device mode |
| 6269 | * |
| 6270 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6271 | * not connected. |
| 6272 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6273 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6274 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6275 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6276 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6277 | uint8_t operatingChannel = 0; |
| 6278 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6279 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | if (mode == adapter->device_mode) { |
| 6281 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6282 | case QDF_STA_MODE: |
| 6283 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6284 | if (hdd_conn_is_connected |
| 6285 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6286 | (adapter))) { |
| 6287 | operatingChannel = |
| 6288 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6289 | (adapter))->conn_info. |
| 6290 | operationChannel; |
| 6291 | } |
| 6292 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6293 | case QDF_SAP_MODE: |
| 6294 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6295 | /* softap connection info */ |
| 6296 | if (test_bit |
| 6297 | (SOFTAP_BSS_STARTED, |
| 6298 | &adapter->event_flags)) |
| 6299 | operatingChannel = |
| 6300 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6301 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6302 | break; |
| 6303 | default: |
| 6304 | break; |
| 6305 | } |
| 6306 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6307 | /* Found the device of interest. break the loop */ |
| 6308 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6309 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6311 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6312 | return operatingChannel; |
| 6313 | } |
| 6314 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6315 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6316 | hdd_ctx) |
| 6317 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6318 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6319 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6320 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6321 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6322 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6323 | if (adapter->device_mode == QDF_STA_MODE || |
| 6324 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6325 | adapter->device_mode == QDF_IBSS_MODE || |
| 6326 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6327 | adapter->device_mode == QDF_SAP_MODE || |
| 6328 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6329 | hdd_unregister_wext(adapter->dev); |
| 6330 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | } |
| 6332 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6333 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6334 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6335 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6336 | } |
| 6337 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6338 | 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] | 6339 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6340 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6342 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6343 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6344 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6345 | if (adapter->device_mode == QDF_STA_MODE || |
| 6346 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6347 | adapter->device_mode == QDF_IBSS_MODE || |
| 6348 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6349 | adapter->device_mode == QDF_SAP_MODE || |
| 6350 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6351 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6352 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6353 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6355 | } |
| 6356 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6357 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6358 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6359 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6360 | } |
| 6361 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6362 | /** |
| 6363 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6364 | * adapters |
| 6365 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6366 | * |
| 6367 | * return: QDF_STATUS_SUCCESS |
| 6368 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6369 | 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] | 6370 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6371 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6372 | int err; |
| 6373 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6374 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6375 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6376 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6377 | if (adapter->device_mode == QDF_STA_MODE || |
| 6378 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6379 | adapter->device_mode == QDF_IBSS_MODE || |
| 6380 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6381 | adapter->device_mode == QDF_SAP_MODE || |
| 6382 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6383 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6384 | if (err) |
| 6385 | hdd_err("Unable to stop scheduled scan"); |
| 6386 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6387 | } |
| 6388 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6389 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6390 | |
| 6391 | return QDF_STATUS_SUCCESS; |
| 6392 | } |
| 6393 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6394 | #ifdef WLAN_NS_OFFLOAD |
| 6395 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6396 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | * @hdd_ctx: Pointer to hdd context |
| 6398 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6399 | * Unregister for IPv6 address change notifications. |
| 6400 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6401 | * Return: None |
| 6402 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6403 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6404 | { |
| 6405 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6406 | } |
| 6407 | |
| 6408 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6409 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6410 | * @hdd_ctx: Pointer to hdd context |
| 6411 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6412 | * Register for IPv6 address change notifications. |
| 6413 | * |
| 6414 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6415 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6416 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6417 | { |
| 6418 | int ret; |
| 6419 | |
| 6420 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6421 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6422 | if (ret) { |
| 6423 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6424 | goto out; |
| 6425 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6426 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6427 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6428 | out: |
| 6429 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6430 | } |
| 6431 | #else |
| 6432 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6433 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6434 | * @hdd_ctx: Pointer to hdd context |
| 6435 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6436 | * Unregister for IPv6 address change notifications. |
| 6437 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6438 | * Return: None |
| 6439 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6440 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6441 | { |
| 6442 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6443 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6444 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6445 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6446 | * @hdd_ctx: Pointer to hdd context |
| 6447 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6448 | * Register for IPv6 address change notifications. |
| 6449 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | * Return: None |
| 6451 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6452 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6453 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6454 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6455 | } |
| 6456 | #endif |
| 6457 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6458 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6459 | { |
| 6460 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6461 | adapter->disconnection_in_progress = status; |
| 6462 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6463 | hdd_debug("setting disconnection status: %d", status); |
| 6464 | } |
| 6465 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6466 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6467 | * hdd_register_notifiers - Register netdev notifiers. |
| 6468 | * @hdd_ctx: HDD context |
| 6469 | * |
| 6470 | * Register netdev notifiers like IPv4 and IPv6. |
| 6471 | * |
| 6472 | * Return: 0 on success and errno on failure |
| 6473 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6474 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6475 | { |
| 6476 | int ret; |
| 6477 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6478 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6479 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6480 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6481 | |
| 6482 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6483 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6484 | if (ret) { |
| 6485 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6486 | goto unregister_ip6_notifier; |
| 6487 | } |
| 6488 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6489 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6490 | if (ret) { |
| 6491 | hdd_err("Failed to register netevent notifier: %d", |
| 6492 | ret); |
| 6493 | goto unregister_inetaddr_notifier; |
| 6494 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6495 | return 0; |
| 6496 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6497 | unregister_inetaddr_notifier: |
| 6498 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6499 | unregister_ip6_notifier: |
| 6500 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6501 | out: |
| 6502 | return ret; |
| 6503 | |
| 6504 | } |
| 6505 | |
| 6506 | /** |
| 6507 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6508 | * @hdd_ctx: HDD context |
| 6509 | * |
| 6510 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6511 | * |
| 6512 | * Return: None. |
| 6513 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6514 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6515 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6516 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6517 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6518 | |
| 6519 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6520 | } |
| 6521 | |
| 6522 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6523 | * hdd_exit_netlink_services - Exit netlink services |
| 6524 | * @hdd_ctx: HDD context |
| 6525 | * |
| 6526 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6527 | * nl service. |
| 6528 | * |
| 6529 | * Return: None. |
| 6530 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6531 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6532 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6533 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6534 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6535 | ptt_sock_deactivate_svc(); |
| 6536 | |
| 6537 | nl_srv_exit(); |
| 6538 | } |
| 6539 | |
| 6540 | /** |
| 6541 | * hdd_init_netlink_services- Init netlink services |
| 6542 | * @hdd_ctx: HDD context |
| 6543 | * |
| 6544 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6545 | * nl service. |
| 6546 | * |
| 6547 | * Return: 0 on success and errno on failure. |
| 6548 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6549 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6550 | { |
| 6551 | int ret; |
| 6552 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6553 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6554 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6555 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6556 | goto out; |
| 6557 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6558 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6559 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6560 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6561 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6562 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6563 | goto err_nl_srv; |
| 6564 | } |
| 6565 | |
| 6566 | ret = ptt_sock_activate_svc(); |
| 6567 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6568 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6569 | goto err_nl_srv; |
| 6570 | } |
| 6571 | |
| 6572 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6573 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6574 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6575 | |
| 6576 | ret = cnss_diag_activate_service(); |
| 6577 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6578 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6579 | goto err_close_cesium; |
| 6580 | } |
| 6581 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6582 | ret = spectral_scan_activate_service(); |
| 6583 | if (ret) { |
| 6584 | hdd_alert("spectral_scan_activate_service failed: %d", ret); |
| 6585 | goto err_close_cesium; |
| 6586 | } |
| 6587 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6588 | return 0; |
| 6589 | |
| 6590 | err_close_cesium: |
| 6591 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6592 | ptt_sock_deactivate_svc(); |
| 6593 | err_nl_srv: |
| 6594 | nl_srv_exit(); |
| 6595 | out: |
| 6596 | return ret; |
| 6597 | } |
| 6598 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6599 | /** |
| 6600 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6601 | * @hdd_ctx: HDD context. |
| 6602 | * |
| 6603 | * Destroy RX wakelock. |
| 6604 | * |
| 6605 | * Return: None. |
| 6606 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6607 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6608 | { |
| 6609 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6610 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6611 | |
| 6612 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6613 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6614 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6615 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6616 | * Create RX wakelock. |
| 6617 | * |
| 6618 | * Return: None. |
| 6619 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6620 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6621 | { |
| 6622 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6623 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6624 | |
| 6625 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6626 | * hdd_context_deinit() - Deinitialize HDD context |
| 6627 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6628 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6629 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6630 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6631 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6632 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6633 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6634 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6635 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6636 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6637 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6638 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6639 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6640 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6641 | hdd_sap_context_destroy(hdd_ctx); |
| 6642 | |
| 6643 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6644 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6645 | hdd_scan_context_destroy(hdd_ctx); |
| 6646 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6647 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6648 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6649 | return 0; |
| 6650 | } |
| 6651 | |
| 6652 | /** |
| 6653 | * hdd_context_destroy() - Destroy HDD context |
| 6654 | * @hdd_ctx: HDD context to be destroyed. |
| 6655 | * |
| 6656 | * Free config and HDD context as well as destroy all the resources. |
| 6657 | * |
| 6658 | * Return: None |
| 6659 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6660 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6661 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6662 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6663 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6664 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6665 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6666 | hdd_context_deinit(hdd_ctx); |
| 6667 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6668 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6669 | hdd_ctx->config = NULL; |
| 6670 | |
| 6671 | wiphy_free(hdd_ctx->wiphy); |
| 6672 | } |
| 6673 | |
| 6674 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6675 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6676 | * |
| 6677 | * This function is used to destroy bug report lock |
| 6678 | * |
| 6679 | * Return: None |
| 6680 | */ |
| 6681 | static void wlan_destroy_bug_report_lock(void) |
| 6682 | { |
| 6683 | p_cds_contextType p_cds_context; |
| 6684 | |
| 6685 | p_cds_context = cds_get_global_context(); |
| 6686 | if (!p_cds_context) { |
| 6687 | hdd_err("cds context is NULL"); |
| 6688 | return; |
| 6689 | } |
| 6690 | |
| 6691 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6692 | } |
| 6693 | |
| 6694 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6695 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6696 | * @hdd_ctx: Pointer to the HDD Context |
| 6697 | * |
| 6698 | * This is the driver exit point (invoked during rmmod) |
| 6699 | * |
| 6700 | * Return: None |
| 6701 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6702 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6703 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6704 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6705 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6706 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6707 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6708 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6709 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6710 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6711 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6712 | |
| 6713 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6714 | if (QDF_TIMER_STATE_RUNNING == |
| 6715 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6716 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6717 | } |
| 6718 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6719 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6720 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6721 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6723 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6724 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6725 | hdd_ctx->last_acs_channel_list = NULL; |
| 6726 | hdd_ctx->num_of_channels = 0; |
| 6727 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6728 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6729 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6730 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6731 | driver_status = hdd_ctx->driver_status; |
| 6732 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6733 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6734 | /* |
| 6735 | * Powersave Offload Case |
| 6736 | * Disable Idle Power Save Mode |
| 6737 | */ |
| 6738 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6739 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6740 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6741 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6742 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6743 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6744 | /* |
| 6745 | * Cancel any outstanding scan requests. We are about to close |
| 6746 | * all of our adapters, but an adapter structure is what SME |
| 6747 | * passes back to our callback function. Hence if there |
| 6748 | * are any outstanding scan requests then there is a |
| 6749 | * race condition between when the adapter is closed and |
| 6750 | * when the callback is invoked. We try to resolve that |
| 6751 | * race condition here by canceling any outstanding scans |
| 6752 | * before we close the adapters. |
| 6753 | * Note that the scans may be cancelled in an asynchronous |
| 6754 | * manner, so ideally there needs to be some kind of |
| 6755 | * synchronization. Rather than introduce a new |
| 6756 | * synchronization here, we will utilize the fact that we are |
| 6757 | * about to Request Full Power, and since that is synchronized, |
| 6758 | * the expectation is that by the time Request Full Power has |
| 6759 | * completed, all scans will be cancelled |
| 6760 | */ |
| 6761 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6762 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6763 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6764 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6765 | } |
| 6766 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6767 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6768 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6769 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6770 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6771 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6772 | hdd_driver_memdump_deinit(); |
| 6773 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6774 | qdf_nbuf_deinit_replenish_timer(); |
| 6775 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6776 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6777 | hdd_info("Release wakelock for monitor mode!"); |
| 6778 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6779 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6780 | } |
| 6781 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6782 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6783 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6784 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6785 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6786 | /* |
| 6787 | * Close CDS |
| 6788 | * This frees pMac(HAL) context. There should not be any call |
| 6789 | * that requires pMac access after this. |
| 6790 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6791 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6792 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 6793 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6794 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6795 | hdd_close_all_adapters(hdd_ctx, false); |
| 6796 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6797 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6798 | /* |
| 6799 | * If there is re_init failure wiphy would have already de-registered |
| 6800 | * check the wiphy status before un-registering again |
| 6801 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6802 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6803 | wiphy_unregister(wiphy); |
| 6804 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6805 | hdd_lpass_notify_stop(hdd_ctx); |
| 6806 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6807 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6808 | hdd_exit_netlink_services(hdd_ctx); |
| 6809 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6810 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6811 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6812 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6813 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6814 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6815 | if (driver_status) |
| 6816 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6817 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6818 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6819 | } |
| 6820 | |
| 6821 | void __hdd_wlan_exit(void) |
| 6822 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6823 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6824 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6825 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6826 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6827 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6828 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6829 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6830 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6831 | return; |
| 6832 | } |
| 6833 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6834 | /* Do all the cleanup before deregistering the driver */ |
| 6835 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6836 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6837 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6838 | } |
| 6839 | |
| 6840 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6841 | /** |
| 6842 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6843 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6844 | * |
| 6845 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6846 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6847 | * scan information. |
| 6848 | * |
| 6849 | * Return: void |
| 6850 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6851 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6852 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6853 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6854 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6855 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6856 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6857 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6858 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6859 | hdd_ctx->last_acs_channel_list = NULL; |
| 6860 | hdd_ctx->num_of_channels = 0; |
| 6861 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6862 | |
| 6863 | if (!hdd_ctx->hHal) |
| 6864 | return; |
| 6865 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6866 | } |
| 6867 | #endif |
| 6868 | |
| 6869 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6870 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6871 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6872 | { |
| 6873 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6874 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6875 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6876 | |
| 6877 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6878 | |
| 6879 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6880 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6881 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6882 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6883 | if (!hdd_ctx->hHal) |
| 6884 | return -EINVAL; |
| 6885 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6886 | 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] | 6887 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6888 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6889 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | return -EINVAL; |
| 6891 | } |
| 6892 | |
| 6893 | return 0; |
| 6894 | } |
| 6895 | #endif |
| 6896 | |
| 6897 | /** |
| 6898 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6899 | * @state: state |
| 6900 | * |
| 6901 | * This function notifies FW with modem power status |
| 6902 | * |
| 6903 | * Return: 0 if successful, error number otherwise |
| 6904 | */ |
| 6905 | int hdd_wlan_notify_modem_power_state(int state) |
| 6906 | { |
| 6907 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6908 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6909 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6910 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6911 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6912 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6913 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6915 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6916 | if (!hdd_ctx->hHal) |
| 6917 | return -EINVAL; |
| 6918 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6919 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6920 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6921 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6922 | state); |
| 6923 | return -EINVAL; |
| 6924 | } |
| 6925 | return 0; |
| 6926 | } |
| 6927 | |
| 6928 | /** |
| 6929 | * |
| 6930 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6931 | * @adapter - Pointer to the HDD |
| 6932 | * |
| 6933 | * Return: None |
| 6934 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6935 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6936 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6937 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6938 | |
| 6939 | /* |
| 6940 | * Send ready indication to the HDD. This will kick off the MAC |
| 6941 | * into a 'running' state and should kick off an initial scan. |
| 6942 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6943 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 6944 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6945 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 6946 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6947 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6948 | } |
| 6949 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6950 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | } |
| 6952 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 6953 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 6954 | { |
| 6955 | struct hdd_adapter *adapter; |
| 6956 | |
| 6957 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6958 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 6959 | return adapter; |
| 6960 | } |
| 6961 | |
| 6962 | return NULL; |
| 6963 | } |
| 6964 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6965 | /* wake lock APIs for HDD */ |
| 6966 | void hdd_prevent_suspend(uint32_t reason) |
| 6967 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6968 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6969 | } |
| 6970 | |
| 6971 | void hdd_allow_suspend(uint32_t reason) |
| 6972 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 6973 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6974 | } |
| 6975 | |
| 6976 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 6977 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 6978 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 6979 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | } |
| 6981 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6982 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6983 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6984 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 6985 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 6986 | return sme_init_chan_list(hdd_ctx->hHal, |
| 6987 | hdd_ctx->reg.alpha2, |
| 6988 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6989 | } |
| 6990 | |
| 6991 | /** |
| 6992 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 6993 | * @hdd_ctx: Pointer to the hdd context |
| 6994 | * |
| 6995 | * HDD function to know if hardware supports 5GHz |
| 6996 | * |
| 6997 | * Return: true if hardware supports 5GHz |
| 6998 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6999 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7001 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7002 | return true; |
| 7003 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7004 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7005 | return true; |
| 7006 | else |
| 7007 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7008 | } |
| 7009 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7010 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7011 | { |
| 7012 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7013 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | |
| 7015 | wiphy = hdd_ctx->wiphy; |
| 7016 | |
| 7017 | /* |
| 7018 | * The channel information in |
| 7019 | * wiphy needs to be initialized before wiphy registration |
| 7020 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7021 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7022 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7023 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7024 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7025 | } |
| 7026 | |
| 7027 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7028 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7029 | #else |
| 7030 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7031 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7032 | WIPHY_WOWLAN_DISCONNECT | |
| 7033 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7034 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7035 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7036 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7037 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7038 | |
| 7039 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7040 | WOW_MAX_FILTERS_PER_LIST); |
| 7041 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7042 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7043 | #endif |
| 7044 | |
| 7045 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7046 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7047 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7048 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7049 | return ret_val; |
| 7050 | } |
| 7051 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7052 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7053 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7054 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7055 | } |
| 7056 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7057 | #ifdef MSM_PLATFORM |
| 7058 | /** |
| 7059 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7060 | * @hdd_ctx - handle to hdd context |
| 7061 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7062 | * |
| 7063 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7064 | * Stats show up in wlan driver logs. |
| 7065 | * |
| 7066 | * Returns: None |
| 7067 | */ |
| 7068 | static inline |
| 7069 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7070 | bool data_in_interval) |
| 7071 | { |
| 7072 | static u32 counter; |
| 7073 | static bool data_in_time_period; |
| 7074 | ol_txrx_pdev_handle pdev; |
| 7075 | |
| 7076 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7077 | return; |
| 7078 | |
| 7079 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7080 | if (!pdev) { |
| 7081 | hdd_err("pdev is NULL"); |
| 7082 | return; |
| 7083 | } |
| 7084 | |
| 7085 | counter++; |
| 7086 | if (data_in_interval) |
| 7087 | data_in_time_period = data_in_interval; |
| 7088 | |
| 7089 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7090 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7091 | if (data_in_time_period) { |
| 7092 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7093 | CDP_TXRX_PATH_STATS, |
| 7094 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7095 | wlan_hdd_display_netif_queue_history |
| 7096 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7097 | qdf_dp_trace_dump_stats(); |
| 7098 | } |
| 7099 | counter = 0; |
| 7100 | data_in_time_period = false; |
| 7101 | } |
| 7102 | } |
| 7103 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7104 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7105 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7106 | * @hdd_ctx: pointer to struct hdd_context |
| 7107 | * |
| 7108 | * Return: none |
| 7109 | */ |
| 7110 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7111 | { |
| 7112 | struct hdd_adapter *adapter; |
| 7113 | |
| 7114 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7115 | hdd_send_rps_disable_ind(adapter); |
| 7116 | } |
| 7117 | |
| 7118 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7119 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7120 | * @hdd_ctx - handle to hdd context |
| 7121 | * @tx_packets - transmit packet count |
| 7122 | * @rx_packets - receive packet count |
| 7123 | * |
| 7124 | * The function controls the bus bandwidth and dynamic control of |
| 7125 | * tcp delayed ack configuration |
| 7126 | * |
| 7127 | * Returns: None |
| 7128 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7129 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7130 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7131 | const uint64_t tx_packets, |
| 7132 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7133 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7134 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7135 | uint64_t temp_rx = 0; |
| 7136 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7137 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7138 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7139 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7140 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7141 | uint16_t index = 0; |
| 7142 | bool vote_level_change = false; |
| 7143 | bool rx_level_change = false; |
| 7144 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7145 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7146 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7147 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7148 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7149 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7150 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7151 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7152 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7153 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7154 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7155 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7156 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7157 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7158 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7159 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7160 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7161 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7162 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7163 | if (hdd_ctx->hbw_requested) { |
| 7164 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7165 | hdd_ctx->hbw_requested = false; |
| 7166 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7167 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7168 | hdd_warn("low bandwidth set rx affinity fail"); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7169 | |
| 7170 | if (hdd_ctx->dynamic_rps) |
| 7171 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7172 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7173 | if (!hdd_ctx->hbw_requested) { |
| 7174 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7175 | hdd_ctx->hbw_requested = true; |
| 7176 | } |
| 7177 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7178 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7179 | hdd_warn("high bandwidth set rx affinity fail"); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7180 | |
| 7181 | if (hdd_ctx->dynamic_rps) |
| 7182 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7183 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 7184 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7185 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7186 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 7187 | qdf_dp_trace_throttle_live_mode( |
| 7188 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 7189 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7190 | /* fine-tuning parameters for RX Flows */ |
| 7191 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 7192 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7193 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7194 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7195 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 7196 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7197 | else |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 7198 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7199 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7200 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 7201 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7202 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7203 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7204 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7205 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7206 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7207 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7208 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7209 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7210 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7211 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7212 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7213 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7214 | next_rx_level, temp_rx); |
| 7215 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7216 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7217 | /* Send throughput indication only if it is enabled. |
| 7218 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7219 | * to default delayed ack. Note that this will disable the |
| 7220 | * dynamic delayed ack mechanism across the system |
| 7221 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7222 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7223 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7224 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7225 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7226 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7227 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7228 | rx_tp_data.level = next_rx_level; |
| 7229 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7230 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7231 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7232 | } |
| 7233 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7234 | /* fine-tuning parameters for TX Flows */ |
| 7235 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7236 | hdd_ctx->prev_tx = tx_packets; |
| 7237 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7238 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7239 | else |
| 7240 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7241 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7242 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7243 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7244 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7245 | next_tx_level, temp_tx); |
| 7246 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7247 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7248 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7249 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7250 | &next_tx_level, |
| 7251 | sizeof(next_tx_level)); |
| 7252 | } |
| 7253 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7254 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7255 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7256 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7257 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7258 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7259 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7260 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7261 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7262 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7263 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7264 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7265 | |
| 7266 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7267 | } |
| 7268 | |
| 7269 | #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] | 7270 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7271 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7272 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7273 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7274 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7275 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7276 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7277 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7278 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7279 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7280 | bool connected = false; |
| 7281 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7282 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7283 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7284 | return; |
| 7285 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7286 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7287 | goto restart_timer; |
| 7288 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7289 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7290 | /* |
| 7291 | * Validate magic so we don't end up accessing |
| 7292 | * an invalid adapter. |
| 7293 | */ |
| 7294 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7295 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7296 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7297 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7298 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7299 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7300 | != eConnectionState_Associated) { |
| 7301 | |
| 7302 | continue; |
| 7303 | } |
| 7304 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7305 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7306 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7307 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7308 | |
| 7309 | continue; |
| 7310 | } |
| 7311 | |
| 7312 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7313 | adapter->prev_tx_packets); |
| 7314 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7315 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7316 | |
| 7317 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7318 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7319 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7320 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7321 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7322 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7323 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7324 | &fwd_tx_packets, &fwd_rx_packets); |
| 7325 | if (ret == A_OK) { |
| 7326 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7327 | fwd_tx_packets, |
| 7328 | adapter->prev_fwd_tx_packets); |
| 7329 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7330 | fwd_tx_packets, |
| 7331 | adapter->prev_fwd_rx_packets); |
| 7332 | } |
| 7333 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7334 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7335 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7336 | con_sap_adapter = adapter; |
| 7337 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7338 | total_rx += adapter->stats.rx_packets; |
| 7339 | total_tx += adapter->stats.tx_packets; |
| 7340 | |
| 7341 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7342 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7343 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7344 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7345 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7346 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7347 | connected = true; |
| 7348 | } |
| 7349 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7350 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7351 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7352 | return; |
| 7353 | } |
| 7354 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7355 | /* add intra bss forwarded tx and rx packets */ |
| 7356 | tx_packets += fwd_tx_packets_diff; |
| 7357 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7358 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7359 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->hdd_pdev)) { |
| 7360 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7361 | &ipa_rx_packets); |
| 7362 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7363 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7364 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7365 | if (con_sap_adapter) { |
| 7366 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7367 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7368 | } |
| 7369 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7370 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
| 7371 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
| 7372 | } |
| 7373 | |
| 7374 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7375 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7376 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7377 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7378 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7379 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7380 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7381 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7382 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7383 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7384 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7385 | /** |
| 7386 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7387 | * @arg: Argument of timer function |
| 7388 | * |
| 7389 | * Schedule a workqueue in this function where all the processing is done. |
| 7390 | * |
| 7391 | * Return: None. |
| 7392 | */ |
| 7393 | static void __hdd_bus_bw_cbk(void *arg) |
| 7394 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7395 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7396 | |
| 7397 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7398 | return; |
| 7399 | |
| 7400 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7401 | } |
| 7402 | |
| 7403 | /** |
| 7404 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7405 | * @arg: Argument of timer function |
| 7406 | * |
| 7407 | * Return: None. |
| 7408 | */ |
| 7409 | static void hdd_bus_bw_cbk(void *arg) |
| 7410 | { |
| 7411 | cds_ssr_protect(__func__); |
| 7412 | __hdd_bus_bw_cbk(arg); |
| 7413 | cds_ssr_unprotect(__func__); |
| 7414 | } |
| 7415 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7416 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7417 | { |
| 7418 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7419 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7420 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7421 | hdd_ctx->bus_bw_timer_running = false; |
| 7422 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7423 | qdf_timer_init(NULL, |
| 7424 | &hdd_ctx->bus_bw_timer, |
| 7425 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7426 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7427 | |
| 7428 | return 0; |
| 7429 | } |
| 7430 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7431 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7432 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7433 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7434 | hdd_reset_tcp_delack(hdd_ctx); |
| 7435 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7436 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7437 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7438 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7439 | hdd_ctx->bus_bw_timer_running = false; |
| 7440 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7441 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7442 | |
| 7443 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7444 | { |
| 7445 | if (hdd_ctx) |
| 7446 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7447 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7448 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7449 | #endif |
| 7450 | |
| 7451 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7452 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7453 | * @hdd_ctx: hdd context |
| 7454 | * |
| 7455 | * Return: 0 for success or error code |
| 7456 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7457 | 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] | 7458 | { |
| 7459 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7460 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7461 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7462 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7463 | return -ENOMEM; |
| 7464 | } |
| 7465 | return 0; |
| 7466 | } |
| 7467 | |
| 7468 | /** |
| 7469 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7470 | * @hdd_ctx: hdd context |
| 7471 | * |
| 7472 | * Return: none |
| 7473 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7474 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7475 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7476 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7477 | return; |
| 7478 | |
| 7479 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7480 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7481 | } |
| 7482 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7483 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7484 | { |
| 7485 | switch (level) { |
| 7486 | /* initialize the wlan sub system */ |
| 7487 | case WLAN_SVC_TP_NONE: |
| 7488 | return "NONE"; |
| 7489 | case WLAN_SVC_TP_LOW: |
| 7490 | return "LOW"; |
| 7491 | case WLAN_SVC_TP_MEDIUM: |
| 7492 | return "MED"; |
| 7493 | case WLAN_SVC_TP_HIGH: |
| 7494 | return "HIGH"; |
| 7495 | default: |
| 7496 | return "INVAL"; |
| 7497 | } |
| 7498 | } |
| 7499 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7500 | |
| 7501 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7502 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7503 | * @hdd_ctx: hdd context |
| 7504 | * |
| 7505 | * Return: none |
| 7506 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7507 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7508 | { |
| 7509 | int i; |
| 7510 | |
| 7511 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7512 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7513 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7514 | 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] | 7515 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7516 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7517 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7518 | hdd_debug("Enable TCP DEL ACK: %d", |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7519 | hdd_ctx->en_tcp_delack_no_lro); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7520 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7521 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7522 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7523 | 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] | 7524 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7525 | #endif |
| 7526 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7527 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7528 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7529 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7530 | 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] | 7531 | |
| 7532 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7533 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7534 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7535 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7536 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7537 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7538 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7539 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7540 | hdd_ctx->hdd_txrx_hist[i]. |
| 7541 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7542 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7543 | hdd_ctx->hdd_txrx_hist[i]. |
| 7544 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7545 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7546 | hdd_ctx->hdd_txrx_hist[i]. |
| 7547 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7548 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7549 | } |
| 7550 | |
| 7551 | /** |
| 7552 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7553 | * @hdd_ctx: hdd context |
| 7554 | * |
| 7555 | * Return: none |
| 7556 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7557 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | { |
| 7559 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7560 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7561 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7562 | } |
| 7563 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7564 | /* length of the netif queue log needed per adapter */ |
| 7565 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7566 | |
| 7567 | /** |
| 7568 | * |
| 7569 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7570 | * @hdd_ctx: hdd context |
| 7571 | * |
| 7572 | * Return: none |
| 7573 | */ |
| 7574 | static void |
| 7575 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7576 | { |
| 7577 | int adapter_num = 0; |
| 7578 | int i; |
| 7579 | int bytes_written; |
| 7580 | u32 tbytes; |
| 7581 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7582 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7583 | char *comb_log_str; |
| 7584 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7585 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7586 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7587 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7588 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7589 | if (!comb_log_str) { |
| 7590 | hdd_err("failed to alloc comb_log_str"); |
| 7591 | return; |
| 7592 | } |
| 7593 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7594 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7595 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7596 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7597 | curr_time = qdf_system_ticks(); |
| 7598 | total = curr_time - adapter->start_time; |
| 7599 | delta = curr_time - adapter->last_time; |
| 7600 | |
| 7601 | if (adapter->pause_map) { |
| 7602 | pause = adapter->total_pause_time + delta; |
| 7603 | unpause = adapter->total_unpause_time; |
| 7604 | } else { |
| 7605 | unpause = adapter->total_unpause_time + delta; |
| 7606 | pause = adapter->total_pause_time; |
| 7607 | } |
| 7608 | |
| 7609 | tbytes = 0; |
| 7610 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7611 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7612 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7613 | continue; |
| 7614 | tbytes += |
| 7615 | snprintf( |
| 7616 | &temp_str[tbytes], |
| 7617 | (tbytes >= sizeof(temp_str) ? |
| 7618 | 0 : sizeof(temp_str) - tbytes), |
| 7619 | "%d(%d,%d) ", |
| 7620 | i, |
| 7621 | adapter->queue_oper_stats[i]. |
| 7622 | pause_count, |
| 7623 | adapter->queue_oper_stats[i]. |
| 7624 | unpause_count); |
| 7625 | } |
| 7626 | if (tbytes >= sizeof(temp_str)) |
| 7627 | hdd_warn("log truncated"); |
| 7628 | |
| 7629 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7630 | bytes_written >= comb_log_str_size ? 0 : |
| 7631 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7632 | "[%d %d] (%d) %u/%ums %s|", |
| 7633 | adapter->session_id, adapter->device_mode, |
| 7634 | adapter->pause_map, |
| 7635 | qdf_system_ticks_to_msecs(pause), |
| 7636 | qdf_system_ticks_to_msecs(total), |
| 7637 | temp_str); |
| 7638 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7639 | adapter_num++; |
| 7640 | } |
| 7641 | |
| 7642 | /* using QDF_TRACE to avoid printing function name */ |
| 7643 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7644 | "STATS |%s", comb_log_str); |
| 7645 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7646 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7647 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7648 | |
| 7649 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7650 | } |
| 7651 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7652 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7653 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7654 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7655 | * |
| 7656 | * Return: none |
| 7657 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7658 | void |
| 7659 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7660 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7661 | { |
| 7662 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7663 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7664 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7665 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7666 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7667 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7668 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7669 | return; |
| 7670 | } |
| 7671 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7672 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7673 | hdd_debug("Netif queue operation statistics:"); |
| 7674 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7675 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7676 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7677 | curr_time = qdf_system_ticks(); |
| 7678 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7679 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7680 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7681 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7682 | unpause = adapter->total_unpause_time; |
| 7683 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7684 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7685 | pause = adapter->total_pause_time; |
| 7686 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7687 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7688 | qdf_system_ticks_to_msecs(total), |
| 7689 | qdf_system_ticks_to_msecs(pause), |
| 7690 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7691 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7692 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7693 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7694 | qdf_time_t pause_delta = 0; |
| 7695 | |
| 7696 | if (adapter->pause_map & (1 << i)) |
| 7697 | pause_delta = delta; |
| 7698 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7699 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7700 | hdd_debug("%s: %d: %d: %ums", |
| 7701 | hdd_reason_type_to_string(i), |
| 7702 | adapter->queue_oper_stats[i].pause_count, |
| 7703 | adapter->queue_oper_stats[i].unpause_count, |
| 7704 | qdf_system_ticks_to_msecs( |
| 7705 | adapter->queue_oper_stats[i].total_pause_time + |
| 7706 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7707 | } |
| 7708 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7709 | hdd_debug("Netif queue operation history:"); |
| 7710 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7711 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7712 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7713 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7714 | |
| 7715 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7716 | /* using hdd_log to avoid printing function name */ |
| 7717 | if (adapter->queue_oper_history[i].time == 0) |
| 7718 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7719 | hdd_debug("%d: %u: %s: %s: %x", |
| 7720 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7721 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7722 | hdd_action_type_to_string( |
| 7723 | adapter->queue_oper_history[i].netif_action), |
| 7724 | hdd_reason_type_to_string( |
| 7725 | adapter->queue_oper_history[i].netif_reason), |
| 7726 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7727 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7728 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7729 | } |
| 7730 | |
| 7731 | /** |
| 7732 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7733 | * @hdd_ctx: hdd context |
| 7734 | * |
| 7735 | * Return: none |
| 7736 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7737 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7738 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7739 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7740 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7741 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7742 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7743 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7744 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7745 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7746 | adapter->history_index = 0; |
| 7747 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7748 | adapter->total_pause_time = 0; |
| 7749 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7750 | } |
| 7751 | } |
| 7752 | |
| 7753 | /** |
| 7754 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7755 | * @halHandle: Hal handle |
| 7756 | * @pContext: Pointer to the context |
| 7757 | * @sessionId: Session ID |
| 7758 | * @scanId: Scan ID |
| 7759 | * @status: Status |
| 7760 | * |
| 7761 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7762 | * the scan results |
| 7763 | * |
| 7764 | * 11d scan is done during driver load and is a passive scan on all |
| 7765 | * channels supported by the device, 11d scans may find some APs on |
| 7766 | * frequencies which are forbidden to be used in the regulatory domain |
| 7767 | * the device is operating in. If these APs are notified to the supplicant |
| 7768 | * it may try to connect to these APs, thus flush out all the scan results |
| 7769 | * which are present in SME after 11d scan is done. |
| 7770 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7771 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7772 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7773 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7774 | uint8_t sessionId, uint32_t scanId, |
| 7775 | eCsrScanStatus status) |
| 7776 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7777 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7778 | |
| 7779 | sme_scan_flush_result(halHandle); |
| 7780 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7781 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7782 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7783 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7784 | } |
| 7785 | |
| 7786 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7787 | /** |
| 7788 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7789 | * @hdd_ctx: hdd global context |
| 7790 | * |
| 7791 | * Return: none |
| 7792 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7793 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7794 | { |
| 7795 | uint8_t i; |
| 7796 | |
| 7797 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7798 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7799 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7800 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7801 | } |
| 7802 | } |
| 7803 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7804 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7805 | { |
| 7806 | } |
| 7807 | #endif |
| 7808 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7809 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7810 | /** |
| 7811 | * 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] | 7812 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7813 | * @enable: enable or disable this behaviour |
| 7814 | * |
| 7815 | * Return: int |
| 7816 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7817 | 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] | 7818 | { |
| 7819 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7820 | struct wow_pulse_mode wow_pulse_set_info; |
| 7821 | QDF_STATUS status; |
| 7822 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7823 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7824 | |
| 7825 | if (false == phddctx->config->wow_pulse_support) |
| 7826 | return 0; |
| 7827 | |
| 7828 | /* prepare the request to send to SME */ |
| 7829 | if (enable == true) { |
| 7830 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7831 | wow_pulse_set_info.wow_pulse_pin = |
| 7832 | pcfg_ini->wow_pulse_pin; |
| 7833 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7834 | pcfg_ini->wow_pulse_interval_low; |
| 7835 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7836 | pcfg_ini->wow_pulse_interval_high; |
| 7837 | } else { |
| 7838 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7839 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7840 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7841 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7842 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7843 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7844 | wow_pulse_set_info.wow_pulse_enable, |
| 7845 | wow_pulse_set_info.wow_pulse_pin, |
| 7846 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7847 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7848 | |
| 7849 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7850 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7851 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7852 | return -EIO; |
| 7853 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7854 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7855 | return 0; |
| 7856 | } |
| 7857 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7858 | 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] | 7859 | { |
| 7860 | return 0; |
| 7861 | } |
| 7862 | #endif |
| 7863 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7864 | #ifdef WLAN_FEATURE_FASTPATH |
| 7865 | /** |
| 7866 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7867 | * @hdd_cfg: hdd config |
| 7868 | * @context: lower layer context |
| 7869 | * |
| 7870 | * Return: none |
| 7871 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7872 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7873 | void *context) |
| 7874 | { |
| 7875 | if (hdd_cfg->fastpath_enable) |
| 7876 | hif_enable_fastpath(context); |
| 7877 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7878 | #endif |
| 7879 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7880 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7881 | /** |
| 7882 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7883 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7884 | * @level: thermal level |
| 7885 | * |
| 7886 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7887 | * than 0, and restore the original data path when throttle level is 0 |
| 7888 | * |
| 7889 | * Return: none |
| 7890 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7891 | 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] | 7892 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7893 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7894 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7895 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7896 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7897 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7898 | else |
| 7899 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7900 | 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] | 7901 | } |
| 7902 | |
| 7903 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7904 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7905 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7906 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7907 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7908 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7909 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7910 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7911 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7912 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7913 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7914 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7915 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7916 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7917 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7918 | struct sir_pcl_list pcl; |
| 7919 | QDF_STATUS status; |
| 7920 | uint32_t i, j; |
| 7921 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7922 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7923 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7924 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7925 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7926 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7927 | if (!hdd_ctx) { |
| 7928 | hdd_err("invalid HDD context"); |
| 7929 | return INVALID_CHANNEL_ID; |
| 7930 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7931 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7932 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7933 | if (!hal_handle) { |
| 7934 | hdd_err("invalid HAL handle"); |
| 7935 | return INVALID_CHANNEL_ID; |
| 7936 | } |
| 7937 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7938 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7939 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7940 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7941 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7942 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7943 | hdd_err("Get PCL failed"); |
| 7944 | return INVALID_CHANNEL_ID; |
| 7945 | } |
| 7946 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 7947 | /* |
| 7948 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 7949 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 7950 | * try to choose a safe channel from acs range. |
| 7951 | */ |
| 7952 | if (!pcl.pcl_len) |
| 7953 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7954 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7955 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7956 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 7957 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7958 | |
| 7959 | /* PCL already takes unsafe channel into account */ |
| 7960 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7961 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7962 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7963 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7964 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7965 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7966 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7967 | return pcl.pcl_list[i]; |
| 7968 | } |
| 7969 | } |
| 7970 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7971 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7972 | |
| 7973 | /* Try for safe channel from all valid channel */ |
| 7974 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7975 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 7976 | &pcl.pcl_len); |
| 7977 | if (ret) { |
| 7978 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7979 | return INVALID_CHANNEL_ID; |
| 7980 | } |
| 7981 | |
| 7982 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7983 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7984 | found = false; |
| 7985 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 7986 | if (pcl.pcl_list[i] == |
| 7987 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7988 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7989 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7990 | break; |
| 7991 | } |
| 7992 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7993 | |
| 7994 | if (found) |
| 7995 | continue; |
| 7996 | |
| 7997 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 7998 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7999 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8000 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8001 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8002 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8003 | } |
| 8004 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8005 | |
| 8006 | return INVALID_CHANNEL_ID; |
| 8007 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8008 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8009 | |
| 8010 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8011 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8012 | * @adapter: AP adapter |
| 8013 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8014 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8015 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8016 | * Moves the SAP interface by invoking the function which |
| 8017 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8018 | * |
| 8019 | * Return: None |
| 8020 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8021 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8022 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8023 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8024 | struct hdd_ap_ctx *hdd_ap_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8025 | tHalHandle *hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8026 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8027 | |
| 8028 | if (!adapter) { |
| 8029 | hdd_err("invalid adapter"); |
| 8030 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8031 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8032 | |
| 8033 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8034 | |
| 8035 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 8036 | if (!hal_handle) { |
| 8037 | hdd_err("invalid HAL handle"); |
| 8038 | return; |
| 8039 | } |
| 8040 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8041 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8042 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8043 | hdd_ap_ctx->sap_config.channel = channel; |
| 8044 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 8045 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8046 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8047 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8048 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8049 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 8050 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8051 | hdd_ap_ctx->sap_config.channel, |
| 8052 | hdd_ap_ctx->sap_config.sec_ch, |
| 8053 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8054 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8055 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8056 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8057 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8058 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8059 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8060 | 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] | 8061 | { |
| 8062 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8063 | int status; |
| 8064 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8065 | |
| 8066 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8067 | |
| 8068 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8069 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8070 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8071 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8072 | } |
| 8073 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8074 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8075 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8076 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8077 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8078 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8079 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8080 | hdd_err("failed to start external acs timer"); |
| 8081 | return -ENOSPC; |
| 8082 | } |
| 8083 | /* Update config to application */ |
| 8084 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8085 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8086 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8087 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8088 | } |
| 8089 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8090 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8091 | /** |
| 8092 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8093 | * @hdd_ctx: hdd context pointer |
| 8094 | * |
| 8095 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8096 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8097 | * sap. User space on LTE coex indication restart driver. |
| 8098 | * |
| 8099 | * Return - none |
| 8100 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8101 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8102 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8103 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8104 | uint32_t i; |
| 8105 | bool found = false; |
| 8106 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8107 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8108 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8109 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8110 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8111 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8112 | adapter->device_mode, |
| 8113 | adapter->session.ap.sap_config. |
| 8114 | acs_cfg.acs_mode); |
| 8115 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8116 | } |
| 8117 | |
| 8118 | found = false; |
| 8119 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8120 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8121 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8122 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8123 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8124 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8125 | break; |
| 8126 | } |
| 8127 | } |
| 8128 | |
| 8129 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8130 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8131 | adapter->session.ap.operating_channel); |
| 8132 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8133 | } |
| 8134 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8135 | if (hdd_ctxt->config->vendor_acs_support && |
| 8136 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8137 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8138 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8139 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8140 | } else |
| 8141 | restart_chan = |
| 8142 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8143 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8144 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8145 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8146 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8147 | /* |
| 8148 | * SAP restart due to unsafe channel. While |
| 8149 | * restarting the SAP, make sure to clear |
| 8150 | * acs_channel, channel to reset to |
| 8151 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8152 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8153 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8154 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8155 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8156 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8157 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8158 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8159 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8160 | hdd_debug("driver to start sap: %d", |
| 8161 | hdd_ctxt->config->sap_internal_restart); |
| 8162 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8163 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8164 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8165 | else |
| 8166 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8167 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8168 | } |
| 8169 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8170 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8171 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8172 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8173 | * @hdd_ctx: HDD global context |
| 8174 | * |
| 8175 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8176 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8177 | * down to the lower layers. Then subscribe to subsequent channel |
| 8178 | * avoidance events. |
| 8179 | * |
| 8180 | * Return: None |
| 8181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8182 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8183 | { |
| 8184 | uint16_t unsafe_channel_count; |
| 8185 | int index; |
| 8186 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8187 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8188 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8189 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8190 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8191 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8192 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8193 | hdd_ctx->unsafe_channel_count); |
| 8194 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8195 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8196 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8197 | |
| 8198 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8199 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8200 | hdd_ctx->unsafe_channel_list[index]); |
| 8201 | |
| 8202 | } |
| 8203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8204 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8205 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8206 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8207 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8208 | { |
| 8209 | uint8_t restart_chan; |
| 8210 | |
| 8211 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8212 | if (!restart_chan) { |
| 8213 | hdd_alert("fail to restart SAP"); |
| 8214 | return; |
| 8215 | } |
| 8216 | |
| 8217 | /* SAP restart due to unsafe channel. While restarting |
| 8218 | * the SAP, make sure to clear acs_channel, channel to |
| 8219 | * reset to 0. Otherwise these settings will override |
| 8220 | * the ACS while restart. |
| 8221 | */ |
| 8222 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8223 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8224 | |
| 8225 | hdd_debug("sending coex indication"); |
| 8226 | |
| 8227 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8228 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8229 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8230 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8231 | |
| 8232 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8233 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8234 | { |
| 8235 | uint32_t size; |
| 8236 | uint16_t *unsafe_list; |
| 8237 | uint16_t chan_count; |
| 8238 | |
| 8239 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8240 | return -EINVAL; |
| 8241 | |
| 8242 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8243 | NUM_CHANNELS); |
| 8244 | if (chan_count) { |
| 8245 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8246 | unsafe_list = qdf_mem_malloc(size); |
| 8247 | if (!unsafe_list) { |
| 8248 | hdd_err("No memory for unsafe chan list size%d", |
| 8249 | size); |
| 8250 | return -ENOMEM; |
| 8251 | } |
| 8252 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8253 | } else { |
| 8254 | unsafe_list = NULL; |
| 8255 | } |
| 8256 | |
| 8257 | *local_unsafe_list = unsafe_list; |
| 8258 | *local_unsafe_list_count = chan_count; |
| 8259 | |
| 8260 | return 0; |
| 8261 | } |
| 8262 | |
| 8263 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8264 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8265 | { |
| 8266 | int i, j; |
| 8267 | |
| 8268 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8269 | return true; |
| 8270 | if (local_unsafe_list_count == 0) |
| 8271 | return false; |
| 8272 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8273 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8274 | if (local_unsafe_list[i] == |
| 8275 | hdd_ctx->unsafe_channel_list[j]) |
| 8276 | break; |
| 8277 | if (j >= local_unsafe_list_count) |
| 8278 | break; |
| 8279 | } |
| 8280 | if (i >= local_unsafe_list_count) { |
| 8281 | hdd_info("unsafe chan list same"); |
| 8282 | return false; |
| 8283 | } |
| 8284 | |
| 8285 | return true; |
| 8286 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8287 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8288 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8289 | { |
| 8290 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8291 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8292 | 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] | 8293 | { |
| 8294 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8295 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8296 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8297 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8298 | { |
| 8299 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8300 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8301 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8302 | |
| 8303 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8304 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8305 | * user space |
| 8306 | * @frame_ind: Management frame data to be informed. |
| 8307 | * |
| 8308 | * This function is used to indicate management frame to |
| 8309 | * user space |
| 8310 | * |
| 8311 | * Return: None |
| 8312 | * |
| 8313 | */ |
| 8314 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8315 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8316 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8317 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8318 | int i; |
| 8319 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8320 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8321 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8322 | return; |
| 8323 | |
| 8324 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8325 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8326 | adapter = |
| 8327 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8328 | if (adapter) |
| 8329 | break; |
| 8330 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8331 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8332 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8333 | if ((NULL != adapter) && |
| 8334 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8335 | __hdd_indicate_mgmt_frame(adapter, |
| 8336 | frame_ind->frame_len, |
| 8337 | frame_ind->frameBuf, |
| 8338 | frame_ind->frameType, |
| 8339 | frame_ind->rxChan, |
| 8340 | frame_ind->rxRssi); |
| 8341 | } |
| 8342 | } |
| 8343 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8344 | } else { |
| 8345 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8346 | frame_ind->sessionId); |
| 8347 | } |
| 8348 | |
| 8349 | if ((NULL != adapter) && |
| 8350 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8351 | __hdd_indicate_mgmt_frame(adapter, |
| 8352 | frame_ind->frame_len, |
| 8353 | frame_ind->frameBuf, |
| 8354 | frame_ind->frameType, |
| 8355 | frame_ind->rxChan, |
| 8356 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8357 | } |
| 8358 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8359 | void hdd_acs_response_timeout_handler(void *context) |
| 8360 | { |
| 8361 | struct hdd_external_acs_timer_context *timer_context = |
| 8362 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8363 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8364 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8365 | uint8_t reason; |
| 8366 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8367 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8368 | if (!timer_context) { |
| 8369 | hdd_err("invlaid timer context"); |
| 8370 | return; |
| 8371 | } |
| 8372 | adapter = timer_context->adapter; |
| 8373 | reason = timer_context->reason; |
| 8374 | |
| 8375 | |
| 8376 | if ((!adapter) || |
| 8377 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8378 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8379 | return; |
| 8380 | } |
| 8381 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8382 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8383 | return; |
| 8384 | |
| 8385 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8386 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8387 | else |
| 8388 | return; |
| 8389 | |
| 8390 | hdd_err("ACS timeout happened for %s reason %d", |
| 8391 | adapter->dev->name, reason); |
| 8392 | switch (reason) { |
| 8393 | /* SAP init case */ |
| 8394 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8395 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8396 | false); |
| 8397 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8398 | break; |
| 8399 | /* DFS detected on current channel */ |
| 8400 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8401 | wlan_sap_update_next_channel( |
| 8402 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8403 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8404 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8405 | break; |
| 8406 | /* LTE coex event on current channel */ |
| 8407 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8408 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8409 | break; |
| 8410 | default: |
| 8411 | hdd_info("invalid reason for timer invoke"); |
| 8412 | |
| 8413 | } |
| 8414 | } |
| 8415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8416 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8417 | * hdd_override_ini_config - Override INI config |
| 8418 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8419 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8420 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8421 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8422 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8423 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8424 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8425 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8426 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8427 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8428 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8429 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8430 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8431 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8432 | if (0 == enable_11d || 1 == enable_11d) { |
| 8433 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8434 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8435 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8436 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8437 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8438 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8439 | hdd_debug("IpaConfig override to %d", |
| 8440 | hdd_ctx->config->IpaConfig); |
| 8441 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8442 | |
| 8443 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8444 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8445 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8446 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8447 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8448 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8449 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8450 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8451 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8452 | /** |
| 8453 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8454 | * @hdd_ctx - HDD context |
| 8455 | * |
| 8456 | * Set trace level for each module based on INI config. |
| 8457 | * |
| 8458 | * Return: None |
| 8459 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8460 | 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] | 8461 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8462 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8463 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8464 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8465 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8466 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8467 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8468 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8469 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8470 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8471 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8472 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8473 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8474 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8475 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8476 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8477 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8478 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8479 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8480 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8481 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8482 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8483 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8484 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8485 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8486 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8487 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8488 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8489 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8490 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8491 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8492 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8493 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8494 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8495 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8496 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8497 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8498 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8499 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8500 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8501 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8502 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8503 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8504 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8505 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8506 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8507 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8508 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8509 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8510 | } |
| 8511 | |
| 8512 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8513 | * hdd_context_init() - Initialize HDD context |
| 8514 | * @hdd_ctx: HDD context. |
| 8515 | * |
| 8516 | * Initialize HDD context along with all the feature specific contexts. |
| 8517 | * |
| 8518 | * return: 0 on success and errno on failure. |
| 8519 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8520 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8521 | { |
| 8522 | int ret; |
| 8523 | |
| 8524 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8525 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8526 | |
| 8527 | hdd_init_ll_stats_ctx(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 8528 | hdd_init_nud_stats_ctx(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8529 | |
| 8530 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8531 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8532 | |
| 8533 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8534 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8535 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8536 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8537 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8538 | |
| 8539 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8540 | |
| 8541 | ret = hdd_scan_context_init(hdd_ctx); |
| 8542 | if (ret) |
| 8543 | goto list_destroy; |
| 8544 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8545 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8546 | |
| 8547 | ret = hdd_sap_context_init(hdd_ctx); |
| 8548 | if (ret) |
| 8549 | goto scan_destroy; |
| 8550 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8551 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8552 | |
| 8553 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8554 | |
| 8555 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8556 | hdd_ctx->config); |
| 8557 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8558 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8559 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8560 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8561 | "monitor_mode_wakelock"); |
| 8562 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8563 | return 0; |
| 8564 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8565 | sap_destroy: |
| 8566 | hdd_sap_context_destroy(hdd_ctx); |
| 8567 | |
| 8568 | scan_destroy: |
| 8569 | hdd_scan_context_destroy(hdd_ctx); |
| 8570 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8571 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8572 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8573 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8574 | return ret; |
| 8575 | } |
| 8576 | |
| 8577 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8578 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8579 | * @hdd_ctx: pointer to hdd context |
| 8580 | * |
| 8581 | * Return: status of initialization |
| 8582 | * 0 - success |
| 8583 | * negative value - failure |
| 8584 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8585 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8586 | { |
| 8587 | int ret; |
| 8588 | |
| 8589 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8590 | return 0; |
| 8591 | |
| 8592 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8593 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8594 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8595 | return -EINVAL; |
| 8596 | } |
| 8597 | |
| 8598 | /* parse ini string probe req oui */ |
| 8599 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8600 | if (ret) { |
| 8601 | hdd_err("parsing error: disable ie whitelisting"); |
| 8602 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8603 | } |
| 8604 | |
| 8605 | return ret; |
| 8606 | } |
| 8607 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8608 | /** |
| 8609 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8610 | * @priv: pointer to hdd context |
| 8611 | * |
| 8612 | * This function is invoked when the timer waiting for the interface change |
| 8613 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8614 | * |
| 8615 | * Return: void |
| 8616 | */ |
| 8617 | static void hdd_iface_change_callback(void *priv) |
| 8618 | { |
| 8619 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8620 | int ret; |
| 8621 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8622 | |
| 8623 | if (status) |
| 8624 | return; |
| 8625 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8626 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8627 | hdd_debug("Interface change timer expired close the modules!"); |
| 8628 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8629 | if (ret) |
| 8630 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8631 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8632 | } |
| 8633 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8634 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8635 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8636 | { |
| 8637 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8638 | wlan_logging_to_console); |
| 8639 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8640 | } |
| 8641 | #else |
| 8642 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8643 | { } |
| 8644 | #endif |
| 8645 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8646 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8647 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8648 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8649 | * |
| 8650 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8651 | * wiphy allocation and then context is initialized. |
| 8652 | * |
| 8653 | * Return: HDD context on success and ERR_PTR on failure |
| 8654 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8655 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8656 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8657 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8658 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8659 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8660 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8661 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8662 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8663 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8664 | if (hdd_ctx == NULL) { |
| 8665 | ret = -ENOMEM; |
| 8666 | goto err_out; |
| 8667 | } |
| 8668 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8669 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8670 | hdd_iface_change_callback, |
| 8671 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8672 | |
| 8673 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8674 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8675 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8676 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8677 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8678 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8679 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8680 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8681 | ret = -ENOMEM; |
| 8682 | goto err_free_hdd_context; |
| 8683 | } |
| 8684 | |
| 8685 | /* Read and parse the qcom_cfg.ini file */ |
| 8686 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8687 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8688 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8689 | WLAN_INI_FILE); |
| 8690 | ret = -EINVAL; |
| 8691 | goto err_free_config; |
| 8692 | } |
| 8693 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8694 | ie_whitelist_attrs_init(hdd_ctx); |
| 8695 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8696 | hdd_debug("setting timer multiplier: %u", |
| 8697 | hdd_ctx->config->timer_multiplier); |
| 8698 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8699 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8700 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8701 | if (hdd_ctx->config->fhostNSOffload) |
| 8702 | hdd_ctx->ns_offload_enable = true; |
| 8703 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8704 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8705 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8706 | hdd_override_ini_config(hdd_ctx); |
| 8707 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8708 | ret = hdd_context_init(hdd_ctx); |
| 8709 | |
| 8710 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8711 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8712 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8713 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8714 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8715 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8716 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8717 | goto skip_multicast_logging; |
| 8718 | |
| 8719 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8720 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8721 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8722 | if (ret) |
| 8723 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8724 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8725 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8726 | if (ret) |
| 8727 | goto err_deinit_txrx_histogram; |
| 8728 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8729 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8730 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8731 | skip_multicast_logging: |
| 8732 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8733 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8734 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8735 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8736 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8737 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8738 | return hdd_ctx; |
| 8739 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8740 | err_deinit_txrx_histogram: |
| 8741 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8742 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8743 | err_deinit_hdd_context: |
| 8744 | hdd_context_deinit(hdd_ctx); |
| 8745 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8746 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8747 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8748 | |
| 8749 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8750 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8751 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8752 | |
| 8753 | err_out: |
| 8754 | return ERR_PTR(ret); |
| 8755 | } |
| 8756 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8757 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8758 | /** |
| 8759 | * hdd_open_p2p_interface - Open P2P interface |
| 8760 | * @hdd_ctx: HDD context |
| 8761 | * @rtnl_held: True if RTNL lock held |
| 8762 | * |
| 8763 | * Open P2P interface during probe. This function called to open the P2P |
| 8764 | * interface at probe along with STA interface. |
| 8765 | * |
| 8766 | * Return: 0 on success and errno on failure |
| 8767 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8768 | 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] | 8769 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8770 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8771 | uint8_t *p2p_dev_addr; |
| 8772 | |
| 8773 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8774 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8775 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8776 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8777 | sizeof(tSirMacAddr)); |
| 8778 | |
| 8779 | /* |
| 8780 | * Generate the P2P Device Address. This consists of |
| 8781 | * the device's primary MAC address with the locally |
| 8782 | * administered bit set. |
| 8783 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8784 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8785 | } else { |
| 8786 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8787 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8788 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8789 | return -ENOSPC; |
| 8790 | } |
| 8791 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8792 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8793 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8794 | } |
| 8795 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8796 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8797 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8798 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8799 | |
| 8800 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8801 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8802 | return -ENOSPC; |
| 8803 | } |
| 8804 | |
| 8805 | return 0; |
| 8806 | } |
| 8807 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8808 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8809 | bool rtnl_held) |
| 8810 | { |
| 8811 | return 0; |
| 8812 | } |
| 8813 | #endif |
| 8814 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8815 | 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] | 8816 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8817 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8818 | int ret = 0; |
| 8819 | |
| 8820 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8821 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8822 | NET_NAME_UNKNOWN, rtnl_held); |
| 8823 | if (adapter == NULL) { |
| 8824 | hdd_err("Failed to open 802.11p interface"); |
| 8825 | ret = -ENOSPC; |
| 8826 | } |
| 8827 | |
| 8828 | return ret; |
| 8829 | } |
| 8830 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8831 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8832 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8833 | * @adapter: HDD adapter |
| 8834 | * |
| 8835 | * This function initializes the adapter for the station mode. |
| 8836 | * |
| 8837 | * Return: 0 on success or errno on failure. |
| 8838 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8839 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8840 | { |
| 8841 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8842 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8843 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8844 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8845 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8846 | hdd_err("session is already opened, %d", |
| 8847 | adapter->session_id); |
| 8848 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8849 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8850 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8851 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8852 | if (ret) { |
| 8853 | hdd_err("failed to create vdev: %d", ret); |
| 8854 | return ret; |
| 8855 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8856 | status = hdd_init_station_mode(adapter); |
| 8857 | |
| 8858 | if (QDF_STATUS_SUCCESS != status) { |
| 8859 | hdd_err("Error Initializing station mode: %d", status); |
| 8860 | return qdf_status_to_os_return(status); |
| 8861 | } |
| 8862 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8863 | hdd_register_tx_flow_control(adapter, |
| 8864 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8865 | hdd_tx_resume_cb, |
| 8866 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8867 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8868 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8869 | return 0; |
| 8870 | } |
| 8871 | |
| 8872 | /** |
| 8873 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8874 | * @adapter: HDD adapter |
| 8875 | * |
| 8876 | * This function initializes the adapter for the AP mode. |
| 8877 | * |
| 8878 | * Return: 0 on success errno on failure. |
| 8879 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8880 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8881 | { |
| 8882 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8883 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8884 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8885 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8886 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8887 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8888 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8889 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8890 | hdd_err("session is already opened, %d", |
| 8891 | adapter->session_id); |
| 8892 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8893 | } |
| 8894 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8895 | * In SSR case no need to create new sap context. |
| 8896 | * Otherwise create sap context first and then create |
| 8897 | * vdev as while creating the vdev, driver needs to |
| 8898 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8899 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8900 | if (adapter->session.ap.sap_context) { |
| 8901 | is_ssr = true; |
| 8902 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8903 | hdd_err("sap creation failed"); |
| 8904 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8905 | } |
| 8906 | |
| 8907 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8908 | adapter->session.ap.sap_context); |
| 8909 | if (ret) { |
| 8910 | hdd_err("failed to create vdev, status:%d", ret); |
| 8911 | hdd_sap_destroy_ctx(adapter); |
| 8912 | return ret; |
| 8913 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8914 | |
| 8915 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8916 | sme_cli_set_command(adapter->session_id, |
| 8917 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8918 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8919 | WMI_FW_AP_RTT_RESPR), |
| 8920 | VDEV_CMD); |
| 8921 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8922 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8923 | |
| 8924 | if (QDF_STATUS_SUCCESS != status) { |
| 8925 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8926 | return qdf_status_to_os_return(status); |
| 8927 | } |
| 8928 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8929 | hdd_register_tx_flow_control(adapter, |
| 8930 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8931 | hdd_softap_tx_resume_cb, |
| 8932 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8933 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8934 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8935 | return 0; |
| 8936 | } |
| 8937 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8938 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8939 | bool rtnl_held) |
| 8940 | { |
| 8941 | struct hdd_adapter *adapter; |
| 8942 | |
| 8943 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8944 | hdd_ctx->config->enableConcurrentSTA, |
| 8945 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8946 | NET_NAME_UNKNOWN, rtnl_held); |
| 8947 | |
| 8948 | if (!adapter) |
| 8949 | return -ENOSPC; |
| 8950 | |
| 8951 | return 0; |
| 8952 | } |
| 8953 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8954 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8955 | * hdd_open_interfaces - Open all required interfaces |
| 8956 | * hdd_ctx: HDD context |
| 8957 | * rtnl_held: True if RTNL lock is held |
| 8958 | * |
| 8959 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 8960 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8961 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8962 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8963 | 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] | 8964 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8965 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8966 | int ret; |
| 8967 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8968 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8969 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 8970 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 8971 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 8972 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 8973 | |
| 8974 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 8975 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8976 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8977 | if (!adapter) { |
| 8978 | hdd_err("open adapter failed"); |
| 8979 | return -ENOSPC; |
| 8980 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 8981 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 8982 | return 0; |
| 8983 | } |
| 8984 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8985 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8986 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8987 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8988 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8989 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8990 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8991 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8992 | |
| 8993 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8994 | return -ENOSPC; |
| 8995 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8996 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 8997 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 8998 | if (ret) |
| 8999 | hdd_err("Cannot create concurrent STA interface"); |
| 9000 | } |
| 9001 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9002 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9003 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9004 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9005 | |
| 9006 | /* Open 802.11p Interface */ |
| 9007 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9008 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9009 | if (ret) |
| 9010 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9011 | } |
| 9012 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9013 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9014 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9015 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9016 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9017 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9018 | } |
| 9019 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9020 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9021 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9022 | /** |
| 9023 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9024 | * @cds_cfg: CDS Configuration |
| 9025 | * @hdd_ctx: Pointer to hdd context |
| 9026 | * |
| 9027 | * Return: none |
| 9028 | */ |
| 9029 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9030 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9031 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9032 | { |
| 9033 | cds_cfg->tx_flow_stop_queue_th = |
| 9034 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9035 | cds_cfg->tx_flow_start_queue_offset = |
| 9036 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 9037 | } |
| 9038 | #else |
| 9039 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9040 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9041 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9042 | { |
| 9043 | } |
| 9044 | #endif |
| 9045 | |
| 9046 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9047 | /** |
| 9048 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9049 | * @cds_cfg: CDS Configuration |
| 9050 | * @hdd_ctx: Pointer to hdd context |
| 9051 | * |
| 9052 | * Return: none |
| 9053 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9054 | 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] | 9055 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9056 | { |
| 9057 | cds_cfg->ra_ratelimit_interval = |
| 9058 | hdd_ctx->config->RArateLimitInterval; |
| 9059 | cds_cfg->is_ra_ratelimit_enabled = |
| 9060 | hdd_ctx->config->IsRArateLimitEnabled; |
| 9061 | } |
| 9062 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9063 | 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] | 9064 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9065 | { |
| 9066 | } |
| 9067 | #endif |
| 9068 | |
| 9069 | /** |
| 9070 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9071 | * @hdd_ctx: HDD Context |
| 9072 | * |
| 9073 | * Return: 0 for Success, errno on failure |
| 9074 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9075 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9076 | { |
| 9077 | struct cds_config_info *cds_cfg; |
| 9078 | |
| 9079 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9080 | if (!cds_cfg) { |
| 9081 | hdd_err("failed to allocate cds config"); |
| 9082 | return -ENOMEM; |
| 9083 | } |
| 9084 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9085 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 9086 | if (!hdd_ctx->config->nMaxPsPoll || |
| 9087 | !hdd_ctx->config->enablePowersaveOffload) { |
| 9088 | cds_cfg->powersave_offload_enabled = |
| 9089 | hdd_ctx->config->enablePowersaveOffload; |
| 9090 | } else { |
| 9091 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9092 | PS_QPOWER_NODEEPSLEEP) || |
| 9093 | (hdd_ctx->config->enablePowersaveOffload == |
| 9094 | PS_LEGACY_NODEEPSLEEP)) |
| 9095 | cds_cfg->powersave_offload_enabled = |
| 9096 | PS_LEGACY_NODEEPSLEEP; |
| 9097 | else |
| 9098 | cds_cfg->powersave_offload_enabled = |
| 9099 | PS_LEGACY_DEEPSLEEP; |
| 9100 | hdd_info("Qpower disabled in cds config, %d", |
| 9101 | cds_cfg->powersave_offload_enabled); |
| 9102 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9103 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9104 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9105 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9106 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9107 | |
| 9108 | /* |
| 9109 | * Copy the DFS Phyerr Filtering Offload status. |
| 9110 | * This parameter reflects the value of the |
| 9111 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9112 | */ |
| 9113 | cds_cfg->dfs_phyerr_filter_offload = |
| 9114 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9115 | if (hdd_ctx->config->ssdp) |
| 9116 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9117 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9118 | cds_cfg->force_target_assert_enabled = |
| 9119 | hdd_ctx->config->crash_inject_enabled; |
| 9120 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9121 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9122 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9123 | |
| 9124 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9125 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9126 | |
| 9127 | cds_cfg->ap_disable_intrabss_fwd = |
| 9128 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9129 | |
| 9130 | cds_cfg->dfs_pri_multiplier = |
| 9131 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9132 | cds_cfg->reorder_offload = |
| 9133 | hdd_ctx->config->reorderOffloadSupport; |
| 9134 | |
| 9135 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9136 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9137 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9138 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9139 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9140 | hdd_ctx->config->IpaUcTxBufCount); |
| 9141 | hdd_ctx->config->IpaUcTxBufCount = |
| 9142 | rounddown_pow_of_two( |
| 9143 | hdd_ctx->config->IpaUcTxBufCount); |
| 9144 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9145 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9146 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9147 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9148 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9149 | hdd_ctx->config->IpaUcTxBufCount); |
| 9150 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9151 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9152 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9153 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9154 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9155 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9156 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9157 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9158 | rounddown_pow_of_two( |
| 9159 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9160 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9161 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9162 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9163 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9164 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9165 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9166 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9167 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9168 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9169 | cds_cfg->uc_tx_partition_base = |
| 9170 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9171 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9172 | |
| 9173 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9174 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9175 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9176 | cds_cfg->ce_classify_enabled = |
| 9177 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 9178 | cds_cfg->bpf_packet_filter_enable = |
| 9179 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9180 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9181 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9182 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9183 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9184 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9185 | cds_cfg->max_msdus_per_rxinorderind = |
| 9186 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9187 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9188 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 9189 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 9190 | 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] | 9191 | cds_cfg->auto_power_save_fail_mode = |
| 9192 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9193 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9194 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9195 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9196 | cds_cfg->delay_before_vdev_stop = |
| 9197 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9198 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9199 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9200 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9201 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9202 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9203 | cds_init_ini_config(cds_cfg); |
| 9204 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9205 | |
| 9206 | exit: |
| 9207 | qdf_mem_free(cds_cfg); |
| 9208 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9209 | } |
| 9210 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9211 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9212 | * hdd_update_user_config() - API to update user configuration |
| 9213 | * parameters to obj mgr which are used by multiple components |
| 9214 | * @hdd_ctx: HDD Context |
| 9215 | * |
| 9216 | * Return: 0 for Success, errno on failure |
| 9217 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9218 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9219 | { |
| 9220 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9221 | |
| 9222 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9223 | if (user_config == NULL) { |
| 9224 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9225 | return -ENOMEM; |
| 9226 | } |
| 9227 | |
| 9228 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9229 | user_config->dual_mac_feature_disable = |
| 9230 | hdd_ctx->config->dual_mac_feature_disable; |
| 9231 | user_config->indoor_channel_support = |
| 9232 | hdd_ctx->config->indoor_channel_support; |
| 9233 | user_config->is_11d_support_enabled = |
| 9234 | hdd_ctx->config->Is11dSupportEnabled; |
| 9235 | user_config->is_11h_support_enabled = |
| 9236 | hdd_ctx->config->Is11hSupportEnabled; |
| 9237 | user_config->optimize_chan_avoid_event = |
| 9238 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9239 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9240 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9241 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9242 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9243 | |
| 9244 | qdf_mem_free(user_config); |
| 9245 | return 0; |
| 9246 | } |
| 9247 | |
| 9248 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9249 | * hdd_init_thermal_info - Initialize thermal level |
| 9250 | * @hdd_ctx: HDD context |
| 9251 | * |
| 9252 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9253 | * which would be called when a configured thermal threshold is hit. |
| 9254 | * |
| 9255 | * Return: 0 on success and errno on failure |
| 9256 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9257 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9258 | { |
| 9259 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9260 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9261 | |
| 9262 | thermal_param.smeThermalMgmtEnabled = |
| 9263 | hdd_ctx->config->thermalMitigationEnable; |
| 9264 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9265 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9266 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9267 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9268 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9269 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9270 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9271 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9272 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9273 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9274 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9275 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9276 | hdd_ctx->config->thermalTempMinLevel0; |
| 9277 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9278 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9279 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9280 | hdd_ctx->config->thermalTempMinLevel1; |
| 9281 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9282 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9283 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9284 | hdd_ctx->config->thermalTempMinLevel2; |
| 9285 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9286 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9287 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9288 | hdd_ctx->config->thermalTempMinLevel3; |
| 9289 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9290 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9291 | |
| 9292 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9293 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9294 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9295 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9296 | |
| 9297 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9298 | hdd_set_thermal_level_cb); |
| 9299 | |
| 9300 | return 0; |
| 9301 | |
| 9302 | } |
| 9303 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9304 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9305 | /** |
| 9306 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9307 | * |
| 9308 | * Hold RTNL lock |
| 9309 | * |
| 9310 | * Return: True if held and false otherwise |
| 9311 | */ |
| 9312 | static inline bool hdd_hold_rtnl_lock(void) |
| 9313 | { |
| 9314 | rtnl_lock(); |
| 9315 | return true; |
| 9316 | } |
| 9317 | |
| 9318 | /** |
| 9319 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9320 | * |
| 9321 | * Release RTNL lock |
| 9322 | * |
| 9323 | * Return: None |
| 9324 | */ |
| 9325 | static inline void hdd_release_rtnl_lock(void) |
| 9326 | { |
| 9327 | rtnl_unlock(); |
| 9328 | } |
| 9329 | #else |
| 9330 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9331 | static inline void hdd_release_rtnl_lock(void) { } |
| 9332 | #endif |
| 9333 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9334 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9335 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9336 | /* MAX iwpriv command support */ |
| 9337 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9338 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9339 | #define MAX_PKTLOG_SIZE 16 |
| 9340 | |
| 9341 | /** |
| 9342 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9343 | * @hdd_ctx: hdd context |
| 9344 | * @set_value2: pktlog buffer size value |
| 9345 | * |
| 9346 | * |
| 9347 | * Return: 0 for success or error. |
| 9348 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9349 | 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] | 9350 | { |
| 9351 | struct sir_wifi_start_log start_log = { 0 }; |
| 9352 | QDF_STATUS status; |
| 9353 | |
| 9354 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9355 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9356 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9357 | start_log.user_triggered = 1; |
| 9358 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9359 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9360 | |
| 9361 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9362 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9363 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9364 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9365 | return -EINVAL; |
| 9366 | } |
| 9367 | |
| 9368 | return 0; |
| 9369 | } |
| 9370 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9371 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9372 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9373 | * @hdd_ctx: hdd context |
| 9374 | * |
| 9375 | * Return: 0 for success or error. |
| 9376 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9377 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9378 | { |
| 9379 | struct sir_wifi_start_log start_log; |
| 9380 | QDF_STATUS status; |
| 9381 | |
| 9382 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9383 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9384 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9385 | start_log.user_triggered = 1; |
| 9386 | start_log.size = 0; |
| 9387 | start_log.is_pktlog_buff_clear = true; |
| 9388 | |
| 9389 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9390 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9391 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9392 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9393 | return -EINVAL; |
| 9394 | } |
| 9395 | |
| 9396 | return 0; |
| 9397 | } |
| 9398 | |
| 9399 | |
| 9400 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9401 | * hdd_process_pktlog_command() - process pktlog command |
| 9402 | * @hdd_ctx: hdd context |
| 9403 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9404 | * @set_value2: pktlog buffer size value |
| 9405 | * |
| 9406 | * This function process pktlog command. |
| 9407 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9408 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9409 | * |
| 9410 | * Return: 0 for success or error. |
| 9411 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9412 | 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] | 9413 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9414 | { |
| 9415 | int ret; |
| 9416 | bool enable; |
| 9417 | uint8_t user_triggered = 0; |
| 9418 | |
| 9419 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9420 | if (0 != ret) |
| 9421 | return ret; |
| 9422 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9423 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9424 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9425 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9426 | hdd_err("invalid pktlog value %d", set_value); |
| 9427 | return -EINVAL; |
| 9428 | } |
| 9429 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9430 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9431 | if (set_value2 <= 0) { |
| 9432 | hdd_err("invalid pktlog size %d", set_value2); |
| 9433 | return -EINVAL; |
| 9434 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9435 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9436 | return -EINVAL; |
| 9437 | } |
| 9438 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9439 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9440 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9441 | } |
| 9442 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9443 | /* |
| 9444 | * set_value = 0 then disable packetlog |
| 9445 | * set_value = 1 enable packetlog forcefully |
| 9446 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9447 | * enable packetlog with AUTO type. |
| 9448 | */ |
| 9449 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9450 | true : false; |
| 9451 | |
| 9452 | if (1 == set_value) { |
| 9453 | enable = true; |
| 9454 | user_triggered = 1; |
| 9455 | } |
| 9456 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9457 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9458 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9459 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9460 | /** |
| 9461 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9462 | * @hdd_ctx: HDD context |
| 9463 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9464 | * @user_triggered: triggered through iwpriv |
| 9465 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9466 | * |
| 9467 | * Return: 0 on success; error number otherwise |
| 9468 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9469 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9470 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9471 | { |
| 9472 | struct sir_wifi_start_log start_log; |
| 9473 | QDF_STATUS status; |
| 9474 | |
| 9475 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9476 | start_log.verbose_level = |
| 9477 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9478 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9479 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9480 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9481 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9482 | /* |
| 9483 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9484 | * commands. Host uses this flag to decide whether to send pktlog |
| 9485 | * disable command to fw without sending pktlog enable command |
| 9486 | * previously. For eg, If vendor sends pktlog disable command without |
| 9487 | * sending pktlog enable command, then host discards the packet |
| 9488 | * but for iwpriv command, host will send it to fw. |
| 9489 | */ |
| 9490 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9491 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9492 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9493 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9494 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9495 | return -EINVAL; |
| 9496 | } |
| 9497 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9498 | if (enable == true) |
| 9499 | hdd_ctx->is_pktlog_enabled = 1; |
| 9500 | else |
| 9501 | hdd_ctx->is_pktlog_enabled = 0; |
| 9502 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9503 | return 0; |
| 9504 | } |
| 9505 | #endif /* REMOVE_PKT_LOG */ |
| 9506 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9507 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9508 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9509 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9510 | * @dev: Device Pointer |
| 9511 | * @num: Number of Valid Mac address |
| 9512 | * |
| 9513 | * Return: Pointer to MAC address buffer |
| 9514 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9515 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9516 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9517 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9518 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9519 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9520 | |
| 9521 | /** |
| 9522 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9523 | * @hdd_ctx: HDD Context |
| 9524 | * @num: Number of random mac addresses needed |
| 9525 | * |
| 9526 | * Generate random addresses using bit manipulation on the base mac address |
| 9527 | * |
| 9528 | * Return: None |
| 9529 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9530 | 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] | 9531 | { |
| 9532 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9533 | uint32_t iter; |
| 9534 | struct hdd_config *ini = hdd_ctx->config; |
| 9535 | uint8_t *buf = NULL; |
| 9536 | uint8_t macaddr_b3, tmp_br3; |
| 9537 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9538 | |
| 9539 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9540 | buf = ini->intfMacAddr[iter].bytes; |
| 9541 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9542 | macaddr_b3 = buf[3]; |
| 9543 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9544 | INTF_MACADDR_MASK; |
| 9545 | macaddr_b3 += tmp_br3; |
| 9546 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9547 | buf[0] |= 0x02; |
| 9548 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9549 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9550 | } |
| 9551 | } |
| 9552 | |
| 9553 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9554 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9555 | * @hdd_ctx: HDD Context |
| 9556 | * |
| 9557 | * API to get mac addresses from platform driver and update the driver |
| 9558 | * structures and configure FW with the base mac address. |
| 9559 | * Return: int |
| 9560 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9561 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9562 | { |
| 9563 | uint32_t no_of_mac_addr, iter; |
| 9564 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9565 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9566 | uint8_t *addr, *buf; |
| 9567 | struct device *dev = hdd_ctx->parent_dev; |
| 9568 | struct hdd_config *ini = hdd_ctx->config; |
| 9569 | tSirMacAddr mac_addr; |
| 9570 | QDF_STATUS status; |
| 9571 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9572 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9573 | |
| 9574 | if (no_of_mac_addr == 0 || !addr) { |
| 9575 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9576 | return -EINVAL; |
| 9577 | } |
| 9578 | |
| 9579 | if (no_of_mac_addr > max_mac_addr) |
| 9580 | no_of_mac_addr = max_mac_addr; |
| 9581 | |
| 9582 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9583 | |
| 9584 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9585 | buf = ini->intfMacAddr[iter].bytes; |
| 9586 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9587 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9588 | } |
| 9589 | |
| 9590 | status = sme_set_custom_mac_addr(mac_addr); |
| 9591 | |
| 9592 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9593 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9594 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9595 | if (no_of_mac_addr < max_mac_addr) |
| 9596 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9597 | no_of_mac_addr); |
| 9598 | return 0; |
| 9599 | } |
| 9600 | |
| 9601 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9602 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9603 | * @hdd_ctx: HDD Context |
| 9604 | * |
| 9605 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9606 | * will generate its own MAC and update it to FW. |
| 9607 | * |
| 9608 | * Return: 0 for success |
| 9609 | * Non-zero error code for failure |
| 9610 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9611 | 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] | 9612 | { |
| 9613 | tSirMacAddr customMacAddr; |
| 9614 | QDF_STATUS status; |
| 9615 | |
| 9616 | qdf_mem_copy(&customMacAddr, |
| 9617 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9618 | sizeof(tSirMacAddr)); |
| 9619 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9620 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9621 | return -EAGAIN; |
| 9622 | return 0; |
| 9623 | } |
| 9624 | |
| 9625 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9626 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9627 | * @hdd_ctx: HDD Context |
| 9628 | * |
| 9629 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9630 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9631 | * wlan_mac.bin to update HW MAC addresses. |
| 9632 | * |
| 9633 | * Return: None |
| 9634 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9635 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9636 | { |
| 9637 | QDF_STATUS status; |
| 9638 | int ret; |
| 9639 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9640 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9641 | if (ret == 0) |
| 9642 | return; |
| 9643 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9644 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9645 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9646 | |
| 9647 | status = hdd_update_mac_config(hdd_ctx); |
| 9648 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9649 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9650 | return; |
| 9651 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9652 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9653 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9654 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9655 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9656 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9657 | if (ret != 0) { |
| 9658 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9659 | QDF_ASSERT(ret); |
| 9660 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9661 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9662 | } |
| 9663 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9664 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9665 | { |
| 9666 | int vdev_id = 0; |
| 9667 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9668 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9669 | int vpdev = PDEV_CMD; |
| 9670 | int ret; |
| 9671 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9672 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9673 | if (ret) |
| 9674 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9675 | |
| 9676 | return ret; |
| 9677 | } |
| 9678 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9679 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9680 | { |
| 9681 | int vdev_id = 0; |
| 9682 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9683 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9684 | int vpdev = PDEV_CMD; |
| 9685 | int ret; |
| 9686 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9687 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9688 | if (ret) |
| 9689 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9690 | ret); |
| 9691 | |
| 9692 | return ret; |
| 9693 | } |
| 9694 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9695 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9696 | { |
| 9697 | int vdev_id = 0; |
| 9698 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9699 | int value = hdd_ctx->config->ani_enabled; |
| 9700 | int vpdev = PDEV_CMD; |
| 9701 | int ret; |
| 9702 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9703 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9704 | if (ret) |
| 9705 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9706 | |
| 9707 | return ret; |
| 9708 | } |
| 9709 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9710 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9711 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9712 | * @hdd_ctx: HDD context |
| 9713 | * |
| 9714 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9715 | * |
| 9716 | * Return: 0 on success and errno on failure. |
| 9717 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9718 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9719 | { |
| 9720 | int ret; |
| 9721 | QDF_STATUS status; |
| 9722 | tSirRetStatus hal_status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9723 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9724 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9725 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9726 | /* |
| 9727 | * Set 802.11p config |
| 9728 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9729 | * parameter is set in CSR when we init the channel list. This should |
| 9730 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9731 | * domain. |
| 9732 | */ |
| 9733 | hdd_set_dot11p_config(hdd_ctx); |
| 9734 | |
| 9735 | /* |
| 9736 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9737 | * The cfg download must occur before we update the SME config |
| 9738 | * since the SME config operation must access the cfg database |
| 9739 | */ |
| 9740 | status = hdd_set_sme_config(hdd_ctx); |
| 9741 | |
| 9742 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9743 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9744 | ret = qdf_status_to_os_return(status); |
| 9745 | goto out; |
| 9746 | } |
| 9747 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9748 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9749 | if (QDF_STATUS_SUCCESS != status) { |
| 9750 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9751 | ret = qdf_status_to_os_return(status); |
| 9752 | goto out; |
| 9753 | } |
| 9754 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9755 | 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] | 9756 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9757 | PDEV_CMD); |
| 9758 | if (0 != ret) { |
| 9759 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9760 | goto out; |
| 9761 | } |
| 9762 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9763 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9764 | if (ret) |
| 9765 | goto out; |
| 9766 | |
| 9767 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9768 | if (ret) |
| 9769 | goto out; |
| 9770 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9771 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9772 | if (ret) |
| 9773 | goto out; |
| 9774 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9775 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9776 | hdd_ctx->config->arp_ac_category, |
| 9777 | PDEV_CMD); |
| 9778 | if (0 != ret) { |
| 9779 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9780 | hdd_ctx->config->arp_ac_category, ret); |
| 9781 | goto out; |
| 9782 | } |
| 9783 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9784 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9785 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9786 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9787 | ret = qdf_status_to_os_return(status); |
| 9788 | goto out; |
| 9789 | } |
| 9790 | |
| 9791 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9792 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9793 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9794 | ret = -EINVAL; |
| 9795 | goto out; |
| 9796 | } |
| 9797 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9798 | /* |
| 9799 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9800 | * Remove this once self sta is added as part of session open. |
| 9801 | */ |
| 9802 | hal_status = cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9803 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9804 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
| 9805 | |
| 9806 | if (!IS_SIR_STATUS_SUCCESS(hal_status)) { |
| 9807 | hdd_err("Failed to set MAC Address. HALStatus is %08d [x%08x]", |
| 9808 | hal_status, hal_status); |
| 9809 | ret = -EINVAL; |
| 9810 | goto out; |
| 9811 | } |
| 9812 | |
| 9813 | hdd_init_channel_avoidance(hdd_ctx); |
| 9814 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9815 | /* update enable sap mandatory chan list */ |
| 9816 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9817 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9818 | out: |
| 9819 | return ret; |
| 9820 | } |
| 9821 | |
| 9822 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9823 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9824 | * @context_ptr - hdd context pointer |
| 9825 | * @event_ptr - event structure pointer |
| 9826 | * |
| 9827 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9828 | * event back to supplicant to notify the stop reason. |
| 9829 | * |
| 9830 | * Return: None |
| 9831 | */ |
| 9832 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9833 | void *event_ptr) |
| 9834 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9835 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9836 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9837 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9838 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9839 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9840 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9841 | |
| 9842 | if (hdd_ctx == NULL) { |
| 9843 | hdd_err("Invalid HDD context pointer"); |
| 9844 | return; |
| 9845 | } |
| 9846 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9847 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9848 | if (!adapter) { |
| 9849 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9850 | evt->vdev_id); |
| 9851 | return; |
| 9852 | } |
| 9853 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9854 | vendor_event = |
| 9855 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9856 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9857 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9858 | GFP_KERNEL); |
| 9859 | |
| 9860 | if (!vendor_event) { |
| 9861 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9862 | return; |
| 9863 | } |
| 9864 | |
| 9865 | if (nla_put_u32(vendor_event, |
| 9866 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9867 | evt->reason_code)) { |
| 9868 | hdd_err("nla put failed"); |
| 9869 | kfree_skb(vendor_event); |
| 9870 | return; |
| 9871 | } |
| 9872 | |
| 9873 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9874 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9875 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9876 | } |
| 9877 | |
| 9878 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9879 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9880 | * @hdd_ctx: HDD context |
| 9881 | * |
| 9882 | * This function sends the adaptive dwell time config configuration to the |
| 9883 | * firmware via WMA |
| 9884 | * |
| 9885 | * Return: 0 - success, < 0 - failure |
| 9886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9887 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9888 | { |
| 9889 | QDF_STATUS status; |
| 9890 | struct adaptive_dwelltime_params dwelltime_params; |
| 9891 | |
| 9892 | dwelltime_params.is_enabled = |
| 9893 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9894 | dwelltime_params.dwelltime_mode = |
| 9895 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9896 | dwelltime_params.lpf_weight = |
| 9897 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9898 | dwelltime_params.passive_mon_intval = |
| 9899 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9900 | dwelltime_params.wifi_act_threshold = |
| 9901 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9902 | |
| 9903 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9904 | &dwelltime_params); |
| 9905 | |
| 9906 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9907 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9908 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9909 | return -EAGAIN; |
| 9910 | } |
| 9911 | return 0; |
| 9912 | } |
| 9913 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9914 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9915 | { |
| 9916 | QDF_STATUS status; |
| 9917 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9918 | uint32_t i = 0; |
| 9919 | uint8_t count = 0, numentries = 0; |
| 9920 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9921 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9922 | |
| 9923 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 9924 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 9925 | DISABLE_DBS_CXN_AND_SCAN) || |
| 9926 | (hdd_ctx->config->dual_mac_feature_disable == |
| 9927 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9928 | return -EINVAL; |
| 9929 | |
| 9930 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9931 | dbs_scan_config, &numentries, |
| 9932 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9933 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9934 | |
| 9935 | hdd_info("numentries %hu", numentries); |
| 9936 | if (!numentries) { |
| 9937 | hdd_info("Donot send scan_selection_config"); |
| 9938 | return 0; |
| 9939 | } |
| 9940 | |
| 9941 | /* hdd_set_fw_log_params */ |
| 9942 | dbs_scan_params.num_clients = 0; |
| 9943 | while (count < (numentries - 2)) { |
| 9944 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9945 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9946 | dbs_scan_params.num_non_dbs_scans[i] = |
| 9947 | dbs_scan_config[count + 2]; |
| 9948 | dbs_scan_params.num_clients++; |
| 9949 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 9950 | dbs_scan_params.module_id[i], |
| 9951 | dbs_scan_params.num_dbs_scans[i], |
| 9952 | dbs_scan_params.num_non_dbs_scans[i]); |
| 9953 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 9954 | i++; |
| 9955 | } |
| 9956 | |
| 9957 | dbs_scan_params.pdev_id = 0; |
| 9958 | |
| 9959 | hdd_debug("clients:%d pdev:%d", |
| 9960 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 9961 | |
| 9962 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 9963 | &dbs_scan_params); |
| 9964 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 9965 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9966 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 9967 | return -EAGAIN; |
| 9968 | } |
| 9969 | return 0; |
| 9970 | } |
| 9971 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9972 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9973 | /** |
| 9974 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 9975 | * @hdd_ctx: HDD context |
| 9976 | * |
| 9977 | * Set auto shutdown callback to get indications from firmware to indicate |
| 9978 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 9979 | * |
| 9980 | * Return: 0 on success and errno on failure. |
| 9981 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9982 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9983 | { |
| 9984 | QDF_STATUS status; |
| 9985 | |
| 9986 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 9987 | return 0; |
| 9988 | |
| 9989 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 9990 | wlan_hdd_auto_shutdown_cb); |
| 9991 | if (status != QDF_STATUS_SUCCESS) |
| 9992 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 9993 | status); |
| 9994 | |
| 9995 | return qdf_status_to_os_return(status); |
| 9996 | } |
| 9997 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9998 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 9999 | { |
| 10000 | return 0; |
| 10001 | } |
| 10002 | #endif |
| 10003 | |
| 10004 | /** |
| 10005 | * hdd_features_init() - Init features |
| 10006 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10007 | * |
| 10008 | * Initialize features and their feature context after WLAN firmware is up. |
| 10009 | * |
| 10010 | * Return: 0 on success and errno on failure. |
| 10011 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10012 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10013 | { |
| 10014 | tSirTxPowerLimit hddtxlimit; |
| 10015 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10016 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10017 | int ret; |
| 10018 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10019 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10020 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10021 | /* FW capabilities received, Set the Dot11 mode */ |
| 10022 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 10023 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 10024 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10025 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10026 | |
| 10027 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10028 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10029 | else |
| 10030 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10031 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10032 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10033 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10034 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10035 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10036 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10037 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10038 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10039 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 10040 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10041 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10042 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10043 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10044 | |
| 10045 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10046 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10047 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10048 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10049 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10050 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10051 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10052 | if (ret) { |
| 10053 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10054 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10055 | } |
| 10056 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10057 | /** |
| 10058 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10059 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10060 | * device up. |
| 10061 | */ |
| 10062 | if (cds_is_driver_recovering()) { |
| 10063 | if (hdd_ctx->is_pktlog_enabled) |
| 10064 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 10065 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10066 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10067 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10068 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 10069 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 10070 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10071 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10072 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10073 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10074 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10075 | ret = hdd_register_cb(hdd_ctx); |
| 10076 | if (ret) { |
| 10077 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10078 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10079 | } |
| 10080 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10081 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 10082 | status = sme_enable_disable_chanavoidind_event( |
| 10083 | hdd_ctx->hHal, 0); |
| 10084 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10085 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10086 | goto deregister_cb; |
| 10087 | } |
| 10088 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10089 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10090 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10091 | band_pref_params.rssi_boost_threshold_5g = |
| 10092 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10093 | band_pref_params.rssi_boost_factor_5g = |
| 10094 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10095 | band_pref_params.max_rssi_boost_5g = |
| 10096 | hdd_ctx->config->max_rssi_boost_5g; |
| 10097 | band_pref_params.rssi_penalize_threshold_5g = |
| 10098 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10099 | band_pref_params.rssi_penalize_factor_5g = |
| 10100 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10101 | band_pref_params.max_rssi_penalize_5g = |
| 10102 | hdd_ctx->config->max_rssi_penalize_5g; |
| 10103 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 10104 | } |
| 10105 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10106 | /* register P2P Listen Offload event callback */ |
| 10107 | if (wma_is_p2p_lo_capable()) |
| 10108 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 10109 | wlan_hdd_p2p_lo_event_callback); |
| 10110 | |
| 10111 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10112 | |
| 10113 | if (ret) |
| 10114 | goto deregister_cb; |
| 10115 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10116 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10117 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10118 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10119 | return 0; |
| 10120 | |
| 10121 | deregister_cb: |
| 10122 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10123 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10124 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10125 | } |
| 10126 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10127 | /** |
| 10128 | * hdd_features_deinit() - Deinit features |
| 10129 | * @hdd_ctx: HDD context |
| 10130 | * |
| 10131 | * De-Initialize features and their feature context. |
| 10132 | * |
| 10133 | * Return: none. |
| 10134 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10135 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10136 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10137 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10138 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10139 | } |
| 10140 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10141 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10142 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10143 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10144 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10145 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10146 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10147 | 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] | 10148 | { |
| 10149 | QDF_STATUS status; |
| 10150 | |
| 10151 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10152 | wlan_cfg80211_inform_bss_frame, |
| 10153 | SCAN_CB_TYPE_INFORM_BCN); |
| 10154 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10155 | hdd_err("failed with status code %08d [x%08x]", |
| 10156 | status, status); |
| 10157 | return status; |
| 10158 | } |
| 10159 | |
| 10160 | return QDF_STATUS_SUCCESS; |
| 10161 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10162 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10163 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10164 | * hdd_configure_cds() - Configure cds modules |
| 10165 | * @hdd_ctx: HDD context |
| 10166 | * @adapter: Primary adapter context |
| 10167 | * |
| 10168 | * Enable Cds modules after WLAN firmware is up. |
| 10169 | * |
| 10170 | * Return: 0 on success and errno on failure. |
| 10171 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10172 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10173 | { |
| 10174 | int ret; |
| 10175 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10176 | int set_value; |
| 10177 | uint32_t num_abg_tx_chains = 0; |
| 10178 | uint32_t num_11b_tx_chains = 0; |
| 10179 | uint32_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10180 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10181 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10182 | if (hdd_ctx->config->is_force_1x1) |
| 10183 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10184 | 1, PDEV_CMD); |
| 10185 | /* set chip power save failure detected callback */ |
| 10186 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 10187 | hdd_chip_pwr_save_fail_detected_cb); |
| 10188 | |
| 10189 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10190 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10191 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10192 | set_value, PDEV_CMD); |
| 10193 | } |
| 10194 | |
| 10195 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10196 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10197 | sme_cli_set_command(0, |
| 10198 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10199 | set_value, PDEV_CMD); |
| 10200 | } |
| 10201 | |
| 10202 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10203 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10204 | sme_cli_set_command(0, |
| 10205 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10206 | set_value, PDEV_CMD); |
| 10207 | } |
| 10208 | |
| 10209 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10210 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10211 | if (!hdd_ctx->config->enable2x2) { |
| 10212 | if (num_11b_tx_chains > 1) |
| 10213 | num_11b_tx_chains = 1; |
| 10214 | if (num_11ag_tx_chains > 1) |
| 10215 | num_11ag_tx_chains = 1; |
| 10216 | } |
| 10217 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10218 | num_11b_tx_chains); |
| 10219 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10220 | num_11ag_tx_chains); |
| 10221 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10222 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10223 | |
| 10224 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10225 | if (ret) { |
| 10226 | hdd_err("Failed to pre-configure cds"); |
| 10227 | goto out; |
| 10228 | } |
| 10229 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10230 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10231 | * IPA module before configuring them to FW. Sequence required as crash |
| 10232 | * observed otherwise. |
| 10233 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10234 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10235 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10236 | hdd_err("Failed to setup pipes"); |
| 10237 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10238 | } |
| 10239 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10240 | /* |
| 10241 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10242 | * else |
| 10243 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10244 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10245 | |
| 10246 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10247 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10248 | goto out; |
| 10249 | } |
| 10250 | |
| 10251 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10252 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10253 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10254 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10255 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10256 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10257 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10258 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10259 | goto cds_disable; |
| 10260 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10261 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10262 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10263 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10264 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10265 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10266 | if (hdd_ctx->ol_enable) |
| 10267 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10268 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10269 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10270 | 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] | 10271 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10272 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10273 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10274 | goto cds_disable; |
| 10275 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10276 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10277 | wlan_hdd_send_mode_change_event); |
| 10278 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10279 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10280 | goto cds_disable; |
| 10281 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10282 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10283 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10284 | hdd_debug("enhance green ap is not enabled"); |
| 10285 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10286 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10287 | hdd_debug("Failed to set wow pulse"); |
| 10288 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10289 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10290 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10291 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10292 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10293 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10294 | |
| 10295 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10296 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10297 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10298 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10299 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10300 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10301 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10302 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10303 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10304 | out: |
| 10305 | return -EINVAL; |
| 10306 | } |
| 10307 | |
| 10308 | /** |
| 10309 | * hdd_deconfigure_cds() -De-Configure cds |
| 10310 | * @hdd_ctx: HDD context |
| 10311 | * |
| 10312 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10313 | * |
| 10314 | * Return: 0 on success and errno on failure. |
| 10315 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10316 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10317 | { |
| 10318 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10319 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10320 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10321 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10322 | |
| 10323 | /* De-init features */ |
| 10324 | hdd_features_deinit(hdd_ctx); |
| 10325 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10326 | /* De-register the SME callbacks */ |
| 10327 | hdd_deregister_cb(hdd_ctx); |
| 10328 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10329 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10330 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10331 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10332 | } |
| 10333 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10334 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10335 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10336 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10337 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10338 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10339 | } |
| 10340 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10341 | 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] | 10342 | hdd_err("Failed to disconnect pipes"); |
| 10343 | ret = -EINVAL; |
| 10344 | } |
| 10345 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10346 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10347 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10348 | } |
| 10349 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10350 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10351 | static void hdd_deregister_policy_manager_callback( |
| 10352 | struct wlan_objmgr_psoc *psoc) |
| 10353 | { |
| 10354 | if (QDF_STATUS_SUCCESS != |
| 10355 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10356 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10357 | } |
| 10358 | } |
| 10359 | #else |
| 10360 | static void hdd_deregister_policy_manager_callback( |
| 10361 | struct wlan_objmgr_psoc *psoc) |
| 10362 | { |
| 10363 | } |
| 10364 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10365 | |
| 10366 | /** |
| 10367 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10368 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10369 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10370 | * |
| 10371 | * This function maintains the driver state machine it will be invoked from |
| 10372 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10373 | * shall perform the stopping/closing of the modules. |
| 10374 | * |
| 10375 | * Return: 0 for success; non-zero for failure |
| 10376 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10377 | 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] | 10378 | { |
| 10379 | void *hif_ctx; |
| 10380 | qdf_device_t qdf_ctx; |
| 10381 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10382 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10383 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10384 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10385 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10386 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10387 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10388 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10389 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10390 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10391 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10392 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10393 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10394 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10395 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10396 | if (!qdf_ctx) { |
| 10397 | hdd_err("QDF device context NULL"); |
| 10398 | return -EINVAL; |
| 10399 | } |
| 10400 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10401 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10402 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10403 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10404 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10405 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10406 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10407 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10408 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10409 | |
| 10410 | cds_print_external_threads(); |
| 10411 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10412 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10413 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10414 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10415 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10416 | hdd_prevent_suspend_timeout( |
| 10417 | hdd_ctx->config->iface_change_wait_time, |
| 10418 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10419 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10420 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10421 | return 0; |
| 10422 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10423 | } |
| 10424 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10425 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10426 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10427 | /* free user wowl patterns */ |
| 10428 | hdd_free_user_wowl_ptrns(); |
| 10429 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10430 | switch (hdd_ctx->driver_status) { |
| 10431 | case DRIVER_MODULES_UNINITIALIZED: |
| 10432 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10433 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10434 | case DRIVER_MODULES_CLOSED: |
| 10435 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10436 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10437 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10438 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10439 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10440 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10441 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10442 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10443 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10444 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10445 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10446 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10447 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10448 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10449 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10450 | |
| 10451 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10452 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10453 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10454 | break; |
| 10455 | default: |
| 10456 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10457 | hdd_ctx->driver_status); |
| 10458 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10459 | ret = -EINVAL; |
| 10460 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10461 | } |
| 10462 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10463 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10464 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10465 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10466 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10467 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10468 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10469 | qdf_status); |
| 10470 | ret = -EINVAL; |
| 10471 | QDF_ASSERT(0); |
| 10472 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10473 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10474 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10475 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10476 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10477 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10478 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10479 | ret = -EINVAL; |
| 10480 | QDF_ASSERT(0); |
| 10481 | } |
| 10482 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10483 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10484 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10485 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10486 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10487 | QDF_ASSERT(0); |
| 10488 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10489 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10490 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10491 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10492 | if (ret) { |
| 10493 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10494 | QDF_ASSERT(0); |
| 10495 | } |
| 10496 | |
| 10497 | /* |
| 10498 | * Reset total mac phy during module stop such that during |
| 10499 | * next module start same psoc is used to populate new service |
| 10500 | * ready data |
| 10501 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10502 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10503 | if (tgt_hdl) |
| 10504 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10505 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10506 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10507 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10508 | if (!hif_ctx) { |
| 10509 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10510 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10511 | } |
| 10512 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10513 | if (hdd_ctx->target_hw_name) { |
| 10514 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10515 | hdd_ctx->target_hw_name = NULL; |
| 10516 | } |
| 10517 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10518 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10519 | |
| 10520 | ol_cds_free(); |
| 10521 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10522 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10523 | ret = pld_power_off(qdf_ctx->dev); |
| 10524 | if (ret) |
| 10525 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10526 | ret); |
| 10527 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10528 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10529 | /* many adapter resources are not freed by design in SSR case */ |
| 10530 | if (!is_recovery_stop) |
| 10531 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10532 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10533 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10534 | /* Once the firmware sequence is completed reset this flag */ |
| 10535 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10536 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10537 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10538 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10539 | done: |
| 10540 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10541 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10542 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10543 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10544 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10545 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10546 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10547 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10548 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10549 | } |
| 10550 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10551 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10552 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10553 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10554 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10555 | * @buf: buffer pointer |
| 10556 | * @size: size of buffer to be filled |
| 10557 | * |
| 10558 | * This function is used to dump state information of hdd layer |
| 10559 | * |
| 10560 | * Return: None |
| 10561 | */ |
| 10562 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10563 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10564 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10565 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10566 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10567 | uint16_t len = 0; |
| 10568 | char *buf = *buf_ptr; |
| 10569 | |
| 10570 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10571 | if (!hdd_ctx) { |
| 10572 | hdd_err("Failed to get hdd context "); |
| 10573 | return; |
| 10574 | } |
| 10575 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10576 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10577 | |
| 10578 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10579 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10580 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10581 | "\n is_scheduler_suspended %d", |
| 10582 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10583 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10584 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10585 | if (adapter->dev) |
| 10586 | len += scnprintf(buf + len, *size - len, |
| 10587 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10588 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10589 | "\n device_mode: %d", adapter->device_mode); |
| 10590 | switch (adapter->device_mode) { |
| 10591 | case QDF_STA_MODE: |
| 10592 | case QDF_P2P_CLIENT_MODE: |
| 10593 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10594 | len += scnprintf(buf + len, *size - len, |
| 10595 | "\n connState: %d", |
| 10596 | hdd_sta_ctx->conn_info.connState); |
| 10597 | break; |
| 10598 | |
| 10599 | default: |
| 10600 | break; |
| 10601 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10602 | } |
| 10603 | |
| 10604 | *size -= len; |
| 10605 | *buf_ptr += len; |
| 10606 | } |
| 10607 | |
| 10608 | /** |
| 10609 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10610 | * to print hdd state information |
| 10611 | * |
| 10612 | * Return: None |
| 10613 | */ |
| 10614 | static void hdd_register_debug_callback(void) |
| 10615 | { |
| 10616 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10617 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10618 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 10619 | static void hdd_register_debug_callback(void) |
| 10620 | { |
| 10621 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10622 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10623 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10624 | /* |
| 10625 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10626 | * |
| 10627 | * This function is used to create bug report lock |
| 10628 | * |
| 10629 | * Return: None |
| 10630 | */ |
| 10631 | static void wlan_init_bug_report_lock(void) |
| 10632 | { |
| 10633 | p_cds_contextType p_cds_context; |
| 10634 | |
| 10635 | p_cds_context = cds_get_global_context(); |
| 10636 | if (!p_cds_context) { |
| 10637 | hdd_err("cds context is NULL"); |
| 10638 | return; |
| 10639 | } |
| 10640 | |
| 10641 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10642 | } |
| 10643 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10644 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10645 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10646 | { |
| 10647 | |
| 10648 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10649 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10650 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10651 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10652 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10653 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10654 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10655 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10656 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10657 | if (!config->enable_dp_trace) { |
| 10658 | hdd_err("dp trace is disabled from ini"); |
| 10659 | return; |
| 10660 | } |
| 10661 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10662 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10663 | &num_entries, sizeof(config_params)); |
| 10664 | |
| 10665 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10666 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10667 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10668 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10669 | else if (bw_compute_interval > 1000) { |
| 10670 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10671 | thresh_time_limit = 1; |
| 10672 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10673 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10674 | |
| 10675 | switch (num_entries) { |
| 10676 | case 4: |
| 10677 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10678 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10679 | case 3: |
| 10680 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10681 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10682 | case 2: |
| 10683 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10684 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10685 | case 1: |
| 10686 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10687 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10688 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10689 | 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] | 10690 | live_mode, thresh, thresh_time_limit, |
| 10691 | verbosity, proto_bitmap); |
| 10692 | }; |
| 10693 | |
| 10694 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10695 | verbosity, proto_bitmap); |
| 10696 | |
| 10697 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10698 | #endif |
| 10699 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10700 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10701 | * hdd_wlan_startup() - HDD init function |
| 10702 | * @dev: Pointer to the underlying device |
| 10703 | * |
| 10704 | * This is the driver startup code executed once a WLAN device has been detected |
| 10705 | * |
| 10706 | * Return: 0 for success, < 0 for failure |
| 10707 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10708 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10709 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10710 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10711 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10712 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10713 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10714 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10715 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10716 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10717 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10718 | |
| 10719 | if (IS_ERR(hdd_ctx)) |
| 10720 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10721 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10722 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10723 | DEFAULT_PSOC_ID); |
| 10724 | if (ret) { |
| 10725 | hdd_err("Psoc creation fails!"); |
| 10726 | QDF_BUG(0); |
| 10727 | goto err_hdd_free_context; |
| 10728 | } |
| 10729 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10730 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10731 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10732 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10733 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10734 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10735 | osif_request_manager_init(); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10736 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10737 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10738 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10739 | hdd_driver_memdump_init(); |
| 10740 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10741 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10742 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10743 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10744 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10745 | } |
| 10746 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10747 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10748 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10749 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10750 | |
| 10751 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10752 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10753 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10754 | } |
| 10755 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10756 | ret = hdd_wiphy_init(hdd_ctx); |
| 10757 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10758 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10759 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10760 | } |
| 10761 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10762 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10763 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10764 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10765 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10766 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10767 | if (ret) { |
| 10768 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10769 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10770 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10771 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10772 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 10773 | if (ret) { |
| 10774 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 10775 | goto err_unregister_netdev; |
| 10776 | } |
| 10777 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10778 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10779 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10780 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10781 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10782 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10783 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10784 | } |
| 10785 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10786 | hdd_release_rtnl_lock(); |
| 10787 | rtnl_held = false; |
| 10788 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10789 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10790 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10791 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10792 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10793 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10794 | hdd_skip_acs_scan_timer_handler, |
| 10795 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10796 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10797 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10798 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10799 | #endif |
| 10800 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10801 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10802 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10803 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10804 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10805 | if (hdd_ctx->rps) |
| 10806 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10807 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10808 | ret = hdd_register_notifiers(hdd_ctx); |
| 10809 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10810 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10811 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10812 | status = wlansap_global_init(); |
| 10813 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10814 | hdd_unregister_notifiers(hdd_ctx); |
| 10815 | goto err_close_adapters; |
| 10816 | } |
| 10817 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10818 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10819 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10820 | else |
| 10821 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10822 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10823 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10824 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10825 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10826 | hdd_prevent_suspend_timeout( |
| 10827 | hdd_ctx->config->iface_change_wait_time, |
| 10828 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10829 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10830 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10831 | goto success; |
| 10832 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10833 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10834 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10835 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10836 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10837 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10838 | if (rtnl_held) |
| 10839 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10840 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10841 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10842 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10843 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10844 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10845 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10846 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10847 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10848 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10849 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10850 | err_memdump_deinit: |
| 10851 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10852 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10853 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10854 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10855 | hdd_exit_netlink_services(hdd_ctx); |
| 10856 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10857 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10858 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10859 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10860 | if (cds_is_fw_down()) |
| 10861 | hdd_err("Not setting the complete event as fw is down"); |
| 10862 | else |
| 10863 | hdd_start_complete(ret); |
| 10864 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10865 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10866 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10867 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10868 | |
| 10869 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10870 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10871 | return 0; |
| 10872 | } |
| 10873 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10874 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10875 | * hdd_wlan_update_target_info() - update target type info |
| 10876 | * @hdd_ctx: HDD context |
| 10877 | * @context: hif context |
| 10878 | * |
| 10879 | * Update target info received from firmware in hdd context |
| 10880 | * Return:None |
| 10881 | */ |
| 10882 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10883 | 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] | 10884 | { |
| 10885 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10886 | |
| 10887 | if (!tgt_info) { |
| 10888 | hdd_err("Target info is Null"); |
| 10889 | return; |
| 10890 | } |
| 10891 | |
| 10892 | hdd_ctx->target_type = tgt_info->target_type; |
| 10893 | } |
| 10894 | |
| 10895 | /** |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10896 | * hdd_get_nud_stats_cb() - callback api to update the stats |
| 10897 | * received from the firmware |
| 10898 | * @data: pointer to adapter. |
| 10899 | * @rsp: pointer to data received from FW. |
| 10900 | * |
| 10901 | * This is called when wlan driver received response event for |
| 10902 | * get arp stats to firmware. |
| 10903 | * |
| 10904 | * Return: None |
| 10905 | */ |
| 10906 | static void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp) |
| 10907 | { |
| 10908 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
| 10909 | struct hdd_nud_stats_context *context; |
| 10910 | int status; |
| 10911 | struct hdd_adapter *adapter = NULL; |
| 10912 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10913 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10914 | |
| 10915 | if (!rsp) { |
| 10916 | hdd_err("data is null"); |
| 10917 | return; |
| 10918 | } |
| 10919 | |
| 10920 | status = wlan_hdd_validate_context(hdd_ctx); |
| 10921 | if (0 != status) |
| 10922 | return; |
| 10923 | |
| 10924 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 10925 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 10926 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 10927 | return; |
| 10928 | } |
| 10929 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 10930 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 10931 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 10932 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 10933 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 10934 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 10935 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 10936 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 10937 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 10938 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 10939 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10940 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10941 | 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] | 10942 | adapter->dad |= rsp->dad_detected; |
| 10943 | adapter->con_status = rsp->connect_status; |
| 10944 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 10945 | /* Flag true indicates connectivity check stats present. */ |
| 10946 | if (rsp->connect_stats_present) { |
| 10947 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 10948 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 10949 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 10950 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 10951 | rsp->icmpv4_rsp_recvd; |
| 10952 | } |
| 10953 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10954 | spin_lock(&hdd_context_lock); |
| 10955 | context = &hdd_ctx->nud_stats_context; |
| 10956 | complete(&context->response_event); |
| 10957 | spin_unlock(&hdd_context_lock); |
| 10958 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10959 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10960 | } |
| 10961 | |
| 10962 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10963 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10964 | * @hdd_ctx: HDD context |
| 10965 | * |
| 10966 | * Register the HDD callbacks to CDS/SME. |
| 10967 | * |
| 10968 | * Return: 0 for success or Error code for failure |
| 10969 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10970 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10971 | { |
| 10972 | QDF_STATUS status; |
| 10973 | int ret = 0; |
| 10974 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10975 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10976 | |
| 10977 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 10978 | |
| 10979 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 10980 | hdd_send_oem_data_rsp_msg); |
| 10981 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 10982 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 10983 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10984 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 10985 | sme_nan_register_callback(hdd_ctx->hHal, |
| 10986 | wlan_hdd_cfg80211_nan_callback); |
| 10987 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 10988 | wlan_hdd_cfg80211_stats_ext_callback); |
| 10989 | |
| 10990 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 10991 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 10992 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 10993 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10994 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10995 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 10996 | hdd_rssi_threshold_breached); |
| 10997 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10998 | sme_set_nud_debug_stats_cb(hdd_ctx->hHal, hdd_get_nud_stats_cb); |
| 10999 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11000 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 11001 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11002 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 11003 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 11004 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11005 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 11006 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11007 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11008 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 11009 | hdd_lost_link_info_cb); |
| 11010 | /* print error and not block the startup process */ |
| 11011 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11012 | hdd_err("set lost link info callback failed"); |
| 11013 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11014 | ret = hdd_register_data_stall_detect_cb(); |
| 11015 | if (ret) { |
| 11016 | hdd_err("Register data stall detect detect callback failed."); |
| 11017 | return ret; |
| 11018 | } |
| 11019 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11020 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11021 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11022 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11023 | hdd_set_connection_in_progress, |
| 11024 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11025 | |
| 11026 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 11027 | hdd_update_cca_info_cb); |
| 11028 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11029 | hdd_err("set congestion callback failed"); |
| 11030 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11031 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 11032 | hdd_bt_activity_cb); |
| 11033 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11034 | hdd_err("set bt activity info callback failed"); |
| 11035 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11036 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 11037 | hdd_tx_queue_cb); |
| 11038 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11039 | hdd_err("Register tx queue callback failed"); |
| 11040 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11041 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11042 | |
| 11043 | return ret; |
| 11044 | } |
| 11045 | |
| 11046 | /** |
| 11047 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11048 | * @hdd_ctx: HDD context |
| 11049 | * |
| 11050 | * De-Register the HDD callbacks to CDS/SME. |
| 11051 | * |
| 11052 | * Return: void |
| 11053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11054 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11055 | { |
| 11056 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11057 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11058 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11059 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11060 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11061 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11062 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 11063 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11064 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11065 | status); |
| 11066 | |
| 11067 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11068 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 11069 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11070 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 11071 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11072 | |
| 11073 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 11074 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 11075 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11076 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11077 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11078 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11079 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11080 | if (ret) |
| 11081 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11082 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11083 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 11084 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 11085 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11086 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11087 | } |
| 11088 | |
| 11089 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11090 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11091 | * @adapter: Pointer to the HDD |
| 11092 | * @enable: bool value |
| 11093 | * |
| 11094 | * This to take counter measure to handle deauth req from HDD |
| 11095 | * |
| 11096 | * Return: None |
| 11097 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11098 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11099 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11100 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11101 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11102 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11103 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11105 | /* Ignore request to deauth bcmc station */ |
| 11106 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11107 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11108 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11109 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11110 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11111 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11112 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11113 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11114 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11115 | } |
| 11116 | |
| 11117 | /** |
| 11118 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11119 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11120 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11121 | * |
| 11122 | * This to take counter measure to handle deauth req from HDD |
| 11123 | * |
| 11124 | * Return: None |
| 11125 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11126 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11127 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11128 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11129 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11130 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11131 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11132 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11133 | return; |
| 11134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11135 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11136 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11137 | } |
| 11138 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11139 | /** |
| 11140 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11141 | * @hdd_ctx: HDD Context |
| 11142 | * |
| 11143 | * API to find if there is any STA or P2P-Client is connected |
| 11144 | * |
| 11145 | * Return: true if connected; false otherwise |
| 11146 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11147 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11148 | { |
| 11149 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 11150 | } |
| 11151 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11152 | /** |
| 11153 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 11154 | * @adapter: HDD adapter pointer |
| 11155 | * |
| 11156 | * This function loop through each adapter and disable roaming on each STA |
| 11157 | * device mode except the input adapter. |
| 11158 | * |
| 11159 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 11160 | * disable. |
| 11161 | * |
| 11162 | * Return: None |
| 11163 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11164 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11165 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11166 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11167 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11168 | |
| 11169 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11170 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11171 | QDF_STA_MODE == adapter->device_mode && |
| 11172 | policy_mgr_is_sta_active_connection_exists( |
| 11173 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11174 | hdd_debug("Connect received on STA session Id(%d)", |
| 11175 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11176 | /* |
| 11177 | * Loop through adapter and disable roaming for each STA device |
| 11178 | * mode except the input adapter. |
| 11179 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11180 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11181 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11182 | adapter->session_id != adapterIdx->session_id) { |
| 11183 | hdd_debug("Disable Roaming on session Id(%d)", |
| 11184 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11185 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 11186 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11187 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11188 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11189 | } |
| 11190 | } |
| 11191 | } |
| 11192 | |
| 11193 | /** |
| 11194 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 11195 | * @adapter: HDD adapter pointer |
| 11196 | * |
| 11197 | * This function loop through each adapter and enable roaming on each STA |
| 11198 | * device mode except the input adapter. |
| 11199 | * Note: On the input adapter no need to enable roaming because link got |
| 11200 | * disconnected on this. |
| 11201 | * |
| 11202 | * Return: None |
| 11203 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11204 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11206 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11207 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11208 | |
| 11209 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11210 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11211 | QDF_STA_MODE == adapter->device_mode && |
| 11212 | policy_mgr_is_sta_active_connection_exists( |
| 11213 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11214 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 11215 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11216 | /* |
| 11217 | * Loop through adapter and enable roaming for each STA device |
| 11218 | * mode except the input adapter. |
| 11219 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11220 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11221 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11222 | adapter->session_id != adapterIdx->session_id) { |
| 11223 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 11224 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11225 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 11226 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11227 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11228 | REASON_CONNECT); |
| 11229 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11230 | } |
| 11231 | } |
| 11232 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11233 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11234 | /** |
| 11235 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11236 | * @skb: sk buffer pointer |
| 11237 | * |
| 11238 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11239 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11240 | * |
| 11241 | * Return: None |
| 11242 | */ |
| 11243 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11244 | { |
| 11245 | #ifdef CNSS_GENL |
| 11246 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11247 | #else |
| 11248 | nl_srv_bcast(skb); |
| 11249 | #endif |
| 11250 | } |
| 11251 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11252 | 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] | 11253 | { |
| 11254 | struct sk_buff *skb; |
| 11255 | struct nlmsghdr *nlh; |
| 11256 | tAniMsgHdr *ani_hdr; |
| 11257 | void *nl_data = NULL; |
| 11258 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11259 | struct radio_index_tlv *radio_info; |
| 11260 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11261 | |
| 11262 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11263 | flags = GFP_ATOMIC; |
| 11264 | |
| 11265 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11266 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11267 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11268 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11269 | |
| 11270 | nlh = (struct nlmsghdr *)skb->data; |
| 11271 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11272 | nlh->nlmsg_flags = 0; |
| 11273 | nlh->nlmsg_seq = 0; |
| 11274 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11275 | |
| 11276 | ani_hdr = NLMSG_DATA(nlh); |
| 11277 | ani_hdr->type = type; |
| 11278 | |
| 11279 | switch (type) { |
| 11280 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11281 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11282 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11283 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11284 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11285 | ani_hdr->length = 0; |
| 11286 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11287 | break; |
| 11288 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11289 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11290 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11291 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11292 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11293 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11294 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11295 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11296 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11297 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11298 | ani_hdr->length = len; |
| 11299 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11300 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11301 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11302 | break; |
| 11303 | |
| 11304 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11305 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11306 | type); |
| 11307 | kfree_skb(skb); |
| 11308 | return; |
| 11309 | } |
| 11310 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11311 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11312 | * Add radio index at the end of the svc event in TLV format |
| 11313 | * to maintain the backward compatibility with userspace |
| 11314 | * applications. |
| 11315 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11316 | |
| 11317 | tlv_len = 0; |
| 11318 | |
| 11319 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11320 | < WLAN_NL_MAX_PAYLOAD) { |
| 11321 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11322 | sizeof(*ani_hdr) + len); |
| 11323 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11324 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11325 | radio_info->radio = radio; |
| 11326 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11327 | hdd_debug("Added radio index tlv - radio index %d", |
| 11328 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11329 | } |
| 11330 | |
| 11331 | nlh->nlmsg_len += tlv_len; |
| 11332 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11333 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11334 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11335 | } |
| 11336 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11337 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11338 | void wlan_hdd_auto_shutdown_cb(void) |
| 11339 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11340 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11341 | |
| 11342 | if (!hdd_ctx) |
| 11343 | return; |
| 11344 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11345 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11346 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11347 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11348 | } |
| 11349 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11350 | 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] | 11351 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11352 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11353 | bool ap_connected = false, sta_connected = false; |
| 11354 | tHalHandle hal_handle; |
| 11355 | |
| 11356 | hal_handle = hdd_ctx->hHal; |
| 11357 | if (hal_handle == NULL) |
| 11358 | return; |
| 11359 | |
| 11360 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11361 | return; |
| 11362 | |
| 11363 | if (enable == false) { |
| 11364 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11365 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11366 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11367 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11368 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11369 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11370 | return; |
| 11371 | } |
| 11372 | |
| 11373 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11374 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11375 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11376 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11377 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11378 | conn_info.connState == |
| 11379 | eConnectionState_Associated) { |
| 11380 | sta_connected = true; |
| 11381 | break; |
| 11382 | } |
| 11383 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11384 | |
| 11385 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11386 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11387 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11388 | ap_connected = true; |
| 11389 | break; |
| 11390 | } |
| 11391 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11392 | } |
| 11393 | } |
| 11394 | |
| 11395 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11396 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11397 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11398 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11399 | |
| 11400 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11401 | hdd_ctx->config->WlanAutoShutdown) |
| 11402 | != QDF_STATUS_SUCCESS) |
| 11403 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11404 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11405 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11406 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11407 | } |
| 11408 | #endif |
| 11409 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11410 | struct hdd_adapter * |
| 11411 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11412 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11413 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11414 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11415 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11416 | |
| 11417 | con_sap_adapter = NULL; |
| 11418 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11419 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11420 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11421 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11422 | adapter != this_sap_adapter) { |
| 11423 | if (check_start_bss) { |
| 11424 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11425 | &adapter->event_flags)) { |
| 11426 | con_sap_adapter = adapter; |
| 11427 | break; |
| 11428 | } |
| 11429 | } else { |
| 11430 | con_sap_adapter = adapter; |
| 11431 | break; |
| 11432 | } |
| 11433 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11434 | } |
| 11435 | |
| 11436 | return con_sap_adapter; |
| 11437 | } |
| 11438 | |
| 11439 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11440 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11441 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11442 | return adapter->device_mode == QDF_STA_MODE || |
| 11443 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11444 | } |
| 11445 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11446 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11447 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11448 | return adapter->device_mode == QDF_SAP_MODE || |
| 11449 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11450 | } |
| 11451 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11452 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11453 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11454 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11455 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11456 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11457 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11458 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11459 | conn_info.connState == eConnectionState_Associated) { |
| 11460 | return true; |
| 11461 | } |
| 11462 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11463 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11464 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11465 | return true; |
| 11466 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11467 | } |
| 11468 | |
| 11469 | return false; |
| 11470 | } |
| 11471 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11472 | 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] | 11473 | { |
| 11474 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11475 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11476 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11477 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11478 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11479 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11480 | return is_running; |
| 11481 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11482 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11483 | 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] | 11484 | { |
| 11485 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11486 | hdd_ctx->bus_bw_timer_running = true; |
| 11487 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11488 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11489 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11490 | } |
| 11491 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11492 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11493 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11494 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11495 | |
| 11496 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11497 | hdd_debug("Bandwidth compute timer already started"); |
| 11498 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11499 | } |
| 11500 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11501 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11502 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11503 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11504 | } |
| 11505 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11506 | 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] | 11507 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11508 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11509 | |
| 11510 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11511 | hdd_debug("Bandwidth compute timer already started"); |
| 11512 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11513 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11514 | |
| 11515 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11516 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11517 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11518 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11519 | } |
| 11520 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11521 | 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] | 11522 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11523 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11524 | |
| 11525 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11526 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11527 | hdd_ctx->bus_bw_timer_running = false; |
| 11528 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11529 | |
| 11530 | hdd_reset_tcp_delack(hdd_ctx); |
| 11531 | } |
| 11532 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11533 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11534 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11535 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11536 | |
| 11537 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11538 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11539 | return; |
| 11540 | } |
| 11541 | |
| 11542 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11543 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11544 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11545 | } |
| 11546 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11547 | 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] | 11548 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11549 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11550 | |
| 11551 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11552 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11553 | return; |
| 11554 | } |
| 11555 | |
| 11556 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11557 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11558 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11559 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11560 | } |
| 11561 | #endif |
| 11562 | |
| 11563 | /** |
| 11564 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11565 | * and sta's operating channel. |
| 11566 | * @sta_adapter: Describe the first argument to foobar. |
| 11567 | * @ap_adapter: Describe the second argument to foobar. |
| 11568 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11569 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11570 | * set this flag to true else false. |
| 11571 | * |
| 11572 | * This function checks the sap's operating channel and sta's operating channel. |
| 11573 | * if both are same then it will return false else it will restart the sap in |
| 11574 | * sta's channel and return true. |
| 11575 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11576 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11577 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11578 | QDF_STATUS |
| 11579 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11580 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11581 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11582 | tScanResultHandle *scan_cache, |
| 11583 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11584 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11585 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11586 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11587 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11588 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11589 | *concurrent_chnl_same = true; |
| 11590 | |
| 11591 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11592 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11593 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11594 | scan_cache, |
| 11595 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11596 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11597 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11598 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11599 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11600 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11601 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11602 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11603 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11604 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11605 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11606 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11607 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11608 | } |
| 11609 | } |
| 11610 | } else { |
| 11611 | /* |
| 11612 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11613 | * failed so we have to stop the SAP to avoid any channel |
| 11614 | * discrepancy between SAP's channel and STA's channel. |
| 11615 | * Return the status as failure so caller function could know |
| 11616 | * that scan look up is failed. |
| 11617 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11618 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11619 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11620 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11621 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11622 | } |
| 11623 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11624 | /** |
| 11625 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11626 | * @ap_adapter: SAP adapter |
| 11627 | * |
| 11628 | * This function will process the stopping of sap adapter. |
| 11629 | * |
| 11630 | * Return: None |
| 11631 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11632 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11633 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11634 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11635 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11636 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11637 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11638 | |
| 11639 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11640 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11641 | return; |
| 11642 | } |
| 11643 | |
| 11644 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11645 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11646 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11647 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11649 | mutex_lock(&hdd_ctx->sap_lock); |
| 11650 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11651 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11652 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11653 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11654 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11655 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11656 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11657 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11658 | qdf_stop_bss_event, |
| 11659 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11660 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11661 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11662 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11663 | return; |
| 11664 | } |
| 11665 | } |
| 11666 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11667 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11668 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11669 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11670 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11671 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11672 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11673 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11674 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11675 | } |
| 11676 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11677 | } |
| 11678 | |
| 11679 | /** |
| 11680 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11681 | * @ap_adapter: SAP adapter |
| 11682 | * |
| 11683 | * This function will process the starting of sap adapter. |
| 11684 | * |
| 11685 | * Return: None |
| 11686 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11687 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11688 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11689 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11690 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11691 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11692 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 11693 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11694 | |
| 11695 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11696 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11697 | return; |
| 11698 | } |
| 11699 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11700 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11701 | hdd_err("SoftAp role has not been enabled"); |
| 11702 | return; |
| 11703 | } |
| 11704 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11705 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11706 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11707 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11708 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11709 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11710 | mutex_lock(&hdd_ctx->sap_lock); |
| 11711 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11712 | goto end; |
| 11713 | |
| 11714 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11715 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11716 | goto end; |
| 11717 | } |
| 11718 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11719 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11720 | 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] | 11721 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11722 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11723 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11724 | goto end; |
| 11725 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11726 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11727 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11728 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11729 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11730 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11731 | goto end; |
| 11732 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11733 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11734 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11735 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11736 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11737 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11738 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11739 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11740 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11741 | true); |
| 11742 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11743 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11744 | |
| 11745 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11746 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11747 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11748 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11749 | /* SAP context and beacon cleanup will happen during driver unload |
| 11750 | * in hdd_stop_adapter |
| 11751 | */ |
| 11752 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11753 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11754 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11755 | |
| 11756 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11757 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11758 | * mac scan config |
| 11759 | * @status: Status of set antenna mode |
| 11760 | * |
| 11761 | * Callback on setting the dual mac configuration |
| 11762 | * |
| 11763 | * Return: None |
| 11764 | */ |
| 11765 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11766 | enum set_antenna_mode_status status) |
| 11767 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11768 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11769 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11770 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11771 | |
| 11772 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11773 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11774 | return; |
| 11775 | |
| 11776 | /* Signal the completion of set dual mac config */ |
| 11777 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11778 | } |
| 11779 | |
| 11780 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11781 | * hdd_get_fw_version() - Get FW version |
| 11782 | * @hdd_ctx: pointer to HDD context. |
| 11783 | * @major_spid: FW version - major spid. |
| 11784 | * @minor_spid: FW version - minor spid |
| 11785 | * @ssid: FW version - ssid |
| 11786 | * @crmid: FW version - crmid |
| 11787 | * |
| 11788 | * This function is called to get the firmware build version stored |
| 11789 | * as part of the HDD context |
| 11790 | * |
| 11791 | * Return: None |
| 11792 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11793 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11794 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11795 | uint32_t *siid, uint32_t *crmid) |
| 11796 | { |
| 11797 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11798 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11799 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11800 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11801 | } |
| 11802 | |
| 11803 | #ifdef QCA_CONFIG_SMP |
| 11804 | /** |
| 11805 | * wlan_hdd_get_cpu() - get cpu_index |
| 11806 | * |
| 11807 | * Return: cpu_index |
| 11808 | */ |
| 11809 | int wlan_hdd_get_cpu(void) |
| 11810 | { |
| 11811 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11813 | put_cpu(); |
| 11814 | return cpu_index; |
| 11815 | } |
| 11816 | #endif |
| 11817 | |
| 11818 | /** |
| 11819 | * hdd_get_fwpath() - get framework path |
| 11820 | * |
| 11821 | * This function is used to get the string written by |
| 11822 | * userspace to start the wlan driver |
| 11823 | * |
| 11824 | * Return: string |
| 11825 | */ |
| 11826 | const char *hdd_get_fwpath(void) |
| 11827 | { |
| 11828 | return fwpath.string; |
| 11829 | } |
| 11830 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11831 | static int hdd_qdf_print_init(void) |
| 11832 | { |
| 11833 | int qdf_print_idx; |
| 11834 | QDF_STATUS status; |
| 11835 | |
| 11836 | status = qdf_print_setup(); |
| 11837 | if (status != QDF_STATUS_SUCCESS) { |
| 11838 | pr_err("qdf_print_setup failed\n"); |
| 11839 | return -EINVAL; |
| 11840 | } |
| 11841 | |
| 11842 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11843 | |
| 11844 | if (qdf_print_idx < 0) { |
| 11845 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11846 | qdf_print_idx); |
| 11847 | return -EINVAL; |
| 11848 | } |
| 11849 | |
| 11850 | qdf_set_pidx(qdf_print_idx); |
| 11851 | |
| 11852 | return 0; |
| 11853 | } |
| 11854 | |
| 11855 | static void hdd_qdf_print_deinit(void) |
| 11856 | { |
| 11857 | int qdf_print_idx; |
| 11858 | |
| 11859 | qdf_print_idx = qdf_get_pidx(); |
| 11860 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11861 | } |
| 11862 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11863 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11864 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11865 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11866 | * This function initilizes CDS global context with the help of cds_init. This |
| 11867 | * has to be the first function called after probe to get a valid global |
| 11868 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11869 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11870 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11871 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11872 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11873 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11874 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11875 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11876 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11877 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11878 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11879 | hdd_err("Failed to allocate CDS context"); |
| 11880 | ret = -ENOMEM; |
| 11881 | goto err_out; |
| 11882 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11883 | |
| 11884 | wlan_init_bug_report_lock(); |
| 11885 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11886 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11887 | wlan_logging_sock_init_svc(); |
| 11888 | #endif |
| 11889 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11890 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11891 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11892 | QDF_TIMER_TYPE_SW); |
| 11893 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11894 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11895 | hdd_qdf_print_init(); |
| 11896 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11897 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11898 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11899 | err_out: |
| 11900 | return ret; |
| 11901 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11902 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11903 | /** |
| 11904 | * hdd_deinit() - Deinitialize Driver |
| 11905 | * |
| 11906 | * This function frees CDS global context with the help of cds_deinit. This |
| 11907 | * has to be the last function call in remove callback to free the global |
| 11908 | * context. |
| 11909 | */ |
| 11910 | void hdd_deinit(void) |
| 11911 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11912 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11913 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11914 | wlan_destroy_bug_report_lock(); |
| 11915 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11916 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11917 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11918 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11919 | wlan_logging_sock_deinit_svc(); |
| 11920 | #endif |
| 11921 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11922 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11923 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 11924 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 11925 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11926 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 11927 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11928 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11929 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 11930 | struct file *file) |
| 11931 | { |
| 11932 | return 0; |
| 11933 | } |
| 11934 | |
| 11935 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 11936 | const char __user *user_buf, |
| 11937 | size_t count, |
| 11938 | loff_t *f_pos) |
| 11939 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11940 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11941 | static const char wlan_off_str[] = "OFF"; |
| 11942 | static const char wlan_on_str[] = "ON"; |
| 11943 | int ret; |
| 11944 | unsigned long rc; |
| 11945 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11946 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11947 | pr_err("Failed to read buffer\n"); |
| 11948 | return -EINVAL; |
| 11949 | } |
| 11950 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11951 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11952 | pr_debug("Wifi turning off from UI\n"); |
| 11953 | goto exit; |
| 11954 | } |
| 11955 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 11956 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 11957 | pr_info("Wifi Turning On from UI\n"); |
| 11958 | } |
| 11959 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 11960 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11961 | pr_err("Invalid value received from framework"); |
| 11962 | goto exit; |
| 11963 | } |
| 11964 | |
| 11965 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 11966 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11967 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 11968 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 11969 | if (!rc) { |
| 11970 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 11971 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 11972 | return ret; |
| 11973 | } |
| 11974 | |
| 11975 | hdd_start_complete(0); |
| 11976 | } |
| 11977 | |
| 11978 | exit: |
| 11979 | return count; |
| 11980 | } |
| 11981 | |
| 11982 | |
| 11983 | const struct file_operations wlan_hdd_state_fops = { |
| 11984 | .owner = THIS_MODULE, |
| 11985 | .open = wlan_hdd_state_ctrl_param_open, |
| 11986 | .write = wlan_hdd_state_ctrl_param_write, |
| 11987 | }; |
| 11988 | |
| 11989 | static int wlan_hdd_state_ctrl_param_create(void) |
| 11990 | { |
| 11991 | unsigned int wlan_hdd_state_major = 0; |
| 11992 | int ret; |
| 11993 | struct device *dev; |
| 11994 | |
| 11995 | device = MKDEV(wlan_hdd_state_major, 0); |
| 11996 | |
| 11997 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 11998 | if (ret) { |
| 11999 | pr_err("Failed to register qcwlanstate"); |
| 12000 | goto dev_alloc_err; |
| 12001 | } |
| 12002 | wlan_hdd_state_major = MAJOR(device); |
| 12003 | |
| 12004 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12005 | if (IS_ERR(class)) { |
| 12006 | pr_err("wlan_hdd_state class_create error"); |
| 12007 | goto class_err; |
| 12008 | } |
| 12009 | |
| 12010 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12011 | if (IS_ERR(dev)) { |
| 12012 | pr_err("wlan_hdd_statedevice_create error"); |
| 12013 | goto err_class_destroy; |
| 12014 | } |
| 12015 | |
| 12016 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12017 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12018 | if (ret) { |
| 12019 | pr_err("Failed to add cdev error"); |
| 12020 | goto cdev_add_err; |
| 12021 | } |
| 12022 | |
| 12023 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12024 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12025 | |
| 12026 | return 0; |
| 12027 | |
| 12028 | cdev_add_err: |
| 12029 | device_destroy(class, device); |
| 12030 | err_class_destroy: |
| 12031 | class_destroy(class); |
| 12032 | class_err: |
| 12033 | unregister_chrdev_region(device, dev_num); |
| 12034 | dev_alloc_err: |
| 12035 | return -ENODEV; |
| 12036 | } |
| 12037 | |
| 12038 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12039 | { |
| 12040 | cdev_del(&wlan_hdd_state_cdev); |
| 12041 | device_destroy(class, device); |
| 12042 | class_destroy(class); |
| 12043 | unregister_chrdev_region(device, dev_num); |
| 12044 | |
| 12045 | pr_info("Device node unregistered"); |
| 12046 | } |
| 12047 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12048 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12049 | * component_init - API to init cld component's |
| 12050 | * |
| 12051 | * Return: None |
| 12052 | */ |
| 12053 | static void component_init(void) |
| 12054 | { |
| 12055 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12056 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12057 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12058 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12059 | } |
| 12060 | |
| 12061 | /** |
| 12062 | * component_deinit - API to deinit cld component's |
| 12063 | * |
| 12064 | * Return: None |
| 12065 | */ |
| 12066 | static void component_deinit(void) |
| 12067 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12068 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12069 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12070 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12071 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12072 | } |
| 12073 | |
| 12074 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12075 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12076 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12077 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12078 | } |
| 12079 | |
| 12080 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12081 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12082 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12083 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12084 | } |
| 12085 | |
| 12086 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12087 | * __hdd_module_init - Module init helper |
| 12088 | * |
| 12089 | * Module init helper function used by both module and static driver. |
| 12090 | * |
| 12091 | * Return: 0 for success, errno on failure |
| 12092 | */ |
| 12093 | static int __hdd_module_init(void) |
| 12094 | { |
| 12095 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12096 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12097 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12098 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12099 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12100 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12101 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12102 | pld_init(); |
| 12103 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12104 | ret = hdd_init(); |
| 12105 | if (ret) { |
| 12106 | pr_err("hdd_init failed %x\n", ret); |
| 12107 | goto err_hdd_init; |
| 12108 | } |
| 12109 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12110 | dispatcher_init(); |
| 12111 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12112 | /* Ensure to call post objmgr init */ |
| 12113 | component_init(); |
| 12114 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12115 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12116 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12117 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12118 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12119 | ret = wlan_hdd_register_driver(); |
| 12120 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12121 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12122 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12123 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12124 | } |
| 12125 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12126 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12127 | if (ret) { |
| 12128 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12129 | goto out; |
| 12130 | } |
| 12131 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12132 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12133 | |
| 12134 | return 0; |
| 12135 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12136 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12137 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12138 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12139 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12140 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12141 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12142 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12143 | return ret; |
| 12144 | } |
| 12145 | |
| 12146 | /** |
| 12147 | * __hdd_module_exit - Module exit helper |
| 12148 | * |
| 12149 | * Module exit helper function used by both module and static driver. |
| 12150 | */ |
| 12151 | static void __hdd_module_exit(void) |
| 12152 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12153 | 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] | 12154 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12155 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12156 | QWLAN_VERSIONSTR); |
| 12157 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12158 | if (!hdd_wait_for_recovery_completion()) |
| 12159 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12160 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12161 | if (hdd_ctx) |
| 12162 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12163 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12164 | wlan_hdd_unregister_driver(); |
| 12165 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12166 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12167 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12168 | /* Ensure to call prior to objmgr deinit */ |
| 12169 | component_deinit(); |
| 12170 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12171 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12172 | |
| 12173 | hdd_sysfs_destroy_version_interface(); |
| 12174 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12175 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12176 | pld_deinit(); |
| 12177 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12178 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12179 | } |
| 12180 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12181 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12182 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12183 | * wlan_boot_cb() - Wlan boot callback |
| 12184 | * @kobj: object whose directory we're creating the link in. |
| 12185 | * @attr: attribute the user is interacting with |
| 12186 | * @buff: the buffer containing the user data |
| 12187 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12188 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12189 | * This callback is invoked when the fs is ready to start the |
| 12190 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12191 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12192 | * 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] | 12193 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12194 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12195 | struct kobj_attribute *attr, |
| 12196 | const char *buf, |
| 12197 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12198 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12199 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12200 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12201 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12202 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12203 | } |
| 12204 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12205 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12206 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12207 | return -EIO; |
| 12208 | } |
| 12209 | |
| 12210 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12211 | |
| 12212 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12213 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12214 | |
| 12215 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12216 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12217 | * |
| 12218 | * Return: None |
| 12219 | * |
| 12220 | */ |
| 12221 | static void hdd_sysfs_cleanup(void) |
| 12222 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12223 | /* remove from group */ |
| 12224 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12225 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12226 | wlan_loader->attr_group); |
| 12227 | |
| 12228 | /* unlink the object from parent */ |
| 12229 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12230 | |
| 12231 | /* free the object */ |
| 12232 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12233 | |
| 12234 | kfree(wlan_loader->attr_group); |
| 12235 | kfree(wlan_loader); |
| 12236 | |
| 12237 | wlan_loader = NULL; |
| 12238 | } |
| 12239 | |
| 12240 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12241 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12242 | * ready |
| 12243 | * |
| 12244 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12245 | * when the filesystem is ready. |
| 12246 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12247 | * QDF API cannot be used here since this function is called even before |
| 12248 | * initializing WLAN driver. |
| 12249 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12250 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12251 | */ |
| 12252 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12253 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12254 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12255 | |
| 12256 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12257 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12258 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12259 | |
| 12260 | wlan_loader->boot_wlan_obj = NULL; |
| 12261 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12262 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12263 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12264 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12265 | |
| 12266 | wlan_loader->loaded_state = 0; |
| 12267 | wlan_loader->attr_group->attrs = attrs; |
| 12268 | |
| 12269 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12270 | kernel_kobj); |
| 12271 | if (!wlan_loader->boot_wlan_obj) { |
| 12272 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12273 | goto error_return; |
| 12274 | } |
| 12275 | |
| 12276 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12277 | wlan_loader->attr_group); |
| 12278 | if (ret) { |
| 12279 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12280 | goto error_return; |
| 12281 | } |
| 12282 | |
| 12283 | return 0; |
| 12284 | |
| 12285 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12286 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12287 | |
| 12288 | return ret; |
| 12289 | } |
| 12290 | |
| 12291 | /** |
| 12292 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12293 | * |
| 12294 | * Return: 0 on success or errno on failure |
| 12295 | */ |
| 12296 | static int wlan_deinit_sysfs(void) |
| 12297 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12298 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12299 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12300 | return -EINVAL; |
| 12301 | } |
| 12302 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12303 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12304 | return 0; |
| 12305 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12306 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12307 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12308 | |
| 12309 | #ifdef MODULE |
| 12310 | /** |
| 12311 | * __hdd_module_init - Module init helper |
| 12312 | * |
| 12313 | * Module init helper function used by both module and static driver. |
| 12314 | * |
| 12315 | * Return: 0 for success, errno on failure |
| 12316 | */ |
| 12317 | static int hdd_module_init(void) |
| 12318 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12319 | if (__hdd_module_init()) { |
| 12320 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12321 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12322 | } |
| 12323 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12324 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12325 | } |
| 12326 | #else |
| 12327 | static int __init hdd_module_init(void) |
| 12328 | { |
| 12329 | int ret = -EINVAL; |
| 12330 | |
| 12331 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12332 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12333 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12334 | |
| 12335 | return ret; |
| 12336 | } |
| 12337 | #endif |
| 12338 | |
| 12339 | |
| 12340 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12341 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12342 | * hdd_module_exit() - Exit function |
| 12343 | * |
| 12344 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12345 | * |
| 12346 | * Return: None |
| 12347 | */ |
| 12348 | static void __exit hdd_module_exit(void) |
| 12349 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12350 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12351 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12352 | #else |
| 12353 | static void __exit hdd_module_exit(void) |
| 12354 | { |
| 12355 | __hdd_module_exit(); |
| 12356 | wlan_deinit_sysfs(); |
| 12357 | } |
| 12358 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12359 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12360 | static int fwpath_changed_handler(const char *kmessage, |
| 12361 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12362 | { |
| 12363 | return param_set_copystring(kmessage, kp); |
| 12364 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12365 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12366 | /** |
| 12367 | * is_con_mode_valid() check con mode is valid or not |
| 12368 | * @mode: global con mode |
| 12369 | * |
| 12370 | * Return: TRUE on success FALSE on failure |
| 12371 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12372 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12373 | { |
| 12374 | switch (mode) { |
| 12375 | case QDF_GLOBAL_MONITOR_MODE: |
| 12376 | case QDF_GLOBAL_FTM_MODE: |
| 12377 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12378 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12379 | return true; |
| 12380 | default: |
| 12381 | return false; |
| 12382 | } |
| 12383 | } |
| 12384 | |
| 12385 | /** |
| 12386 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12387 | * @mode: global con mode |
| 12388 | * |
| 12389 | * Return: adapter mode |
| 12390 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12391 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12392 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12393 | { |
| 12394 | |
| 12395 | switch (mode) { |
| 12396 | case QDF_GLOBAL_MISSION_MODE: |
| 12397 | return QDF_STA_MODE; |
| 12398 | case QDF_GLOBAL_MONITOR_MODE: |
| 12399 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12400 | case QDF_GLOBAL_EPPING_MODE: |
| 12401 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12402 | case QDF_GLOBAL_FTM_MODE: |
| 12403 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12404 | case QDF_GLOBAL_QVIT_MODE: |
| 12405 | return QDF_QVIT_MODE; |
| 12406 | default: |
| 12407 | return QDF_MAX_NO_OF_MODE; |
| 12408 | } |
| 12409 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12410 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12411 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12412 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12413 | { |
| 12414 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12415 | return; |
| 12416 | |
| 12417 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12418 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12419 | hdd_info("Release wakelock for monitor mode!"); |
| 12420 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12421 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 12422 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12423 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12424 | case QDF_GLOBAL_FTM_MODE: |
| 12425 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12426 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12427 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12428 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12429 | break; |
| 12430 | default: |
| 12431 | break; |
| 12432 | } |
| 12433 | } |
| 12434 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12435 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12436 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12437 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12438 | int driver_status; |
| 12439 | |
| 12440 | driver_status = hdd_ctx->driver_status; |
| 12441 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12442 | switch (curr_mode) { |
| 12443 | case QDF_GLOBAL_MISSION_MODE: |
| 12444 | case QDF_GLOBAL_MONITOR_MODE: |
| 12445 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12446 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12447 | hdd_close_all_adapters(hdd_ctx, false); |
| 12448 | break; |
| 12449 | case QDF_GLOBAL_EPPING_MODE: |
| 12450 | epping_disable(); |
| 12451 | epping_close(); |
| 12452 | break; |
| 12453 | default: |
| 12454 | return; |
| 12455 | } |
| 12456 | } |
| 12457 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12458 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12459 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12460 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12461 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12462 | int ret = 0; |
| 12463 | bool rtnl_held; |
| 12464 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12465 | QDF_STATUS status; |
| 12466 | |
| 12467 | if (!qdf_dev) { |
| 12468 | hdd_err("qdf device context is Null return!"); |
| 12469 | return -EINVAL; |
| 12470 | } |
| 12471 | |
| 12472 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12473 | switch (mode) { |
| 12474 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12475 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12476 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12477 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12478 | break; |
| 12479 | case QDF_GLOBAL_FTM_MODE: |
| 12480 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12481 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12482 | NET_NAME_UNKNOWN, rtnl_held); |
| 12483 | if (adapter == NULL) |
| 12484 | ret = -EINVAL; |
| 12485 | break; |
| 12486 | case QDF_GLOBAL_MONITOR_MODE: |
| 12487 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12488 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12489 | NET_NAME_UNKNOWN, rtnl_held); |
| 12490 | if (adapter == NULL) |
| 12491 | ret = -EINVAL; |
| 12492 | break; |
| 12493 | case QDF_GLOBAL_EPPING_MODE: |
| 12494 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12495 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12496 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12497 | ret = -EINVAL; |
| 12498 | break; |
| 12499 | } |
| 12500 | ret = epping_enable(qdf_dev->dev); |
| 12501 | if (ret) { |
| 12502 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12503 | epping_close(); |
| 12504 | } |
| 12505 | break; |
| 12506 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12507 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12508 | ret = -ENOTSUPP; |
| 12509 | break; |
| 12510 | } |
| 12511 | hdd_release_rtnl_lock(); |
| 12512 | rtnl_held = false; |
| 12513 | return ret; |
| 12514 | } |
| 12515 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12516 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12517 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12518 | * @kmessage: con mode name on which driver to be bring up |
| 12519 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12520 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12521 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12522 | * This function is invoked when user updates con mode using sys entry, |
| 12523 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12524 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12525 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12526 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12527 | static int __con_mode_handler(const char *kmessage, |
| 12528 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12529 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12530 | { |
| 12531 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12532 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12533 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12534 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12535 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12536 | hdd_info("con_mode handler: %s", kmessage); |
| 12537 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12538 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12539 | if (ret) |
| 12540 | return ret; |
| 12541 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12542 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12543 | cds_set_load_in_progress(true); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12544 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12545 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12546 | if (ret) { |
| 12547 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12548 | goto reset_flags; |
| 12549 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12550 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12551 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12552 | if (!is_con_mode_valid(new_con_mode)) { |
| 12553 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12554 | ret = -EINVAL; |
| 12555 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12556 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12557 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12558 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12559 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12560 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12561 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12562 | ret = 0; |
| 12563 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12564 | } |
| 12565 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12566 | /* ensure adapters are stopped */ |
| 12567 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12568 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12569 | /* Cleanup present mode before switching to new mode */ |
| 12570 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 12571 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12572 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12573 | if (ret) { |
| 12574 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12575 | goto reset_flags; |
| 12576 | } |
| 12577 | |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12578 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12579 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12580 | |
Frank Liu | 6666f83 | 2018-01-04 10:06:05 +0800 | [diff] [blame] | 12581 | /* |
| 12582 | * Set ACTIVE domain before adapters created, otherwise check domain |
| 12583 | * match will fail when cleanup adapters. |
| 12584 | */ |
| 12585 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12586 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12587 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12588 | if (ret) { |
| 12589 | hdd_err("Failed to register for new mode"); |
| 12590 | goto reset_flags; |
| 12591 | } |
| 12592 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12593 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12594 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12595 | hdd_err("invalid adapter"); |
| 12596 | ret = -EINVAL; |
| 12597 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12598 | } |
| 12599 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12600 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12601 | if (ret) { |
| 12602 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12603 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12604 | } |
| 12605 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12606 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12607 | struct hdd_adapter *adapter = |
| 12608 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 12609 | |
| 12610 | if (!adapter) { |
| 12611 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12612 | goto reset_flags; |
| 12613 | } |
| 12614 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12615 | if (hdd_start_adapter(adapter)) { |
| 12616 | hdd_err("Failed to start %s adapter", kmessage); |
| 12617 | ret = -EINVAL; |
| 12618 | goto reset_flags; |
| 12619 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12620 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12621 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12622 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12623 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12624 | } |
| 12625 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12626 | /* con_mode is a global module parameter */ |
| 12627 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12628 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12629 | ret = 0; |
| 12630 | |
| 12631 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12632 | mutex_unlock(&hdd_init_deinit_lock); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12633 | cds_set_load_in_progress(false); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12634 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12635 | return ret; |
| 12636 | } |
| 12637 | |
| 12638 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12639 | 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] | 12640 | { |
| 12641 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12642 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12643 | |
| 12644 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12645 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12646 | if (ret) |
| 12647 | return ret; |
| 12648 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame^] | 12649 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 12650 | hdd_warn("External threads are still active, can not change mode"); |
| 12651 | return -EAGAIN; |
| 12652 | } |
| 12653 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12654 | cds_ssr_protect(__func__); |
| 12655 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12656 | cds_ssr_unprotect(__func__); |
| 12657 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12658 | return ret; |
| 12659 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12660 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12661 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12662 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12663 | { |
| 12664 | int ret; |
| 12665 | |
| 12666 | ret = param_set_int(kmessage, kp); |
| 12667 | |
| 12668 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12669 | pr_err("Only FTM mode supported!"); |
| 12670 | return -ENOTSUPP; |
| 12671 | } |
| 12672 | |
| 12673 | hdd_set_conparam(con_mode_ftm); |
| 12674 | con_mode = con_mode_ftm; |
| 12675 | |
| 12676 | return ret; |
| 12677 | } |
| 12678 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12679 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12680 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12681 | { |
| 12682 | int ret; |
| 12683 | |
| 12684 | ret = param_set_int(kmessage, kp); |
| 12685 | |
| 12686 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12687 | pr_err("Only Monitor mode supported!"); |
| 12688 | return -ENOTSUPP; |
| 12689 | } |
| 12690 | |
| 12691 | hdd_set_conparam(con_mode_monitor); |
| 12692 | con_mode = con_mode_monitor; |
| 12693 | |
| 12694 | return ret; |
| 12695 | } |
| 12696 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12697 | /** |
| 12698 | * hdd_get_conparam() - driver exit point |
| 12699 | * |
| 12700 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12701 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12702 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12703 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12704 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12705 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12706 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12707 | } |
| 12708 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12709 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12710 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12711 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12712 | } |
| 12713 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12714 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12715 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12716 | * @hdd_ctx: HDD context |
| 12717 | * |
| 12718 | * Cleans up the pre cac interface, if it exists |
| 12719 | * |
| 12720 | * Return: None |
| 12721 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12722 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12723 | { |
| 12724 | uint8_t session_id; |
| 12725 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12726 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12727 | |
| 12728 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12729 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12730 | hdd_err("failed to get pre cac vdev id"); |
| 12731 | return; |
| 12732 | } |
| 12733 | |
| 12734 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12735 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 12736 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12737 | return; |
| 12738 | } |
| 12739 | |
| 12740 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12741 | wlan_hdd_sap_pre_cac_failure, |
| 12742 | (void *)precac_adapter); |
| 12743 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12744 | |
| 12745 | } |
| 12746 | |
| 12747 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12748 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12749 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12750 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12751 | * Return: void |
| 12752 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12753 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12754 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12755 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12756 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12757 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12758 | if (!ol_ctx) |
| 12759 | return; |
| 12760 | |
| 12761 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12762 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12763 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12764 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12765 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12766 | |
| 12767 | ol_init_ini_config(ol_ctx, &cfg); |
| 12768 | } |
| 12769 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12770 | #ifdef FEATURE_RUNTIME_PM |
| 12771 | /** |
| 12772 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12773 | * @hdd_ctx: hdd context |
| 12774 | * @cfg: pointer to the configuration memory being populated |
| 12775 | * |
| 12776 | * Return: void |
| 12777 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12778 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12779 | struct hif_config_info *cfg) |
| 12780 | { |
| 12781 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12782 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12783 | } |
| 12784 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12785 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12786 | struct hif_config_info *cfg) |
| 12787 | { |
| 12788 | } |
| 12789 | #endif |
| 12790 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12791 | /** |
| 12792 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12793 | * @hdd_ctx: HDD Context |
| 12794 | * |
| 12795 | * Return: void |
| 12796 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12797 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12798 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12799 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12800 | struct hif_config_info cfg; |
| 12801 | |
| 12802 | if (!scn) |
| 12803 | return; |
| 12804 | |
| 12805 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12806 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12807 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12808 | |
| 12809 | if (hdd_ctx->config->prevent_link_down) |
| 12810 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12811 | } |
| 12812 | |
| 12813 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12814 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12815 | * datapath |
| 12816 | * @hdd_ctx: HDD Context |
| 12817 | * |
| 12818 | * Return: 0 for success/errno for failure |
| 12819 | */ |
| 12820 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12821 | { |
| 12822 | struct cdp_config_params params; |
| 12823 | QDF_STATUS status; |
| 12824 | |
| 12825 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12826 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12827 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12828 | params.tx_flow_stop_queue_threshold = |
| 12829 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12830 | params.tx_flow_start_queue_offset = |
| 12831 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12832 | #endif |
| 12833 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12834 | params.napi_enable = hdd_ctx->napi_enable; |
| 12835 | params.tcp_udp_checksumoffload = |
| 12836 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12837 | |
| 12838 | status = cdp_update_config_parameters( |
| 12839 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12840 | ¶ms); |
| 12841 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12842 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12843 | return status; |
| 12844 | } |
| 12845 | |
| 12846 | return 0; |
| 12847 | } |
| 12848 | |
| 12849 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12850 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12851 | * @hdd_ctx: HDD Context |
| 12852 | * |
| 12853 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12854 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12855 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12856 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12857 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12858 | int ret; |
| 12859 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12860 | hdd_update_ol_config(hdd_ctx); |
| 12861 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12862 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12863 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12864 | else |
| 12865 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12866 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12867 | |
| 12868 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12869 | } |
| 12870 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12871 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12872 | /** |
| 12873 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12874 | * @psoc_cfg: pmo psoc Configuration |
| 12875 | * @hdd_ctx: Pointer to hdd context |
| 12876 | * |
| 12877 | * Return: none |
| 12878 | */ |
| 12879 | static inline void hdd_ra_populate_pmo_config( |
| 12880 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12881 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12882 | { |
| 12883 | psoc_cfg->ra_ratelimit_interval = |
| 12884 | hdd_ctx->config->RArateLimitInterval; |
| 12885 | psoc_cfg->ra_ratelimit_enable = |
| 12886 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12887 | } |
| 12888 | #else |
| 12889 | static inline void hdd_ra_populate_pmo_config( |
| 12890 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12891 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12892 | { |
| 12893 | } |
| 12894 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12895 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12896 | /** |
| 12897 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12898 | * @hdd_ctx: HDD context |
| 12899 | * |
| 12900 | * Return: void |
| 12901 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12902 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12903 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12904 | struct pmo_psoc_cfg psoc_cfg; |
| 12905 | QDF_STATUS status; |
| 12906 | |
| 12907 | /* |
| 12908 | * Value of hdd_ctx->wowEnable can be, |
| 12909 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12910 | * 1 - Enable magic pattern match on all interfaces. |
| 12911 | * 2 - Enable pattern byte match on all interfaces. |
| 12912 | * 3 - Enable both magic patter and pattern byte match on |
| 12913 | * all interfaces. |
| 12914 | */ |
| 12915 | psoc_cfg.magic_ptrn_enable = |
| 12916 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12917 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12918 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12919 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12920 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12921 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12922 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12923 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12924 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12925 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 12926 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12927 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12928 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12929 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12930 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 12931 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 12932 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12933 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 12934 | psoc_cfg.auto_power_save_fail_mode = |
| 12935 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12936 | |
| 12937 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 12938 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 12939 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12940 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12941 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 12942 | if (QDF_IS_STATUS_ERROR(status)) |
| 12943 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 12944 | |
| 12945 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12946 | } |
| 12947 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12948 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 12949 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 12950 | struct hdd_config *cfg) |
| 12951 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12952 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 12953 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12954 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 12955 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 12956 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 12957 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 12958 | pno_cfg->channel_prediction_full_scan = |
| 12959 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 12960 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 12961 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 12962 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 12963 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12964 | } |
| 12965 | #else |
| 12966 | static inline void |
| 12967 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 12968 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12969 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 12970 | } |
| 12971 | #endif |
| 12972 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 12973 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 12974 | struct hdd_config *cfg) |
| 12975 | { |
| 12976 | uint8_t i = 0; |
| 12977 | |
| 12978 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 12979 | if (!ie_whitelist->white_list) |
| 12980 | return; |
| 12981 | |
| 12982 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 12983 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 12984 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 12985 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 12986 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 12987 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 12988 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 12989 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 12990 | |
| 12991 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 12992 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 12993 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 12994 | } |
| 12995 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 12996 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 12997 | { |
| 12998 | uint8_t i, score; |
| 12999 | |
| 13000 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13001 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13002 | if (score > MAX_INDEX_SCORE) |
| 13003 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13004 | MAX_INDEX_SCORE, i); |
| 13005 | } |
| 13006 | |
| 13007 | return per_index_score; |
| 13008 | } |
| 13009 | |
| 13010 | /** |
| 13011 | * hdd_update_score_config - API to update candidate scoring related params |
| 13012 | * configuration parameters |
| 13013 | * @score_config: score config to update |
| 13014 | * @cfg: config params |
| 13015 | * |
| 13016 | * Return: 0 if success else err |
| 13017 | */ |
| 13018 | static void hdd_update_score_config( |
| 13019 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 13020 | { |
| 13021 | int total_weight; |
| 13022 | |
| 13023 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 13024 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 13025 | score_config->weight_cfg.vht_caps_weightage = |
| 13026 | cfg->vht_caps_weightage; |
| 13027 | score_config->weight_cfg.he_caps_weightage = |
| 13028 | cfg->he_caps_weightage; |
| 13029 | score_config->weight_cfg.chan_width_weightage = |
| 13030 | cfg->chan_width_weightage; |
| 13031 | score_config->weight_cfg.chan_band_weightage = |
| 13032 | cfg->chan_band_weightage; |
| 13033 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 13034 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13035 | cfg->beamforming_cap_weightage; |
| 13036 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 13037 | score_config->weight_cfg.channel_congestion_weightage = |
| 13038 | cfg->channel_congestion_weightage; |
| 13039 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 13040 | |
| 13041 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 13042 | score_config->weight_cfg.ht_caps_weightage + |
| 13043 | score_config->weight_cfg.vht_caps_weightage + |
| 13044 | score_config->weight_cfg.he_caps_weightage + |
| 13045 | score_config->weight_cfg.chan_width_weightage + |
| 13046 | score_config->weight_cfg.chan_band_weightage + |
| 13047 | score_config->weight_cfg.nss_weightage + |
| 13048 | score_config->weight_cfg.beamforming_cap_weightage + |
| 13049 | score_config->weight_cfg.pcl_weightage + |
| 13050 | score_config->weight_cfg.channel_congestion_weightage + |
| 13051 | score_config->weight_cfg.oce_wan_weightage; |
| 13052 | |
| 13053 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 13054 | hdd_err("total weight is greater than %d fallback to default values", |
| 13055 | BEST_CANDIDATE_MAX_WEIGHT); |
| 13056 | |
| 13057 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 13058 | score_config->weight_cfg.ht_caps_weightage = |
| 13059 | HT_CAPABILITY_WEIGHTAGE; |
| 13060 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 13061 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 13062 | score_config->weight_cfg.chan_width_weightage = |
| 13063 | CHAN_WIDTH_WEIGHTAGE; |
| 13064 | score_config->weight_cfg.chan_band_weightage = |
| 13065 | CHAN_BAND_WEIGHTAGE; |
| 13066 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 13067 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13068 | BEAMFORMING_CAP_WEIGHTAGE; |
| 13069 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 13070 | score_config->weight_cfg.channel_congestion_weightage = |
| 13071 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 13072 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 13073 | } |
| 13074 | |
| 13075 | score_config->bandwidth_weight_per_index = |
| 13076 | hdd_limit_max_per_index_score( |
| 13077 | cfg->bandwidth_weight_per_index); |
| 13078 | score_config->nss_weight_per_index = |
| 13079 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 13080 | score_config->band_weight_per_index = |
| 13081 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 13082 | |
| 13083 | score_config->rssi_score.best_rssi_threshold = |
| 13084 | cfg->best_rssi_threshold; |
| 13085 | score_config->rssi_score.good_rssi_threshold = |
| 13086 | cfg->good_rssi_threshold; |
| 13087 | score_config->rssi_score.bad_rssi_threshold = |
| 13088 | cfg->bad_rssi_threshold; |
| 13089 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 13090 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 13091 | score_config->rssi_score.good_rssi_bucket_size = |
| 13092 | cfg->good_rssi_bucket_size; |
| 13093 | score_config->rssi_score.bad_rssi_bucket_size = |
| 13094 | cfg->bad_rssi_bucket_size; |
| 13095 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 13096 | cfg->rssi_pref_5g_rssi_thresh; |
| 13097 | |
| 13098 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 13099 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 13100 | hdd_limit_max_per_index_score( |
| 13101 | cfg->esp_qbss_score_slots3_to_0); |
| 13102 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13103 | hdd_limit_max_per_index_score( |
| 13104 | cfg->esp_qbss_score_slots7_to_4); |
| 13105 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13106 | hdd_limit_max_per_index_score( |
| 13107 | cfg->esp_qbss_score_slots11_to_8); |
| 13108 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13109 | hdd_limit_max_per_index_score( |
| 13110 | cfg->esp_qbss_score_slots15_to_12); |
| 13111 | |
| 13112 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13113 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13114 | hdd_limit_max_per_index_score( |
| 13115 | cfg->oce_wan_score_slots3_to_0); |
| 13116 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13117 | hdd_limit_max_per_index_score( |
| 13118 | cfg->oce_wan_score_slots7_to_4); |
| 13119 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13120 | hdd_limit_max_per_index_score( |
| 13121 | cfg->oce_wan_score_slots11_to_8); |
| 13122 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13123 | hdd_limit_max_per_index_score( |
| 13124 | cfg->oce_wan_score_slots15_to_12); |
| 13125 | |
| 13126 | |
| 13127 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13128 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13129 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13130 | |
| 13131 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13132 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13133 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13134 | score_config->he_cap = 1; |
| 13135 | |
| 13136 | if (score_config->he_cap || |
| 13137 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13138 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13139 | score_config->vht_cap = 1; |
| 13140 | |
| 13141 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13142 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13143 | score_config->ht_cap = 1; |
| 13144 | |
| 13145 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13146 | score_config->vht_24G_cap = 1; |
| 13147 | |
| 13148 | if (cfg->enableTxBF) |
| 13149 | score_config->beamformee_cap = 1; |
| 13150 | |
| 13151 | } |
| 13152 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13153 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13154 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13155 | * @hdd_ctx: HDD context |
| 13156 | * |
| 13157 | * Return: 0 if success else err |
| 13158 | */ |
| 13159 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13160 | { |
| 13161 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13162 | struct hdd_config *cfg = hdd_ctx->config; |
| 13163 | struct dfs_user_config dfs_cfg; |
| 13164 | QDF_STATUS status; |
| 13165 | |
| 13166 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13167 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13168 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13169 | hdd_err("failed dfs psoc configuration"); |
| 13170 | return -EINVAL; |
| 13171 | } |
| 13172 | |
| 13173 | return 0; |
| 13174 | } |
| 13175 | |
| 13176 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13177 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13178 | * @hdd_ctx: HDD context |
| 13179 | * |
| 13180 | * Return: 0 if success else err |
| 13181 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13182 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13183 | { |
| 13184 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13185 | struct scan_user_cfg scan_cfg; |
| 13186 | struct hdd_config *cfg = hdd_ctx->config; |
| 13187 | QDF_STATUS status; |
| 13188 | |
| 13189 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13190 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13191 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13192 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13193 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13194 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13195 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13196 | /* convert to ms */ |
| 13197 | scan_cfg.scan_cache_aging_time = |
| 13198 | cfg->scanAgingTimeout * 1000; |
| 13199 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13200 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13201 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13202 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13203 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13204 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13205 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13206 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13207 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13208 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13209 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13210 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13211 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13212 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13213 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13214 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13215 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13216 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13217 | if (status != QDF_STATUS_SUCCESS) { |
| 13218 | hdd_err("failed pmo psoc configuration"); |
| 13219 | return -EINVAL; |
| 13220 | } |
| 13221 | |
| 13222 | return 0; |
| 13223 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13224 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13225 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13226 | { |
| 13227 | int ret; |
| 13228 | |
| 13229 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13230 | if (ret) |
| 13231 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13232 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13233 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13234 | if (ret) |
| 13235 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13236 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13237 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13238 | if (ret) |
| 13239 | return ret; |
| 13240 | |
| 13241 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13242 | if (ret) |
| 13243 | return ret; |
| 13244 | |
| 13245 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13246 | |
| 13247 | return ret; |
| 13248 | } |
| 13249 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13250 | /** |
| 13251 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13252 | * @mode : cfg80211 DFS mode |
| 13253 | * |
| 13254 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13255 | */ |
| 13256 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13257 | { |
| 13258 | switch (mode) { |
| 13259 | case DFS_MODE_ENABLE: |
| 13260 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13261 | case DFS_MODE_DISABLE: |
| 13262 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13263 | case DFS_MODE_DEPRIORITIZE: |
| 13264 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13265 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13266 | hdd_debug("ACS dfs mode is NONE"); |
| 13267 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13268 | } |
| 13269 | } |
| 13270 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13271 | /** |
| 13272 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13273 | * @hddctx: pointer to hdd context |
| 13274 | * @set_value: enable/disable |
| 13275 | * |
| 13276 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13277 | * Host(even though it is duplicate). When Host send vendor command |
| 13278 | * disable,FW doesn't perform any action. Whenever any change in |
| 13279 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13280 | * |
| 13281 | * return - 0 on success, appropriate error values on failure. |
| 13282 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13283 | 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] | 13284 | { |
| 13285 | QDF_STATUS status; |
| 13286 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13287 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13288 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13289 | |
| 13290 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13291 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13292 | return -EINVAL; |
| 13293 | } |
| 13294 | |
| 13295 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13296 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13297 | hdd_err("Failed to send chan avoid command to SME"); |
| 13298 | return -EINVAL; |
| 13299 | } |
| 13300 | return 0; |
| 13301 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13302 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13303 | /** |
| 13304 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13305 | * @value: value to set |
| 13306 | * |
| 13307 | * This function will set the passed value to roaming in progress flag. |
| 13308 | * |
| 13309 | * Return: None |
| 13310 | */ |
| 13311 | void hdd_set_roaming_in_progress(bool value) |
| 13312 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13313 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13314 | |
| 13315 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13316 | if (!hdd_ctx) { |
| 13317 | hdd_err("HDD context is NULL"); |
| 13318 | return; |
| 13319 | } |
| 13320 | |
| 13321 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13322 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13323 | } |
| 13324 | |
| 13325 | /** |
| 13326 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13327 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13328 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13329 | * 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] | 13330 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13331 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13332 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13333 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13334 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13335 | |
| 13336 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13337 | if (!hdd_ctx) { |
| 13338 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13339 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13340 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13341 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13342 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13343 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13344 | hdd_ctx->roaming_in_progress); |
| 13345 | |
| 13346 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13347 | } |
| 13348 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13349 | /** |
| 13350 | * hdd_is_connection_in_progress() - check if connection is in |
| 13351 | * progress |
| 13352 | * @session_id: session id |
| 13353 | * @reason: scan reject reason |
| 13354 | * |
| 13355 | * Go through each adapter and check if Connection is in progress |
| 13356 | * |
| 13357 | * Return: true if connection is in progress else false |
| 13358 | */ |
| 13359 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13360 | enum scan_reject_states *reason) |
| 13361 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13362 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13363 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13364 | uint8_t sta_id = 0; |
| 13365 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13366 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13367 | |
| 13368 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13369 | if (!hdd_ctx) { |
| 13370 | hdd_err("HDD context is NULL"); |
| 13371 | return false; |
| 13372 | } |
| 13373 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13374 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13375 | hdd_info("Adapter with device mode %s(%d) exists", |
| 13376 | hdd_device_mode_to_string(adapter->device_mode), |
| 13377 | adapter->device_mode); |
| 13378 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13379 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13380 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13381 | && (eConnectionState_Connecting == |
| 13382 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13383 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13384 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13385 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13386 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13387 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13388 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13389 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13390 | } |
| 13391 | return true; |
| 13392 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13393 | /* |
| 13394 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13395 | * hdd_is_roaming_in_progress is for LFR3 |
| 13396 | */ |
| 13397 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13398 | sme_neighbor_middle_of_roaming( |
| 13399 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13400 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13401 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13402 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13403 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13404 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13405 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13406 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13407 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13408 | } |
| 13409 | return true; |
| 13410 | } |
| 13411 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13412 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13413 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13414 | hdd_sta_ctx = |
| 13415 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13416 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13417 | hdd_sta_ctx->conn_info.connState) |
| 13418 | && sme_is_sta_key_exchange_in_progress( |
| 13419 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13420 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13421 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13422 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13423 | " is in middle of WPS/EAPOL exchange.", |
| 13424 | MAC_ADDR_ARRAY(sta_mac)); |
| 13425 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13426 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13427 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13428 | } |
| 13429 | return true; |
| 13430 | } |
| 13431 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13432 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13433 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13434 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13435 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13436 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13437 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13438 | continue; |
| 13439 | |
| 13440 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13441 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13442 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13443 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13444 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13445 | MAC_ADDR_ARRAY(sta_mac)); |
| 13446 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13447 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13448 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13449 | } |
| 13450 | return true; |
| 13451 | } |
| 13452 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13453 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13454 | return true; |
| 13455 | } |
| 13456 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13457 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13458 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13459 | return false; |
| 13460 | } |
| 13461 | |
| 13462 | /** |
| 13463 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13464 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13465 | * |
| 13466 | * Return: None |
| 13467 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13468 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13469 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13470 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13471 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13472 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13473 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 13474 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13475 | void *sap_ctx; |
| 13476 | |
| 13477 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13478 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13479 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13480 | |
| 13481 | mutex_lock(&hdd_ctx->sap_lock); |
| 13482 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13483 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13484 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13485 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13486 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13487 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13488 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13489 | qdf_stop_bss_event, |
| 13490 | SME_CMD_TIMEOUT_VALUE); |
| 13491 | |
| 13492 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13493 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13494 | goto end; |
| 13495 | } |
| 13496 | } |
| 13497 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13498 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13499 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13500 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13501 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13502 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13503 | |
| 13504 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13505 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13506 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13507 | eUPDATE_IE_ALL); |
| 13508 | goto end; |
| 13509 | } |
| 13510 | |
| 13511 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13512 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13513 | sap_config, |
| 13514 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13515 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13516 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13517 | eUPDATE_IE_ALL); |
| 13518 | goto end; |
| 13519 | } |
| 13520 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13521 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13522 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13523 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13524 | SME_CMD_TIMEOUT_VALUE); |
| 13525 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13526 | eUPDATE_IE_ALL); |
| 13527 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13528 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13529 | goto end; |
| 13530 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13531 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13532 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13533 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13534 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13535 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13536 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13537 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13538 | ap_adapter->device_mode, |
| 13539 | true); |
| 13540 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13541 | } |
| 13542 | end: |
| 13543 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13544 | } |
| 13545 | |
| 13546 | /** |
| 13547 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13548 | * with non dfs acs |
| 13549 | * |
| 13550 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13551 | * |
| 13552 | * Return: None |
| 13553 | */ |
| 13554 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13555 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13556 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13557 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13558 | cds_context_type *cds_ctx; |
| 13559 | |
| 13560 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13561 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13562 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13563 | return; |
| 13564 | } |
| 13565 | |
| 13566 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13567 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13568 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13569 | return; |
| 13570 | } |
| 13571 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13572 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13573 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13574 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13575 | return; |
| 13576 | } |
| 13577 | |
| 13578 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13579 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13580 | &ap_adapter->event_flags) && |
| 13581 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13582 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13583 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13584 | 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] | 13585 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13586 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13587 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13588 | acs_cfg.acs_mode = true; |
| 13589 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13590 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13591 | } |
| 13592 | } |
| 13593 | |
| 13594 | /** |
| 13595 | * hdd_set_connection_in_progress() - to set the connection in |
| 13596 | * progress flag |
| 13597 | * @value: value to set |
| 13598 | * |
| 13599 | * This function will set the passed value to connection in progress flag. |
| 13600 | * If value is previously being set to true then no need to set it again. |
| 13601 | * |
| 13602 | * Return: true if value is being set correctly and false otherwise. |
| 13603 | */ |
| 13604 | bool hdd_set_connection_in_progress(bool value) |
| 13605 | { |
| 13606 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13607 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13608 | |
| 13609 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13610 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13611 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13612 | return false; |
| 13613 | } |
| 13614 | |
| 13615 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13616 | /* |
| 13617 | * if the value is set to true previously and if someone is |
| 13618 | * trying to make it true again then it could be some race |
| 13619 | * condition being triggered. Avoid this situation by returning |
| 13620 | * false |
| 13621 | */ |
| 13622 | if (hdd_ctx->connection_in_progress && value) |
| 13623 | status = false; |
| 13624 | else |
| 13625 | hdd_ctx->connection_in_progress = value; |
| 13626 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13627 | return status; |
| 13628 | } |
| 13629 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13630 | 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] | 13631 | { |
| 13632 | if (!adapter) { |
| 13633 | hdd_err("Invalid adapter"); |
| 13634 | return -EINVAL; |
| 13635 | } |
| 13636 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13637 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13638 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13639 | set_value, VDEV_CMD); |
| 13640 | return 0; |
| 13641 | |
| 13642 | } |
| 13643 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13644 | 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] | 13645 | { |
| 13646 | if (!adapter) { |
| 13647 | hdd_err("Invalid adapter"); |
| 13648 | return -EINVAL; |
| 13649 | } |
| 13650 | |
| 13651 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13652 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13653 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13654 | set_value, VDEV_CMD); |
| 13655 | return 0; |
| 13656 | } |
| 13657 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13658 | 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] | 13659 | *psoc, uint8_t vdev_id) |
| 13660 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13661 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13662 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13663 | |
| 13664 | /* |
| 13665 | * Currently PSOC is not being used. But this logic will |
| 13666 | * change once we have the converged implementation of |
| 13667 | * HDD context per PSOC in place. This would break if |
| 13668 | * multiple vdev objects reuse the vdev id. |
| 13669 | */ |
| 13670 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13671 | if (!adapter) |
| 13672 | hdd_err("Get adapter by vdev id failed"); |
| 13673 | |
| 13674 | return adapter; |
| 13675 | } |
| 13676 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13677 | 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] | 13678 | int8_t *rssi, int8_t *snr) |
| 13679 | { |
| 13680 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13681 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13682 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13683 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13684 | 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] | 13685 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13686 | if (QDF_STATUS_SUCCESS != status) { |
| 13687 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13688 | return -EINVAL; |
| 13689 | } |
| 13690 | |
| 13691 | return 0; |
| 13692 | } |
| 13693 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13694 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13695 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13696 | * @adapter - HDD adapter |
| 13697 | * @tos - type of service |
| 13698 | * @status - status of the traffic |
| 13699 | * |
| 13700 | * Return: 0 on success and non zero value on failure |
| 13701 | */ |
| 13702 | |
| 13703 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13704 | bool is_tos_active) |
| 13705 | { |
| 13706 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13707 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13708 | uint32_t max_off_chan_time = 0; |
| 13709 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13710 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13711 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13712 | |
| 13713 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13714 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13715 | |
| 13716 | if (ret < 0) { |
| 13717 | hdd_err("failed to set limit off chan params"); |
| 13718 | return ret; |
| 13719 | } |
| 13720 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13721 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13722 | |
| 13723 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13724 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13725 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13726 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13727 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13728 | if (adapter->active_ac) { |
| 13729 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13730 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13731 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13732 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13733 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13734 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13735 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13736 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13737 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13738 | PM_LATENCY); |
| 13739 | } else { |
| 13740 | /*ignore this command if only BE/BK is active */ |
| 13741 | is_tos_active = false; |
| 13742 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13743 | hdd_ctx->config->conc_system_pref); |
| 13744 | } |
| 13745 | } else { |
| 13746 | /* No active tos */ |
| 13747 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13748 | hdd_ctx->config->conc_system_pref); |
| 13749 | } |
| 13750 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13751 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13752 | is_tos_active, max_off_chan_time, |
| 13753 | hdd_ctx->config->nRestTimeConc, true); |
| 13754 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13755 | hdd_err("failed to set limit off chan params"); |
| 13756 | ret = -EINVAL; |
| 13757 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13758 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13759 | return ret; |
| 13760 | } |
| 13761 | |
| 13762 | /** |
| 13763 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13764 | * @adapter - HDD adapter |
| 13765 | * |
| 13766 | * Return: 0 on success and non zero value on failure |
| 13767 | */ |
| 13768 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13769 | { |
| 13770 | struct hdd_context *hdd_ctx; |
| 13771 | int ret; |
| 13772 | QDF_STATUS status; |
| 13773 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13774 | |
| 13775 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13776 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13777 | if (ret < 0) |
| 13778 | return ret; |
| 13779 | |
| 13780 | /* set the system preferece to default */ |
| 13781 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13782 | hdd_ctx->config->conc_system_pref); |
| 13783 | |
| 13784 | /* clear the bitmap */ |
| 13785 | adapter->active_ac = 0; |
| 13786 | |
| 13787 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13788 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13789 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13790 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13791 | false, 0, 0, false); |
| 13792 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13793 | hdd_err("failed to reset limit off chan params"); |
| 13794 | ret = -EINVAL; |
| 13795 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13796 | |
| 13797 | return ret; |
| 13798 | } |
| 13799 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13800 | /** |
| 13801 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13802 | * @drv_op: Enum indicating driver op |
| 13803 | * |
| 13804 | * Return: none |
| 13805 | */ |
| 13806 | void hdd_start_driver_ops_timer(int drv_op) |
| 13807 | { |
| 13808 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13809 | switch (drv_op) { |
| 13810 | case eHDD_DRV_OP_PROBE: |
| 13811 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13812 | break; |
| 13813 | case eHDD_DRV_OP_REMOVE: |
| 13814 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13815 | break; |
| 13816 | case eHDD_DRV_OP_SHUTDOWN: |
| 13817 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13818 | break; |
| 13819 | case eHDD_DRV_OP_REINIT: |
| 13820 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13821 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13822 | case eHDD_DRV_OP_IFF_UP: |
| 13823 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13824 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13825 | } |
| 13826 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13827 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13828 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13829 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13830 | } |
| 13831 | |
| 13832 | /** |
| 13833 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13834 | * |
| 13835 | * Return: none |
| 13836 | */ |
| 13837 | void hdd_stop_driver_ops_timer(void) |
| 13838 | { |
| 13839 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13840 | } |
| 13841 | |
| 13842 | /** |
| 13843 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13844 | * inactivity timer |
| 13845 | * |
| 13846 | * Return: None |
| 13847 | */ |
| 13848 | void hdd_drv_ops_inactivity_handler(void) |
| 13849 | { |
| 13850 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13851 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13852 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13853 | if (hdd_drv_ops_task) { |
| 13854 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13855 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13856 | } else { |
| 13857 | hdd_err("hdd_drv_ops_task is null"); |
| 13858 | } |
| 13859 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13860 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13861 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13862 | sizeof("shutdown"))) |
| 13863 | QDF_BUG(0); |
| 13864 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13865 | if (cds_is_fw_down()) { |
| 13866 | hdd_err("FW is down"); |
| 13867 | return; |
| 13868 | } |
| 13869 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13870 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13871 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13872 | else |
| 13873 | QDF_BUG(0); |
| 13874 | } |
| 13875 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13876 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13877 | { |
| 13878 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13879 | |
| 13880 | if (!hdd_ctx) |
| 13881 | return; |
| 13882 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13883 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13884 | } |
| 13885 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13886 | /** |
| 13887 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13888 | * @struct hdd_context *hdd_ctx |
| 13889 | * @struct hdd_adapter *padapter |
| 13890 | * @bool enble |
| 13891 | * |
| 13892 | * Return: none |
| 13893 | */ |
| 13894 | void hdd_set_rx_mode_rps(bool enable) |
| 13895 | { |
| 13896 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 13897 | struct hdd_context *hdd_ctx; |
| 13898 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13899 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 13900 | if (!cds_cfg) |
| 13901 | return; |
| 13902 | |
| 13903 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13904 | if (!hdd_ctx) |
| 13905 | return; |
| 13906 | |
| 13907 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13908 | if (!adapter) |
| 13909 | return; |
| 13910 | |
| 13911 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13912 | if (enable && !cds_cfg->rps_enabled) |
| 13913 | hdd_send_rps_ind(adapter); |
| 13914 | else if (!enable && cds_cfg->rps_enabled) |
| 13915 | hdd_send_rps_disable_ind(adapter); |
| 13916 | } |
| 13917 | } |
| 13918 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13919 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13920 | { |
| 13921 | struct hdd_adapter *adapter = NULL; |
| 13922 | |
| 13923 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 13924 | if ((adapter->device_mode == QDF_STA_MODE || |
| 13925 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 13926 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 13927 | &adapter->event_flags)){ |
| 13928 | return true; |
| 13929 | } |
| 13930 | } |
| 13931 | |
| 13932 | return false; |
| 13933 | } |
| 13934 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13935 | /* Register the module init/exit functions */ |
| 13936 | module_init(hdd_module_init); |
| 13937 | module_exit(hdd_module_exit); |
| 13938 | |
| 13939 | MODULE_LICENSE("Dual BSD/GPL"); |
| 13940 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 13941 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 13942 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13943 | static const struct kernel_param_ops con_mode_ops = { |
| 13944 | .set = con_mode_handler, |
| 13945 | .get = param_get_int, |
| 13946 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13947 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13948 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 13949 | .set = con_mode_handler_ftm, |
| 13950 | .get = param_get_int, |
| 13951 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 13952 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13953 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 13954 | .set = con_mode_handler_monitor, |
| 13955 | .get = param_get_int, |
| 13956 | }; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 13957 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 13958 | static const struct kernel_param_ops fwpath_ops = { |
| 13959 | .set = fwpath_changed_handler, |
| 13960 | .get = param_get_string, |
| 13961 | }; |
| 13962 | |
| 13963 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 13964 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13965 | |
| 13966 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 13967 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13968 | |
| 13969 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 13970 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 13971 | |
| 13972 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 13973 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 13974 | |
| 13975 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13976 | |
| 13977 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 13978 | |
| 13979 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |