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" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 139 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 140 | #ifdef MODULE |
| 141 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 142 | #else |
| 143 | #define WLAN_MODULE_NAME "wlan" |
| 144 | #endif |
| 145 | |
| 146 | #ifdef TIMER_MANAGER |
| 147 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 148 | #else |
| 149 | #define TIMER_MANAGER_STR "" |
| 150 | #endif |
| 151 | |
| 152 | #ifdef MEMORY_DEBUG |
| 153 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 154 | #else |
| 155 | #define MEMORY_DEBUG_STR "" |
| 156 | #endif |
| 157 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 158 | #ifdef PANIC_ON_BUG |
| 159 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 160 | #else |
| 161 | #define PANIC_ON_BUG_STR "" |
| 162 | #endif |
| 163 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 164 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 165 | int wlan_start_ret_val; |
| 166 | static DECLARE_COMPLETION(wlan_start_comp); |
| 167 | static unsigned int dev_num = 1; |
| 168 | static struct cdev wlan_hdd_state_cdev; |
| 169 | static struct class *class; |
| 170 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 171 | #ifndef MODULE |
| 172 | static struct gwlan_loader *wlan_loader; |
| 173 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 174 | struct kobj_attribute *attr, |
| 175 | const char *buf, size_t count); |
| 176 | struct gwlan_loader { |
| 177 | bool loaded_state; |
| 178 | struct kobject *boot_wlan_obj; |
| 179 | struct attribute_group *attr_group; |
| 180 | }; |
| 181 | |
| 182 | static struct kobj_attribute wlan_boot_attribute = |
| 183 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 184 | |
| 185 | static struct attribute *attrs[] = { |
| 186 | &wlan_boot_attribute.attr, |
| 187 | NULL, |
| 188 | }; |
| 189 | |
| 190 | #define MODULE_INITIALIZED 1 |
| 191 | #endif |
| 192 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 193 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 194 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 195 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 196 | |
| 197 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 198 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 199 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 200 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 201 | /* the Android framework expects this param even though we don't use it */ |
| 202 | #define BUF_LEN 20 |
| 203 | static char fwpath_buffer[BUF_LEN]; |
| 204 | static struct kparam_string fwpath = { |
| 205 | .string = fwpath_buffer, |
| 206 | .maxlen = BUF_LEN, |
| 207 | }; |
| 208 | |
| 209 | static char *country_code; |
| 210 | static int enable_11d = -1; |
| 211 | static int enable_dfs_chan_scan = -1; |
| 212 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 213 | /* |
| 214 | * spinlock for synchronizing asynchronous request/response |
| 215 | * (full description of use in wlan_hdd_main.h) |
| 216 | */ |
| 217 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 218 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 219 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 220 | #define WLAN_NLINK_CESIUM 30 |
| 221 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 222 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | |
| 224 | #define WOW_MAX_FILTER_LISTS 1 |
| 225 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 226 | #define WOW_MIN_PATTERN_SIZE 6 |
| 227 | #define WOW_MAX_PATTERN_SIZE 64 |
| 228 | |
| 229 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 230 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 231 | .flags = WIPHY_WOWLAN_ANY | |
| 232 | WIPHY_WOWLAN_MAGIC_PKT | |
| 233 | WIPHY_WOWLAN_DISCONNECT | |
| 234 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 235 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 236 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 237 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 238 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 239 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 240 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 241 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 242 | }; |
| 243 | #endif |
| 244 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 245 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 246 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 247 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 248 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 249 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 258 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 259 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 260 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 261 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 262 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 265 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 280 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 281 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 282 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 283 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 284 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 285 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 286 | }; |
| 287 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 288 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 289 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 290 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 291 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 292 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 293 | }; |
| 294 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 295 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 296 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 297 | |
| 298 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 299 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 300 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 301 | #endif |
| 302 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 303 | void hdd_start_complete(int ret) |
| 304 | { |
| 305 | wlan_start_ret_val = ret; |
| 306 | |
| 307 | complete(&wlan_start_comp); |
| 308 | } |
| 309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 310 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 311 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 312 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 313 | * |
| 314 | * Return: none |
| 315 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 316 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 317 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 318 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 319 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 320 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 321 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 325 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 326 | * @vdev_id: vdev_id |
| 327 | * @action: action type |
| 328 | * @reason: reason type |
| 329 | * |
| 330 | * Return: none |
| 331 | */ |
| 332 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 333 | enum netif_action_type action, enum netif_reason_type reason) |
| 334 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 335 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 336 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 337 | |
| 338 | if (!hdd_ctx) { |
| 339 | hdd_err("hdd ctx is NULL"); |
| 340 | return; |
| 341 | } |
| 342 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 343 | |
| 344 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 348 | * Store WLAN driver version and timestamp info in global variables such that |
| 349 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 350 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 351 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 352 | #ifdef BUILD_TAG |
| 353 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 354 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 356 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 357 | |
| 358 | /** |
| 359 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 360 | * @device_mode: device mode |
| 361 | * |
| 362 | * This utility function helps log string conversion of device mode. |
| 363 | * |
| 364 | * Return: string conversion of device mode, if match found; |
| 365 | * "Unknown" otherwise. |
| 366 | */ |
| 367 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 368 | { |
| 369 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 370 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 371 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 372 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 373 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 374 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 375 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 376 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 377 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 378 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 379 | default: |
| 380 | return "Unknown"; |
| 381 | } |
| 382 | } |
| 383 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 384 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 385 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 386 | * @hdd_ctx: HDD context |
| 387 | * @chan_list: buf hold returned chan list |
| 388 | * @chan_num: input buf size and output returned chan num |
| 389 | * |
| 390 | * This function helps get current available chan list from regulatory |
| 391 | * module. It excludes the "disabled" and "invalid" channels. |
| 392 | * |
| 393 | * Return: 0 for success. |
| 394 | */ |
| 395 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 396 | uint8_t *chan_list, |
| 397 | uint32_t *chan_num) |
| 398 | { |
| 399 | int i = 0, j = 0; |
| 400 | struct regulatory_channel *cur_chan_list; |
| 401 | struct wlan_objmgr_pdev *pdev; |
| 402 | |
| 403 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 404 | return -EINVAL; |
| 405 | |
| 406 | pdev = hdd_ctx->hdd_pdev; |
| 407 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 408 | sizeof(struct regulatory_channel)); |
| 409 | if (!cur_chan_list) |
| 410 | return -ENOMEM; |
| 411 | |
| 412 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 413 | QDF_STATUS_SUCCESS) { |
| 414 | qdf_mem_free(cur_chan_list); |
| 415 | return -EINVAL; |
| 416 | } |
| 417 | |
| 418 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 419 | uint32_t ch = cur_chan_list[i].chan_num; |
| 420 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 421 | ch); |
| 422 | |
| 423 | if (state != CHANNEL_STATE_DISABLE && |
| 424 | state != CHANNEL_STATE_INVALID && |
| 425 | j < *chan_num) { |
| 426 | chan_list[j] = (uint8_t)ch; |
| 427 | j++; |
| 428 | } |
| 429 | } |
| 430 | *chan_num = j; |
| 431 | qdf_mem_free(cur_chan_list); |
| 432 | return 0; |
| 433 | } |
| 434 | |
| 435 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 436 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 437 | * @adapter: HDD adapter |
| 438 | * @chan_number: Channel number |
| 439 | * @chan_bw: Bandwidth |
| 440 | * |
| 441 | * Checks if the given bandwidth is valid for the given channel number. |
| 442 | * |
| 443 | * Return: 0 for success, non-zero for failure |
| 444 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 445 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 446 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 447 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 448 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 449 | uint8_t chan[NUM_CHANNELS]; |
| 450 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 451 | bool found = false; |
| 452 | tHalHandle hal; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 453 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 454 | |
| 455 | hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 456 | if (!hal) { |
| 457 | hdd_err("Invalid HAL context"); |
| 458 | return -EINVAL; |
| 459 | } |
| 460 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 461 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 462 | &len); |
| 463 | if (ret) { |
| 464 | hdd_err("error %d in getting valid channel list", ret); |
| 465 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | for (i = 0; i < len; i++) { |
| 469 | if (chan[i] == chan_number) { |
| 470 | found = true; |
| 471 | break; |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | if (found == false) { |
| 476 | hdd_err("Channel not in driver's valid channel list"); |
| 477 | return -EOPNOTSUPP; |
| 478 | } |
| 479 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 480 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 481 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 482 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 483 | return -EINVAL; |
| 484 | } |
| 485 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 486 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 487 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 488 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 489 | return -EINVAL; |
| 490 | } |
| 491 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 492 | (chan_bw != CH_WIDTH_MAX)) { |
| 493 | hdd_err("Only BW20 possible on channel 14"); |
| 494 | return -EINVAL; |
| 495 | } |
| 496 | } |
| 497 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 498 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 499 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 500 | (chan_bw != CH_WIDTH_MAX)) { |
| 501 | hdd_err("Only BW20 possible on channel 165"); |
| 502 | return -EINVAL; |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | return 0; |
| 507 | } |
| 508 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 509 | /** |
| 510 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 511 | * |
| 512 | * Block the unloading of the driver (or) interface up until the |
| 513 | * cds recovery is completed |
| 514 | * |
| 515 | * Return: true for recovery completion else false |
| 516 | */ |
| 517 | static bool hdd_wait_for_recovery_completion(void) |
| 518 | { |
| 519 | int retry = 0; |
| 520 | |
| 521 | /* Wait for recovery to complete */ |
| 522 | while (cds_is_driver_recovering()) { |
| 523 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 524 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 525 | |
| 526 | if (g_is_system_reboot_triggered) { |
| 527 | hdd_info("System Reboot happening ignore unload!!"); |
| 528 | return false; |
| 529 | } |
| 530 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 531 | msleep(1000); |
| 532 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 533 | hdd_err("SSR never completed, error"); |
| 534 | /* |
| 535 | * Trigger the bug_on in the internal builds, in the |
| 536 | * customer builds self-recovery will be enabled |
| 537 | * in those cases just return error. |
| 538 | */ |
| 539 | if (cds_is_self_recovery_enabled()) |
| 540 | return false; |
| 541 | QDF_BUG(0); |
| 542 | } |
| 543 | } |
| 544 | |
| 545 | hdd_info("Recovery completed successfully!"); |
| 546 | return true; |
| 547 | } |
| 548 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 549 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 550 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 551 | unsigned long state, void *data) |
| 552 | { |
| 553 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 554 | struct netdev_notifier_info *dev_notif_info = data; |
| 555 | struct net_device *dev = dev_notif_info->dev; |
| 556 | #else |
| 557 | struct net_device *dev = data; |
| 558 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 559 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 560 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 561 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 562 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 563 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | /* Make sure that this callback corresponds to our device. */ |
| 565 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 566 | return NOTIFY_DONE; |
| 567 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 568 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 569 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 570 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 571 | return NOTIFY_DONE; |
| 572 | } |
| 573 | |
| 574 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 575 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | return NOTIFY_DONE; |
| 577 | } |
| 578 | |
| 579 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 580 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 581 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 582 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 583 | return NOTIFY_DONE; |
| 584 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 585 | |
| 586 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 587 | hdd_err("%s: Driver module is closed", __func__); |
| 588 | return NOTIFY_DONE; |
| 589 | } |
| 590 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 591 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | return NOTIFY_DONE; |
| 593 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 594 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 595 | dev->name, state); |
| 596 | |
| 597 | switch (state) { |
| 598 | case NETDEV_REGISTER: |
| 599 | break; |
| 600 | |
| 601 | case NETDEV_UNREGISTER: |
| 602 | break; |
| 603 | |
| 604 | case NETDEV_UP: |
| 605 | sme_ch_avoid_update_req(hdd_ctx->hHal); |
| 606 | break; |
| 607 | |
| 608 | case NETDEV_DOWN: |
| 609 | break; |
| 610 | |
| 611 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 612 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 613 | complete(&adapter->linkup_event_var); |
| 614 | break; |
| 615 | |
| 616 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 617 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 618 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 619 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 620 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 621 | } else { |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 622 | cds_flush_work(&adapter->scan_block_work); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 623 | hdd_debug("Scan is not Pending from user"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 624 | } |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 625 | /* |
| 626 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 627 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 628 | * flag after which driver does not send the cfg80211_scan_done. |
| 629 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 630 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 631 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 632 | break; |
| 633 | |
| 634 | default: |
| 635 | break; |
| 636 | } |
| 637 | |
| 638 | return NOTIFY_DONE; |
| 639 | } |
| 640 | |
| 641 | /** |
| 642 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 643 | * @nb: pointer to notifier block |
| 644 | * @state: state |
| 645 | * @ndev: ndev pointer |
| 646 | * |
| 647 | * Return: 0 on success, error number otherwise. |
| 648 | */ |
| 649 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 650 | unsigned long state, |
| 651 | void *ndev) |
| 652 | { |
| 653 | int ret; |
| 654 | |
| 655 | cds_ssr_protect(__func__); |
| 656 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 657 | cds_ssr_unprotect(__func__); |
| 658 | |
| 659 | return ret; |
| 660 | } |
| 661 | |
| 662 | struct notifier_block hdd_netdev_notifier = { |
| 663 | .notifier_call = hdd_netdev_notifier_call, |
| 664 | }; |
| 665 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 666 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 667 | unsigned long msg_type, void *_unused) |
| 668 | { |
| 669 | switch (msg_type) { |
| 670 | case SYS_DOWN: |
| 671 | case SYS_HALT: |
| 672 | case SYS_POWER_OFF: |
| 673 | g_is_system_reboot_triggered = true; |
| 674 | hdd_info("reboot, reason: %ld", msg_type); |
| 675 | break; |
| 676 | default: |
| 677 | break; |
| 678 | } |
| 679 | |
| 680 | return NOTIFY_OK; |
| 681 | } |
| 682 | |
| 683 | struct notifier_block system_reboot_notifier = { |
| 684 | .notifier_call = system_reboot_notifier_call, |
| 685 | }; |
| 686 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 687 | /* variable to hold the insmod parameters */ |
| 688 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 689 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 690 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 691 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 692 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 693 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 694 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 695 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 696 | /** |
| 697 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 698 | * @ch_width: NL channel width |
| 699 | * |
| 700 | * Converts the NL channel width to the driver's internal representation |
| 701 | * |
| 702 | * Return: Converted channel width. In case of non matching NL channel width, |
| 703 | * CH_WIDTH_MAX will be returned. |
| 704 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 705 | 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] | 706 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 707 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 708 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 709 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 710 | switch (ch_width) { |
| 711 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 712 | case NL80211_CHAN_WIDTH_20: |
| 713 | return CH_WIDTH_20MHZ; |
| 714 | case NL80211_CHAN_WIDTH_40: |
| 715 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 716 | case NL80211_CHAN_WIDTH_80: |
| 717 | return CH_WIDTH_80MHZ; |
| 718 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 719 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 720 | return CH_WIDTH_80P80MHZ; |
| 721 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 722 | return CH_WIDTH_160MHZ; |
| 723 | else |
| 724 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 725 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 726 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 727 | return CH_WIDTH_160MHZ; |
| 728 | else |
| 729 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 730 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 731 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 732 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 733 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 734 | default: |
| 735 | hdd_err("Invalid channel width %d, setting to default", |
| 736 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 737 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 741 | /* wlan_hdd_find_opclass() - Find operating class for a channel |
| 742 | * @hal: handler to HAL |
| 743 | * @channel: channel id |
| 744 | * @bw_offset: bandwidth offset |
| 745 | * |
| 746 | * Function invokes sme api to find the operating class |
| 747 | * |
| 748 | * Return: operating class |
| 749 | */ |
| 750 | uint8_t wlan_hdd_find_opclass(tHalHandle hal, uint8_t channel, |
| 751 | uint8_t bw_offset) |
| 752 | { |
| 753 | uint8_t opclass = 0; |
| 754 | |
| 755 | sme_get_opclass(hal, channel, bw_offset, &opclass); |
| 756 | return opclass; |
| 757 | } |
| 758 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 759 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 760 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 761 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 762 | * @bitmask: Bitmask of log levels to be enabled |
| 763 | * |
| 764 | * Called immediately after the cfg.ini is read in order to configure |
| 765 | * the desired trace levels. |
| 766 | * |
| 767 | * Return: None |
| 768 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 769 | 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] | 770 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 771 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 772 | int qdf_print_idx = -1; |
| 773 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | /* |
| 775 | * if the bitmask is the default value, then a bitmask was not |
| 776 | * specified in cfg.ini, so leave the logging level alone (it |
| 777 | * will remain at the "compiled in" default value) |
| 778 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 779 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 780 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 782 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 783 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 784 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 785 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 786 | QDF_TRACE_LEVEL_NONE, 0); |
| 787 | |
| 788 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 789 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 790 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 791 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 792 | while (0 != bitmask) { |
| 793 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 794 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 795 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 796 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 797 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 798 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 799 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | level++; |
| 801 | bitmask >>= 1; |
| 802 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 803 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 807 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 808 | * @hdd_ctx: HDD context pointer |
| 809 | * |
| 810 | * Return: 0 if the context is valid. Error code otherwise |
| 811 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 812 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 813 | { |
| 814 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 815 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 816 | return -ENODEV; |
| 817 | } |
| 818 | |
| 819 | if (cds_is_driver_recovering()) { |
| 820 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 821 | (void *)_RET_IP_, cds_get_driver_state()); |
| 822 | return -EAGAIN; |
| 823 | } |
| 824 | |
| 825 | if (hdd_ctx->start_modules_in_progress || |
| 826 | hdd_ctx->stop_modules_in_progress) { |
| 827 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 828 | (void *)_RET_IP_); |
| 829 | return -EAGAIN; |
| 830 | } |
| 831 | |
| 832 | return 0; |
| 833 | } |
| 834 | |
| 835 | |
| 836 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 837 | * wlan_hdd_validate_context() - check the HDD context |
| 838 | * @hdd_ctx: HDD context pointer |
| 839 | * |
| 840 | * Return: 0 if the context is valid. Error code otherwise |
| 841 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 842 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 843 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 844 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 845 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 846 | return -ENODEV; |
| 847 | } |
| 848 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 849 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 850 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 851 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 852 | return -EAGAIN; |
| 853 | } |
| 854 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 855 | if (cds_is_load_or_unload_in_progress()) { |
| 856 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 857 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 858 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 859 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 860 | |
| 861 | if (hdd_ctx->start_modules_in_progress || |
| 862 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 863 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 864 | (void *)_RET_IP_); |
| 865 | return -EAGAIN; |
| 866 | } |
| 867 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 868 | if (cds_is_driver_in_bad_state()) { |
| 869 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 870 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 871 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 872 | } |
| 873 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 874 | if (cds_is_fw_down()) { |
| 875 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 876 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 877 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 878 | } |
| 879 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 880 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 881 | hdd_debug("con_mode_handler is in progress Ignore!!!"); |
| 882 | return -EAGAIN; |
| 883 | } |
| 884 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 885 | return 0; |
| 886 | } |
| 887 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 888 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 889 | { |
| 890 | if (!adapter) { |
| 891 | hdd_err("adapter is null"); |
| 892 | return -EINVAL; |
| 893 | } |
| 894 | |
| 895 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 896 | hdd_err("bad adapter magic: 0x%x (should be 0x%x)", |
| 897 | adapter->magic, WLAN_HDD_ADAPTER_MAGIC); |
| 898 | return -EINVAL; |
| 899 | } |
| 900 | |
| 901 | if (!adapter->dev) { |
| 902 | hdd_err("adapter net_device is null"); |
| 903 | return -EINVAL; |
| 904 | } |
| 905 | |
| 906 | if (!(adapter->dev->flags & IFF_UP)) { |
| 907 | hdd_info("adapter net_device is not up"); |
| 908 | return -EAGAIN; |
| 909 | } |
| 910 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 911 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 912 | hdd_info("adapter session is not open"); |
| 913 | return -EAGAIN; |
| 914 | } |
| 915 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 916 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 917 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 918 | return -EINVAL; |
| 919 | } |
| 920 | |
| 921 | return 0; |
| 922 | } |
| 923 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 924 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 925 | * wlan_hdd_validate_modules_state() - Check modules status |
| 926 | * @hdd_ctx: HDD context pointer |
| 927 | * |
| 928 | * Check's the driver module's state and returns true if the |
| 929 | * modules are enabled returns false if modules are closed. |
| 930 | * |
| 931 | * Return: True if modules are enabled or false. |
| 932 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 933 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 934 | { |
| 935 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 936 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 937 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 938 | hdd_info("Modules not enabled, Present status: %d", |
| 939 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 940 | return false; |
| 941 | } |
| 942 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 943 | return true; |
| 944 | } |
| 945 | |
| 946 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 947 | * 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] | 948 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | * |
| 950 | * This function sets the IBSS power save config parameters to WMA |
| 951 | * which will send it to firmware if FW supports IBSS power save |
| 952 | * before vdev start. |
| 953 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 954 | * 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] | 955 | * on failure. |
| 956 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 957 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 958 | { |
| 959 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 960 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 961 | |
| 962 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 963 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 964 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 965 | } |
| 966 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 967 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 968 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 969 | hdd_ctx->config->ibssATIMWinSize, |
| 970 | VDEV_CMD); |
| 971 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 972 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 973 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | } |
| 975 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 976 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 978 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 979 | VDEV_CMD); |
| 980 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 981 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 982 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 983 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 984 | } |
| 985 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 986 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 987 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 988 | hdd_ctx->config-> |
| 989 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 990 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 991 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 992 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 993 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | } |
| 995 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 996 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 997 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 998 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 999 | VDEV_CMD); |
| 1000 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1001 | 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] | 1002 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1003 | } |
| 1004 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1005 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1007 | hdd_ctx->config->ibssInactivityCount, |
| 1008 | VDEV_CMD); |
| 1009 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1010 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1011 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | } |
| 1013 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1014 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1016 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1017 | VDEV_CMD); |
| 1018 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1019 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1020 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1021 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | } |
| 1023 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1024 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1025 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1026 | hdd_ctx->config->ibssPsWarmupTime, |
| 1027 | VDEV_CMD); |
| 1028 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1029 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1030 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1031 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | } |
| 1033 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1034 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1035 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1036 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1037 | VDEV_CMD); |
| 1038 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1039 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1040 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1041 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1042 | } |
| 1043 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1044 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1045 | } |
| 1046 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1047 | #ifdef FEATURE_RUNTIME_PM |
| 1048 | /** |
| 1049 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1050 | * @hdd_ctx: HDD context |
| 1051 | * |
| 1052 | * Return: None |
| 1053 | */ |
| 1054 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1055 | { |
| 1056 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1057 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1058 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1059 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1060 | |
| 1061 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1062 | } |
| 1063 | |
| 1064 | /** |
| 1065 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1066 | * @hdd_ctx: HDD Context |
| 1067 | * |
| 1068 | * Return: None |
| 1069 | */ |
| 1070 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1071 | { |
| 1072 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1073 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1074 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1075 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1076 | |
| 1077 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1078 | } |
| 1079 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1080 | #else /* FEATURE_RUNTIME_PM */ |
| 1081 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1082 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1083 | #endif /* FEATURE_RUNTIME_PM */ |
| 1084 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1085 | #define INTF_MACADDR_MASK 0x7 |
| 1086 | |
| 1087 | /** |
| 1088 | * hdd_update_macaddr() - update mac address |
| 1089 | * @config: hdd configuration |
| 1090 | * @hw_macaddr: mac address |
| 1091 | * |
| 1092 | * Mac address for multiple virtual interface is found as following |
| 1093 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1094 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1095 | * define the mac address for the remaining interfaces and locally |
| 1096 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1097 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1098 | * interface). |
| 1099 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1100 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1101 | * |
| 1102 | * Return: None |
| 1103 | */ |
| 1104 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1105 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1106 | { |
| 1107 | int8_t i; |
| 1108 | uint8_t macaddr_b3, tmp_br3; |
| 1109 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1110 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1111 | QDF_MAC_ADDR_SIZE); |
| 1112 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1113 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1114 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1115 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1116 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1117 | INTF_MACADDR_MASK; |
| 1118 | macaddr_b3 += tmp_br3; |
| 1119 | |
| 1120 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1121 | * mac address range before collision |
| 1122 | */ |
| 1123 | macaddr_b3 ^= (1 << 7); |
| 1124 | |
| 1125 | /* Set locally administered bit */ |
| 1126 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1127 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1128 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1129 | MAC_ADDRESS_STR, i, |
| 1130 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1131 | } |
| 1132 | } |
| 1133 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1134 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1135 | { |
| 1136 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1137 | struct tdls_start_params tdls_cfg; |
| 1138 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1139 | struct hdd_config *cfg = hdd_ctx->config; |
| 1140 | QDF_STATUS status; |
| 1141 | |
| 1142 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1143 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1144 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1145 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1146 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1147 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1148 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1149 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1150 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1151 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1152 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1153 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1154 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1155 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1156 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1157 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1158 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1159 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1160 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1161 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1162 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1163 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1164 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1165 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1166 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1167 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1168 | (cfg->fTDLSExternalControl ? |
| 1169 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1170 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1171 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1172 | |
| 1173 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1174 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1175 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1176 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1177 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1178 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1179 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1180 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1181 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1182 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1183 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1184 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1185 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1186 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1187 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1188 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1189 | |
| 1190 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1191 | if (status != QDF_STATUS_SUCCESS) { |
| 1192 | hdd_err("failed pmo psoc configuration"); |
| 1193 | return -EINVAL; |
| 1194 | } |
| 1195 | |
| 1196 | hdd_ctx->tdls_umac_comp_active = true; |
| 1197 | /* enable napier specific tdls data path */ |
| 1198 | hdd_ctx->tdls_nap_active = true; |
| 1199 | |
| 1200 | return 0; |
| 1201 | } |
| 1202 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1203 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1204 | struct wma_tgt_services *cfg) |
| 1205 | { |
| 1206 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1207 | |
| 1208 | /* Set up UAPSD */ |
| 1209 | config->apUapsdEnabled &= cfg->uapsd; |
| 1210 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1211 | /* 11AX mode support */ |
| 1212 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1213 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1214 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1215 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1216 | /* 11AC mode support */ |
| 1217 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1218 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1219 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1220 | |
| 1221 | /* ARP offload: override user setting if invalid */ |
| 1222 | config->fhostArpOffload &= cfg->arp_offload; |
| 1223 | |
| 1224 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1225 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1226 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1227 | if (cfg->pno_offload) |
| 1228 | config->PnoOffload = true; |
| 1229 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1230 | #ifdef FEATURE_WLAN_TDLS |
| 1231 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1232 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1233 | cfg->en_tdls_offchan; |
| 1234 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1235 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1236 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1238 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1240 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1242 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1243 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1244 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1245 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1246 | hdd_update_tdls_config(hdd_ctx); |
Krishna Kumaar Natarajan | 052c6e6 | 2015-09-28 15:32:55 -0700 | [diff] [blame] | 1247 | sme_update_tgt_services(hdd_ctx->hHal, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1248 | |
| 1249 | } |
| 1250 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1251 | /** |
| 1252 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1253 | * @hdd_ctx: HDD context |
| 1254 | * |
| 1255 | * Sets the Nss per vdev type based on INI |
| 1256 | * |
| 1257 | * Return: None |
| 1258 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1259 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1260 | { |
| 1261 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1262 | uint8_t max_supp_nss = 1; |
| 1263 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1264 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1265 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1266 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1267 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1268 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1269 | |
| 1270 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1271 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1272 | |
| 1273 | sme_update_vdev_type_nss(hdd_ctx->hHal, max_supp_nss, |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1274 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1277 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1278 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1279 | * @hdd_ctx: HDD context |
| 1280 | * |
| 1281 | * Updates wiphy vhtcap fields |
| 1282 | * |
| 1283 | * Return: None |
| 1284 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1285 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1286 | { |
| 1287 | struct ieee80211_supported_band *band_5g = |
| 1288 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1289 | uint32_t val; |
| 1290 | |
| 1291 | if (!band_5g) { |
| 1292 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1293 | return; |
| 1294 | } |
| 1295 | |
| 1296 | val = hdd_ctx->config->txBFCsnValue; |
| 1297 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1298 | |
| 1299 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1300 | band_5g->vht_cap.cap |= |
| 1301 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1302 | |
| 1303 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1304 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1305 | } |
| 1306 | |
| 1307 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1308 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1309 | * @hdd_ctx: HDD context |
| 1310 | * |
| 1311 | * Sets the DBS capability as per INI and firmware capability |
| 1312 | * |
| 1313 | * Return: None |
| 1314 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1315 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1316 | { |
| 1317 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1318 | uint8_t hw_dbs_capable = 0; |
| 1319 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1320 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1321 | ((cfg_ini->dual_mac_feature_disable == |
| 1322 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1323 | (cfg_ini->dual_mac_feature_disable == |
| 1324 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1325 | hw_dbs_capable = 1; |
| 1326 | |
| 1327 | sme_update_hw_dbs_capable(hdd_ctx->hHal, hw_dbs_capable); |
| 1328 | } |
| 1329 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1330 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1331 | struct wma_tgt_ht_cap *cfg) |
| 1332 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1333 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1334 | uint32_t value, val32; |
| 1335 | uint16_t val16; |
| 1336 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1337 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1338 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1339 | uint8_t enable_tx_stbc; |
| 1340 | |
| 1341 | /* check and update RX STBC */ |
| 1342 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1343 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1344 | |
| 1345 | /* get the MPDU density */ |
| 1346 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, &value); |
| 1347 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1348 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1349 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1350 | value = 0; |
| 1351 | } |
| 1352 | |
| 1353 | /* |
| 1354 | * MPDU density: |
| 1355 | * override user's setting if value is larger |
| 1356 | * than the one supported by target |
| 1357 | */ |
| 1358 | if (value > cfg->mpdu_density) { |
| 1359 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_MPDU_DENSITY, |
| 1360 | cfg->mpdu_density); |
| 1361 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1362 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1363 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | } |
| 1365 | |
| 1366 | /* get the HT capability info */ |
| 1367 | 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] | 1368 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1369 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1370 | return; |
| 1371 | } |
| 1372 | val16 = (uint16_t) val32; |
| 1373 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1374 | |
| 1375 | /* Set the LDPC capability */ |
| 1376 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1377 | |
| 1378 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1379 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1380 | |
| 1381 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1382 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1383 | |
| 1384 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1385 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1386 | |
| 1387 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1388 | |
| 1389 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1390 | pconfig->enable2x2 = 1; |
| 1391 | } else { |
| 1392 | pconfig->enable2x2 = 0; |
| 1393 | enable_tx_stbc = 0; |
| 1394 | |
| 1395 | /* 1x1 */ |
| 1396 | /* Update Rx Highest Long GI data Rate */ |
| 1397 | if (sme_cfg_set_int(hdd_ctx->hHal, |
| 1398 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1399 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1400 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1401 | 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] | 1402 | } |
| 1403 | |
| 1404 | /* Update Tx Highest Long GI data Rate */ |
| 1405 | if (sme_cfg_set_int |
| 1406 | (hdd_ctx->hHal, |
| 1407 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1408 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1409 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1410 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1411 | } |
| 1412 | } |
| 1413 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1414 | enable_tx_stbc = 0; |
| 1415 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1416 | |
| 1417 | val32 = val16; |
| 1418 | 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] | 1419 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1420 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1421 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1422 | value = SIZE_OF_SUPPORTED_MCS_SET; |
| 1423 | 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] | 1424 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1425 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1426 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1427 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | if (pconfig->enable2x2) { |
| 1429 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1430 | mcs_set[value] = |
| 1431 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1432 | |
| 1433 | status = |
| 1434 | sme_cfg_set_str(hdd_ctx->hHal, |
| 1435 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1436 | mcs_set, |
| 1437 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1438 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1439 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1440 | } |
| 1441 | } |
| 1442 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1443 | } |
| 1444 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1445 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1446 | struct wma_tgt_vht_cap *cfg) |
| 1447 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1448 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1449 | uint32_t value = 0; |
| 1450 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1451 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1452 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1453 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1454 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1455 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1456 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1457 | struct wma_caps_per_phy caps_per_phy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1459 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1460 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1461 | return; |
| 1462 | } |
| 1463 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1464 | /* Get the current MPDU length */ |
| 1465 | status = |
| 1466 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1467 | &value); |
| 1468 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1469 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1470 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1471 | value = 0; |
| 1472 | } |
| 1473 | |
| 1474 | /* |
| 1475 | * VHT max MPDU length: |
| 1476 | * override if user configured value is too high |
| 1477 | * that the target cannot support |
| 1478 | */ |
| 1479 | if (value > cfg->vht_max_mpdu) { |
| 1480 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1481 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1482 | cfg->vht_max_mpdu); |
| 1483 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1484 | if (status == QDF_STATUS_E_FAILURE) |
| 1485 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1486 | } |
| 1487 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1488 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
| 1489 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1490 | |
| 1491 | if (pconfig->enable2x2) |
| 1492 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1493 | |
| 1494 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
| 1495 | QDF_STATUS_E_FAILURE) { |
| 1496 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1497 | } |
| 1498 | |
| 1499 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
| 1500 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1501 | if (pconfig->enable2x2) |
| 1502 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1503 | |
| 1504 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
| 1505 | QDF_STATUS_E_FAILURE) { |
| 1506 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1507 | } |
| 1508 | |
| 1509 | sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
| 1510 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1511 | if (pconfig->enable2x2) |
| 1512 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1513 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1514 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1515 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1516 | |
| 1517 | if (sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
| 1518 | QDF_STATUS_E_FAILURE) { |
| 1519 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1520 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1521 | /* Get the current RX LDPC setting */ |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1522 | 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] | 1523 | &value); |
| 1524 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1525 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1526 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1527 | value = 0; |
| 1528 | } |
| 1529 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1530 | /* Set HW RX LDPC capability */ |
| 1531 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1532 | if (hw_rx_ldpc_enabled != value) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1533 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1534 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1535 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1536 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1537 | if (status == QDF_STATUS_E_FAILURE) |
| 1538 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1539 | } |
| 1540 | |
| 1541 | /* Get current GI 80 value */ |
| 1542 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1543 | &value); |
| 1544 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1545 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1546 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1547 | value = 0; |
| 1548 | } |
| 1549 | |
| 1550 | /* set the Guard interval 80MHz */ |
| 1551 | if (value && !cfg->vht_short_gi_80) { |
| 1552 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1553 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1554 | cfg->vht_short_gi_80); |
| 1555 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1556 | if (status == QDF_STATUS_E_FAILURE) |
| 1557 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1558 | } |
| 1559 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | /* Get VHT TX STBC cap */ |
| 1561 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, &value); |
| 1562 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1563 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1564 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | value = 0; |
| 1566 | } |
| 1567 | |
| 1568 | /* VHT TX STBC cap */ |
| 1569 | if (value && !cfg->vht_tx_stbc) { |
| 1570 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXSTBC, |
| 1571 | cfg->vht_tx_stbc); |
| 1572 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1573 | if (status == QDF_STATUS_E_FAILURE) |
| 1574 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | } |
| 1576 | |
| 1577 | /* Get VHT RX STBC cap */ |
| 1578 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, &value); |
| 1579 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1580 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1581 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | value = 0; |
| 1583 | } |
| 1584 | |
| 1585 | /* VHT RX STBC cap */ |
| 1586 | if (value && !cfg->vht_rx_stbc) { |
| 1587 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_RXSTBC, |
| 1588 | cfg->vht_rx_stbc); |
| 1589 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1590 | if (status == QDF_STATUS_E_FAILURE) |
| 1591 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1592 | } |
| 1593 | |
| 1594 | /* Get VHT SU Beamformer cap */ |
| 1595 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1596 | &value); |
| 1597 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1598 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1599 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | value = 0; |
| 1601 | } |
| 1602 | |
| 1603 | /* set VHT SU Beamformer cap */ |
| 1604 | if (value && !cfg->vht_su_bformer) { |
| 1605 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1606 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1607 | cfg->vht_su_bformer); |
| 1608 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1609 | if (status == QDF_STATUS_E_FAILURE) |
| 1610 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | } |
| 1612 | |
| 1613 | /* check and update SU BEAMFORMEE capabality */ |
| 1614 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1615 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1616 | |
| 1617 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1618 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1619 | pconfig->enableTxBF); |
| 1620 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1621 | if (status == QDF_STATUS_E_FAILURE) |
| 1622 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1623 | |
| 1624 | /* Get VHT MU Beamformer cap */ |
| 1625 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1626 | &value); |
| 1627 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1628 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1629 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1630 | value = 0; |
| 1631 | } |
| 1632 | |
| 1633 | /* set VHT MU Beamformer cap */ |
| 1634 | if (value && !cfg->vht_mu_bformer) { |
| 1635 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1636 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1637 | cfg->vht_mu_bformer); |
| 1638 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1639 | if (status == QDF_STATUS_E_FAILURE) |
| 1640 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | /* Get VHT MU Beamformee cap */ |
| 1644 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1645 | &value); |
| 1646 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1647 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1648 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1649 | value = 0; |
| 1650 | } |
| 1651 | |
| 1652 | /* set VHT MU Beamformee cap */ |
| 1653 | if (value && !cfg->vht_mu_bformee) { |
| 1654 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1655 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1656 | cfg->vht_mu_bformee); |
| 1657 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1658 | if (status == QDF_STATUS_E_FAILURE) |
| 1659 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | /* Get VHT MAX AMPDU Len exp */ |
| 1663 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1664 | &value); |
| 1665 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1666 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1667 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1668 | value = 0; |
| 1669 | } |
| 1670 | |
| 1671 | /* |
| 1672 | * VHT max AMPDU len exp: |
| 1673 | * override if user configured value is too high |
| 1674 | * that the target cannot support. |
| 1675 | * Even though Rome publish ampdu_len=7, it can |
| 1676 | * only support 4 because of some h/w bug. |
| 1677 | */ |
| 1678 | |
| 1679 | if (value > cfg->vht_max_ampdu_len_exp) { |
| 1680 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1681 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1682 | cfg->vht_max_ampdu_len_exp); |
| 1683 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1684 | if (status == QDF_STATUS_E_FAILURE) |
| 1685 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1686 | } |
| 1687 | |
| 1688 | /* Get VHT TXOP PS CAP */ |
| 1689 | status = sme_cfg_get_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, &value); |
| 1690 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1691 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1692 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | value = 0; |
| 1694 | } |
| 1695 | |
| 1696 | /* set VHT TXOP PS cap */ |
| 1697 | if (value && !cfg->vht_txop_ps) { |
| 1698 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_VHT_TXOP_PS, |
| 1699 | cfg->vht_txop_ps); |
| 1700 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1701 | if (status == QDF_STATUS_E_FAILURE) |
| 1702 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1703 | } |
| 1704 | |
| 1705 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1706 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1707 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1708 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1709 | else |
| 1710 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1711 | |
| 1712 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1713 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
| 1714 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1715 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1716 | VHT_CAP_160_AND_80P80_SUPP); |
| 1717 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1718 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1719 | band_5g->vht_cap.cap |= |
| 1720 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1721 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1722 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
| 1723 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 1724 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1725 | VHT_CAP_160_SUPP); |
| 1726 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1727 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1728 | band_5g->vht_cap.cap |= |
| 1729 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1730 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1731 | } |
| 1732 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1733 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1734 | /* Get the current GI 160 value */ |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1735 | status = sme_cfg_get_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1736 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1737 | &value); |
| 1738 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1739 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1740 | value = 0; |
| 1741 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1742 | /* set the Guard interval 160MHz */ |
| 1743 | if (value && !cfg->vht_short_gi_160) { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1744 | status = sme_cfg_set_int(hdd_ctx->hHal, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1745 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1746 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1747 | |
| 1748 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1749 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1750 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1751 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1752 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1753 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1754 | hdd_debug("VHT RxLDPC capability is set"); |
| 1755 | } else { |
| 1756 | /* |
| 1757 | * Get the RX LDPC capability for the NON DBS |
| 1758 | * hardware mode for 5G band |
| 1759 | */ |
| 1760 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1761 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1762 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1763 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1764 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1765 | hdd_debug("VHT RX LDPC capability is set"); |
| 1766 | } |
| 1767 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1768 | |
| 1769 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1770 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1771 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1772 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1773 | |
| 1774 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1775 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1776 | |
| 1777 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1778 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1779 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1780 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1781 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1782 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1783 | |
| 1784 | band_5g->vht_cap.cap |= |
| 1785 | (cfg->vht_max_ampdu_len_exp << |
| 1786 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1787 | |
| 1788 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1789 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1790 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1791 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1792 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1793 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1794 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1795 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1796 | |
| 1797 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1798 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1799 | |
| 1800 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1801 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1802 | /** |
| 1803 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1804 | * @hdd_ctx: Pointer to the HDD context |
| 1805 | * |
| 1806 | * Auto-generate mac address using device serial number. |
| 1807 | * Keep the first 3 bytes of OUI as before and replace |
| 1808 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1809 | * |
| 1810 | * Return: 0 for success |
| 1811 | * Non zero failure code for errors |
| 1812 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1813 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1814 | { |
| 1815 | unsigned int serialno = 0; |
| 1816 | struct qdf_mac_addr mac_addr = { |
| 1817 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1818 | }; |
| 1819 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1820 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1821 | if (serialno == 0) |
| 1822 | return -EINVAL; |
| 1823 | |
| 1824 | serialno &= 0x00ffffff; |
| 1825 | |
| 1826 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1827 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1828 | mac_addr.bytes[5] = serialno & 0xff; |
| 1829 | |
| 1830 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1831 | return 0; |
| 1832 | } |
| 1833 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1834 | /** |
| 1835 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1836 | * configuration to cfg_ini in HDD |
| 1837 | * @hdd_ctx: Pointer to hdd_ctx |
| 1838 | * @cfg: target configuration |
| 1839 | * |
| 1840 | * Return: None |
| 1841 | */ |
| 1842 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1843 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1844 | struct wma_tgt_cfg *cfg) |
| 1845 | { |
| 1846 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1847 | } |
| 1848 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1849 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1850 | struct wma_tgt_cfg *cfg) |
| 1851 | { |
| 1852 | } |
| 1853 | #endif |
| 1854 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1855 | void hdd_update_tgt_cfg(hdd_handle_t hdd_handle, struct wma_tgt_cfg *cfg) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1856 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1857 | int ret; |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1858 | struct hdd_context *hdd_ctx = (struct hdd_context *)hdd_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1859 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1860 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1861 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1862 | QDF_STATUS status; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1863 | |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1864 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1865 | if (ret) { |
| 1866 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1867 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1868 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1869 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1870 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1871 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1872 | hdd_err("dispatcher pdev open failed"); |
| 1873 | QDF_BUG(0); |
| 1874 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1875 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1876 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1877 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1878 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1879 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1880 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1881 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1882 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1883 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1884 | hdd_softap_hard_start_xmit); |
| 1885 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1886 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1887 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1888 | if (cds_cfg) { |
| 1889 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1890 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1891 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1892 | cds_cfg->sub_20_channel_width = |
| 1893 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1894 | } else { |
| 1895 | cds_cfg->sub_20_channel_width = |
| 1896 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1897 | } |
| 1898 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1899 | |
| 1900 | /* first store the INI band capability */ |
| 1901 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1902 | |
| 1903 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1904 | hdd_ctx->is_fils_roaming_supported = |
| 1905 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1907 | hdd_ctx->config->is_11k_offload_supported = |
| 1908 | cfg->services.is_11k_offload_supported; |
| 1909 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1910 | /* |
| 1911 | * now overwrite the target band capability with INI |
| 1912 | * setting if INI setting is a subset |
| 1913 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1914 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1915 | 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; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1918 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1919 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1920 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1921 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1922 | } |
| 1923 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1924 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1925 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1926 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1927 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1928 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1929 | } |
| 1930 | |
| 1931 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1932 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1933 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1934 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1935 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1936 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1937 | static struct qdf_mac_addr default_mac_addr = { |
| 1938 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1939 | }; |
| 1940 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1941 | &default_mac_addr)) { |
| 1942 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1943 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1944 | MAC_ADDRESS_STR, |
| 1945 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1946 | intfMacAddr[0].bytes)); |
| 1947 | } else { |
| 1948 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1949 | MAC_ADDRESS_STR, |
| 1950 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1951 | intfMacAddr[0].bytes)); |
| 1952 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1953 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1954 | } |
| 1955 | |
| 1956 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1957 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1959 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1960 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1961 | sizeof(cfg->hw_bd_info)); |
| 1962 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1964 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1965 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1966 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1967 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1968 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1969 | |
| 1970 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1971 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1972 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1973 | if (cfg->services.en_11ax) { |
| 1974 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1975 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1976 | } |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1977 | |
| 1978 | hdd_update_vdev_nss(hdd_ctx); |
| 1979 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1980 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 1981 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 1982 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1983 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1984 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1985 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1986 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1987 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 1988 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1989 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1990 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1991 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1992 | |
Rajeev Kumar | dd3bc60 | 2016-08-16 14:21:05 -0700 | [diff] [blame] | 1993 | hdd_ctx->bpf_enabled = (cfg->bpf_enabled && |
| 1994 | hdd_ctx->config->bpf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1995 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1996 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1997 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 1998 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1999 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2000 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2001 | hdd_ctx->config->txBFCsnValue = |
| 2002 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2003 | |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2004 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2005 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2006 | hdd_ctx->config->txBFCsnValue); |
| 2007 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2008 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2009 | |
| 2010 | |
| 2011 | 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] | 2012 | cfg->bpf_enabled, hdd_ctx->config->bpf_packet_filter_enable, |
| 2013 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2014 | |
| 2015 | /* |
| 2016 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2017 | */ |
| 2018 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2019 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2020 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2021 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2022 | /* |
| 2023 | * This needs to be done after HDD pdev is created and stored since |
| 2024 | * it will access the HDD pdev object lock. |
| 2025 | */ |
| 2026 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2027 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2028 | /* Configure NAN datapath features */ |
| 2029 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2030 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2031 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2032 | status = sme_cfg_set_int(hdd_ctx->hHal, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
| 2033 | cfg->obss_detection_offloaded); |
| 2034 | if (QDF_IS_STATUS_ERROR(status)) |
| 2035 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2036 | |
| 2037 | status = sme_cfg_set_int(hdd_ctx->hHal, |
| 2038 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2039 | cfg->obss_color_collision_offloaded); |
| 2040 | if (QDF_IS_STATUS_ERROR(status)) |
| 2041 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | } |
| 2043 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2044 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2045 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2046 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2047 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2048 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2049 | if (!hdd_ctx) { |
| 2050 | hdd_info("Couldn't get hdd_ctx"); |
| 2051 | return true; |
| 2052 | } |
| 2053 | |
| 2054 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2055 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2056 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2057 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2058 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2059 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2060 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2061 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2062 | |
| 2063 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2064 | QDF_P2P_GO_MODE == adapter->device_mode) && |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2065 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2066 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2067 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2068 | true; |
| 2069 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2070 | adapter->session_id); |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2071 | cdp_fc_vdev_flush(cds_get_context(QDF_MODULE_ID_SOC), |
| 2072 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2073 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2074 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2075 | |
| 2076 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2077 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2078 | |
| 2079 | /** |
| 2080 | * hdd_is_valid_mac_address() - validate MAC address |
| 2081 | * @pMacAddr: Pointer to the input MAC address |
| 2082 | * |
| 2083 | * This function validates whether the given MAC address is valid or not |
| 2084 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2085 | * where X is the hexa decimal digit character and separated by ':' |
| 2086 | * This algorithm works even if MAC address is not separated by ':' |
| 2087 | * |
| 2088 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2089 | * digits and a separator colon : appears in the input string only after |
| 2090 | * an even number of hex digits. |
| 2091 | * |
| 2092 | * Return: 1 for valid and 0 for invalid |
| 2093 | */ |
| 2094 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2095 | { |
| 2096 | int xdigit = 0; |
| 2097 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2098 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2099 | while (*pMacAddr) { |
| 2100 | if (isxdigit(*pMacAddr)) { |
| 2101 | xdigit++; |
| 2102 | } else if (':' == *pMacAddr) { |
| 2103 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2104 | break; |
| 2105 | |
| 2106 | ++separator; |
| 2107 | } else { |
| 2108 | /* Invalid MAC found */ |
| 2109 | return 0; |
| 2110 | } |
| 2111 | ++pMacAddr; |
| 2112 | } |
| 2113 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2114 | } |
| 2115 | |
| 2116 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2117 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2118 | * @dev: Handle to struct net_device to be updated. |
| 2119 | * |
| 2120 | * Return: None |
| 2121 | */ |
| 2122 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2123 | { |
| 2124 | dev->header_ops = NULL; |
| 2125 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2126 | dev->hard_header_len = ETH_HLEN; |
| 2127 | dev->mtu = ETH_DATA_LEN; |
| 2128 | dev->addr_len = ETH_ALEN; |
| 2129 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2130 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2131 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2132 | |
| 2133 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2134 | } |
| 2135 | |
| 2136 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2137 | * __hdd__mon_open() - HDD Open function |
| 2138 | * @dev: Pointer to net_device structure |
| 2139 | * |
| 2140 | * This is called in response to ifconfig up |
| 2141 | * |
| 2142 | * Return: 0 for success; non-zero for failure |
| 2143 | */ |
| 2144 | static int __hdd_mon_open(struct net_device *dev) |
| 2145 | { |
| 2146 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2147 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2148 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2149 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2150 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2151 | |
| 2152 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2153 | if (ret) |
| 2154 | return ret; |
| 2155 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2156 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2157 | |
| 2158 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2159 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2160 | if (ret) { |
| 2161 | hdd_err("Failed to start WLAN modules return"); |
| 2162 | return ret; |
| 2163 | } |
| 2164 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2165 | |
| 2166 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2167 | ret = hdd_start_adapter(adapter); |
| 2168 | if (ret) { |
| 2169 | hdd_err("Failed to start adapter :%d", |
| 2170 | adapter->device_mode); |
| 2171 | return ret; |
| 2172 | } |
| 2173 | hdd_err("hdd_start_adapters() successful !"); |
| 2174 | } |
| 2175 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2176 | } |
| 2177 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2178 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2179 | |
| 2180 | if (!ret) |
| 2181 | ret = hdd_enable_monitor_mode(dev); |
| 2182 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2183 | return ret; |
| 2184 | } |
| 2185 | |
| 2186 | /** |
| 2187 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2188 | * @dev: Pointer to net_device structure |
| 2189 | * |
| 2190 | * This is called in response to ifconfig up |
| 2191 | * |
| 2192 | * Return: 0 for success; non-zero for failure |
| 2193 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2194 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2195 | { |
| 2196 | int ret; |
| 2197 | |
| 2198 | cds_ssr_protect(__func__); |
| 2199 | ret = __hdd_mon_open(dev); |
| 2200 | cds_ssr_unprotect(__func__); |
| 2201 | |
| 2202 | return ret; |
| 2203 | } |
| 2204 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2205 | static QDF_STATUS |
| 2206 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2207 | { |
| 2208 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2209 | QDF_STATUS status; |
| 2210 | uint32_t channel_select_logic_conc; |
| 2211 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2212 | |
| 2213 | if (!hdd_ctx) { |
| 2214 | hdd_err("HDD context is NULL"); |
| 2215 | return QDF_STATUS_E_FAILURE; |
| 2216 | } |
| 2217 | |
| 2218 | |
| 2219 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2220 | return QDF_STATUS_SUCCESS; |
| 2221 | |
| 2222 | cfg.scan_config = 0; |
| 2223 | cfg.fw_mode_config = 0; |
| 2224 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2225 | |
| 2226 | channel_select_logic_conc = hdd_ctx->config-> |
| 2227 | channel_select_logic_conc; |
| 2228 | |
| 2229 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2230 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2231 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2232 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2233 | &cfg.fw_mode_config, |
| 2234 | hdd_ctx->config->dual_mac_feature_disable, |
| 2235 | channel_select_logic_conc); |
| 2236 | |
| 2237 | if (status != QDF_STATUS_SUCCESS) { |
| 2238 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2239 | status); |
| 2240 | return status; |
| 2241 | } |
| 2242 | } |
| 2243 | |
| 2244 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2245 | cfg.scan_config, cfg.fw_mode_config); |
| 2246 | |
| 2247 | status = sme_soc_set_dual_mac_config(cfg); |
| 2248 | if (status != QDF_STATUS_SUCCESS) { |
| 2249 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2250 | return status; |
| 2251 | } |
| 2252 | |
| 2253 | return QDF_STATUS_SUCCESS; |
| 2254 | } |
| 2255 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2256 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2257 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2258 | * @adapter: pointer to HDD adapter |
| 2259 | * |
| 2260 | * This function is called to start the device specific adapter for |
| 2261 | * the mode passed in the adapter's device_mode. |
| 2262 | * |
| 2263 | * Return: 0 for success; non-zero for failure |
| 2264 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2265 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2266 | { |
| 2267 | |
| 2268 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2269 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2270 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2271 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2272 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2273 | |
| 2274 | switch (device_mode) { |
| 2275 | case QDF_P2P_CLIENT_MODE: |
| 2276 | case QDF_P2P_DEVICE_MODE: |
| 2277 | case QDF_OCB_MODE: |
| 2278 | case QDF_STA_MODE: |
| 2279 | case QDF_MONITOR_MODE: |
| 2280 | ret = hdd_start_station_adapter(adapter); |
| 2281 | if (ret) |
| 2282 | goto err_start_adapter; |
| 2283 | break; |
| 2284 | case QDF_P2P_GO_MODE: |
| 2285 | case QDF_SAP_MODE: |
| 2286 | ret = hdd_start_ap_adapter(adapter); |
| 2287 | if (ret) |
| 2288 | goto err_start_adapter; |
| 2289 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2290 | case QDF_IBSS_MODE: |
| 2291 | /* |
| 2292 | * For IBSS interface is initialized as part of |
| 2293 | * hdd_init_station_mode() |
| 2294 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2295 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2296 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2297 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2298 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2299 | default: |
| 2300 | hdd_err("Invalid session type %d", device_mode); |
| 2301 | QDF_ASSERT(0); |
| 2302 | goto err_start_adapter; |
| 2303 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2304 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2305 | if (hdd_set_fw_params(adapter)) |
| 2306 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2307 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2308 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2309 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2310 | if (ret < 0) { |
| 2311 | hdd_err("Failed to register frames - ret %d", ret); |
| 2312 | goto err_start_adapter; |
| 2313 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2314 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2315 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2316 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2317 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2318 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2319 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2320 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2321 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2322 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2323 | err_start_adapter: |
| 2324 | return -EINVAL; |
| 2325 | } |
| 2326 | |
| 2327 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2328 | * hdd_enable_power_management() - API to Enable Power Management |
| 2329 | * |
| 2330 | * API invokes Bus Interface Layer power management functionality |
| 2331 | * |
| 2332 | * Return: None |
| 2333 | */ |
| 2334 | static void hdd_enable_power_management(void) |
| 2335 | { |
| 2336 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2337 | |
| 2338 | if (!hif_ctx) { |
| 2339 | hdd_err("Bus Interface Context is Invalid"); |
| 2340 | return; |
| 2341 | } |
| 2342 | |
| 2343 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2344 | } |
| 2345 | |
| 2346 | /** |
| 2347 | * hdd_disable_power_management() - API to disable Power Management |
| 2348 | * |
| 2349 | * API disable Bus Interface Layer Power management functionality |
| 2350 | * |
| 2351 | * Return: None |
| 2352 | */ |
| 2353 | static void hdd_disable_power_management(void) |
| 2354 | { |
| 2355 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2356 | |
| 2357 | if (!hif_ctx) { |
| 2358 | hdd_err("Bus Interface Context is Invalid"); |
| 2359 | return; |
| 2360 | } |
| 2361 | |
| 2362 | hif_disable_power_management(hif_ctx); |
| 2363 | } |
| 2364 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2365 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2366 | { |
| 2367 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2368 | size_t target_hw_name_len; |
| 2369 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2370 | uint8_t *buf; |
| 2371 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2372 | |
| 2373 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2374 | if (!hif_sc) { |
| 2375 | hdd_err("HIF context is NULL"); |
| 2376 | return; |
| 2377 | } |
| 2378 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2379 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2380 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2381 | &target_hw_name); |
| 2382 | |
| 2383 | if (hdd_ctx->target_hw_name) |
| 2384 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2385 | |
| 2386 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2387 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2388 | if (hdd_ctx->target_hw_name) |
| 2389 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2390 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2391 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2392 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2393 | if (buf) { |
| 2394 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2395 | hdd_info("%s", buf); |
| 2396 | qdf_mem_free(buf); |
| 2397 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2398 | } |
| 2399 | |
| 2400 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2401 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2402 | * @hdd_ctx: Pointer to hdd context |
| 2403 | * |
| 2404 | * Return: none |
| 2405 | */ |
| 2406 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2407 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2408 | { |
| 2409 | uint8_t num_entries = 0; |
| 2410 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2411 | uint8_t *tx_sched_wrr_ac; |
| 2412 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2413 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2414 | |
| 2415 | if (NULL == hdd_ctx) |
| 2416 | return; |
| 2417 | |
| 2418 | if (NULL == hdd_ctx->config) { |
| 2419 | /* Do nothing if hdd_ctx is invalid */ |
| 2420 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2421 | return; |
| 2422 | } |
| 2423 | |
| 2424 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2425 | |
| 2426 | if (!cds_ctx) { |
| 2427 | hdd_err("Invalid CDS Context"); |
| 2428 | return; |
| 2429 | } |
| 2430 | |
| 2431 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2432 | switch (i) { |
| 2433 | case OL_TX_WMM_AC_BE: |
| 2434 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2435 | break; |
| 2436 | case OL_TX_WMM_AC_BK: |
| 2437 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2438 | break; |
| 2439 | case OL_TX_WMM_AC_VI: |
| 2440 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2441 | break; |
| 2442 | case OL_TX_WMM_AC_VO: |
| 2443 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2444 | break; |
| 2445 | default: |
| 2446 | tx_sched_wrr_ac = NULL; |
| 2447 | break; |
| 2448 | } |
| 2449 | |
| 2450 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2451 | tx_sched_wrr_param, |
| 2452 | &num_entries, |
| 2453 | sizeof(tx_sched_wrr_param)); |
| 2454 | |
| 2455 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2456 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2457 | tx_sched_wrr_param[0]; |
| 2458 | cds_ctx->ac_specs[i].credit_threshold = |
| 2459 | tx_sched_wrr_param[1]; |
| 2460 | cds_ctx->ac_specs[i].send_limit = |
| 2461 | tx_sched_wrr_param[2]; |
| 2462 | cds_ctx->ac_specs[i].credit_reserve = |
| 2463 | tx_sched_wrr_param[3]; |
| 2464 | cds_ctx->ac_specs[i].discard_weight = |
| 2465 | tx_sched_wrr_param[4]; |
| 2466 | } |
| 2467 | |
| 2468 | num_entries = 0; |
| 2469 | } |
| 2470 | } |
| 2471 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2472 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2473 | const size_t version_len, uint8_t *version) |
| 2474 | { |
| 2475 | uint32_t size; |
| 2476 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2477 | |
| 2478 | if (!hdd_ctx) { |
| 2479 | hdd_err("Invalid context, HDD context is null"); |
| 2480 | return 0; |
| 2481 | } |
| 2482 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2483 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2484 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2485 | return 0; |
| 2486 | } |
| 2487 | |
| 2488 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2489 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2490 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2491 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2492 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2493 | |
| 2494 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2495 | "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] | 2496 | QWLAN_VERSIONSTR, |
| 2497 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2498 | hdd_ctx->target_hw_name, |
| 2499 | hdd_ctx->hw_bd_info.bdf_version, |
| 2500 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2501 | hdd_ctx->hw_bd_info.customer_id, |
| 2502 | hdd_ctx->hw_bd_info.project_id, |
| 2503 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2504 | |
| 2505 | return size; |
| 2506 | } |
| 2507 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2508 | #ifdef IPA_OFFLOAD |
| 2509 | /** |
| 2510 | * hdd_update_ipa_component_config() - update ipa config |
| 2511 | * @hdd_ctx: Pointer to hdd context |
| 2512 | * |
| 2513 | * Return: none |
| 2514 | */ |
| 2515 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2516 | { |
| 2517 | struct hdd_config *cfg = hdd_ctx->config; |
| 2518 | struct wlan_ipa_config ipa_cfg; |
| 2519 | |
| 2520 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2521 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2522 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2523 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2524 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2525 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2526 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2527 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2528 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2529 | |
| 2530 | ucfg_ipa_update_config(&ipa_cfg); |
| 2531 | } |
| 2532 | #else |
| 2533 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2534 | { |
| 2535 | } |
| 2536 | #endif |
| 2537 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2538 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2539 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2540 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2541 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2542 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2543 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2544 | |
| 2545 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2546 | if (!adapter) { |
| 2547 | hdd_err("Adapter is NULL"); |
| 2548 | return PM_MAX_NUM_OF_MODE; |
| 2549 | } |
| 2550 | |
| 2551 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2552 | adapter->device_mode); |
| 2553 | } |
| 2554 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2555 | static void hdd_register_policy_manager_callback( |
| 2556 | struct wlan_objmgr_psoc *psoc) |
| 2557 | { |
| 2558 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2559 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2560 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2561 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2562 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2563 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2564 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2565 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2566 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2567 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2568 | if (QDF_STATUS_SUCCESS != |
| 2569 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2570 | hdd_err("HDD callback registration with policy manager failed"); |
| 2571 | } |
| 2572 | } |
| 2573 | #else |
| 2574 | static void hdd_register_policy_manager_callback( |
| 2575 | struct wlan_objmgr_psoc *psoc) |
| 2576 | { |
| 2577 | } |
| 2578 | #endif |
| 2579 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2580 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2581 | { |
| 2582 | struct nan_callbacks cb_obj = {0}; |
| 2583 | |
| 2584 | cb_obj.ndi_open = hdd_ndi_open; |
| 2585 | cb_obj.ndi_close = hdd_ndi_close; |
| 2586 | cb_obj.ndi_start = hdd_ndi_start; |
| 2587 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2588 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2589 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2590 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2591 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2592 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2593 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2594 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2595 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2596 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2597 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2598 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2599 | /** |
| 2600 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
| 2601 | * |
| 2602 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2603 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2604 | * |
| 2605 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2606 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2607 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2608 | * fixed. |
| 2609 | * |
| 2610 | * Return: None |
| 2611 | */ |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2612 | static void hdd_check_for_leaks(void) |
| 2613 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2614 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2615 | |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2616 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2617 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2618 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2619 | } |
| 2620 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2621 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2622 | #else |
| 2623 | static inline void hdd_check_for_leaks(void) {} |
| 2624 | |
| 2625 | #define hdd_debug_domain_set(domain) |
| 2626 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2627 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2628 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2629 | * hdd_update_country_code - Update country code |
| 2630 | * @hdd_ctx: HDD context |
| 2631 | * |
| 2632 | * Update country code based on module parameter country_code |
| 2633 | * |
| 2634 | * Return: 0 on success and errno on failure |
| 2635 | */ |
| 2636 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2637 | { |
| 2638 | if (!country_code) |
| 2639 | return 0; |
| 2640 | |
| 2641 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2642 | } |
| 2643 | |
| 2644 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2645 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2646 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2647 | * @reinit: flag to indicate from SSR or normal path |
| 2648 | * |
| 2649 | * This function maintains the driver state machine it will be invoked from |
| 2650 | * startup, reinit and change interface. Depending on the driver state shall |
| 2651 | * perform the opening of the modules. |
| 2652 | * |
| 2653 | * Return: 0 for success; non-zero for failure |
| 2654 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2655 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2656 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2657 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2658 | qdf_device_t qdf_dev; |
| 2659 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2660 | bool unint = false; |
| 2661 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2662 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2663 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2664 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2665 | |
| 2666 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2667 | if (!qdf_dev) { |
| 2668 | hdd_err("QDF Device Context is Invalid return"); |
| 2669 | return -EINVAL; |
| 2670 | } |
| 2671 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2672 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2673 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2674 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2675 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2676 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2677 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2678 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2679 | return 0; |
| 2680 | } |
| 2681 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2682 | hdd_ctx->start_modules_in_progress = true; |
| 2683 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2684 | switch (hdd_ctx->driver_status) { |
| 2685 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2686 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2687 | unint = true; |
| 2688 | /* Fall through dont add break here */ |
| 2689 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2690 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2691 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2692 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2693 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2694 | if (!reinit && !unint) { |
| 2695 | ret = pld_power_on(qdf_dev->dev); |
| 2696 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2697 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2698 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2699 | goto release_lock; |
| 2700 | } |
| 2701 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2702 | |
| 2703 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2704 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2705 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2706 | qdf_dev->bus_type, |
| 2707 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2708 | HIF_ENABLE_TYPE_PROBE); |
| 2709 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2710 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2711 | goto power_down; |
| 2712 | } |
| 2713 | |
| 2714 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2715 | if (!hif_ctx) { |
| 2716 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2717 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2718 | goto power_down; |
| 2719 | } |
| 2720 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2721 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2722 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2723 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2724 | status); |
| 2725 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2726 | goto hif_close; |
| 2727 | } |
| 2728 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2729 | hdd_update_ipa_component_config(hdd_ctx); |
| 2730 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2731 | ret = hdd_update_config(hdd_ctx); |
| 2732 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2733 | hdd_err("Failed to update configuration; errno: %d", |
| 2734 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2735 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2736 | } |
| 2737 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2738 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2739 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2740 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2741 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2742 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2743 | ret = qdf_status_to_os_return(status); |
| 2744 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2745 | } |
| 2746 | |
Jeff Johnson | 79e3688 | 2018-05-06 17:15:33 -0700 | [diff] [blame] | 2747 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2748 | ret = hdd_update_components_config(hdd_ctx); |
| 2749 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2750 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2751 | ret); |
| 2752 | goto close; |
| 2753 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2754 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2755 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2756 | hdd_err("Failed to Open cds post open; status: %d", |
| 2757 | status); |
| 2758 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2759 | goto close; |
| 2760 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2761 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2762 | /* |
| 2763 | * NAN compoenet requires certian operations like, open adapter, |
| 2764 | * close adapter, etc. to be initiated by HDD, for those |
| 2765 | * register HDD callbacks with UMAC's NAN componenet. |
| 2766 | */ |
| 2767 | hdd_nan_register_callbacks(hdd_ctx); |
| 2768 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2769 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
| 2770 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2771 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2772 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2773 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2774 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2775 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2776 | } |
| 2777 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2778 | hdd_register_policy_manager_callback( |
| 2779 | hdd_ctx->hdd_psoc); |
| 2780 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2781 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2782 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2783 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2784 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2785 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2786 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2787 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2788 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | break; |
| 2790 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2791 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2792 | /* Fall through dont add break here */ |
| 2793 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2794 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2795 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2796 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2797 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2798 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2799 | break; |
| 2800 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2801 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2802 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2803 | if (ret) { |
| 2804 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2805 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2806 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2807 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2808 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2809 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2810 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2811 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2812 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2813 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2814 | default: |
| 2815 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2816 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2817 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2818 | goto release_lock; |
| 2819 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2820 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2821 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2822 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2823 | ret = hdd_update_country_code(hdd_ctx); |
| 2824 | if (ret) |
| 2825 | hdd_err("Failed to update command line country code!"); |
| 2826 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2827 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2828 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2829 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2830 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2831 | return 0; |
| 2832 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2833 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2834 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2835 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2836 | cds_txrx_free: |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2837 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 2838 | |
| 2839 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2840 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 2841 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
| 2842 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2843 | } |
| 2844 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2845 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2846 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2847 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2848 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2849 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2850 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2851 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2852 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2853 | deinit_config: |
| 2854 | cds_deinit_ini_config(); |
| 2855 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2856 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2857 | ol_cds_free(); |
| 2858 | |
| 2859 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2860 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2861 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2862 | power_down: |
| 2863 | if (!reinit && !unint) |
| 2864 | pld_power_off(qdf_dev->dev); |
| 2865 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2866 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2867 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 2868 | if (hdd_ctx->target_hw_name) { |
| 2869 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2870 | hdd_ctx->target_hw_name = NULL; |
| 2871 | } |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2872 | /* many adapter resources are not freed by design in SSR case */ |
| 2873 | if (!reinit) |
| 2874 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2875 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2876 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2877 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2878 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2879 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2880 | } |
| 2881 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2882 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2883 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2884 | { |
| 2885 | int ret = os_if_wifi_pos_register_nl(); |
| 2886 | |
| 2887 | if (ret) |
| 2888 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2889 | |
| 2890 | return ret; |
| 2891 | } |
| 2892 | |
| 2893 | static int hdd_deactivate_wifi_pos(void) |
| 2894 | { |
| 2895 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2896 | |
| 2897 | if (ret) |
| 2898 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2899 | |
| 2900 | return ret; |
| 2901 | } |
| 2902 | |
| 2903 | /** |
| 2904 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 2905 | * @hdd_ctx: hdd context |
| 2906 | * |
| 2907 | * Return: status of operation |
| 2908 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2909 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2910 | { |
| 2911 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 2912 | struct hdd_config *cfg = hdd_ctx->config; |
| 2913 | |
| 2914 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 2915 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 2916 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 2917 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 2918 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 2919 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 2920 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 2921 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 2922 | } |
| 2923 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2924 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2925 | { |
| 2926 | return oem_activate_service(hdd_ctx); |
| 2927 | } |
| 2928 | |
| 2929 | static int hdd_deactivate_wifi_pos(void) |
| 2930 | { |
| 2931 | return 0; |
| 2932 | } |
| 2933 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2934 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2935 | { |
| 2936 | } |
| 2937 | #endif |
| 2938 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2939 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2940 | * __hdd_open() - HDD Open function |
| 2941 | * @dev: Pointer to net_device structure |
| 2942 | * |
| 2943 | * This is called in response to ifconfig up |
| 2944 | * |
| 2945 | * Return: 0 for success; non-zero for failure |
| 2946 | */ |
| 2947 | static int __hdd_open(struct net_device *dev) |
| 2948 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2949 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2950 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2951 | int ret; |
| 2952 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2953 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 2954 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2955 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2956 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 2957 | /* Nothing to be done if device is unloading */ |
| 2958 | if (cds_is_driver_unloading()) { |
| 2959 | hdd_err("Driver is unloading can not open the hdd"); |
| 2960 | return -EBUSY; |
| 2961 | } |
| 2962 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 2963 | if (cds_is_driver_recovering()) { |
| 2964 | hdd_err("WLAN is currently recovering; Please try again."); |
| 2965 | return -EBUSY; |
| 2966 | } |
| 2967 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2968 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 2969 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 2970 | return -EBUSY; |
| 2971 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2972 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 2973 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 2974 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 2975 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2976 | /* |
| 2977 | * This scenario can be hit in cases where in the wlan driver after |
| 2978 | * registering the netdevices and there is a failure in driver |
| 2979 | * initialization. So return error gracefully because the netdevices |
| 2980 | * will be de-registered as part of the load failure. |
| 2981 | */ |
| 2982 | |
| 2983 | if (!cds_is_driver_loaded()) { |
| 2984 | hdd_err("Failed to start the wlan driver!!"); |
| 2985 | ret = -EIO; |
| 2986 | goto err_hdd_hdd_init_deinit_lock; |
| 2987 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 2988 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2989 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2990 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2991 | if (ret) { |
| 2992 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 2993 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2994 | } |
| 2995 | |
| 2996 | |
| 2997 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2998 | ret = hdd_start_adapter(adapter); |
| 2999 | if (ret) { |
| 3000 | hdd_err("Failed to start adapter :%d", |
| 3001 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3002 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3003 | } |
| 3004 | } |
| 3005 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3006 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3007 | 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] | 3008 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3009 | /* Enable TX queues only when we are connected */ |
| 3010 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3011 | WLAN_START_ALL_NETIF_QUEUE, |
| 3012 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3013 | } |
| 3014 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3015 | /* Enable carrier and transmit queues for NDI */ |
| 3016 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3017 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3018 | wlan_hdd_netif_queue_control(adapter, |
| 3019 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3020 | WLAN_CONTROL_PATH); |
| 3021 | } |
| 3022 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3023 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3024 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3025 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3026 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3027 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3028 | return ret; |
| 3029 | } |
| 3030 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3031 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3032 | /** |
| 3033 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3034 | * @dev: Pointer to net_device structure |
| 3035 | * |
| 3036 | * This is called in response to ifconfig up |
| 3037 | * |
| 3038 | * Return: 0 for success; non-zero for failure |
| 3039 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3040 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3041 | { |
| 3042 | int ret; |
| 3043 | |
| 3044 | cds_ssr_protect(__func__); |
| 3045 | ret = __hdd_open(dev); |
| 3046 | cds_ssr_unprotect(__func__); |
| 3047 | |
| 3048 | return ret; |
| 3049 | } |
| 3050 | |
| 3051 | /** |
| 3052 | * __hdd_stop() - HDD stop function |
| 3053 | * @dev: Pointer to net_device structure |
| 3054 | * |
| 3055 | * This is called in response to ifconfig down |
| 3056 | * |
| 3057 | * Return: 0 for success; non-zero for failure |
| 3058 | */ |
| 3059 | static int __hdd_stop(struct net_device *dev) |
| 3060 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3061 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3062 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3063 | int ret; |
| 3064 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3065 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3066 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3067 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3068 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3069 | |
| 3070 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3071 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3072 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3073 | |
| 3074 | /* Nothing to be done if the interface is not opened */ |
| 3075 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3076 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3077 | return -ENODEV; |
| 3078 | } |
| 3079 | |
| 3080 | /* Make sure the interface is marked as closed */ |
| 3081 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3082 | |
| 3083 | hdd_debug("Disabling Auto Power save timer"); |
| 3084 | sme_ps_disable_auto_ps_timer( |
| 3085 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3086 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3087 | |
| 3088 | /* |
| 3089 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3090 | * be called on that interface |
| 3091 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3092 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3093 | hdd_device_mode_to_string(adapter->device_mode), |
| 3094 | adapter->device_mode); |
| 3095 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3096 | wlan_hdd_netif_queue_control(adapter, |
| 3097 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3098 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3099 | |
| 3100 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3101 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3102 | * bursty in nature and depends on the need to transfer. The service |
| 3103 | * layer may down the interface after the usage and up again when |
| 3104 | * required. In some sense, the NDI is expected to be available |
| 3105 | * (like SAP) iface until NDI delete request is issued by the service |
| 3106 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3107 | * interface (NDI). |
| 3108 | */ |
| 3109 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3110 | return 0; |
| 3111 | |
| 3112 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3113 | * The interface is marked as down for outside world (aka kernel) |
| 3114 | * But the driver is pretty much alive inside. The driver needs to |
| 3115 | * tear down the existing connection on the netdev (session) |
| 3116 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3117 | * for this interface. The call also needs to wait until the above |
| 3118 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3119 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3120 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3121 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3122 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3123 | |
| 3124 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3125 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3126 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3127 | |
| 3128 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3129 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3130 | * this is the last cli iface, flush the scan database. |
| 3131 | */ |
| 3132 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
| 3133 | sme_scan_flush_result(hdd_ctx->hHal); |
| 3134 | |
| 3135 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3136 | * Find if any iface is up. If any iface is up then can't put device to |
| 3137 | * sleep/power save mode |
| 3138 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3139 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3140 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3141 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3142 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3143 | hdd_prevent_suspend_timeout( |
| 3144 | hdd_ctx->config->iface_change_wait_time, |
| 3145 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3146 | } |
| 3147 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3148 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3149 | return 0; |
| 3150 | } |
| 3151 | |
| 3152 | /** |
| 3153 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3154 | * @dev: pointer to net_device structure |
| 3155 | * |
| 3156 | * This is called in response to ifconfig down |
| 3157 | * |
| 3158 | * Return: 0 for success and error number for failure |
| 3159 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3160 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3161 | { |
| 3162 | int ret; |
| 3163 | |
| 3164 | cds_ssr_protect(__func__); |
| 3165 | ret = __hdd_stop(dev); |
| 3166 | cds_ssr_unprotect(__func__); |
| 3167 | |
| 3168 | return ret; |
| 3169 | } |
| 3170 | |
| 3171 | /** |
| 3172 | * __hdd_uninit() - HDD uninit function |
| 3173 | * @dev: Pointer to net_device structure |
| 3174 | * |
| 3175 | * This is called during the netdev unregister to uninitialize all data |
| 3176 | * associated with the device |
| 3177 | * |
| 3178 | * Return: None |
| 3179 | */ |
| 3180 | static void __hdd_uninit(struct net_device *dev) |
| 3181 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3182 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3183 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3184 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3185 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3186 | |
| 3187 | do { |
| 3188 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3189 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3190 | break; |
| 3191 | } |
| 3192 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3193 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3194 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3195 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3196 | break; |
| 3197 | } |
| 3198 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3199 | if (dev != adapter->dev) |
| 3200 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3201 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3202 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3203 | |
| 3204 | /* after uninit our adapter structure will no longer be valid */ |
| 3205 | adapter->dev = NULL; |
| 3206 | adapter->magic = 0; |
| 3207 | } while (0); |
| 3208 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3209 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3210 | } |
| 3211 | |
| 3212 | /** |
| 3213 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3214 | * @dev: pointer to net_device structure |
| 3215 | * |
| 3216 | * This is called during the netdev unregister to uninitialize all data |
| 3217 | * associated with the device |
| 3218 | * |
| 3219 | * Return: none |
| 3220 | */ |
| 3221 | static void hdd_uninit(struct net_device *dev) |
| 3222 | { |
| 3223 | cds_ssr_protect(__func__); |
| 3224 | __hdd_uninit(dev); |
| 3225 | cds_ssr_unprotect(__func__); |
| 3226 | } |
| 3227 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3228 | static int hdd_open_cesium_nl_sock(void) |
| 3229 | { |
| 3230 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3231 | struct netlink_kernel_cfg cfg = { |
| 3232 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3233 | .input = NULL |
| 3234 | }; |
| 3235 | #endif |
| 3236 | int ret = 0; |
| 3237 | |
| 3238 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3239 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3240 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3241 | THIS_MODULE, |
| 3242 | #endif |
| 3243 | &cfg); |
| 3244 | #else |
| 3245 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3246 | WLAN_NLINK_MCAST_GRP_ID, |
| 3247 | NULL, NULL, THIS_MODULE); |
| 3248 | #endif |
| 3249 | |
| 3250 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3251 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3252 | ret = -ECONNREFUSED; |
| 3253 | } |
| 3254 | |
| 3255 | return ret; |
| 3256 | } |
| 3257 | |
| 3258 | static void hdd_close_cesium_nl_sock(void) |
| 3259 | { |
| 3260 | if (NULL != cesium_nl_srv_sock) { |
| 3261 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3262 | cesium_nl_srv_sock = NULL; |
| 3263 | } |
| 3264 | } |
| 3265 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3266 | /** |
| 3267 | * __hdd_set_mac_address() - set the user specified mac address |
| 3268 | * @dev: Pointer to the net device. |
| 3269 | * @addr: Pointer to the sockaddr. |
| 3270 | * |
| 3271 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3272 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3273 | * |
| 3274 | * Return: 0 for success, non zero for failure |
| 3275 | */ |
| 3276 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3277 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3278 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3279 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3280 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3281 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3282 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3283 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3284 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3285 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3287 | if (netif_running(dev)) { |
| 3288 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3289 | return -EBUSY; |
| 3290 | } |
| 3291 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3292 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3293 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3294 | if (0 != ret) |
| 3295 | return ret; |
| 3296 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3297 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
| 3298 | |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3299 | if (hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes)) { |
| 3300 | hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, |
| 3301 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3302 | return -EINVAL; |
| 3303 | } |
| 3304 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3305 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3306 | hdd_err("MAC is all zero"); |
| 3307 | return -EINVAL; |
| 3308 | } |
| 3309 | |
| 3310 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3311 | hdd_err("MAC is Broadcast"); |
| 3312 | return -EINVAL; |
| 3313 | } |
| 3314 | |
| 3315 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3316 | hdd_err("MAC is Multicast"); |
| 3317 | return -EINVAL; |
| 3318 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3319 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3320 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3321 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3322 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3323 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3324 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3325 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3326 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | } |
| 3328 | |
| 3329 | /** |
| 3330 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3331 | * function from SSR |
| 3332 | * @dev: pointer to net_device structure |
| 3333 | * @addr: Pointer to the sockaddr |
| 3334 | * |
| 3335 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3336 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3337 | * |
| 3338 | * Return: 0 for success. |
| 3339 | */ |
| 3340 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3341 | { |
| 3342 | int ret; |
| 3343 | |
| 3344 | cds_ssr_protect(__func__); |
| 3345 | ret = __hdd_set_mac_address(dev, addr); |
| 3346 | cds_ssr_unprotect(__func__); |
| 3347 | |
| 3348 | return ret; |
| 3349 | } |
| 3350 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3351 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | { |
| 3353 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3354 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3355 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3356 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3357 | break; |
| 3358 | } |
| 3359 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3360 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | return NULL; |
| 3362 | |
| 3363 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3364 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3365 | } |
| 3366 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3367 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3368 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3369 | { |
| 3370 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3371 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3372 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3373 | if (!memcmp(releaseAddr, |
| 3374 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3375 | 6)) { |
| 3376 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3377 | break; |
| 3378 | } |
| 3379 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3380 | } |
| 3381 | |
| 3382 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3383 | /** |
| 3384 | * __hdd_set_multicast_list() - set the multicast address list |
| 3385 | * @dev: Pointer to the WLAN device. |
| 3386 | * @skb: Pointer to OS packet (sk_buff). |
| 3387 | * |
| 3388 | * This funciton sets the multicast address list. |
| 3389 | * |
| 3390 | * Return: None |
| 3391 | */ |
| 3392 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3393 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3394 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | int i = 0, status; |
| 3396 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3397 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3398 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3399 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3400 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3401 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3402 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3403 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3404 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3405 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3406 | status = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3407 | if (0 != status) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3408 | goto out; |
| 3409 | |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3410 | status = hdd_validate_adapter(adapter); |
| 3411 | if (status) |
| 3412 | goto out; |
| 3413 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3414 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3415 | hdd_err("%s: Driver module is closed", __func__); |
| 3416 | return; |
| 3417 | } |
| 3418 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3419 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3420 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3421 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3422 | goto out; |
| 3423 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3424 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3425 | /* Delete already configured multicast address list */ |
| 3426 | if (adapter->mc_addr_list.mc_cnt > 0) { |
| 3427 | hdd_info("clear previously configured MC address list"); |
| 3428 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3429 | pmo_mc_list_change_notify); |
| 3430 | } |
| 3431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3432 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3433 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3434 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3435 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3436 | } else { |
| 3437 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3438 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3439 | 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] | 3440 | pmo_ucfg_max_mc_addr_supported(psoc)); |
| 3441 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3442 | pmo_mc_list_change_notify); |
| 3443 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3445 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3446 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3447 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3448 | if (i == mc_count) |
| 3449 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3450 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3451 | 0, ETH_ALEN); |
| 3452 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3453 | ha->addr, ETH_ALEN); |
| 3454 | hdd_info("mlist[%d] = %pM", i, |
| 3455 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3456 | i++; |
| 3457 | } |
| 3458 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3459 | |
| 3460 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3461 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3462 | mc_list_request->count = mc_count; |
| 3463 | status = hdd_cache_mc_addr_list(mc_list_request); |
| 3464 | if (status == 0) { |
| 3465 | hdd_enable_mc_addr_filtering(adapter, |
| 3466 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | } else { |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3468 | hdd_err("error while caching mc list"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3469 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3470 | out: |
| 3471 | if (mc_list_request) |
| 3472 | qdf_mem_free(mc_list_request); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3473 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3474 | } |
| 3475 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3476 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3477 | /** |
| 3478 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3479 | * @dev: pointer to net_device |
| 3480 | * |
| 3481 | * Return: none |
| 3482 | */ |
| 3483 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3484 | { |
| 3485 | cds_ssr_protect(__func__); |
| 3486 | __hdd_set_multicast_list(dev); |
| 3487 | cds_ssr_unprotect(__func__); |
| 3488 | } |
| 3489 | #endif |
| 3490 | |
| 3491 | /** |
| 3492 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3493 | * @dev: Pointer to the WLAN device. |
| 3494 | * @skb: Pointer to OS packet (sk_buff). |
| 3495 | * |
| 3496 | * This function is registered with the Linux OS for network |
| 3497 | * core to decide which queue to use first. |
| 3498 | * |
| 3499 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3500 | */ |
| 3501 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3502 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3503 | , void *accel_priv |
| 3504 | #endif |
| 3505 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3506 | , select_queue_fallback_t fallback |
| 3507 | #endif |
| 3508 | ) |
| 3509 | { |
| 3510 | return hdd_wmm_select_queue(dev, skb); |
| 3511 | } |
| 3512 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3513 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3514 | .ndo_open = hdd_open, |
| 3515 | .ndo_stop = hdd_stop, |
| 3516 | .ndo_uninit = hdd_uninit, |
| 3517 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3518 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3519 | .ndo_get_stats = hdd_get_stats, |
| 3520 | .ndo_do_ioctl = hdd_ioctl, |
| 3521 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3522 | .ndo_select_queue = hdd_select_queue, |
| 3523 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3524 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3525 | #endif |
| 3526 | }; |
| 3527 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3528 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3529 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3530 | .ndo_open = hdd_mon_open, |
| 3531 | .ndo_stop = hdd_stop, |
| 3532 | .ndo_get_stats = hdd_get_stats, |
| 3533 | }; |
| 3534 | |
| 3535 | /** |
| 3536 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3537 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3538 | * Return: None |
| 3539 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3540 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3541 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3542 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3543 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3544 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3545 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3546 | } |
| 3547 | |
| 3548 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3549 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3550 | * @hdd_ctx: global hdd context |
| 3551 | * @macAddr: mac address to assign to the interface |
| 3552 | * @name: User-visible name of the interface |
| 3553 | * |
| 3554 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3555 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3556 | * |
| 3557 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3558 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3559 | 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] | 3560 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3561 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | const char *name) |
| 3563 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3564 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3565 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3566 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3567 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3568 | /* |
| 3569 | * cfg80211 initialization and registration.... |
| 3570 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3571 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3572 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3573 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3575 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3576 | hdd_mon_mode_ether_setup : ether_setup), |
| 3577 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3579 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3580 | |
| 3581 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3582 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3583 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3584 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3585 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3586 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3587 | sizeof(sta_ctx->conn_info.staId), |
| 3588 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3589 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3590 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3591 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3592 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3593 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3594 | qdf_status = qdf_event_create( |
| 3595 | &adapter->qdf_session_open_event); |
| 3596 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3597 | hdd_err("Session open QDF event init failed!"); |
| 3598 | free_netdev(adapter->dev); |
| 3599 | return NULL; |
| 3600 | } |
| 3601 | |
| 3602 | qdf_status = qdf_event_create( |
| 3603 | &adapter->qdf_session_close_event); |
| 3604 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3605 | hdd_err("Session close QDF event init failed!"); |
| 3606 | free_netdev(adapter->dev); |
| 3607 | return NULL; |
| 3608 | } |
| 3609 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3610 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3611 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3612 | init_completion(&adapter->linkup_event_var); |
| 3613 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3614 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3615 | init_completion(&adapter->sta_authorized_event); |
| 3616 | init_completion(&adapter->offchannel_tx_event); |
| 3617 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3618 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3619 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | |
| 3621 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3622 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3623 | adapter->disconnection_in_progress = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3624 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3625 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3626 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3627 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3629 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3630 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3631 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3632 | |
| 3633 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3634 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3636 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3637 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3638 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3639 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3640 | hdd_set_station_ops(adapter->dev); |
| 3641 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3642 | hdd_dev_setup_destructor(dev); |
| 3643 | dev->ieee80211_ptr = &adapter->wdev; |
| 3644 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3645 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3646 | adapter->wdev.netdev = dev; |
| 3647 | /* set dev's parent to underlying device */ |
| 3648 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3649 | hdd_wmm_init(adapter); |
| 3650 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3651 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3652 | } |
| 3653 | |
| 3654 | return adapter; |
| 3655 | } |
| 3656 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3657 | 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] | 3658 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3659 | struct net_device *dev = adapter->dev; |
| 3660 | int ret; |
| 3661 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3662 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3663 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3664 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3665 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3666 | |
| 3667 | ret = dev_alloc_name(dev, dev->name); |
| 3668 | if (ret < 0) { |
| 3669 | hdd_err( |
| 3670 | "unable to get dev name: %s, err = 0x%x", |
| 3671 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3672 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3673 | } |
| 3674 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3675 | |
| 3676 | ret = register_netdevice(dev); |
| 3677 | if (ret) { |
| 3678 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3679 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3680 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3681 | } |
| 3682 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3683 | ret = register_netdev(dev); |
| 3684 | if (ret) { |
| 3685 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3686 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3687 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | } |
| 3689 | } |
| 3690 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3691 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3692 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3693 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3694 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3695 | } |
| 3696 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3697 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3699 | struct hdd_adapter *adapter; |
| 3700 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3702 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3703 | if (!hdd_ctx) { |
| 3704 | hdd_err("Invalid HDD_CTX"); |
| 3705 | return QDF_STATUS_E_FAILURE; |
| 3706 | } |
| 3707 | |
| 3708 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3709 | if (NULL == adapter) { |
| 3710 | hdd_err("NULL adapter"); |
| 3711 | return QDF_STATUS_E_INVAL; |
| 3712 | } |
| 3713 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3714 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3715 | hdd_debug("session %d opened", adapter->session_id); |
| 3716 | |
| 3717 | return QDF_STATUS_SUCCESS; |
| 3718 | } |
| 3719 | |
| 3720 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3721 | { |
| 3722 | struct hdd_adapter *adapter; |
| 3723 | struct hdd_context *hdd_ctx; |
| 3724 | |
| 3725 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3726 | if (!hdd_ctx) { |
| 3727 | hdd_err("Invalid HDD_CTX"); |
| 3728 | return QDF_STATUS_E_FAILURE; |
| 3729 | } |
| 3730 | |
| 3731 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3732 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3733 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3734 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3735 | } |
| 3736 | |
| 3737 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3738 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3739 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3740 | } |
| 3741 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3742 | /* |
| 3743 | * For NAN Data interface, the close session results in the final |
| 3744 | * indication to the userspace |
| 3745 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3746 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3747 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3748 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3749 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3750 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | /* |
| 3752 | * We can be blocked while waiting for scheduled work to be |
| 3753 | * flushed, and the adapter structure can potentially be freed, in |
| 3754 | * which case the magic will have been reset. So make sure the |
| 3755 | * magic is still good, and hence the adapter structure is still |
| 3756 | * valid, before signaling completion |
| 3757 | */ |
| 3758 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3759 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3760 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3761 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3762 | } |
| 3763 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3764 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3765 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3766 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3767 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3768 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3769 | if (QDF_IS_STATUS_ERROR(status)) |
| 3770 | return qdf_status_to_os_return(status); |
| 3771 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3772 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3773 | if (QDF_IS_STATUS_ERROR(status)) |
| 3774 | return qdf_status_to_os_return(status); |
| 3775 | |
| 3776 | if (wma_capability_enhanced_mcast_filter()) |
| 3777 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3778 | else |
| 3779 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3780 | |
| 3781 | return qdf_status_to_os_return(status); |
| 3782 | } |
| 3783 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3784 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3785 | { |
| 3786 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3787 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3788 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3789 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3790 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3791 | vdev_id = adapter->session_id; |
| 3792 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3793 | |
| 3794 | /* vdev created sanity check */ |
| 3795 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3796 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3797 | return -EINVAL; |
| 3798 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3799 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3800 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3801 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3802 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3803 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3804 | status = sme_close_session(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3805 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3806 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3807 | errno = qdf_status_to_os_return(status); |
| 3808 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3809 | } |
| 3810 | |
| 3811 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3812 | status = qdf_wait_for_event_completion( |
| 3813 | &adapter->qdf_session_close_event, |
| 3814 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3815 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3816 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3817 | hdd_ndp_session_end_handler(adapter); |
| 3818 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3819 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3820 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3821 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3822 | errno = -ETIMEDOUT; |
| 3823 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3824 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3825 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3826 | errno = -EINVAL; |
| 3827 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3828 | } else { |
| 3829 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3830 | errno = -EINVAL; |
| 3831 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3832 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3833 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3834 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3835 | release_vdev: |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3836 | /* |
| 3837 | * In SSR or driver unloading case, directly exit may cause objects |
| 3838 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3839 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3840 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3841 | return errno; |
| 3842 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3843 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3844 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3845 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3846 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3847 | return errno; |
| 3848 | } |
| 3849 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3850 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3851 | |
| 3852 | return 0; |
| 3853 | } |
| 3854 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3855 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3856 | struct sme_session_params *session_param, |
| 3857 | csr_roam_completeCallback callback, |
| 3858 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3859 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3860 | uint32_t type; |
| 3861 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3862 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3863 | |
| 3864 | /* determine vdev (sub)type */ |
| 3865 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3866 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3867 | hdd_err("failed to get vdev type: %d", status); |
| 3868 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3869 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3870 | session_param->sme_session_id = adapter->session_id; |
| 3871 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3872 | session_param->type_of_persona = type; |
| 3873 | session_param->subtype_of_persona = sub_type; |
| 3874 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3875 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3876 | session_param->callback = callback; |
| 3877 | session_param->callback_ctx = callback_ctx; |
| 3878 | |
| 3879 | return 0; |
| 3880 | } |
| 3881 | |
| 3882 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 3883 | csr_roam_completeCallback callback, void *ctx) |
| 3884 | { |
| 3885 | QDF_STATUS status; |
| 3886 | int errno; |
| 3887 | struct hdd_context *hdd_ctx; |
| 3888 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3889 | |
| 3890 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3891 | |
| 3892 | /* do vdev create via objmgr */ |
| 3893 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3894 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3895 | if (errno) { |
| 3896 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 3897 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3898 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3899 | |
| 3900 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3901 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 3902 | if (QDF_STATUS_SUCCESS != status) { |
| 3903 | hdd_err("failed to reinit session open event"); |
| 3904 | return -EINVAL; |
| 3905 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3906 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 3907 | callback, ctx); |
| 3908 | if (errno) { |
| 3909 | hdd_err("failed to populating SME params"); |
| 3910 | goto objmgr_vdev_destroy_procedure; |
| 3911 | } |
| 3912 | |
| 3913 | status = sme_open_session(hdd_ctx->hHal, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3914 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3915 | hdd_err("failed to open sme session: %d", status); |
| 3916 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3917 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3918 | } |
| 3919 | |
| 3920 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3921 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 3922 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3923 | if (QDF_STATUS_SUCCESS != status) { |
| 3924 | if (adapter->qdf_session_open_event.force_set) { |
| 3925 | /* |
| 3926 | * SSR/PDR has caused shutdown, which has forcefully |
| 3927 | * set the event. Return without the closing session. |
| 3928 | */ |
| 3929 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3930 | hdd_err("Session open event forcefully set"); |
| 3931 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3932 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 3933 | |
| 3934 | if (QDF_STATUS_E_TIMEOUT == status) |
| 3935 | hdd_err("Session failed to open within timeout period"); |
| 3936 | else |
| 3937 | hdd_err("Failed to wait for session open event(status-%d)", |
| 3938 | status); |
| 3939 | errno = -ETIMEDOUT; |
| 3940 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3941 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3942 | } |
| 3943 | |
| 3944 | /* firmware ready for component communication, raise vdev_ready event */ |
| 3945 | errno = hdd_vdev_ready(adapter); |
| 3946 | if (errno) { |
| 3947 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3948 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3949 | } |
| 3950 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 3951 | if (adapter->device_mode == QDF_STA_MODE) { |
| 3952 | hdd_debug("setting RTT mac randomization param: %d", |
| 3953 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 3954 | errno = sme_cli_set_command(adapter->session_id, |
| 3955 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 3956 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 3957 | VDEV_CMD); |
| 3958 | if (0 != errno) |
| 3959 | hdd_err("RTT mac randomization param set failed %d", |
| 3960 | errno); |
| 3961 | } |
| 3962 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3963 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3964 | |
| 3965 | return 0; |
| 3966 | |
| 3967 | /* |
| 3968 | * Due to legacy constraints, we need to destroy in the same order as |
| 3969 | * create. So, split error handling into 2 cases to accommodate. |
| 3970 | */ |
| 3971 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3972 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 3973 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3974 | |
| 3975 | return errno; |
| 3976 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 3977 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3978 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 3979 | |
| 3980 | return errno; |
| 3981 | } |
| 3982 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3983 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3984 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3985 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3986 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3987 | QDF_STATUS status; |
| 3988 | int ret_val; |
| 3989 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3990 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3991 | sme_set_curr_device_mode(hdd_ctx->hHal, adapter->device_mode); |
| 3992 | 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] | 3993 | sme_set_vdev_ies_per_band(hdd_ctx->hHal, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3994 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 3995 | hdd_roam_profile_init(adapter); |
| 3996 | hdd_register_wext(adapter->dev); |
| 3997 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 3998 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3999 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4000 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4001 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4002 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4003 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4004 | status = sme_config_fast_roaming(hdd_ctx->hHal, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4005 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4006 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4007 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4008 | hdd_ctx->config->OperatingChannel; |
| 4009 | |
| 4010 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4011 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4012 | |
| 4013 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4014 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4015 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4016 | status, status); |
| 4017 | goto error_init_txrx; |
| 4018 | } |
| 4019 | |
| 4020 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4021 | |
| 4022 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4023 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4024 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4025 | status, status); |
| 4026 | goto error_wmm_init; |
| 4027 | } |
| 4028 | |
| 4029 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4030 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4031 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4032 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4033 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4034 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4035 | if (ret_val) |
| 4036 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4037 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4038 | /* |
| 4039 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4040 | * during that time, then as part of SSR init, do not enable |
| 4041 | * the LRO again. Keep the LRO state same as before SSR. |
| 4042 | */ |
| 4043 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4044 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4045 | |
| 4046 | /* rcpi info initialization */ |
| 4047 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4048 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4049 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4050 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4051 | error_wmm_init: |
| 4052 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4053 | hdd_deinit_tx_rx(adapter); |
| 4054 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4055 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4056 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4057 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4058 | return status; |
| 4059 | } |
| 4060 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4061 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4062 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4063 | * @hdd_ctx: global hdd context |
| 4064 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4065 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4066 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4067 | * |
| 4068 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4069 | * |
| 4070 | * Return: None. |
| 4071 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4072 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4073 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4074 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4075 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4076 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4077 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4078 | if (adapter->dev) { |
| 4079 | if (rtnl_held) |
| 4080 | adapter->dev->wireless_handlers = NULL; |
| 4081 | else { |
| 4082 | rtnl_lock(); |
| 4083 | adapter->dev->wireless_handlers = NULL; |
| 4084 | rtnl_unlock(); |
| 4085 | } |
| 4086 | } |
| 4087 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4088 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4089 | hdd_deinit_tx_rx(adapter); |
| 4090 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4091 | } |
| 4092 | |
| 4093 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4094 | hdd_wmm_adapter_close(adapter); |
| 4095 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4096 | } |
| 4097 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4098 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4099 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4100 | } |
| 4101 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4102 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4103 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4104 | bool rtnl_held) |
| 4105 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4106 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4107 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4108 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4109 | case QDF_STA_MODE: |
| 4110 | case QDF_P2P_CLIENT_MODE: |
| 4111 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4112 | case QDF_IBSS_MODE: |
| 4113 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4114 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4115 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4116 | break; |
| 4117 | } |
| 4118 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4119 | case QDF_SAP_MODE: |
| 4120 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4121 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4122 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4123 | break; |
| 4124 | } |
| 4125 | |
| 4126 | default: |
| 4127 | break; |
| 4128 | } |
| 4129 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4130 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4131 | } |
| 4132 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4133 | 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] | 4134 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4135 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4136 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4137 | |
| 4138 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4139 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4140 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4141 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4142 | return; |
| 4143 | } |
| 4144 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4145 | hdd_nud_deinit_tracking(adapter); |
| 4146 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4147 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4148 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4149 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4150 | /* |
| 4151 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4152 | * the driver is almost closed and cannot handle either control |
| 4153 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4154 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4155 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4156 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4157 | * the interface is closed and restricts any operations on that |
| 4158 | */ |
| 4159 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4160 | |
| 4161 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4162 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4163 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4164 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4165 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4166 | /* |
| 4167 | * Note that the adapter is no longer valid at this point |
| 4168 | * since the memory has been reclaimed |
| 4169 | */ |
| 4170 | } |
| 4171 | } |
| 4172 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4173 | 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] | 4174 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4176 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4177 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4178 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4179 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4180 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4181 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4182 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4183 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4184 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4185 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4186 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4187 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4188 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4189 | /** |
| 4190 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4191 | * @hdd_ctx: HDD Context |
| 4192 | * @adapter: HDD Adapter |
| 4193 | * |
| 4194 | * This function set the FW Debug log level based on the INI. |
| 4195 | * |
| 4196 | * Return: None |
| 4197 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4198 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4199 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4200 | { |
| 4201 | uint8_t count = 0, numentries = 0, |
| 4202 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4203 | uint32_t value = 0; |
| 4204 | int ret; |
| 4205 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4206 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4207 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4208 | 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] | 4209 | return; |
| 4210 | } |
| 4211 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4212 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4213 | hdd_ctx->fw_log_settings.dl_type = |
| 4214 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4215 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4216 | WMI_DBGLOG_TYPE, |
| 4217 | hdd_ctx->config->enableFwLogType, |
| 4218 | DBG_CMD); |
| 4219 | if (ret != 0) |
| 4220 | hdd_err("Failed to enable FW log type ret %d", |
| 4221 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4222 | |
| 4223 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4224 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4225 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4226 | WMI_DBGLOG_LOG_LEVEL, |
| 4227 | hdd_ctx->config->enableFwLogLevel, |
| 4228 | DBG_CMD); |
| 4229 | if (ret != 0) |
| 4230 | hdd_err("Failed to enable FW log level ret %d", |
| 4231 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4232 | |
| 4233 | hdd_string_to_u8_array( |
| 4234 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4235 | moduleloglevel, |
| 4236 | &numentries, |
| 4237 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4238 | |
| 4239 | while (count < numentries) { |
| 4240 | /* |
| 4241 | * FW module log level input string looks like |
| 4242 | * below: |
| 4243 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4244 | * <Log Level>,... |
| 4245 | * For example: |
| 4246 | * gFwDebugModuleLoglevel= |
| 4247 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4248 | * Above input string means : |
| 4249 | * For FW module ID 1 enable log level 0 |
| 4250 | * For FW module ID 2 enable log level 1 |
| 4251 | * For FW module ID 3 enable log level 2 |
| 4252 | * For FW module ID 4 enable log level 3 |
| 4253 | * For FW module ID 5 enable log level 4 |
| 4254 | * For FW module ID 6 enable log level 5 |
| 4255 | * For FW module ID 7 enable log level 6 |
| 4256 | */ |
| 4257 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4258 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4259 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4260 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4261 | moduleloglevel[count], |
| 4262 | moduleloglevel[count + 1]); |
| 4263 | return; |
| 4264 | } |
| 4265 | |
| 4266 | value = moduleloglevel[count] << 16; |
| 4267 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4268 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4269 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4270 | value, DBG_CMD); |
| 4271 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4272 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4273 | value, ret); |
| 4274 | |
| 4275 | count += 2; |
| 4276 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4277 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4278 | } |
| 4279 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4280 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4281 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4282 | { |
| 4283 | } |
| 4284 | |
| 4285 | #endif |
| 4286 | |
| 4287 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4288 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4289 | * @adapter: HDD adapter |
| 4290 | * |
| 4291 | * Return: 0 on success or errno on failure |
| 4292 | */ |
| 4293 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4294 | { |
| 4295 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4296 | QDF_STATUS status; |
| 4297 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4298 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4299 | |
| 4300 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4301 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4302 | hdd_ctx->config->txchainmask1x1, |
| 4303 | hdd_ctx->config->rxchainmask1x1); |
| 4304 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4305 | hdd_ctx->config->dual_mac_feature_disable, |
| 4306 | hdd_ctx->config->tx_chain_mask_2g, |
| 4307 | hdd_ctx->config->rx_chain_mask_2g); |
| 4308 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4309 | hdd_ctx->config->tx_chain_mask_5g, |
| 4310 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4311 | hdd_debug("enable_bt_chain_separation %d", |
| 4312 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4313 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4314 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4315 | HW_MODE_DBS_NONE, |
| 4316 | CDS_BAND_ALL); |
| 4317 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4318 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4319 | return qdf_status_to_os_return(status); |
| 4320 | } |
| 4321 | |
| 4322 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4323 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4324 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4325 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
| 4326 | hdd_info("firmware not capable. skip chain mask programming"); |
| 4327 | return 0; |
| 4328 | } |
| 4329 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4330 | if (hdd_ctx->config->enable2x2 && |
| 4331 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4332 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4333 | return 0; |
| 4334 | } |
| 4335 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4336 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4337 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4338 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4339 | hdd_ctx->config->dual_mac_feature_disable); |
| 4340 | return 0; |
| 4341 | } |
| 4342 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4343 | if (hdd_ctx->lte_coex_ant_share) { |
| 4344 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4345 | return 0; |
| 4346 | } |
| 4347 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4348 | if (hdd_ctx->config->txchainmask1x1) { |
| 4349 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4350 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4351 | hdd_ctx->config->txchainmask1x1, |
| 4352 | PDEV_CMD); |
| 4353 | if (ret_val) |
| 4354 | goto error; |
| 4355 | } |
| 4356 | |
| 4357 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4358 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4359 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4360 | hdd_ctx->config->rxchainmask1x1, |
| 4361 | PDEV_CMD); |
| 4362 | if (ret_val) |
| 4363 | goto error; |
| 4364 | } |
| 4365 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4366 | if (hdd_ctx->config->txchainmask1x1 || |
| 4367 | hdd_ctx->config->rxchainmask1x1) { |
| 4368 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4369 | return 0; |
| 4370 | } |
| 4371 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4372 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4373 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4374 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4375 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4376 | if (0 != ret_val) |
| 4377 | goto error; |
| 4378 | } |
| 4379 | |
| 4380 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4381 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4382 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4383 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4384 | if (0 != ret_val) |
| 4385 | goto error; |
| 4386 | } |
| 4387 | |
| 4388 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4389 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4390 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4391 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4392 | if (0 != ret_val) |
| 4393 | goto error; |
| 4394 | } |
| 4395 | |
| 4396 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4397 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4398 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4399 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4400 | if (0 != ret_val) |
| 4401 | goto error; |
| 4402 | } |
| 4403 | |
| 4404 | return 0; |
| 4405 | |
| 4406 | error: |
| 4407 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4408 | return -EINVAL; |
| 4409 | } |
| 4410 | |
| 4411 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4412 | * hdd_set_fw_params() - Set parameters to firmware |
| 4413 | * @adapter: HDD adapter |
| 4414 | * |
| 4415 | * This function Sets various parameters to fw once the |
| 4416 | * adapter is started. |
| 4417 | * |
| 4418 | * Return: 0 on success or errno on failure |
| 4419 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4420 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4421 | { |
| 4422 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4423 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4424 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4425 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4426 | |
| 4427 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4428 | if (!hdd_ctx) |
| 4429 | return -EINVAL; |
| 4430 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4431 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4432 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4433 | return 0; |
| 4434 | } |
| 4435 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4436 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4437 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4438 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4439 | if (ret) { |
| 4440 | hdd_err("Failed to set LPRx"); |
| 4441 | goto error; |
| 4442 | } |
| 4443 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4444 | |
| 4445 | ret = sme_cli_set_command( |
| 4446 | adapter->session_id, |
| 4447 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4448 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4449 | PDEV_CMD); |
| 4450 | if (ret) { |
| 4451 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4452 | goto error; |
| 4453 | } |
| 4454 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4455 | ret = sme_cli_set_command( |
| 4456 | adapter->session_id, |
| 4457 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4458 | hdd_ctx->config->enable_tx_sch_delay, |
| 4459 | PDEV_CMD); |
| 4460 | if (ret) { |
| 4461 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4462 | goto error; |
| 4463 | } |
| 4464 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4465 | ret = sme_cli_set_command( |
| 4466 | adapter->session_id, |
| 4467 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4468 | hdd_ctx->config->enable_secondary_rate, |
| 4469 | PDEV_CMD); |
| 4470 | if (ret) { |
| 4471 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4472 | goto error; |
| 4473 | } |
| 4474 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4475 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4476 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4477 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4478 | hdd_ctx->config->upper_brssi_thresh); |
| 4479 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4480 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4481 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4482 | hdd_ctx->config->lower_brssi_thresh); |
| 4483 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4484 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4485 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4486 | hdd_ctx->config->enable_dtim_1chrx); |
| 4487 | } |
| 4488 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4489 | if (hdd_ctx->config->enable2x2) { |
| 4490 | hdd_debug("configuring 2x2 mode fw params"); |
| 4491 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4492 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4493 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4494 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4495 | PDEV_CMD); |
| 4496 | if (ret) { |
| 4497 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4498 | ret); |
| 4499 | goto error; |
| 4500 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4501 | |
| 4502 | if (hdd_configure_chain_mask(adapter)) |
| 4503 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4504 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4505 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4506 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4507 | hdd_debug("configuring 1x1 mode fw params"); |
| 4508 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4509 | /* |
| 4510 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4511 | * we are passing two value |
| 4512 | * as param_id << 29 | param_value. |
| 4513 | * Below param_value = 0(disable) |
| 4514 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4515 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4516 | WMI_STA_SMPS_PARAM_CMDID, |
| 4517 | HDD_DTIM_1CHAIN_RX_ID << |
| 4518 | HDD_SMPS_PARAM_VALUE_S, |
| 4519 | VDEV_CMD); |
| 4520 | if (ret) { |
| 4521 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4522 | goto error; |
| 4523 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4524 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4525 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4526 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4527 | |
| 4528 | if (hdd_configure_chain_mask(adapter)) |
| 4529 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4530 | } |
| 4531 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4532 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4533 | WMI_PDEV_PARAM_HYST_EN, |
| 4534 | hdd_ctx->config->enableMemDeepSleep, |
| 4535 | PDEV_CMD); |
| 4536 | if (ret) { |
| 4537 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4538 | goto error; |
| 4539 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4540 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4541 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4542 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4543 | hdd_ctx->config->rts_profile, |
| 4544 | VDEV_CMD); |
| 4545 | if (ret) { |
| 4546 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4547 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4548 | } |
| 4549 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4550 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4551 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4552 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4553 | GEN_VDEV_PARAM_AMSDU, |
| 4554 | hdd_ctx->config->max_amsdu_num, |
| 4555 | GEN_CMD); |
| 4556 | if (ret != 0) { |
| 4557 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4558 | goto error; |
| 4559 | } |
| 4560 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4561 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4562 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4563 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4564 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4565 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4566 | error: |
| 4567 | return -EINVAL; |
| 4568 | } |
| 4569 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4570 | /** |
| 4571 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4572 | * @hdd_ctx: global hdd context |
| 4573 | * @session_type: type of the interface to be created |
| 4574 | * @iface_name: User-visible name of the interface |
| 4575 | * @macAddr: MAC address to assign to the interface |
| 4576 | * @name_assign_type: the name of assign type of the netdev |
| 4577 | * @rtnl_held: the rtnl lock hold flag |
| 4578 | * |
| 4579 | * This function open and setup the hdd adpater according to the device |
| 4580 | * type request, assign the name, the mac address assigned, and then prepared |
| 4581 | * the hdd related parameters, queue, lock and ready to start. |
| 4582 | * |
| 4583 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4584 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4585 | 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] | 4586 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4587 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4588 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4589 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4590 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4591 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4592 | |
| 4593 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4594 | /* |
| 4595 | * Max limit reached on the number of vdevs configured by the |
| 4596 | * host. Return error |
| 4597 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4598 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4599 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4600 | return NULL; |
| 4601 | } |
| 4602 | |
| 4603 | if (macAddr == NULL) { |
| 4604 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4605 | 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] | 4606 | return NULL; |
| 4607 | } |
| 4608 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4609 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4610 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4611 | " already exists", |
| 4612 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4613 | return NULL; |
| 4614 | } |
| 4615 | |
| 4616 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4617 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4618 | /* Reset locally administered bit if the device mode is STA */ |
| 4619 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4620 | hdd_info("locally administered bit reset in sta mode: " |
| 4621 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4622 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4623 | case QDF_P2P_CLIENT_MODE: |
| 4624 | case QDF_P2P_DEVICE_MODE: |
| 4625 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4626 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4627 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4628 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4629 | name_assign_type, |
| 4630 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4631 | |
| 4632 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4633 | hdd_err("failed to allocate adapter for session %d", |
| 4634 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4635 | return NULL; |
| 4636 | } |
| 4637 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4638 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4639 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4640 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4641 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4642 | else if (QDF_MONITOR_MODE == session_type) |
| 4643 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4644 | else |
| 4645 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4646 | |
| 4647 | adapter->device_mode = session_type; |
| 4648 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4649 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4650 | /* |
| 4651 | * Workqueue which gets scheduled in IPv4 notification |
| 4652 | * callback |
| 4653 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4654 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4655 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4656 | |
| 4657 | #ifdef WLAN_NS_OFFLOAD |
| 4658 | /* |
| 4659 | * Workqueue which gets scheduled in IPv6 |
| 4660 | * notification callback. |
| 4661 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4662 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4663 | hdd_ipv6_notifier_work_queue); |
| 4664 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4665 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4666 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4667 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4668 | |
| 4669 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4670 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4671 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4672 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4673 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4674 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4675 | /* Initialize NAN Data Interface */ |
| 4676 | if (QDF_NDI_MODE == session_type) { |
| 4677 | status = hdd_init_nan_data_mode(adapter); |
| 4678 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4679 | goto err_free_netdev; |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4680 | } |
| 4681 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4682 | hdd_nud_init_tracking(adapter); |
| 4683 | |
| 4684 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4685 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4686 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4687 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4688 | case QDF_P2P_GO_MODE: |
| 4689 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4690 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4691 | name_assign_type, |
| 4692 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4693 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4694 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4695 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4696 | return NULL; |
| 4697 | } |
| 4698 | |
| 4699 | adapter->wdev.iftype = |
| 4700 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4701 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4702 | NL80211_IFTYPE_P2P_GO; |
| 4703 | adapter->device_mode = session_type; |
| 4704 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4705 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4706 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4707 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4708 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4709 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4710 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4711 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4712 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4713 | |
| 4714 | /* |
| 4715 | * Workqueue which gets scheduled in IPv4 notification |
| 4716 | * callback |
| 4717 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4718 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4719 | hdd_ipv4_notifier_work_queue); |
| 4720 | |
| 4721 | #ifdef WLAN_NS_OFFLOAD |
| 4722 | /* |
| 4723 | * Workqueue which gets scheduled in IPv6 |
| 4724 | * notification callback. |
| 4725 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4726 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4727 | hdd_ipv6_notifier_work_queue); |
| 4728 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4729 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4730 | case QDF_FTM_MODE: |
| 4731 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4732 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4733 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4734 | if (NULL == adapter) { |
| 4735 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4736 | return NULL; |
| 4737 | } |
| 4738 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4739 | adapter->device_mode = session_type; |
| 4740 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4741 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4742 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4743 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4744 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4745 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4746 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4747 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4748 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4749 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4750 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4751 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4752 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | return NULL; |
| 4754 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4755 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4756 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
| 4757 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4758 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4759 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4760 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4761 | } |
| 4762 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4763 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4764 | if (NULL != adapter) { |
| 4765 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4766 | adapter = NULL; |
| 4767 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4768 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4769 | return NULL; |
| 4770 | } |
| 4771 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4772 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4773 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4774 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4775 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4776 | /* Adapter successfully added. Increment the vdev count */ |
| 4777 | hdd_ctx->current_intf_count++; |
| 4778 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4779 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4780 | hdd_ctx->current_intf_count); |
| 4781 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4782 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4783 | } |
| 4784 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4785 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4786 | hdd_err("Interface %s wow debug_fs init failed", |
| 4787 | netdev_name(adapter->dev)); |
| 4788 | |
| 4789 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4790 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4791 | |
| 4792 | return adapter; |
| 4793 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4794 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4795 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4796 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4797 | |
| 4798 | return NULL; |
| 4799 | } |
| 4800 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4801 | #ifdef MSM_PLATFORM |
| 4802 | static inline |
| 4803 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4804 | { |
| 4805 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4806 | } |
| 4807 | #else |
| 4808 | static inline |
| 4809 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4810 | { |
| 4811 | } |
| 4812 | #endif |
| 4813 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4814 | 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] | 4815 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4816 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4817 | /* |
| 4818 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4819 | * |
| 4820 | * The reason is to fix one race condition between |
| 4821 | * bus bandwidth work and cleaning up an adapter. |
| 4822 | * Under some conditions, it is possible for the bus bandwidth |
| 4823 | * work to access a particularly destroyed adapter, leading to |
| 4824 | * use-after-free. |
| 4825 | */ |
| 4826 | hdd_debug("wait for bus bw work to flush"); |
| 4827 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4828 | hdd_bus_bw_cancel_work(hdd_ctx); |
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 | /* cleanup adapter */ |
| 4831 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4832 | adapter->device_mode); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4833 | hdd_remove_adapter(hdd_ctx, adapter); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 4834 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4835 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4836 | /* conditionally restart the bw timer */ |
| 4837 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4838 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4839 | /* Adapter removed. Decrement vdev count */ |
| 4840 | if (hdd_ctx->current_intf_count != 0) |
| 4841 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4842 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4843 | /* Fw will take care incase of concurrency */ |
| 4844 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4845 | } |
| 4846 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4847 | /** |
| 4848 | * hdd_close_all_adapters - Close all open adapters |
| 4849 | * @hdd_ctx: Hdd context |
| 4850 | * rtnl_held: True if RTNL lock held |
| 4851 | * |
| 4852 | * Close all open adapters. |
| 4853 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4854 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4855 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4856 | 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] | 4857 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4858 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4859 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4860 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4861 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4862 | |
| 4863 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4864 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4865 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4866 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4867 | adapter->mac_addr.bytes); |
| 4868 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4869 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4870 | /* Adapter removed. Decrement vdev count */ |
| 4871 | if (hdd_ctx->current_intf_count != 0) |
| 4872 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4873 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4874 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4875 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4876 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4877 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4878 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4879 | } |
| 4880 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4881 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4882 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 4883 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4884 | tSirUpdateIE updateIE; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4885 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4886 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4887 | case QDF_STA_MODE: |
| 4888 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4889 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4890 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4891 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4892 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | break; |
| 4894 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4895 | case QDF_SAP_MODE: |
| 4896 | case QDF_P2P_GO_MODE: |
| 4897 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4898 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4899 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | break; |
| 4901 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4902 | case QDF_FTM_MODE: |
| 4903 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4904 | default: |
| 4905 | /* |
| 4906 | * wlan_hdd_reset_prob_rspies should not have been called |
| 4907 | * for these kind of devices |
| 4908 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4909 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4910 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4911 | return; |
| 4912 | } |
| 4913 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 4914 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4915 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4916 | updateIE.ieBufferlength = 0; |
| 4917 | updateIE.pAdditionIEBuffer = NULL; |
| 4918 | updateIE.append = true; |
| 4919 | updateIE.notify = false; |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 4920 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4921 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4922 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4923 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4924 | } |
| 4925 | } |
| 4926 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 4927 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 4928 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4929 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 4930 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 4931 | } |
| 4932 | |
| 4933 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 4934 | struct hdd_adapter *adapter, |
| 4935 | enum hdd_adapter_stop_flag_t flag) |
| 4936 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4937 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4938 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4939 | union iwreq_data wrqu; |
| 4940 | tSirUpdateIE updateIE; |
| 4941 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 4942 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4943 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4944 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4945 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 4946 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 4947 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 4948 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4949 | hdd_nud_ignore_tracking(adapter, true); |
| 4950 | hdd_nud_reset_tracking(adapter); |
| 4951 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4952 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4953 | wlan_hdd_netif_queue_control(adapter, |
| 4954 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4955 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 4956 | /* |
| 4957 | * if this is the last active connection check & stop the |
| 4958 | * opportunistic timer first |
| 4959 | */ |
| 4960 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 4961 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 4962 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4963 | adapter->device_mode), NULL) == 1)) || |
| 4964 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 4965 | policy_mgr_check_and_stop_opportunistic_timer( |
| 4966 | hdd_ctx->hdd_psoc, adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4967 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4968 | case QDF_STA_MODE: |
| 4969 | case QDF_P2P_CLIENT_MODE: |
| 4970 | case QDF_IBSS_MODE: |
| 4971 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4972 | case QDF_NDI_MODE: |
| 4973 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 4974 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4975 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 4976 | hdd_is_connecting( |
| 4977 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4978 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4979 | roam_profile = hdd_roam_profile(adapter); |
| 4980 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4981 | if (QDF_NDI_MODE == adapter->device_mode) |
| 4982 | qdf_ret_status = sme_roam_disconnect( |
| 4983 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4984 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4985 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 4986 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4987 | eCSR_BSS_TYPE_START_IBSS) |
| 4988 | qdf_ret_status = sme_roam_disconnect( |
| 4989 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4990 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4991 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4992 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 4993 | qdf_ret_status = |
| 4994 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 4995 | hdd_debug("Send disconnected event to userspace"); |
| 4996 | wlan_hdd_cfg80211_indicate_disconnect( |
| 4997 | adapter->dev, true, |
| 4998 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 4999 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5000 | qdf_ret_status = sme_roam_disconnect( |
| 5001 | hdd_ctx->hHal, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5002 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5003 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5004 | /* success implies disconnect command got |
| 5005 | * queued up successfully |
| 5006 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5007 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5008 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5009 | rc = wait_for_completion_timeout( |
| 5010 | &adapter->disconnect_comp_var, |
| 5011 | msecs_to_jiffies |
| 5012 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5013 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5014 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5015 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5016 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5017 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5018 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5019 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5020 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5021 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5022 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5023 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5024 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5025 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5026 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5027 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | |
| 5029 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5030 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5031 | #endif |
| 5032 | |
| 5033 | hdd_deregister_tx_flow_control(adapter); |
| 5034 | |
| 5035 | #ifdef WLAN_NS_OFFLOAD |
| 5036 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5037 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5038 | #endif |
| 5039 | #endif |
| 5040 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5041 | if (adapter->device_mode == QDF_STA_MODE) |
| 5042 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5043 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5044 | |
| 5045 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5046 | hdd_err("Error: Can't disconnect adapter"); |
| 5047 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5048 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5049 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5050 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5051 | break; |
| 5052 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5053 | case QDF_MONITOR_MODE: |
| 5054 | wlan_hdd_scan_abort(adapter); |
| 5055 | hdd_deregister_tx_flow_control(adapter); |
| 5056 | hdd_vdev_destroy(adapter); |
| 5057 | break; |
| 5058 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5059 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5060 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5061 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5062 | sap_config = &adapter->session.ap.sap_config; |
| 5063 | if (sap_config) |
| 5064 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5065 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5066 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5067 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5068 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5069 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5070 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5071 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5072 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5073 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5074 | cds_flush_delayed_work( |
| 5075 | &adapter->acs_pending_work); |
| 5076 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5077 | } |
| 5078 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5079 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5080 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5081 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5082 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5083 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5084 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5085 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5086 | |
| 5087 | hdd_deregister_tx_flow_control(adapter); |
| 5088 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5089 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5090 | mutex_lock(&hdd_ctx->sap_lock); |
| 5091 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5092 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5093 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5094 | |
| 5095 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | status = wlansap_stop_bss( |
| 5097 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5098 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5099 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5100 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5101 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5102 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5103 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5104 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5105 | qdf_wait_for_event_completion( |
| 5106 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5107 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5108 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5109 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5110 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5111 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5112 | } |
| 5113 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5114 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5115 | } |
| 5116 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5117 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5118 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5119 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5120 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5121 | adapter->device_mode, |
| 5122 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5123 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5124 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5125 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5126 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5127 | updateIE.ieBufferlength = 0; |
| 5128 | updateIE.pAdditionIEBuffer = NULL; |
| 5129 | updateIE.append = false; |
| 5130 | updateIE.notify = false; |
| 5131 | /* Probe bcn reset */ |
| 5132 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5133 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5134 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5135 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5136 | } |
| 5137 | /* Assoc resp reset */ |
| 5138 | if (sme_update_add_ie(WLAN_HDD_GET_HAL_CTX(adapter), |
| 5139 | &updateIE, |
| 5140 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5141 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5142 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5143 | } |
| 5144 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5145 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5146 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5147 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5148 | qdf_mem_free(adapter->session.ap.beacon); |
| 5149 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5150 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5151 | /* |
| 5152 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5153 | */ |
| 5154 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5155 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5156 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5157 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5158 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5159 | #endif |
| 5160 | |
| 5161 | #ifdef WLAN_NS_OFFLOAD |
| 5162 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5163 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5164 | #endif |
| 5165 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5166 | |
| 5167 | hdd_vdev_destroy(adapter); |
| 5168 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5169 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5170 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5171 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5172 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5173 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5174 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5175 | hdd_deregister_tx_flow_control(adapter); |
| 5176 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5177 | break; |
| 5178 | default: |
| 5179 | break; |
| 5180 | } |
| 5181 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5182 | if (adapter->scan_info.default_scan_ies) { |
| 5183 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5184 | adapter->scan_info.default_scan_ies = NULL; |
| 5185 | } |
| 5186 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5187 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5188 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5189 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5190 | } |
| 5191 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5192 | /** |
| 5193 | * hdd_deinit_all_adapters - deinit all adapters |
| 5194 | * @hdd_ctx: HDD context |
| 5195 | * @rtnl_held: True if RTNL lock held |
| 5196 | * |
| 5197 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5198 | 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] | 5199 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5200 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5201 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5202 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5203 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5204 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5205 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5206 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5207 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5208 | } |
| 5209 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5210 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5211 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5212 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5213 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5214 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5215 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5216 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5217 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5218 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5219 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5220 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5221 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5222 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5223 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5224 | } |
| 5225 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5226 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5227 | struct hdd_adapter *adapter) |
| 5228 | { |
| 5229 | switch (adapter->device_mode) { |
| 5230 | case QDF_STA_MODE: |
| 5231 | case QDF_P2P_CLIENT_MODE: |
| 5232 | case QDF_IBSS_MODE: |
| 5233 | case QDF_P2P_DEVICE_MODE: |
| 5234 | case QDF_NDI_MODE: |
| 5235 | wlan_hdd_scan_abort(adapter); |
| 5236 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5237 | if (adapter->device_mode == QDF_STA_MODE) |
| 5238 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5239 | adapter->dev); |
| 5240 | break; |
| 5241 | case QDF_P2P_GO_MODE: |
| 5242 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5243 | break; |
| 5244 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5245 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5246 | wlan_hdd_undo_acs(adapter); |
| 5247 | break; |
| 5248 | default: |
| 5249 | break; |
| 5250 | } |
| 5251 | } |
| 5252 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5253 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5254 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5255 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5256 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5257 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5258 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5259 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5260 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5261 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5262 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5263 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5264 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5265 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5266 | hdd_device_mode_to_string(adapter->device_mode), |
| 5267 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5268 | |
| 5269 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5270 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5271 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5272 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5273 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5274 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5275 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5276 | if (hdd_ctx->config->sap_internal_restart && |
| 5277 | adapter->device_mode == QDF_SAP_MODE) { |
| 5278 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5279 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5280 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5281 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5282 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5283 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5284 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5285 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5286 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5287 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5288 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5289 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5291 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5292 | |
| 5293 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5294 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5295 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5296 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5297 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5298 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5299 | hdd_wmm_adapter_close(adapter); |
| 5300 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5301 | } |
| 5302 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5303 | if (adapter->device_mode == QDF_STA_MODE) |
| 5304 | hdd_clear_fils_connection_info(adapter); |
| 5305 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5306 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5307 | /* |
| 5308 | * If adapter is SAP, set session ID to invalid |
| 5309 | * since SAP session will be cleanup during SSR. |
| 5310 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5311 | wlansap_set_invalid_session( |
| 5312 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5313 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5314 | wlansap_cleanup_cac_timer( |
| 5315 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5316 | } |
| 5317 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5318 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5319 | if (adapter->device_mode == QDF_STA_MODE || |
| 5320 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5321 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5322 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5323 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5324 | |
| 5325 | hdd_objmgr_remove_peer_object(adapter->hdd_vdev, |
| 5326 | peerMacAddr.bytes); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5327 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5328 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5329 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5330 | if (adapter->sta_info[sta_id].in_use) { |
| 5331 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5332 | sta_id); |
| 5333 | hdd_softap_deregister_sta(adapter, |
| 5334 | sta_id); |
| 5335 | adapter->sta_info[sta_id].in_use = 0; |
| 5336 | } |
| 5337 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5338 | } |
| 5339 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5340 | hdd_nud_reset_tracking(adapter); |
| 5341 | hdd_nud_ignore_tracking(adapter, true); |
| 5342 | hdd_set_disconnect_status(adapter, false); |
| 5343 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5344 | hdd_softap_deinit_tx_rx(adapter); |
| 5345 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5346 | /* Destroy vdev which will be recreated during reinit. */ |
| 5347 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5348 | } |
| 5349 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5350 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5351 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5352 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5353 | } |
| 5354 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5355 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5356 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5357 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5358 | bool close_modules = true; |
| 5359 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5360 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5361 | hdd_info("FTM mode, don't close the module"); |
| 5362 | return false; |
| 5363 | } |
| 5364 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5365 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5366 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5367 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5368 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5369 | close_modules = false; |
| 5370 | break; |
| 5371 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5372 | } |
| 5373 | |
| 5374 | return close_modules; |
| 5375 | } |
| 5376 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5377 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5378 | { |
| 5379 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5380 | return true; |
| 5381 | else |
| 5382 | return false; |
| 5383 | } |
| 5384 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5385 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5386 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5387 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5388 | struct ieee80211_channel *channel, |
| 5389 | const u8 *bssid, const u8 *ssid, |
| 5390 | size_t ssid_len) |
| 5391 | { |
| 5392 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5393 | ssid, ssid_len, |
| 5394 | WLAN_CAPABILITY_ESS, |
| 5395 | WLAN_CAPABILITY_ESS); |
| 5396 | } |
| 5397 | #else |
| 5398 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5399 | struct ieee80211_channel *channel, |
| 5400 | const u8 *bssid, const u8 *ssid, |
| 5401 | size_t ssid_len) |
| 5402 | { |
| 5403 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5404 | ssid, ssid_len, |
| 5405 | IEEE80211_BSS_TYPE_ESS, |
| 5406 | IEEE80211_PRIVACY_ANY); |
| 5407 | } |
| 5408 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5409 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5410 | #if defined CFG80211_CONNECT_BSS || \ |
| 5411 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5412 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5413 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5414 | /** |
| 5415 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5416 | * @timeout_reason: reason for connect timeout |
| 5417 | * |
| 5418 | * This function is used to convert host timeout |
| 5419 | * reason enum to kernel specific enum. |
| 5420 | * |
| 5421 | * Return: nl timeout enum |
| 5422 | */ |
| 5423 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5424 | tSirResultCodes timeout_reason) |
| 5425 | { |
| 5426 | switch (timeout_reason) { |
| 5427 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5428 | return NL80211_TIMEOUT_SCAN; |
| 5429 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5430 | return NL80211_TIMEOUT_AUTH; |
| 5431 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5432 | return NL80211_TIMEOUT_ASSOC; |
| 5433 | default: |
| 5434 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5435 | } |
| 5436 | } |
| 5437 | |
| 5438 | /** |
| 5439 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5440 | * @dev: network device |
| 5441 | * @bssid: bssid to which we want to associate |
| 5442 | * @timeout_reason: reason for connect timeout |
| 5443 | * |
| 5444 | * This API is used to send connection timeout reason to supplicant |
| 5445 | * |
| 5446 | * Return: void |
| 5447 | */ |
| 5448 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5449 | const u8 *bssid, |
| 5450 | tSirResultCodes timeout_reason) |
| 5451 | { |
| 5452 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5453 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5454 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5455 | |
| 5456 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5457 | nl_timeout_reason); |
| 5458 | } |
| 5459 | |
| 5460 | /** |
| 5461 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5462 | * @dev: network device |
| 5463 | * @bssid: bssid to which we want to associate |
| 5464 | * @req_ie: Request Information Element |
| 5465 | * @req_ie_len: len of the req IE |
| 5466 | * @resp_ie: Response IE |
| 5467 | * @resp_ie_len: len of ht response IE |
| 5468 | * @status: status |
| 5469 | * @gfp: Kernel Flag |
| 5470 | * @timeout_reason: reason for connect timeout |
| 5471 | * |
| 5472 | * Return: void |
| 5473 | */ |
| 5474 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5475 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5476 | size_t req_ie_len, const u8 *resp_ie, |
| 5477 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5478 | tSirResultCodes timeout_reason) |
| 5479 | { |
| 5480 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5481 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5482 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5483 | |
| 5484 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5485 | resp_ie, resp_ie_len, status, gfp, |
| 5486 | nl_timeout_reason); |
| 5487 | } |
| 5488 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5489 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5490 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5491 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5492 | const u8 *bssid, |
| 5493 | tSirResultCodes timeout_reason) |
| 5494 | { |
| 5495 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5496 | } |
| 5497 | #endif |
| 5498 | |
| 5499 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5500 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5501 | size_t req_ie_len, const u8 *resp_ie, |
| 5502 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5503 | tSirResultCodes timeout_reason) |
| 5504 | { |
| 5505 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5506 | resp_ie, resp_ie_len, status, gfp); |
| 5507 | } |
| 5508 | #endif |
| 5509 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5510 | /** |
| 5511 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5512 | * @dev: network device |
| 5513 | * @bssid: bssid to which we want to associate |
| 5514 | * @req_ie: Request Information Element |
| 5515 | * @req_ie_len: len of the req IE |
| 5516 | * @resp_ie: Response IE |
| 5517 | * @resp_ie_len: len of ht response IE |
| 5518 | * @status: status |
| 5519 | * @gfp: Kernel Flag |
| 5520 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5521 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5522 | * |
| 5523 | * The API is a wrapper to send connection status to supplicant |
| 5524 | * |
| 5525 | * Return: Void |
| 5526 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5527 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5528 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5529 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5530 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5531 | size_t req_ie_len, const u8 *resp_ie, |
| 5532 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5533 | bool connect_timeout, |
| 5534 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5535 | { |
| 5536 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5537 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5538 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5539 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5540 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5541 | } |
| 5542 | #else |
| 5543 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5544 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5545 | size_t req_ie_len, const u8 *resp_ie, |
| 5546 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5547 | bool connect_timeout, |
| 5548 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5549 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5550 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5551 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5552 | } |
| 5553 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5554 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5555 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5556 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5557 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5558 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5559 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5560 | /** |
| 5561 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5562 | * @fils_params: connect response to supplicant |
| 5563 | * @fils_kek: FILS kek |
| 5564 | * @fils_kek_len: FILS kek length |
| 5565 | * @pmk: FILS PMK |
| 5566 | * @pmk_len: FILS PMK length |
| 5567 | * @pmkid: PMKID |
| 5568 | * @fils_seq_num: FILS Seq number |
| 5569 | * |
| 5570 | * Return: None |
| 5571 | */ |
| 5572 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5573 | *fils_params, const uint8_t *fils_kek, |
| 5574 | size_t fils_kek_len, const uint8_t *pmk, |
| 5575 | size_t pmk_len, const uint8_t *pmkid, |
| 5576 | uint16_t fils_seq_num) |
| 5577 | { |
| 5578 | /* Increament seq number to be used for next FILS */ |
| 5579 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5580 | fils_params->update_erp_next_seq_num = true; |
| 5581 | fils_params->fils_kek = fils_kek; |
| 5582 | fils_params->fils_kek_len = fils_kek_len; |
| 5583 | fils_params->pmk = pmk; |
| 5584 | fils_params->pmk_len = pmk_len; |
| 5585 | fils_params->pmkid = pmkid; |
| 5586 | } |
| 5587 | #else |
| 5588 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5589 | *fils_params, const uint8_t |
| 5590 | *fils_kek, size_t fils_kek_len, |
| 5591 | const uint8_t *pmk, size_t pmk_len, |
| 5592 | const uint8_t *pmkid, |
| 5593 | uint16_t fils_seq_num) |
| 5594 | { } |
| 5595 | #endif |
| 5596 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5597 | void hdd_update_hlp_info(struct net_device *dev, |
| 5598 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5599 | { |
| 5600 | struct sk_buff *skb; |
| 5601 | uint16_t skb_len; |
| 5602 | struct llc_snap_hdr_t *llc_hdr; |
| 5603 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5604 | uint8_t *hlp_data; |
| 5605 | uint16_t hlp_data_len; |
| 5606 | struct fils_join_rsp_params *roam_fils_params |
| 5607 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5608 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5609 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5610 | if (!roam_fils_params) { |
| 5611 | hdd_err("FILS Roam Param NULL"); |
| 5612 | return; |
| 5613 | } |
| 5614 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5615 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5616 | hdd_err("FILS HLP Data NULL, len %d", |
| 5617 | roam_fils_params->hlp_data_len); |
| 5618 | return; |
| 5619 | } |
| 5620 | |
| 5621 | hlp_data = roam_fils_params->hlp_data; |
| 5622 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5623 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5624 | /* Calculate skb length */ |
| 5625 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5626 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5627 | if (skb == NULL) { |
| 5628 | hdd_err("HLP packet nbuf alloc fails"); |
| 5629 | return; |
| 5630 | } |
| 5631 | |
| 5632 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5633 | QDF_MAC_ADDR_SIZE); |
| 5634 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5635 | QDF_MAC_ADDR_SIZE); |
| 5636 | |
| 5637 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5638 | if (IS_SNAP(llc_hdr)) { |
| 5639 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5640 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5641 | } |
| 5642 | |
| 5643 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5644 | |
| 5645 | /* |
| 5646 | * This HLP packet is formed from HLP info encapsulated |
| 5647 | * in assoc response frame which is AEAD encrypted. |
| 5648 | * Hence, this checksum validation can be set unnecessary. |
| 5649 | * i.e. network layer need not worry about checksum. |
| 5650 | */ |
| 5651 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5652 | |
| 5653 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5654 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5655 | hdd_err("Sending HLP packet fails"); |
| 5656 | return; |
| 5657 | } |
| 5658 | hdd_debug("send HLP packet to netif successfully"); |
| 5659 | } |
| 5660 | |
| 5661 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5662 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5663 | * @dev: network device |
| 5664 | * @bssid: bssid to which we want to associate |
| 5665 | * @bss: cfg80211 bss info |
| 5666 | * @roam_info: information about connected bss |
| 5667 | * @req_ie: Request Information Element |
| 5668 | * @req_ie_len: len of the req IE |
| 5669 | * @resp_ie: Response IE |
| 5670 | * @resp_ie_len: len of ht response IE |
| 5671 | * @status: status |
| 5672 | * @gfp: allocation flags |
| 5673 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5674 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5675 | * |
| 5676 | * This API is used as wrapper to send FILS key/sequence number |
| 5677 | * params etc. to supplicant in case of FILS connection |
| 5678 | * |
| 5679 | * Return: None |
| 5680 | */ |
| 5681 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5682 | struct cfg80211_bss *bss, |
| 5683 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5684 | const u8 *req_ie, size_t req_ie_len, |
| 5685 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5686 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5687 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5688 | { |
| 5689 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5690 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5691 | struct fils_join_rsp_params *roam_fils_params = |
| 5692 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5693 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5694 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5695 | |
| 5696 | if (!roam_fils_params) { |
| 5697 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5698 | } else { |
| 5699 | fils_params.status = status; |
| 5700 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5701 | fils_params.timeout_reason = |
| 5702 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5703 | fils_params.req_ie = req_ie; |
| 5704 | fils_params.req_ie_len = req_ie_len; |
| 5705 | fils_params.resp_ie = resp_ie; |
| 5706 | fils_params.resp_ie_len = resp_ie_len; |
| 5707 | fils_params.bss = bss; |
| 5708 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5709 | roam_fils_params->kek_len, |
| 5710 | roam_fils_params->fils_pmk, |
| 5711 | roam_fils_params->fils_pmk_len, |
| 5712 | roam_fils_params->fils_pmkid, |
| 5713 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5714 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5715 | } |
| 5716 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5717 | fils_params.status, |
| 5718 | fils_params.fils_erp_next_seq_num); |
| 5719 | |
| 5720 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5721 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5722 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5723 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5724 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5725 | /* Clear all the FILS key info */ |
| 5726 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5727 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5728 | if (roam_fils_params) |
| 5729 | qdf_mem_free(roam_fils_params); |
| 5730 | roam_info->fils_join_rsp = NULL; |
| 5731 | } |
| 5732 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5733 | static inline void |
| 5734 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5735 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5736 | const u8 *req_ie, size_t req_ie_len, |
| 5737 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5738 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5739 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5740 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5741 | #endif |
| 5742 | #endif |
| 5743 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5744 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5745 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5746 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5747 | /** |
| 5748 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5749 | * supplicant. |
| 5750 | * @dev: network device |
| 5751 | * @bssid: bssid to which we want to associate |
| 5752 | * @bss: cfg80211 bss info |
| 5753 | * @roam_info: information about connected bss |
| 5754 | * @req_ie: Request Information Element |
| 5755 | * @req_ie_len: len of the req IE |
| 5756 | * @resp_ie: Response IE |
| 5757 | * @resp_ie_len: len of ht response IE |
| 5758 | * @status: status |
| 5759 | * @gfp: allocation flags |
| 5760 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5761 | * @timeout_reason: reason for connect timeout |
| 5762 | * |
| 5763 | * The API is a wrapper to send connection status to supplicant |
| 5764 | * |
| 5765 | * Return: 0 if success else failure |
| 5766 | */ |
| 5767 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5768 | const u8 *bssid, |
| 5769 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5770 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5771 | size_t req_ie_len, const u8 *resp_ie, |
| 5772 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5773 | bool connect_timeout, |
| 5774 | tSirResultCodes timeout_reason) |
| 5775 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5776 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5777 | if (!roam_info || !roam_info->is_fils_connection) |
| 5778 | return -EINVAL; |
| 5779 | |
| 5780 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5781 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5782 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5783 | return 0; |
| 5784 | } |
| 5785 | #else |
| 5786 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5787 | const u8 *bssid, |
| 5788 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5789 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5790 | size_t req_ie_len, const u8 *resp_ie, |
| 5791 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5792 | bool connect_timeout, |
| 5793 | tSirResultCodes timeout_reason) |
| 5794 | { |
| 5795 | return -EINVAL; |
| 5796 | } |
| 5797 | #endif |
| 5798 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5799 | /** |
| 5800 | * hdd_connect_result() - API to send connection status to supplicant |
| 5801 | * @dev: network device |
| 5802 | * @bssid: bssid to which we want to associate |
| 5803 | * @roam_info: information about connected bss |
| 5804 | * @req_ie: Request Information Element |
| 5805 | * @req_ie_len: len of the req IE |
| 5806 | * @resp_ie: Response IE |
| 5807 | * @resp_ie_len: len of ht response IE |
| 5808 | * @status: status |
| 5809 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5810 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5811 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5812 | * |
| 5813 | * The API is a wrapper to send connection status to supplicant |
| 5814 | * and allow runtime suspend |
| 5815 | * |
| 5816 | * Return: Void |
| 5817 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5818 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5819 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5820 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5821 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5822 | bool connect_timeout, |
| 5823 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5824 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5825 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5826 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5827 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5828 | |
| 5829 | if (WLAN_STATUS_SUCCESS == status) { |
| 5830 | struct ieee80211_channel *chan; |
| 5831 | int freq; |
| 5832 | int chan_no = roam_info->pBssDesc->channelId; |
| 5833 | |
| 5834 | if (chan_no <= 14) |
| 5835 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5836 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5837 | else |
| 5838 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5839 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5840 | |
| 5841 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5842 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5843 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5844 | roam_info->u.pConnectedProfile->SSID.length); |
| 5845 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5846 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5847 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5848 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5849 | resp_ie_len, status, gfp, connect_timeout, |
| 5850 | timeout_reason) != 0) { |
| 5851 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5852 | req_ie_len, resp_ie, resp_ie_len, |
| 5853 | status, gfp, connect_timeout, timeout_reason); |
| 5854 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [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 | #else |
| 5860 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5861 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5862 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5863 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5864 | bool connect_timeout, |
| 5865 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5866 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5867 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5868 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5869 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5870 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 5871 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 5872 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5873 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5874 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5875 | } |
| 5876 | #endif |
| 5877 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5878 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 5879 | uint32_t bandwidth) |
| 5880 | { |
| 5881 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 5882 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5883 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 5884 | QDF_STATUS status; |
| 5885 | tHalHandle hal_hdl = hdd_ctx->hHal; |
| 5886 | struct qdf_mac_addr bssid; |
| 5887 | struct csr_roam_profile roam_profile; |
| 5888 | struct ch_params ch_params; |
| 5889 | |
| 5890 | if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) { |
| 5891 | hdd_err("Not supported, device is not in monitor mode"); |
| 5892 | return -EINVAL; |
| 5893 | } |
| 5894 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 5895 | /* Validate Channel */ |
| 5896 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 5897 | hdd_err("Channel %d Not supported", chan); |
| 5898 | return -EINVAL; |
| 5899 | } |
| 5900 | |
| 5901 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 5902 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 5903 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 5904 | return -EINVAL; |
| 5905 | } |
| 5906 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 5907 | (bandwidth != CH_WIDTH_MAX)) { |
| 5908 | hdd_err("Only BW20 possible on channel 14"); |
| 5909 | return -EINVAL; |
| 5910 | } |
| 5911 | } |
| 5912 | |
| 5913 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 5914 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 5915 | (bandwidth != CH_WIDTH_MAX)) { |
| 5916 | hdd_err("Only BW20 possible on channel 165"); |
| 5917 | return -EINVAL; |
| 5918 | } |
| 5919 | } |
| 5920 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 5921 | hdd_debug("Set monitor mode Channel %d", chan); |
| 5922 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 5923 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 5924 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 5925 | roam_profile.phyMode = ch_info->phy_mode; |
| 5926 | roam_profile.ch_params.ch_width = bandwidth; |
| 5927 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
| 5928 | |
| 5929 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 5930 | QDF_MAC_ADDR_SIZE); |
| 5931 | |
| 5932 | ch_params.ch_width = bandwidth; |
| 5933 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 5934 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 5935 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 5936 | return -EINVAL; |
| 5937 | } |
| 5938 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 5939 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 5940 | hdd_err("Failed to change hw mode"); |
| 5941 | return -EINVAL; |
| 5942 | } |
| 5943 | |
| 5944 | status = sme_roam_channel_change_req(hal_hdl, bssid, &ch_params, |
| 5945 | &roam_profile); |
| 5946 | if (status) { |
| 5947 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 5948 | status); |
| 5949 | } |
| 5950 | |
| 5951 | adapter->mon_chan = chan; |
| 5952 | adapter->mon_bandwidth = bandwidth; |
| 5953 | return qdf_status_to_os_return(status); |
| 5954 | } |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5955 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 5956 | #ifdef MSM_PLATFORM |
| 5957 | /** |
| 5958 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 5959 | * @adapter: pointer to adapter |
| 5960 | * |
| 5961 | * This function calls cfg80211 API to stop P2P GO |
| 5962 | * |
| 5963 | * Return: None |
| 5964 | */ |
| 5965 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 5966 | { |
| 5967 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 5968 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 5969 | } |
| 5970 | |
| 5971 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 5972 | { |
| 5973 | } |
| 5974 | #else |
| 5975 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 5976 | { |
| 5977 | } |
| 5978 | |
| 5979 | /** |
| 5980 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 5981 | * @adapter: pointer to adapter |
| 5982 | * |
| 5983 | * This function calls cfg80211 API to delete STA |
| 5984 | * |
| 5985 | * Return: None |
| 5986 | */ |
| 5987 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 5988 | { |
| 5989 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 5990 | |
| 5991 | hdd_debug("[SSR] send restart supplicant"); |
| 5992 | /* event supplicant to restart */ |
| 5993 | cfg80211_del_sta(adapter->dev, |
| 5994 | (const u8 *)&bcast_mac.bytes[0], |
| 5995 | GFP_KERNEL); |
| 5996 | } |
| 5997 | #endif |
| 5998 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5999 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6000 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6001 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6002 | eConnectionState connState; |
| 6003 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6004 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6005 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6006 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6007 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6008 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6009 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6010 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 6011 | hdd_device_mode_to_string(adapter->device_mode), |
| 6012 | adapter->device_mode); |
| 6013 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6014 | hdd_wmm_init(adapter); |
| 6015 | |
| 6016 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6017 | case QDF_STA_MODE: |
| 6018 | case QDF_P2P_CLIENT_MODE: |
| 6019 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6020 | |
| 6021 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6022 | ->conn_info.connState; |
| 6023 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6024 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6025 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6026 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6027 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6028 | /* Indicate disconnect event to supplicant |
| 6029 | * if associated previously |
| 6030 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6031 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6032 | eConnectionState_IbssConnected == connState || |
| 6033 | eConnectionState_NotConnected == connState || |
| 6034 | eConnectionState_IbssDisconnected == connState || |
| 6035 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6036 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6038 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6039 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6040 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6041 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6042 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6043 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6044 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6045 | |
| 6046 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6047 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6048 | adapter->dev, false, |
| 6049 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6050 | } else if (eConnectionState_Connecting == connState) { |
| 6051 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6052 | * Indicate connect failure to supplicant if we |
| 6053 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6054 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6055 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6056 | NULL, 0, NULL, 0, |
| 6057 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6058 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6059 | } |
| 6060 | |
| 6061 | hdd_register_tx_flow_control(adapter, |
| 6062 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6063 | hdd_tx_resume_cb, |
| 6064 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6065 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6066 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6067 | break; |
| 6068 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6069 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6070 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6071 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6072 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6073 | break; |
| 6074 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6075 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6076 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6077 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6078 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6079 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6080 | hdd_set_mon_rx_cb(adapter->dev); |
| 6081 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6082 | adapter->mon_bandwidth); |
| 6083 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6084 | default: |
| 6085 | break; |
| 6086 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6087 | /* |
| 6088 | * Action frame registered in one adapter which will |
| 6089 | * applicable to all interfaces |
| 6090 | */ |
| 6091 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6092 | } |
| 6093 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6094 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6095 | if (!hdd_is_interface_up(adapter)) |
| 6096 | continue; |
| 6097 | |
| 6098 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6099 | hdd_stop_p2p_go(adapter); |
| 6100 | } |
| 6101 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6102 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6103 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6104 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6105 | } |
| 6106 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6107 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6108 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6109 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6110 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6111 | qdf_list_node_t *node; |
| 6112 | |
| 6113 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6114 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6115 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6116 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6117 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6118 | |
| 6119 | if (QDF_IS_STATUS_ERROR(status)) |
| 6120 | return status; |
| 6121 | |
| 6122 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6123 | |
| 6124 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6125 | } |
| 6126 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6127 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6128 | struct hdd_adapter *current_adapter, |
| 6129 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6130 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6131 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6132 | qdf_list_node_t *node; |
| 6133 | |
| 6134 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6135 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6136 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6137 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6138 | ¤t_adapter->node, |
| 6139 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6140 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6141 | |
| 6142 | if (QDF_IS_STATUS_ERROR(status)) |
| 6143 | return status; |
| 6144 | |
| 6145 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6146 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6147 | return status; |
| 6148 | } |
| 6149 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6150 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6151 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6152 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6153 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6154 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6155 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6156 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6157 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6158 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6159 | return status; |
| 6160 | } |
| 6161 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6162 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6163 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6164 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6165 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6166 | qdf_list_node_t *node; |
| 6167 | |
| 6168 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6169 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6170 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6171 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6172 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6173 | |
| 6174 | if (QDF_IS_STATUS_ERROR(status)) |
| 6175 | return status; |
| 6176 | |
| 6177 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6178 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6179 | return status; |
| 6180 | } |
| 6181 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6182 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6183 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6184 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6185 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6186 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6187 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6188 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6189 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6190 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6191 | return status; |
| 6192 | } |
| 6193 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6194 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6195 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6197 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6198 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6199 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6200 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6201 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6202 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6203 | return status; |
| 6204 | } |
| 6205 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6206 | 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] | 6207 | tSirMacAddr macAddr) |
| 6208 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6209 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6210 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6211 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6212 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6213 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6214 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6215 | } |
| 6216 | |
| 6217 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6218 | } |
| 6219 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6220 | 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] | 6221 | uint32_t vdev_id) |
| 6222 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6223 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6224 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6225 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6226 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6227 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6228 | } |
| 6229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6230 | return NULL; |
| 6231 | } |
| 6232 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6233 | /** |
| 6234 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6235 | * the sessionid |
| 6236 | * @hdd_ctx: hdd context. |
| 6237 | * @sme_session_id: sme session is for the adapter to get. |
| 6238 | * |
| 6239 | * This function is used to get the adapter with provided session id |
| 6240 | * |
| 6241 | * Return: adapter pointer if found |
| 6242 | * |
| 6243 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6244 | struct hdd_adapter * |
| 6245 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6246 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6247 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6248 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6249 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6250 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6251 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6252 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6253 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6254 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6255 | return NULL; |
| 6256 | } |
| 6257 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6258 | 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] | 6259 | const char *iface_name) |
| 6260 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6261 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6262 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6263 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6264 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6265 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6266 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6267 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6268 | return NULL; |
| 6269 | } |
| 6270 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6271 | /** |
| 6272 | * hdd_get_adapter() - to get adapter matching the mode |
| 6273 | * @hdd_ctx: hdd context |
| 6274 | * @mode: adapter mode |
| 6275 | * |
| 6276 | * This routine will return the pointer to adapter matching |
| 6277 | * with the passed mode. |
| 6278 | * |
| 6279 | * Return: pointer to adapter or null |
| 6280 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6281 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6282 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6284 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6285 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6286 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6287 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6288 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6289 | } |
| 6290 | |
| 6291 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6292 | } |
| 6293 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6294 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6295 | { |
| 6296 | struct hdd_context *hdd_ctx; |
| 6297 | struct hdd_adapter *adapter; |
| 6298 | |
| 6299 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6300 | if (!hdd_ctx) { |
| 6301 | hdd_err("Invalid HDD context"); |
| 6302 | return QDF_MAX_NO_OF_MODE; |
| 6303 | } |
| 6304 | |
| 6305 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6306 | if (!adapter) { |
| 6307 | hdd_err("Invalid HDD adapter"); |
| 6308 | return QDF_MAX_NO_OF_MODE; |
| 6309 | } |
| 6310 | |
| 6311 | return adapter->device_mode; |
| 6312 | } |
| 6313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6314 | /** |
| 6315 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6316 | * @hdd_ctx: Pointer to the HDD context. |
| 6317 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6318 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6319 | * QDF_STA_MODE, |
| 6320 | * QDF_P2P_CLIENT_MODE, |
| 6321 | * QDF_SAP_MODE, |
| 6322 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6323 | * |
| 6324 | * This API returns the operating channel of the requested device mode |
| 6325 | * |
| 6326 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6327 | * not connected. |
| 6328 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6329 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6330 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6331 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6332 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6333 | uint8_t operatingChannel = 0; |
| 6334 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6335 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6336 | if (mode == adapter->device_mode) { |
| 6337 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6338 | case QDF_STA_MODE: |
| 6339 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6340 | if (hdd_conn_is_connected |
| 6341 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6342 | (adapter))) { |
| 6343 | operatingChannel = |
| 6344 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6345 | (adapter))->conn_info. |
| 6346 | operationChannel; |
| 6347 | } |
| 6348 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6349 | case QDF_SAP_MODE: |
| 6350 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6351 | /* softap connection info */ |
| 6352 | if (test_bit |
| 6353 | (SOFTAP_BSS_STARTED, |
| 6354 | &adapter->event_flags)) |
| 6355 | operatingChannel = |
| 6356 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6357 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6358 | break; |
| 6359 | default: |
| 6360 | break; |
| 6361 | } |
| 6362 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6363 | /* Found the device of interest. break the loop */ |
| 6364 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6365 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6367 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6368 | return operatingChannel; |
| 6369 | } |
| 6370 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6371 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6372 | hdd_ctx) |
| 6373 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6374 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6375 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6376 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6377 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6378 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6379 | if (adapter->device_mode == QDF_STA_MODE || |
| 6380 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6381 | adapter->device_mode == QDF_IBSS_MODE || |
| 6382 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6383 | adapter->device_mode == QDF_SAP_MODE || |
| 6384 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6385 | hdd_unregister_wext(adapter->dev); |
| 6386 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6387 | } |
| 6388 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6389 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6390 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6391 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6392 | } |
| 6393 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6394 | 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] | 6395 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6396 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6397 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6398 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6399 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6400 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6401 | if (adapter->device_mode == QDF_STA_MODE || |
| 6402 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6403 | adapter->device_mode == QDF_IBSS_MODE || |
| 6404 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6405 | adapter->device_mode == QDF_SAP_MODE || |
| 6406 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6407 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6408 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6409 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6410 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6411 | } |
| 6412 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6413 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6414 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6415 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6416 | } |
| 6417 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6418 | /** |
| 6419 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6420 | * adapters |
| 6421 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6422 | * |
| 6423 | * return: QDF_STATUS_SUCCESS |
| 6424 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6425 | 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] | 6426 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6427 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6428 | int err; |
| 6429 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6430 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6431 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6432 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6433 | if (adapter->device_mode == QDF_STA_MODE || |
| 6434 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6435 | adapter->device_mode == QDF_IBSS_MODE || |
| 6436 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6437 | adapter->device_mode == QDF_SAP_MODE || |
| 6438 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6439 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6440 | if (err) |
| 6441 | hdd_err("Unable to stop scheduled scan"); |
| 6442 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6443 | } |
| 6444 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6445 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6446 | |
| 6447 | return QDF_STATUS_SUCCESS; |
| 6448 | } |
| 6449 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6450 | #ifdef WLAN_NS_OFFLOAD |
| 6451 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6452 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6453 | * @hdd_ctx: Pointer to hdd context |
| 6454 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6455 | * Unregister for IPv6 address change notifications. |
| 6456 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6457 | * Return: None |
| 6458 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6459 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6460 | { |
| 6461 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6462 | } |
| 6463 | |
| 6464 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6465 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6466 | * @hdd_ctx: Pointer to hdd context |
| 6467 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6468 | * Register for IPv6 address change notifications. |
| 6469 | * |
| 6470 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6471 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6472 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6473 | { |
| 6474 | int ret; |
| 6475 | |
| 6476 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6477 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6478 | if (ret) { |
| 6479 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6480 | goto out; |
| 6481 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6483 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6484 | out: |
| 6485 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6486 | } |
| 6487 | #else |
| 6488 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6489 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6490 | * @hdd_ctx: Pointer to hdd context |
| 6491 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6492 | * Unregister for IPv6 address change notifications. |
| 6493 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6494 | * Return: None |
| 6495 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6496 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6497 | { |
| 6498 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6500 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6501 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6502 | * @hdd_ctx: Pointer to hdd context |
| 6503 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6504 | * Register for IPv6 address change notifications. |
| 6505 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | * Return: None |
| 6507 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6508 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6509 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6510 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6511 | } |
| 6512 | #endif |
| 6513 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6514 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6515 | { |
| 6516 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6517 | adapter->disconnection_in_progress = status; |
| 6518 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6519 | hdd_debug("setting disconnection status: %d", status); |
| 6520 | } |
| 6521 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6522 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6523 | * hdd_register_notifiers - Register netdev notifiers. |
| 6524 | * @hdd_ctx: HDD context |
| 6525 | * |
| 6526 | * Register netdev notifiers like IPv4 and IPv6. |
| 6527 | * |
| 6528 | * Return: 0 on success and errno on failure |
| 6529 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6530 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6531 | { |
| 6532 | int ret; |
| 6533 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6534 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6535 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6536 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6537 | |
| 6538 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6539 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6540 | if (ret) { |
| 6541 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6542 | goto unregister_ip6_notifier; |
| 6543 | } |
| 6544 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6545 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6546 | if (ret) { |
| 6547 | hdd_err("Failed to register netevent notifier: %d", |
| 6548 | ret); |
| 6549 | goto unregister_inetaddr_notifier; |
| 6550 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6551 | return 0; |
| 6552 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6553 | unregister_inetaddr_notifier: |
| 6554 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6555 | unregister_ip6_notifier: |
| 6556 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6557 | out: |
| 6558 | return ret; |
| 6559 | |
| 6560 | } |
| 6561 | |
| 6562 | /** |
| 6563 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6564 | * @hdd_ctx: HDD context |
| 6565 | * |
| 6566 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6567 | * |
| 6568 | * Return: None. |
| 6569 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6570 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6571 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6572 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6573 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6574 | |
| 6575 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6576 | } |
| 6577 | |
| 6578 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6579 | * hdd_exit_netlink_services - Exit netlink services |
| 6580 | * @hdd_ctx: HDD context |
| 6581 | * |
| 6582 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6583 | * nl service. |
| 6584 | * |
| 6585 | * Return: None. |
| 6586 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6587 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6588 | { |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6589 | hdd_close_cesium_nl_sock(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6590 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6591 | ptt_sock_deactivate_svc(); |
| 6592 | |
| 6593 | nl_srv_exit(); |
| 6594 | } |
| 6595 | |
| 6596 | /** |
| 6597 | * hdd_init_netlink_services- Init netlink services |
| 6598 | * @hdd_ctx: HDD context |
| 6599 | * |
| 6600 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6601 | * nl service. |
| 6602 | * |
| 6603 | * Return: 0 on success and errno on failure. |
| 6604 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6605 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6606 | { |
| 6607 | int ret; |
| 6608 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6609 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6610 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6611 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6612 | goto out; |
| 6613 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6614 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6615 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6616 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6617 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6618 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6619 | goto err_nl_srv; |
| 6620 | } |
| 6621 | |
| 6622 | ret = ptt_sock_activate_svc(); |
| 6623 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6624 | hdd_err("ptt_sock_activate_svc failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6625 | goto err_nl_srv; |
| 6626 | } |
| 6627 | |
| 6628 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6629 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6630 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6631 | |
| 6632 | ret = cnss_diag_activate_service(); |
| 6633 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6634 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6635 | goto err_close_cesium; |
| 6636 | } |
| 6637 | |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6638 | ret = spectral_scan_activate_service(); |
| 6639 | if (ret) { |
Sandeep Puligilla | 8e89d57 | 2018-04-02 18:07:45 -0700 | [diff] [blame^] | 6640 | hdd_err("spectral service initialization failed: %d", ret); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6641 | goto err_close_cesium; |
| 6642 | } |
| 6643 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6644 | return 0; |
| 6645 | |
| 6646 | err_close_cesium: |
| 6647 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6648 | ptt_sock_deactivate_svc(); |
| 6649 | err_nl_srv: |
| 6650 | nl_srv_exit(); |
| 6651 | out: |
| 6652 | return ret; |
| 6653 | } |
| 6654 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6655 | /** |
| 6656 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6657 | * @hdd_ctx: HDD context. |
| 6658 | * |
| 6659 | * Destroy RX wakelock. |
| 6660 | * |
| 6661 | * Return: None. |
| 6662 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6663 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6664 | { |
| 6665 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6666 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6667 | |
| 6668 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6669 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6670 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6671 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6672 | * Create RX wakelock. |
| 6673 | * |
| 6674 | * Return: None. |
| 6675 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6676 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6677 | { |
| 6678 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6679 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6680 | |
| 6681 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6682 | * hdd_context_deinit() - Deinitialize HDD context |
| 6683 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6684 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6685 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6686 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6687 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6688 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6689 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6690 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6691 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6692 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6693 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6694 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6695 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6696 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6697 | hdd_sap_context_destroy(hdd_ctx); |
| 6698 | |
| 6699 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6700 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6701 | hdd_scan_context_destroy(hdd_ctx); |
| 6702 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6703 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6704 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6705 | return 0; |
| 6706 | } |
| 6707 | |
| 6708 | /** |
| 6709 | * hdd_context_destroy() - Destroy HDD context |
| 6710 | * @hdd_ctx: HDD context to be destroyed. |
| 6711 | * |
| 6712 | * Free config and HDD context as well as destroy all the resources. |
| 6713 | * |
| 6714 | * Return: None |
| 6715 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6716 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6717 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6718 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6719 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6720 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6721 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6722 | hdd_context_deinit(hdd_ctx); |
| 6723 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6724 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6725 | hdd_ctx->config = NULL; |
| 6726 | |
| 6727 | wiphy_free(hdd_ctx->wiphy); |
| 6728 | } |
| 6729 | |
| 6730 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6731 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6732 | * |
| 6733 | * This function is used to destroy bug report lock |
| 6734 | * |
| 6735 | * Return: None |
| 6736 | */ |
| 6737 | static void wlan_destroy_bug_report_lock(void) |
| 6738 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 6739 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6740 | |
| 6741 | p_cds_context = cds_get_global_context(); |
| 6742 | if (!p_cds_context) { |
| 6743 | hdd_err("cds context is NULL"); |
| 6744 | return; |
| 6745 | } |
| 6746 | |
| 6747 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6748 | } |
| 6749 | |
| 6750 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6751 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6752 | * @hdd_ctx: Pointer to the HDD Context |
| 6753 | * |
| 6754 | * This is the driver exit point (invoked during rmmod) |
| 6755 | * |
| 6756 | * Return: None |
| 6757 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6758 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6759 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6760 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6761 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6762 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6763 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6764 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6765 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6766 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6767 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6768 | |
| 6769 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6770 | if (QDF_TIMER_STATE_RUNNING == |
| 6771 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6772 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6773 | } |
| 6774 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6775 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6776 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6777 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6778 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6779 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6780 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6781 | hdd_ctx->last_acs_channel_list = NULL; |
| 6782 | hdd_ctx->num_of_channels = 0; |
| 6783 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6784 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6785 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6786 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6787 | driver_status = hdd_ctx->driver_status; |
| 6788 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6789 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6790 | /* |
| 6791 | * Powersave Offload Case |
| 6792 | * Disable Idle Power Save Mode |
| 6793 | */ |
| 6794 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6795 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6796 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6797 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6798 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6799 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6800 | /* |
| 6801 | * Cancel any outstanding scan requests. We are about to close |
| 6802 | * all of our adapters, but an adapter structure is what SME |
| 6803 | * passes back to our callback function. Hence if there |
| 6804 | * are any outstanding scan requests then there is a |
| 6805 | * race condition between when the adapter is closed and |
| 6806 | * when the callback is invoked. We try to resolve that |
| 6807 | * race condition here by canceling any outstanding scans |
| 6808 | * before we close the adapters. |
| 6809 | * Note that the scans may be cancelled in an asynchronous |
| 6810 | * manner, so ideally there needs to be some kind of |
| 6811 | * synchronization. Rather than introduce a new |
| 6812 | * synchronization here, we will utilize the fact that we are |
| 6813 | * about to Request Full Power, and since that is synchronized, |
| 6814 | * the expectation is that by the time Request Full Power has |
| 6815 | * completed, all scans will be cancelled |
| 6816 | */ |
| 6817 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6818 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6819 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6820 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6821 | } |
| 6822 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6823 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6824 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6825 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6826 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6827 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6828 | hdd_driver_memdump_deinit(); |
| 6829 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6830 | qdf_nbuf_deinit_replenish_timer(); |
| 6831 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6832 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6833 | hdd_info("Release wakelock for monitor mode!"); |
| 6834 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6835 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6836 | } |
| 6837 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6838 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6839 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6840 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6841 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6842 | /* |
| 6843 | * Close CDS |
| 6844 | * This frees pMac(HAL) context. There should not be any call |
| 6845 | * that requires pMac access after this. |
| 6846 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6847 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 6848 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 6849 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6850 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6851 | hdd_close_all_adapters(hdd_ctx, false); |
| 6852 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6853 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6854 | /* |
| 6855 | * If there is re_init failure wiphy would have already de-registered |
| 6856 | * check the wiphy status before un-registering again |
| 6857 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6858 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6859 | wiphy_unregister(wiphy); |
| 6860 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6861 | hdd_lpass_notify_stop(hdd_ctx); |
| 6862 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6863 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6864 | hdd_exit_netlink_services(hdd_ctx); |
| 6865 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6866 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6867 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6868 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6869 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6870 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6871 | if (driver_status) |
| 6872 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6873 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6874 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | } |
| 6876 | |
| 6877 | void __hdd_wlan_exit(void) |
| 6878 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6879 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6880 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6881 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6882 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6883 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6884 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6885 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6886 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6887 | return; |
| 6888 | } |
| 6889 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | /* Do all the cleanup before deregistering the driver */ |
| 6891 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 6892 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6893 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6894 | } |
| 6895 | |
| 6896 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6897 | /** |
| 6898 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6899 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6900 | * |
| 6901 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 6902 | * Then new ACS request will do a fresh scan without reusing the cached |
| 6903 | * scan information. |
| 6904 | * |
| 6905 | * Return: void |
| 6906 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 6907 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6908 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6909 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6910 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6911 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6912 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6913 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6914 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6915 | hdd_ctx->last_acs_channel_list = NULL; |
| 6916 | hdd_ctx->num_of_channels = 0; |
| 6917 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6918 | |
| 6919 | if (!hdd_ctx->hHal) |
| 6920 | return; |
| 6921 | sme_scan_flush_result(hdd_ctx->hHal); |
| 6922 | } |
| 6923 | #endif |
| 6924 | |
| 6925 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6926 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 6927 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6928 | { |
| 6929 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6930 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6931 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6932 | |
| 6933 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6934 | |
| 6935 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6936 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6937 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6938 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6939 | if (!hdd_ctx->hHal) |
| 6940 | return -EINVAL; |
| 6941 | |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 6942 | 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] | 6943 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6944 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6945 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6946 | return -EINVAL; |
| 6947 | } |
| 6948 | |
| 6949 | return 0; |
| 6950 | } |
| 6951 | #endif |
| 6952 | |
| 6953 | /** |
| 6954 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 6955 | * @state: state |
| 6956 | * |
| 6957 | * This function notifies FW with modem power status |
| 6958 | * |
| 6959 | * Return: 0 if successful, error number otherwise |
| 6960 | */ |
| 6961 | int hdd_wlan_notify_modem_power_state(int state) |
| 6962 | { |
| 6963 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6964 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6965 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6966 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 6967 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6968 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6969 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6970 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 6971 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6972 | if (!hdd_ctx->hHal) |
| 6973 | return -EINVAL; |
| 6974 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6975 | qdf_status = sme_notify_modem_power_state(hdd_ctx->hHal, state); |
| 6976 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 6977 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6978 | state); |
| 6979 | return -EINVAL; |
| 6980 | } |
| 6981 | return 0; |
| 6982 | } |
| 6983 | |
| 6984 | /** |
| 6985 | * |
| 6986 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 6987 | * @adapter - Pointer to the HDD |
| 6988 | * |
| 6989 | * Return: None |
| 6990 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6991 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6992 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6993 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | |
| 6995 | /* |
| 6996 | * Send ready indication to the HDD. This will kick off the MAC |
| 6997 | * into a 'running' state and should kick off an initial scan. |
| 6998 | */ |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 6999 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->hHal); |
| 7000 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7001 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7002 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7003 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7004 | } |
| 7005 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7006 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | } |
| 7008 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7009 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7010 | { |
| 7011 | struct hdd_adapter *adapter; |
| 7012 | |
| 7013 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7014 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7015 | return adapter; |
| 7016 | } |
| 7017 | |
| 7018 | return NULL; |
| 7019 | } |
| 7020 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7021 | /* wake lock APIs for HDD */ |
| 7022 | void hdd_prevent_suspend(uint32_t reason) |
| 7023 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7024 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7025 | } |
| 7026 | |
| 7027 | void hdd_allow_suspend(uint32_t reason) |
| 7028 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7029 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7030 | } |
| 7031 | |
| 7032 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7033 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7034 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7035 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | } |
| 7037 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7038 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7039 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7040 | { |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 7041 | |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7042 | return sme_init_chan_list(hdd_ctx->hHal, |
| 7043 | hdd_ctx->reg.alpha2, |
| 7044 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7045 | } |
| 7046 | |
| 7047 | /** |
| 7048 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7049 | * @hdd_ctx: Pointer to the hdd context |
| 7050 | * |
| 7051 | * HDD function to know if hardware supports 5GHz |
| 7052 | * |
| 7053 | * Return: true if hardware supports 5GHz |
| 7054 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7055 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7056 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7057 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7058 | return true; |
| 7059 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7060 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7061 | return true; |
| 7062 | else |
| 7063 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7064 | } |
| 7065 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7066 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7067 | { |
| 7068 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7069 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7070 | |
| 7071 | wiphy = hdd_ctx->wiphy; |
| 7072 | |
| 7073 | /* |
| 7074 | * The channel information in |
| 7075 | * wiphy needs to be initialized before wiphy registration |
| 7076 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7077 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7078 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7079 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7080 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7081 | } |
| 7082 | |
| 7083 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7084 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7085 | #else |
| 7086 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7087 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7088 | WIPHY_WOWLAN_DISCONNECT | |
| 7089 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7090 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7091 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7092 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7093 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7094 | |
| 7095 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7096 | WOW_MAX_FILTERS_PER_LIST); |
| 7097 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7098 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7099 | #endif |
| 7100 | |
| 7101 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7102 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7103 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7104 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7105 | return ret_val; |
| 7106 | } |
| 7107 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7108 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7110 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7111 | } |
| 7112 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7113 | #ifdef MSM_PLATFORM |
| 7114 | /** |
| 7115 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7116 | * @hdd_ctx - handle to hdd context |
| 7117 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7118 | * |
| 7119 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7120 | * Stats show up in wlan driver logs. |
| 7121 | * |
| 7122 | * Returns: None |
| 7123 | */ |
| 7124 | static inline |
| 7125 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7126 | bool data_in_interval) |
| 7127 | { |
| 7128 | static u32 counter; |
| 7129 | static bool data_in_time_period; |
| 7130 | ol_txrx_pdev_handle pdev; |
| 7131 | |
| 7132 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7133 | return; |
| 7134 | |
| 7135 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7136 | if (!pdev) { |
| 7137 | hdd_err("pdev is NULL"); |
| 7138 | return; |
| 7139 | } |
| 7140 | |
| 7141 | counter++; |
| 7142 | if (data_in_interval) |
| 7143 | data_in_time_period = data_in_interval; |
| 7144 | |
| 7145 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7146 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7147 | if (data_in_time_period) { |
| 7148 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7149 | CDP_TXRX_PATH_STATS, |
| 7150 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7151 | wlan_hdd_display_netif_queue_history |
| 7152 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7153 | qdf_dp_trace_dump_stats(); |
| 7154 | } |
| 7155 | counter = 0; |
| 7156 | data_in_time_period = false; |
| 7157 | } |
| 7158 | } |
| 7159 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7160 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7161 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7162 | * @hdd_ctx: pointer to struct hdd_context |
| 7163 | * |
| 7164 | * Return: none |
| 7165 | */ |
| 7166 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7167 | { |
| 7168 | struct hdd_adapter *adapter; |
| 7169 | |
| 7170 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7171 | hdd_send_rps_disable_ind(adapter); |
| 7172 | } |
| 7173 | |
| 7174 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7175 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7176 | * @hdd_ctx - handle to hdd context |
| 7177 | * @tx_packets - transmit packet count |
| 7178 | * @rx_packets - receive packet count |
| 7179 | * |
| 7180 | * The function controls the bus bandwidth and dynamic control of |
| 7181 | * tcp delayed ack configuration |
| 7182 | * |
| 7183 | * Returns: None |
| 7184 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7185 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7186 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7187 | const uint64_t tx_packets, |
| 7188 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7189 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7190 | u64 total_pkts = tx_packets + rx_packets; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7191 | uint64_t temp_rx = 0; |
| 7192 | uint64_t temp_tx = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7193 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7194 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7195 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7196 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7197 | uint16_t index = 0; |
| 7198 | bool vote_level_change = false; |
| 7199 | bool rx_level_change = false; |
| 7200 | bool tx_level_change = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7201 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7202 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7203 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7204 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7205 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7206 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7207 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7208 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7209 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7210 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7211 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7212 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7213 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7214 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7215 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7216 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7217 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7218 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7219 | if (hdd_ctx->hbw_requested) { |
| 7220 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7221 | hdd_ctx->hbw_requested = false; |
| 7222 | } |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7223 | if (cds_sched_handle_throughput_req(false)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7224 | hdd_warn("low bandwidth set rx affinity fail"); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7225 | |
| 7226 | if (hdd_ctx->dynamic_rps) |
| 7227 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7228 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7229 | if (!hdd_ctx->hbw_requested) { |
| 7230 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7231 | hdd_ctx->hbw_requested = true; |
| 7232 | } |
| 7233 | |
Nirav Shah | 3bbfa51 | 2016-05-12 16:43:49 +0530 | [diff] [blame] | 7234 | if (cds_sched_handle_throughput_req(true)) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7235 | hdd_warn("high bandwidth set rx affinity fail"); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7236 | |
| 7237 | if (hdd_ctx->dynamic_rps) |
| 7238 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7239 | } |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 7240 | hdd_napi_apply_throughput_policy(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7241 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7242 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 7243 | qdf_dp_trace_throttle_live_mode( |
| 7244 | (next_vote_level > PLD_BUS_WIDTH_NONE) ? true : false); |
| 7245 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7246 | /* fine-tuning parameters for RX Flows */ |
| 7247 | temp_rx = (rx_packets + hdd_ctx->prev_rx) / 2; |
| 7248 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7249 | hdd_ctx->prev_rx = rx_packets; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7250 | |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7251 | if (temp_rx < hdd_ctx->config->busBandwidthLowThreshold) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 7252 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7253 | else |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 7254 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7255 | |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7256 | if (temp_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
| 7257 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7258 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7259 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7260 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7261 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7262 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7263 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7264 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7265 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7266 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7267 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7268 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7269 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7270 | next_rx_level, temp_rx); |
| 7271 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7272 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7273 | /* Send throughput indication only if it is enabled. |
| 7274 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7275 | * to default delayed ack. Note that this will disable the |
| 7276 | * dynamic delayed ack mechanism across the system |
| 7277 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7278 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7279 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7280 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7281 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7282 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7283 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7284 | rx_tp_data.level = next_rx_level; |
| 7285 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7286 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7287 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7288 | } |
| 7289 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7290 | /* fine-tuning parameters for TX Flows */ |
| 7291 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7292 | hdd_ctx->prev_tx = tx_packets; |
| 7293 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7294 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7295 | else |
| 7296 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7297 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7298 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7299 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7300 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7301 | next_tx_level, temp_tx); |
| 7302 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7303 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7304 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7305 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7306 | &next_tx_level, |
| 7307 | sizeof(next_tx_level)); |
| 7308 | } |
| 7309 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7310 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7311 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7312 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7313 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7314 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7315 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7316 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7317 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7318 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7319 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7320 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7321 | |
| 7322 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7323 | } |
| 7324 | |
| 7325 | #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] | 7326 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7327 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7328 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7329 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7330 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7331 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7332 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7333 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7334 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7335 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7336 | bool connected = false; |
| 7337 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7338 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7339 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7340 | return; |
| 7341 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7342 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7343 | goto restart_timer; |
| 7344 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7345 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7346 | /* |
| 7347 | * Validate magic so we don't end up accessing |
| 7348 | * an invalid adapter. |
| 7349 | */ |
| 7350 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7351 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7352 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7353 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7354 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7356 | != eConnectionState_Associated) { |
| 7357 | |
| 7358 | continue; |
| 7359 | } |
| 7360 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7361 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7362 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7363 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7364 | |
| 7365 | continue; |
| 7366 | } |
| 7367 | |
| 7368 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7369 | adapter->prev_tx_packets); |
| 7370 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7371 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7372 | |
| 7373 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7374 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7375 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7376 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7377 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7378 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7379 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7380 | &fwd_tx_packets, &fwd_rx_packets); |
| 7381 | if (ret == A_OK) { |
| 7382 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7383 | fwd_tx_packets, |
| 7384 | adapter->prev_fwd_tx_packets); |
| 7385 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7386 | fwd_tx_packets, |
| 7387 | adapter->prev_fwd_rx_packets); |
| 7388 | } |
| 7389 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7390 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7391 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7392 | con_sap_adapter = adapter; |
| 7393 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7394 | total_rx += adapter->stats.rx_packets; |
| 7395 | total_tx += adapter->stats.tx_packets; |
| 7396 | |
| 7397 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7398 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7399 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7400 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7401 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7402 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7403 | connected = true; |
| 7404 | } |
| 7405 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7406 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7407 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7408 | return; |
| 7409 | } |
| 7410 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7411 | /* add intra bss forwarded tx and rx packets */ |
| 7412 | tx_packets += fwd_tx_packets_diff; |
| 7413 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7414 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7415 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->hdd_pdev)) { |
| 7416 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7417 | &ipa_rx_packets); |
| 7418 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7419 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7420 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7421 | if (con_sap_adapter) { |
| 7422 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7423 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7424 | } |
| 7425 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7426 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
| 7427 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
| 7428 | } |
| 7429 | |
| 7430 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7431 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7432 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7433 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7434 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7435 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7436 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7437 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7438 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7439 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7440 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7441 | /** |
| 7442 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7443 | * @arg: Argument of timer function |
| 7444 | * |
| 7445 | * Schedule a workqueue in this function where all the processing is done. |
| 7446 | * |
| 7447 | * Return: None. |
| 7448 | */ |
| 7449 | static void __hdd_bus_bw_cbk(void *arg) |
| 7450 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7451 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7452 | |
| 7453 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7454 | return; |
| 7455 | |
| 7456 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7457 | } |
| 7458 | |
| 7459 | /** |
| 7460 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7461 | * @arg: Argument of timer function |
| 7462 | * |
| 7463 | * Return: None. |
| 7464 | */ |
| 7465 | static void hdd_bus_bw_cbk(void *arg) |
| 7466 | { |
| 7467 | cds_ssr_protect(__func__); |
| 7468 | __hdd_bus_bw_cbk(arg); |
| 7469 | cds_ssr_unprotect(__func__); |
| 7470 | } |
| 7471 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7472 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7473 | { |
| 7474 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7475 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7476 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7477 | hdd_ctx->bus_bw_timer_running = false; |
| 7478 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7479 | qdf_timer_init(NULL, |
| 7480 | &hdd_ctx->bus_bw_timer, |
| 7481 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7482 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7483 | |
| 7484 | return 0; |
| 7485 | } |
| 7486 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7487 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7488 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7489 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7490 | hdd_reset_tcp_delack(hdd_ctx); |
| 7491 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7492 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7493 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7494 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7495 | hdd_ctx->bus_bw_timer_running = false; |
| 7496 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7497 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7498 | |
| 7499 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7500 | { |
| 7501 | if (hdd_ctx) |
| 7502 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7503 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7504 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7505 | #endif |
| 7506 | |
| 7507 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7508 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7509 | * @hdd_ctx: hdd context |
| 7510 | * |
| 7511 | * Return: 0 for success or error code |
| 7512 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7513 | 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] | 7514 | { |
| 7515 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7516 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7517 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7518 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7519 | return -ENOMEM; |
| 7520 | } |
| 7521 | return 0; |
| 7522 | } |
| 7523 | |
| 7524 | /** |
| 7525 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7526 | * @hdd_ctx: hdd context |
| 7527 | * |
| 7528 | * Return: none |
| 7529 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7530 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7531 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7532 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7533 | return; |
| 7534 | |
| 7535 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7536 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7537 | } |
| 7538 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7539 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7540 | { |
| 7541 | switch (level) { |
| 7542 | /* initialize the wlan sub system */ |
| 7543 | case WLAN_SVC_TP_NONE: |
| 7544 | return "NONE"; |
| 7545 | case WLAN_SVC_TP_LOW: |
| 7546 | return "LOW"; |
| 7547 | case WLAN_SVC_TP_MEDIUM: |
| 7548 | return "MED"; |
| 7549 | case WLAN_SVC_TP_HIGH: |
| 7550 | return "HIGH"; |
| 7551 | default: |
| 7552 | return "INVAL"; |
| 7553 | } |
| 7554 | } |
| 7555 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7556 | |
| 7557 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7558 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7559 | * @hdd_ctx: hdd context |
| 7560 | * |
| 7561 | * Return: none |
| 7562 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7563 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7564 | { |
| 7565 | int i; |
| 7566 | |
| 7567 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7568 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7569 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7570 | 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] | 7571 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7572 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7573 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7574 | hdd_debug("Enable TCP DEL ACK: %d", |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7575 | hdd_ctx->en_tcp_delack_no_lro); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7576 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7577 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7578 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7579 | 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] | 7580 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7581 | #endif |
| 7582 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7583 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7584 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7585 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7586 | 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] | 7587 | |
| 7588 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7589 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7590 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7591 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7592 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7593 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7594 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7595 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7596 | hdd_ctx->hdd_txrx_hist[i]. |
| 7597 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7598 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7599 | hdd_ctx->hdd_txrx_hist[i]. |
| 7600 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7601 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7602 | hdd_ctx->hdd_txrx_hist[i]. |
| 7603 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7604 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7605 | } |
| 7606 | |
| 7607 | /** |
| 7608 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7609 | * @hdd_ctx: hdd context |
| 7610 | * |
| 7611 | * Return: none |
| 7612 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7613 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7614 | { |
| 7615 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7616 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7617 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7618 | } |
| 7619 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7620 | /* length of the netif queue log needed per adapter */ |
| 7621 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7622 | |
| 7623 | /** |
| 7624 | * |
| 7625 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7626 | * @hdd_ctx: hdd context |
| 7627 | * |
| 7628 | * Return: none |
| 7629 | */ |
| 7630 | static void |
| 7631 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7632 | { |
| 7633 | int adapter_num = 0; |
| 7634 | int i; |
| 7635 | int bytes_written; |
| 7636 | u32 tbytes; |
| 7637 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7638 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7639 | char *comb_log_str; |
| 7640 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7641 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7642 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7643 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7644 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7645 | if (!comb_log_str) { |
| 7646 | hdd_err("failed to alloc comb_log_str"); |
| 7647 | return; |
| 7648 | } |
| 7649 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7650 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7651 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7652 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7653 | curr_time = qdf_system_ticks(); |
| 7654 | total = curr_time - adapter->start_time; |
| 7655 | delta = curr_time - adapter->last_time; |
| 7656 | |
| 7657 | if (adapter->pause_map) { |
| 7658 | pause = adapter->total_pause_time + delta; |
| 7659 | unpause = adapter->total_unpause_time; |
| 7660 | } else { |
| 7661 | unpause = adapter->total_unpause_time + delta; |
| 7662 | pause = adapter->total_pause_time; |
| 7663 | } |
| 7664 | |
| 7665 | tbytes = 0; |
| 7666 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7667 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7668 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7669 | continue; |
| 7670 | tbytes += |
| 7671 | snprintf( |
| 7672 | &temp_str[tbytes], |
| 7673 | (tbytes >= sizeof(temp_str) ? |
| 7674 | 0 : sizeof(temp_str) - tbytes), |
| 7675 | "%d(%d,%d) ", |
| 7676 | i, |
| 7677 | adapter->queue_oper_stats[i]. |
| 7678 | pause_count, |
| 7679 | adapter->queue_oper_stats[i]. |
| 7680 | unpause_count); |
| 7681 | } |
| 7682 | if (tbytes >= sizeof(temp_str)) |
| 7683 | hdd_warn("log truncated"); |
| 7684 | |
| 7685 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7686 | bytes_written >= comb_log_str_size ? 0 : |
| 7687 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7688 | "[%d %d] (%d) %u/%ums %s|", |
| 7689 | adapter->session_id, adapter->device_mode, |
| 7690 | adapter->pause_map, |
| 7691 | qdf_system_ticks_to_msecs(pause), |
| 7692 | qdf_system_ticks_to_msecs(total), |
| 7693 | temp_str); |
| 7694 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7695 | adapter_num++; |
| 7696 | } |
| 7697 | |
| 7698 | /* using QDF_TRACE to avoid printing function name */ |
| 7699 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7700 | "STATS |%s", comb_log_str); |
| 7701 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7702 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7703 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7704 | |
| 7705 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7706 | } |
| 7707 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7708 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7709 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7710 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7711 | * |
| 7712 | * Return: none |
| 7713 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7714 | void |
| 7715 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7716 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7717 | { |
| 7718 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7719 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7720 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7721 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7722 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7723 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7724 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7725 | return; |
| 7726 | } |
| 7727 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7728 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7729 | hdd_debug("Netif queue operation statistics:"); |
| 7730 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7731 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7732 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7733 | curr_time = qdf_system_ticks(); |
| 7734 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7735 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7736 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7737 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7738 | unpause = adapter->total_unpause_time; |
| 7739 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7740 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7741 | pause = adapter->total_pause_time; |
| 7742 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7743 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7744 | qdf_system_ticks_to_msecs(total), |
| 7745 | qdf_system_ticks_to_msecs(pause), |
| 7746 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7747 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7748 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7749 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7750 | qdf_time_t pause_delta = 0; |
| 7751 | |
| 7752 | if (adapter->pause_map & (1 << i)) |
| 7753 | pause_delta = delta; |
| 7754 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7755 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7756 | hdd_debug("%s: %d: %d: %ums", |
| 7757 | hdd_reason_type_to_string(i), |
| 7758 | adapter->queue_oper_stats[i].pause_count, |
| 7759 | adapter->queue_oper_stats[i].unpause_count, |
| 7760 | qdf_system_ticks_to_msecs( |
| 7761 | adapter->queue_oper_stats[i].total_pause_time + |
| 7762 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7763 | } |
| 7764 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7765 | hdd_debug("Netif queue operation history:"); |
| 7766 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7767 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7768 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7769 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7770 | |
| 7771 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7772 | /* using hdd_log to avoid printing function name */ |
| 7773 | if (adapter->queue_oper_history[i].time == 0) |
| 7774 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7775 | hdd_debug("%d: %u: %s: %s: %x", |
| 7776 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7777 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7778 | hdd_action_type_to_string( |
| 7779 | adapter->queue_oper_history[i].netif_action), |
| 7780 | hdd_reason_type_to_string( |
| 7781 | adapter->queue_oper_history[i].netif_reason), |
| 7782 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7783 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7784 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7785 | } |
| 7786 | |
| 7787 | /** |
| 7788 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7789 | * @hdd_ctx: hdd context |
| 7790 | * |
| 7791 | * Return: none |
| 7792 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7793 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7794 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7795 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7796 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7797 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7798 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7799 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7800 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7801 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7802 | adapter->history_index = 0; |
| 7803 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7804 | adapter->total_pause_time = 0; |
| 7805 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7806 | } |
| 7807 | } |
| 7808 | |
| 7809 | /** |
| 7810 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
| 7811 | * @halHandle: Hal handle |
| 7812 | * @pContext: Pointer to the context |
| 7813 | * @sessionId: Session ID |
| 7814 | * @scanId: Scan ID |
| 7815 | * @status: Status |
| 7816 | * |
| 7817 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7818 | * the scan results |
| 7819 | * |
| 7820 | * 11d scan is done during driver load and is a passive scan on all |
| 7821 | * channels supported by the device, 11d scans may find some APs on |
| 7822 | * frequencies which are forbidden to be used in the regulatory domain |
| 7823 | * the device is operating in. If these APs are notified to the supplicant |
| 7824 | * it may try to connect to these APs, thus flush out all the scan results |
| 7825 | * which are present in SME after 11d scan is done. |
| 7826 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7827 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7828 | */ |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7829 | static QDF_STATUS hdd_11d_scan_done(tHalHandle halHandle, void *pContext, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7830 | uint8_t sessionId, uint32_t scanId, |
| 7831 | eCsrScanStatus status) |
| 7832 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7833 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7834 | |
| 7835 | sme_scan_flush_result(halHandle); |
| 7836 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7837 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7838 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7839 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7840 | } |
| 7841 | |
| 7842 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 7843 | /** |
| 7844 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 7845 | * @hdd_ctx: hdd global context |
| 7846 | * |
| 7847 | * Return: none |
| 7848 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7849 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7850 | { |
| 7851 | uint8_t i; |
| 7852 | |
| 7853 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 7854 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 7855 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 7856 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 7857 | } |
| 7858 | } |
| 7859 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7860 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7861 | { |
| 7862 | } |
| 7863 | #endif |
| 7864 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7865 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 7866 | /** |
| 7867 | * 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] | 7868 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7869 | * @enable: enable or disable this behaviour |
| 7870 | * |
| 7871 | * Return: int |
| 7872 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7873 | 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] | 7874 | { |
| 7875 | struct hdd_config *pcfg_ini = phddctx->config; |
| 7876 | struct wow_pulse_mode wow_pulse_set_info; |
| 7877 | QDF_STATUS status; |
| 7878 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7879 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7880 | |
| 7881 | if (false == phddctx->config->wow_pulse_support) |
| 7882 | return 0; |
| 7883 | |
| 7884 | /* prepare the request to send to SME */ |
| 7885 | if (enable == true) { |
| 7886 | wow_pulse_set_info.wow_pulse_enable = true; |
| 7887 | wow_pulse_set_info.wow_pulse_pin = |
| 7888 | pcfg_ini->wow_pulse_pin; |
| 7889 | wow_pulse_set_info.wow_pulse_interval_low = |
| 7890 | pcfg_ini->wow_pulse_interval_low; |
| 7891 | wow_pulse_set_info.wow_pulse_interval_high = |
| 7892 | pcfg_ini->wow_pulse_interval_high; |
| 7893 | } else { |
| 7894 | wow_pulse_set_info.wow_pulse_enable = false; |
| 7895 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 7896 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 7897 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 7898 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7899 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7900 | wow_pulse_set_info.wow_pulse_enable, |
| 7901 | wow_pulse_set_info.wow_pulse_pin, |
| 7902 | wow_pulse_set_info.wow_pulse_interval_low, |
| 7903 | wow_pulse_set_info.wow_pulse_interval_high); |
| 7904 | |
| 7905 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 7906 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7907 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7908 | return -EIO; |
| 7909 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7910 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 7911 | return 0; |
| 7912 | } |
| 7913 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7914 | 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] | 7915 | { |
| 7916 | return 0; |
| 7917 | } |
| 7918 | #endif |
| 7919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7920 | #ifdef WLAN_FEATURE_FASTPATH |
| 7921 | /** |
| 7922 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 7923 | * @hdd_cfg: hdd config |
| 7924 | * @context: lower layer context |
| 7925 | * |
| 7926 | * Return: none |
| 7927 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7928 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7929 | void *context) |
| 7930 | { |
| 7931 | if (hdd_cfg->fastpath_enable) |
| 7932 | hif_enable_fastpath(context); |
| 7933 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7934 | #endif |
| 7935 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7936 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7937 | /** |
| 7938 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7939 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7940 | * @level: thermal level |
| 7941 | * |
| 7942 | * Change IPA data path to SW path when the thermal throttle level greater |
| 7943 | * than 0, and restore the original data path when throttle level is 0 |
| 7944 | * |
| 7945 | * Return: none |
| 7946 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7947 | 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] | 7948 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7949 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 7950 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7951 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 7952 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7953 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7954 | else |
| 7955 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 7956 | 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] | 7957 | } |
| 7958 | |
| 7959 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7960 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 7961 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 7962 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7963 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7964 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 7965 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 7966 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7967 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7968 | * Return: Channel number to restart SAP in case of success. In case of any |
| 7969 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7970 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7971 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7972 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7973 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7974 | struct sir_pcl_list pcl; |
| 7975 | QDF_STATUS status; |
| 7976 | uint32_t i, j; |
Jeff Johnson | 796b9a7 | 2018-06-01 17:12:32 -0700 | [diff] [blame] | 7977 | tHalHandle hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7978 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7979 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 7980 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7981 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7982 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7983 | if (!hdd_ctx) { |
| 7984 | hdd_err("invalid HDD context"); |
| 7985 | return INVALID_CHANNEL_ID; |
| 7986 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7987 | |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 7988 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 7989 | if (!hal_handle) { |
| 7990 | hdd_err("invalid HAL handle"); |
| 7991 | return INVALID_CHANNEL_ID; |
| 7992 | } |
| 7993 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 7994 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 7995 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 7996 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 7997 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 7998 | if (QDF_IS_STATUS_ERROR(status)) { |
| 7999 | hdd_err("Get PCL failed"); |
| 8000 | return INVALID_CHANNEL_ID; |
| 8001 | } |
| 8002 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8003 | /* |
| 8004 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8005 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8006 | * try to choose a safe channel from acs range. |
| 8007 | */ |
| 8008 | if (!pcl.pcl_len) |
| 8009 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8010 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8011 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8012 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8013 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8014 | |
| 8015 | /* PCL already takes unsafe channel into account */ |
| 8016 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8017 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8018 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8019 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8020 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8021 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8022 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8023 | return pcl.pcl_list[i]; |
| 8024 | } |
| 8025 | } |
| 8026 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8027 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8028 | |
| 8029 | /* Try for safe channel from all valid channel */ |
| 8030 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 8031 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8032 | &pcl.pcl_len); |
| 8033 | if (ret) { |
| 8034 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8035 | return INVALID_CHANNEL_ID; |
| 8036 | } |
| 8037 | |
| 8038 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8039 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8040 | found = false; |
| 8041 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 8042 | if (pcl.pcl_list[i] == |
| 8043 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8044 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8045 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8046 | break; |
| 8047 | } |
| 8048 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8049 | |
| 8050 | if (found) |
| 8051 | continue; |
| 8052 | |
| 8053 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8054 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8055 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8056 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8057 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8058 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8059 | } |
| 8060 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8061 | |
| 8062 | return INVALID_CHANNEL_ID; |
| 8063 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8064 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8065 | |
| 8066 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8067 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8068 | * @adapter: AP adapter |
| 8069 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8070 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8071 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8072 | * Moves the SAP interface by invoking the function which |
| 8073 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8074 | * |
| 8075 | * Return: None |
| 8076 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8077 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8078 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8079 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8080 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | 796b9a7 | 2018-06-01 17:12:32 -0700 | [diff] [blame] | 8081 | tHalHandle hal_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8082 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8083 | |
| 8084 | if (!adapter) { |
| 8085 | hdd_err("invalid adapter"); |
| 8086 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8087 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8088 | |
| 8089 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8090 | |
| 8091 | hal_handle = WLAN_HDD_GET_HAL_CTX(adapter); |
| 8092 | if (!hal_handle) { |
| 8093 | hdd_err("invalid HAL handle"); |
| 8094 | return; |
| 8095 | } |
| 8096 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8097 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8098 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8099 | hdd_ap_ctx->sap_config.channel = channel; |
| 8100 | hdd_ap_ctx->sap_config.ch_params.ch_width = |
| 8101 | hdd_ap_ctx->sap_config.ch_width_orig; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8102 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8103 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8104 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8105 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 8106 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8107 | hdd_ap_ctx->sap_config.channel, |
| 8108 | hdd_ap_ctx->sap_config.sec_ch, |
| 8109 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8110 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8111 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8112 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8113 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8114 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8115 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8116 | 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] | 8117 | { |
| 8118 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8119 | int status; |
| 8120 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8121 | |
| 8122 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8123 | |
| 8124 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8125 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8126 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8127 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8128 | } |
| 8129 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8130 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8131 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8132 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8133 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8134 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8135 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8136 | hdd_err("failed to start external acs timer"); |
| 8137 | return -ENOSPC; |
| 8138 | } |
| 8139 | /* Update config to application */ |
| 8140 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8141 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8142 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8143 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8144 | } |
| 8145 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8146 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8147 | /** |
| 8148 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8149 | * @hdd_ctx: hdd context pointer |
| 8150 | * |
| 8151 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8152 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8153 | * sap. User space on LTE coex indication restart driver. |
| 8154 | * |
| 8155 | * Return - none |
| 8156 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8157 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8158 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8159 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8160 | uint32_t i; |
| 8161 | bool found = false; |
| 8162 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8163 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8164 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8165 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8166 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8167 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8168 | adapter->device_mode, |
| 8169 | adapter->session.ap.sap_config. |
| 8170 | acs_cfg.acs_mode); |
| 8171 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8172 | } |
| 8173 | |
| 8174 | found = false; |
| 8175 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8176 | if (adapter->session.ap.operating_channel == |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8177 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8178 | found = true; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8179 | hdd_debug("operating ch:%d is unsafe", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8180 | adapter->session.ap.operating_channel); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8181 | break; |
| 8182 | } |
| 8183 | } |
| 8184 | |
| 8185 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8186 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8187 | adapter->session.ap.operating_channel); |
| 8188 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8189 | } |
| 8190 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8191 | if (hdd_ctxt->config->vendor_acs_support && |
| 8192 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8193 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8194 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8195 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8196 | } else |
| 8197 | restart_chan = |
| 8198 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8199 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8200 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8201 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8202 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8203 | /* |
| 8204 | * SAP restart due to unsafe channel. While |
| 8205 | * restarting the SAP, make sure to clear |
| 8206 | * acs_channel, channel to reset to |
| 8207 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8208 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8209 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8210 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8211 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8212 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8213 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8214 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8215 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8216 | hdd_debug("driver to start sap: %d", |
| 8217 | hdd_ctxt->config->sap_internal_restart); |
| 8218 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8219 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8220 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8221 | else |
| 8222 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8223 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8224 | } |
| 8225 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8226 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8227 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8228 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8229 | * @hdd_ctx: HDD global context |
| 8230 | * |
| 8231 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8232 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8233 | * down to the lower layers. Then subscribe to subsequent channel |
| 8234 | * avoidance events. |
| 8235 | * |
| 8236 | * Return: None |
| 8237 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8238 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8239 | { |
| 8240 | uint16_t unsafe_channel_count; |
| 8241 | int index; |
| 8242 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8243 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8244 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8245 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8246 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8247 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8248 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8249 | hdd_ctx->unsafe_channel_count); |
| 8250 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8251 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8252 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8253 | |
| 8254 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8255 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8256 | hdd_ctx->unsafe_channel_list[index]); |
| 8257 | |
| 8258 | } |
| 8259 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8260 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8261 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8262 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8263 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8264 | { |
| 8265 | uint8_t restart_chan; |
| 8266 | |
| 8267 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8268 | if (!restart_chan) { |
| 8269 | hdd_alert("fail to restart SAP"); |
| 8270 | return; |
| 8271 | } |
| 8272 | |
| 8273 | /* SAP restart due to unsafe channel. While restarting |
| 8274 | * the SAP, make sure to clear acs_channel, channel to |
| 8275 | * reset to 0. Otherwise these settings will override |
| 8276 | * the ACS while restart. |
| 8277 | */ |
| 8278 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8279 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8280 | |
| 8281 | hdd_debug("sending coex indication"); |
| 8282 | |
| 8283 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8284 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8285 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8286 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8287 | |
| 8288 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8289 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8290 | { |
| 8291 | uint32_t size; |
| 8292 | uint16_t *unsafe_list; |
| 8293 | uint16_t chan_count; |
| 8294 | |
| 8295 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8296 | return -EINVAL; |
| 8297 | |
| 8298 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8299 | NUM_CHANNELS); |
| 8300 | if (chan_count) { |
| 8301 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8302 | unsafe_list = qdf_mem_malloc(size); |
| 8303 | if (!unsafe_list) { |
| 8304 | hdd_err("No memory for unsafe chan list size%d", |
| 8305 | size); |
| 8306 | return -ENOMEM; |
| 8307 | } |
| 8308 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8309 | } else { |
| 8310 | unsafe_list = NULL; |
| 8311 | } |
| 8312 | |
| 8313 | *local_unsafe_list = unsafe_list; |
| 8314 | *local_unsafe_list_count = chan_count; |
| 8315 | |
| 8316 | return 0; |
| 8317 | } |
| 8318 | |
| 8319 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8320 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8321 | { |
| 8322 | int i, j; |
| 8323 | |
| 8324 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8325 | return true; |
| 8326 | if (local_unsafe_list_count == 0) |
| 8327 | return false; |
| 8328 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8329 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8330 | if (local_unsafe_list[i] == |
| 8331 | hdd_ctx->unsafe_channel_list[j]) |
| 8332 | break; |
| 8333 | if (j >= local_unsafe_list_count) |
| 8334 | break; |
| 8335 | } |
| 8336 | if (i >= local_unsafe_list_count) { |
| 8337 | hdd_info("unsafe chan list same"); |
| 8338 | return false; |
| 8339 | } |
| 8340 | |
| 8341 | return true; |
| 8342 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8343 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8344 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8345 | { |
| 8346 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8347 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8348 | 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] | 8349 | { |
| 8350 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8351 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8352 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8353 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8354 | { |
| 8355 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8356 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8357 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8358 | |
| 8359 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8360 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8361 | * user space |
| 8362 | * @frame_ind: Management frame data to be informed. |
| 8363 | * |
| 8364 | * This function is used to indicate management frame to |
| 8365 | * user space |
| 8366 | * |
| 8367 | * Return: None |
| 8368 | * |
| 8369 | */ |
| 8370 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8371 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8372 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8373 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8374 | int i; |
| 8375 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8376 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8377 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8378 | return; |
| 8379 | |
| 8380 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8381 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8382 | adapter = |
| 8383 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8384 | if (adapter) |
| 8385 | break; |
| 8386 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8387 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8388 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8389 | if ((NULL != adapter) && |
| 8390 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8391 | __hdd_indicate_mgmt_frame(adapter, |
| 8392 | frame_ind->frame_len, |
| 8393 | frame_ind->frameBuf, |
| 8394 | frame_ind->frameType, |
| 8395 | frame_ind->rxChan, |
| 8396 | frame_ind->rxRssi); |
| 8397 | } |
| 8398 | } |
| 8399 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8400 | } else { |
| 8401 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8402 | frame_ind->sessionId); |
| 8403 | } |
| 8404 | |
| 8405 | if ((NULL != adapter) && |
| 8406 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8407 | __hdd_indicate_mgmt_frame(adapter, |
| 8408 | frame_ind->frame_len, |
| 8409 | frame_ind->frameBuf, |
| 8410 | frame_ind->frameType, |
| 8411 | frame_ind->rxChan, |
| 8412 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8413 | } |
| 8414 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8415 | void hdd_acs_response_timeout_handler(void *context) |
| 8416 | { |
| 8417 | struct hdd_external_acs_timer_context *timer_context = |
| 8418 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8419 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8420 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8421 | uint8_t reason; |
| 8422 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8423 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8424 | if (!timer_context) { |
| 8425 | hdd_err("invlaid timer context"); |
| 8426 | return; |
| 8427 | } |
| 8428 | adapter = timer_context->adapter; |
| 8429 | reason = timer_context->reason; |
| 8430 | |
| 8431 | |
| 8432 | if ((!adapter) || |
| 8433 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8434 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8435 | return; |
| 8436 | } |
| 8437 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8438 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8439 | return; |
| 8440 | |
| 8441 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8442 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8443 | else |
| 8444 | return; |
| 8445 | |
| 8446 | hdd_err("ACS timeout happened for %s reason %d", |
| 8447 | adapter->dev->name, reason); |
| 8448 | switch (reason) { |
| 8449 | /* SAP init case */ |
| 8450 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8451 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8452 | false); |
| 8453 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8454 | break; |
| 8455 | /* DFS detected on current channel */ |
| 8456 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8457 | wlan_sap_update_next_channel( |
| 8458 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
| 8459 | sme_update_new_channel_event(WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8460 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8461 | break; |
| 8462 | /* LTE coex event on current channel */ |
| 8463 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8464 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8465 | break; |
| 8466 | default: |
| 8467 | hdd_info("invalid reason for timer invoke"); |
| 8468 | |
| 8469 | } |
| 8470 | } |
| 8471 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8472 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8473 | * hdd_override_ini_config - Override INI config |
| 8474 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8475 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8476 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8477 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8478 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8479 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8480 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8481 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8482 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8483 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8484 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8485 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8486 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8487 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8488 | if (0 == enable_11d || 1 == enable_11d) { |
| 8489 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8490 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8491 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8492 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8493 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8494 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8495 | hdd_debug("IpaConfig override to %d", |
| 8496 | hdd_ctx->config->IpaConfig); |
| 8497 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8498 | |
| 8499 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8500 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8501 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8502 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8503 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8504 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8505 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8506 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8507 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8508 | /** |
| 8509 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8510 | * @hdd_ctx - HDD context |
| 8511 | * |
| 8512 | * Set trace level for each module based on INI config. |
| 8513 | * |
| 8514 | * Return: None |
| 8515 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8516 | 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] | 8517 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8518 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8519 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8520 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8521 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8522 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8523 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8524 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8525 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8526 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8527 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8528 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8529 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8530 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8531 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8532 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8533 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8534 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8535 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8536 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8537 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8538 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8539 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8540 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8541 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8542 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8543 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8544 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8545 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8546 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8547 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8548 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8549 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8550 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8551 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8552 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8553 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8554 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8555 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8556 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8557 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8558 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8559 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8560 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8561 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8562 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8563 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8564 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8565 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8566 | } |
| 8567 | |
| 8568 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8569 | * hdd_context_init() - Initialize HDD context |
| 8570 | * @hdd_ctx: HDD context. |
| 8571 | * |
| 8572 | * Initialize HDD context along with all the feature specific contexts. |
| 8573 | * |
| 8574 | * return: 0 on success and errno on failure. |
| 8575 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8576 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8577 | { |
| 8578 | int ret; |
| 8579 | |
| 8580 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8581 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8582 | |
| 8583 | hdd_init_ll_stats_ctx(); |
| 8584 | |
| 8585 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8586 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8587 | |
| 8588 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8589 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8590 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8591 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8592 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8593 | |
| 8594 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8595 | |
| 8596 | ret = hdd_scan_context_init(hdd_ctx); |
| 8597 | if (ret) |
| 8598 | goto list_destroy; |
| 8599 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8600 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8601 | |
| 8602 | ret = hdd_sap_context_init(hdd_ctx); |
| 8603 | if (ret) |
| 8604 | goto scan_destroy; |
| 8605 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8606 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8607 | |
| 8608 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8609 | |
| 8610 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8611 | hdd_ctx->config); |
| 8612 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8613 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8614 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8615 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8616 | "monitor_mode_wakelock"); |
| 8617 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8618 | return 0; |
| 8619 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8620 | sap_destroy: |
| 8621 | hdd_sap_context_destroy(hdd_ctx); |
| 8622 | |
| 8623 | scan_destroy: |
| 8624 | hdd_scan_context_destroy(hdd_ctx); |
| 8625 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8626 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8627 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8628 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8629 | return ret; |
| 8630 | } |
| 8631 | |
| 8632 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8633 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8634 | * @hdd_ctx: pointer to hdd context |
| 8635 | * |
| 8636 | * Return: status of initialization |
| 8637 | * 0 - success |
| 8638 | * negative value - failure |
| 8639 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8640 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8641 | { |
| 8642 | int ret; |
| 8643 | |
| 8644 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8645 | return 0; |
| 8646 | |
| 8647 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8648 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8649 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8650 | return -EINVAL; |
| 8651 | } |
| 8652 | |
| 8653 | /* parse ini string probe req oui */ |
| 8654 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8655 | if (ret) { |
| 8656 | hdd_err("parsing error: disable ie whitelisting"); |
| 8657 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8658 | } |
| 8659 | |
| 8660 | return ret; |
| 8661 | } |
| 8662 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8663 | /** |
| 8664 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8665 | * @priv: pointer to hdd context |
| 8666 | * |
| 8667 | * This function is invoked when the timer waiting for the interface change |
| 8668 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8669 | * |
| 8670 | * Return: void |
| 8671 | */ |
| 8672 | static void hdd_iface_change_callback(void *priv) |
| 8673 | { |
| 8674 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8675 | int ret; |
| 8676 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8677 | |
| 8678 | if (status) |
| 8679 | return; |
| 8680 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8681 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8682 | hdd_debug("Interface change timer expired close the modules!"); |
| 8683 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8684 | if (ret) |
| 8685 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8686 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8687 | } |
| 8688 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8689 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8690 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8691 | { |
| 8692 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8693 | wlan_logging_to_console); |
| 8694 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8695 | } |
| 8696 | #else |
| 8697 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8698 | { } |
| 8699 | #endif |
| 8700 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8701 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8702 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8703 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8704 | * |
| 8705 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8706 | * wiphy allocation and then context is initialized. |
| 8707 | * |
| 8708 | * Return: HDD context on success and ERR_PTR on failure |
| 8709 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8710 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8711 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8712 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8713 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8714 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8715 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8716 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8717 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8718 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8719 | if (hdd_ctx == NULL) { |
| 8720 | ret = -ENOMEM; |
| 8721 | goto err_out; |
| 8722 | } |
| 8723 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8724 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8725 | hdd_iface_change_callback, |
| 8726 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8727 | |
| 8728 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8729 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8730 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8731 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8732 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8733 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8734 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8735 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8736 | ret = -ENOMEM; |
| 8737 | goto err_free_hdd_context; |
| 8738 | } |
| 8739 | |
| 8740 | /* Read and parse the qcom_cfg.ini file */ |
| 8741 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8742 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8743 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8744 | WLAN_INI_FILE); |
| 8745 | ret = -EINVAL; |
| 8746 | goto err_free_config; |
| 8747 | } |
| 8748 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8749 | ie_whitelist_attrs_init(hdd_ctx); |
| 8750 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8751 | hdd_debug("setting timer multiplier: %u", |
| 8752 | hdd_ctx->config->timer_multiplier); |
| 8753 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8754 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8755 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8756 | if (hdd_ctx->config->fhostNSOffload) |
| 8757 | hdd_ctx->ns_offload_enable = true; |
| 8758 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8759 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8760 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8761 | hdd_override_ini_config(hdd_ctx); |
| 8762 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8763 | ret = hdd_context_init(hdd_ctx); |
| 8764 | |
| 8765 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8766 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8767 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8768 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8769 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8770 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8771 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8772 | goto skip_multicast_logging; |
| 8773 | |
| 8774 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8775 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8776 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8777 | if (ret) |
| 8778 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8779 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8780 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8781 | if (ret) |
| 8782 | goto err_deinit_txrx_histogram; |
| 8783 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8784 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8785 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8786 | skip_multicast_logging: |
| 8787 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8788 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8789 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8790 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8791 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8792 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8793 | return hdd_ctx; |
| 8794 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8795 | err_deinit_txrx_histogram: |
| 8796 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8797 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8798 | err_deinit_hdd_context: |
| 8799 | hdd_context_deinit(hdd_ctx); |
| 8800 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8801 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8802 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8803 | |
| 8804 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8805 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8806 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8807 | |
| 8808 | err_out: |
| 8809 | return ERR_PTR(ret); |
| 8810 | } |
| 8811 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8812 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8813 | /** |
| 8814 | * hdd_open_p2p_interface - Open P2P interface |
| 8815 | * @hdd_ctx: HDD context |
| 8816 | * @rtnl_held: True if RTNL lock held |
| 8817 | * |
| 8818 | * Open P2P interface during probe. This function called to open the P2P |
| 8819 | * interface at probe along with STA interface. |
| 8820 | * |
| 8821 | * Return: 0 on success and errno on failure |
| 8822 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8823 | 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] | 8824 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8825 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8826 | uint8_t *p2p_dev_addr; |
| 8827 | |
| 8828 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 8829 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8830 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8831 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 8832 | sizeof(tSirMacAddr)); |
| 8833 | |
| 8834 | /* |
| 8835 | * Generate the P2P Device Address. This consists of |
| 8836 | * the device's primary MAC address with the locally |
| 8837 | * administered bit set. |
| 8838 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8839 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8840 | } else { |
| 8841 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 8842 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8843 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8844 | return -ENOSPC; |
| 8845 | } |
| 8846 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8847 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 8848 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8849 | } |
| 8850 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 8851 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 8852 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 8853 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8854 | |
| 8855 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8856 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8857 | return -ENOSPC; |
| 8858 | } |
| 8859 | |
| 8860 | return 0; |
| 8861 | } |
| 8862 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8863 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8864 | bool rtnl_held) |
| 8865 | { |
| 8866 | return 0; |
| 8867 | } |
| 8868 | #endif |
| 8869 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8870 | 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] | 8871 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8872 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 8873 | int ret = 0; |
| 8874 | |
| 8875 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 8876 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 8877 | NET_NAME_UNKNOWN, rtnl_held); |
| 8878 | if (adapter == NULL) { |
| 8879 | hdd_err("Failed to open 802.11p interface"); |
| 8880 | ret = -ENOSPC; |
| 8881 | } |
| 8882 | |
| 8883 | return ret; |
| 8884 | } |
| 8885 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8886 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8887 | * hdd_start_station_adapter()- Start the Station Adapter |
| 8888 | * @adapter: HDD adapter |
| 8889 | * |
| 8890 | * This function initializes the adapter for the station mode. |
| 8891 | * |
| 8892 | * Return: 0 on success or errno on failure. |
| 8893 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8894 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8895 | { |
| 8896 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8897 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8898 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 8899 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8900 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8901 | hdd_err("session is already opened, %d", |
| 8902 | adapter->session_id); |
| 8903 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8904 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8905 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8906 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 8907 | if (ret) { |
| 8908 | hdd_err("failed to create vdev: %d", ret); |
| 8909 | return ret; |
| 8910 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8911 | status = hdd_init_station_mode(adapter); |
| 8912 | |
| 8913 | if (QDF_STATUS_SUCCESS != status) { |
| 8914 | hdd_err("Error Initializing station mode: %d", status); |
| 8915 | return qdf_status_to_os_return(status); |
| 8916 | } |
| 8917 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8918 | hdd_register_tx_flow_control(adapter, |
| 8919 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8920 | hdd_tx_resume_cb, |
| 8921 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8922 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8923 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8924 | return 0; |
| 8925 | } |
| 8926 | |
| 8927 | /** |
| 8928 | * hdd_start_ap_adapter()- Start AP Adapter |
| 8929 | * @adapter: HDD adapter |
| 8930 | * |
| 8931 | * This function initializes the adapter for the AP mode. |
| 8932 | * |
| 8933 | * Return: 0 on success errno on failure. |
| 8934 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8935 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8936 | { |
| 8937 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8938 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8939 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8940 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8941 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8942 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8943 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8944 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 8945 | hdd_err("session is already opened, %d", |
| 8946 | adapter->session_id); |
| 8947 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 8948 | } |
| 8949 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8950 | * In SSR case no need to create new sap context. |
| 8951 | * Otherwise create sap context first and then create |
| 8952 | * vdev as while creating the vdev, driver needs to |
| 8953 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8954 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8955 | if (adapter->session.ap.sap_context) { |
| 8956 | is_ssr = true; |
| 8957 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 8958 | hdd_err("sap creation failed"); |
| 8959 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 8960 | } |
| 8961 | |
| 8962 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 8963 | adapter->session.ap.sap_context); |
| 8964 | if (ret) { |
| 8965 | hdd_err("failed to create vdev, status:%d", ret); |
| 8966 | hdd_sap_destroy_ctx(adapter); |
| 8967 | return ret; |
| 8968 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 8969 | |
| 8970 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8971 | sme_cli_set_command(adapter->session_id, |
| 8972 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 8973 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 8974 | WMI_FW_AP_RTT_RESPR), |
| 8975 | VDEV_CMD); |
| 8976 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 8977 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8978 | |
| 8979 | if (QDF_STATUS_SUCCESS != status) { |
| 8980 | hdd_err("Error Initializing the AP mode: %d", status); |
| 8981 | return qdf_status_to_os_return(status); |
| 8982 | } |
| 8983 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8984 | hdd_register_tx_flow_control(adapter, |
| 8985 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 8986 | hdd_softap_tx_resume_cb, |
| 8987 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8988 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8989 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 8990 | return 0; |
| 8991 | } |
| 8992 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 8993 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 8994 | bool rtnl_held) |
| 8995 | { |
| 8996 | struct hdd_adapter *adapter; |
| 8997 | |
| 8998 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 8999 | hdd_ctx->config->enableConcurrentSTA, |
| 9000 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9001 | NET_NAME_UNKNOWN, rtnl_held); |
| 9002 | |
| 9003 | if (!adapter) |
| 9004 | return -ENOSPC; |
| 9005 | |
| 9006 | return 0; |
| 9007 | } |
| 9008 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9009 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9010 | * hdd_open_interfaces - Open all required interfaces |
| 9011 | * hdd_ctx: HDD context |
| 9012 | * rtnl_held: True if RTNL lock is held |
| 9013 | * |
| 9014 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 9015 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9016 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9017 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9018 | 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] | 9019 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9020 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9021 | int ret; |
| 9022 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9023 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9024 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9025 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9026 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 9027 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 9028 | |
| 9029 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 9030 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9031 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9032 | if (!adapter) { |
| 9033 | hdd_err("open adapter failed"); |
| 9034 | return -ENOSPC; |
| 9035 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9036 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9037 | return 0; |
| 9038 | } |
| 9039 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9040 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9041 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9042 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9043 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9044 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9045 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9046 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9047 | |
| 9048 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9049 | return -ENOSPC; |
| 9050 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9051 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 9052 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 9053 | if (ret) |
| 9054 | hdd_err("Cannot create concurrent STA interface"); |
| 9055 | } |
| 9056 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9057 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9058 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9059 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9060 | |
| 9061 | /* Open 802.11p Interface */ |
| 9062 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9063 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9064 | if (ret) |
| 9065 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9066 | } |
| 9067 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9068 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9069 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9070 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9071 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9072 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9073 | } |
| 9074 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9075 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9076 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9077 | /** |
| 9078 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9079 | * @cds_cfg: CDS Configuration |
| 9080 | * @hdd_ctx: Pointer to hdd context |
| 9081 | * |
| 9082 | * Return: none |
| 9083 | */ |
| 9084 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9085 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9086 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9087 | { |
| 9088 | cds_cfg->tx_flow_stop_queue_th = |
| 9089 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9090 | cds_cfg->tx_flow_start_queue_offset = |
| 9091 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 9092 | } |
| 9093 | #else |
| 9094 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9095 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9096 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9097 | { |
| 9098 | } |
| 9099 | #endif |
| 9100 | |
| 9101 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9102 | /** |
| 9103 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9104 | * @cds_cfg: CDS Configuration |
| 9105 | * @hdd_ctx: Pointer to hdd context |
| 9106 | * |
| 9107 | * Return: none |
| 9108 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9109 | 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] | 9110 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9111 | { |
| 9112 | cds_cfg->ra_ratelimit_interval = |
| 9113 | hdd_ctx->config->RArateLimitInterval; |
| 9114 | cds_cfg->is_ra_ratelimit_enabled = |
| 9115 | hdd_ctx->config->IsRArateLimitEnabled; |
| 9116 | } |
| 9117 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9118 | 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] | 9119 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9120 | { |
| 9121 | } |
| 9122 | #endif |
| 9123 | |
| 9124 | /** |
| 9125 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9126 | * @hdd_ctx: HDD Context |
| 9127 | * |
| 9128 | * Return: 0 for Success, errno on failure |
| 9129 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9130 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9131 | { |
| 9132 | struct cds_config_info *cds_cfg; |
| 9133 | |
| 9134 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9135 | if (!cds_cfg) { |
| 9136 | hdd_err("failed to allocate cds config"); |
| 9137 | return -ENOMEM; |
| 9138 | } |
| 9139 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9140 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 9141 | if (!hdd_ctx->config->nMaxPsPoll || |
| 9142 | !hdd_ctx->config->enablePowersaveOffload) { |
| 9143 | cds_cfg->powersave_offload_enabled = |
| 9144 | hdd_ctx->config->enablePowersaveOffload; |
| 9145 | } else { |
| 9146 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9147 | PS_QPOWER_NODEEPSLEEP) || |
| 9148 | (hdd_ctx->config->enablePowersaveOffload == |
| 9149 | PS_LEGACY_NODEEPSLEEP)) |
| 9150 | cds_cfg->powersave_offload_enabled = |
| 9151 | PS_LEGACY_NODEEPSLEEP; |
| 9152 | else |
| 9153 | cds_cfg->powersave_offload_enabled = |
| 9154 | PS_LEGACY_DEEPSLEEP; |
| 9155 | hdd_info("Qpower disabled in cds config, %d", |
| 9156 | cds_cfg->powersave_offload_enabled); |
| 9157 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9158 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9159 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9160 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9161 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9162 | |
| 9163 | /* |
| 9164 | * Copy the DFS Phyerr Filtering Offload status. |
| 9165 | * This parameter reflects the value of the |
| 9166 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9167 | */ |
| 9168 | cds_cfg->dfs_phyerr_filter_offload = |
| 9169 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9170 | if (hdd_ctx->config->ssdp) |
| 9171 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9172 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9173 | cds_cfg->force_target_assert_enabled = |
| 9174 | hdd_ctx->config->crash_inject_enabled; |
| 9175 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9176 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9177 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9178 | |
| 9179 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9180 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9181 | |
| 9182 | cds_cfg->ap_disable_intrabss_fwd = |
| 9183 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9184 | |
| 9185 | cds_cfg->dfs_pri_multiplier = |
| 9186 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9187 | cds_cfg->reorder_offload = |
| 9188 | hdd_ctx->config->reorderOffloadSupport; |
| 9189 | |
| 9190 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9191 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9192 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9193 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9194 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9195 | hdd_ctx->config->IpaUcTxBufCount); |
| 9196 | hdd_ctx->config->IpaUcTxBufCount = |
| 9197 | rounddown_pow_of_two( |
| 9198 | hdd_ctx->config->IpaUcTxBufCount); |
| 9199 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9200 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9201 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9202 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9203 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9204 | hdd_ctx->config->IpaUcTxBufCount); |
| 9205 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9206 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9207 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9208 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9209 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9210 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9211 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9212 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9213 | rounddown_pow_of_two( |
| 9214 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9215 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9216 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9217 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9218 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9219 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9220 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9221 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9222 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9223 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9224 | cds_cfg->uc_tx_partition_base = |
| 9225 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9226 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9227 | |
| 9228 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9229 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9230 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9231 | cds_cfg->ce_classify_enabled = |
| 9232 | hdd_ctx->config->ce_classify_enabled; |
Dustin Brown | d3fc9ee | 2016-09-14 13:57:27 -0700 | [diff] [blame] | 9233 | cds_cfg->bpf_packet_filter_enable = |
| 9234 | hdd_ctx->config->bpf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9235 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9236 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9237 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9238 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9239 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9240 | cds_cfg->max_msdus_per_rxinorderind = |
| 9241 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9242 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9243 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Hanumanth Reddy Pothula | e87621b | 2017-04-12 20:53:35 +0530 | [diff] [blame] | 9244 | cds_cfg->active_uc_bpf_mode = hdd_ctx->config->active_uc_bpf_mode; |
| 9245 | 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] | 9246 | cds_cfg->auto_power_save_fail_mode = |
| 9247 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9248 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9249 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9250 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9251 | cds_cfg->delay_before_vdev_stop = |
| 9252 | hdd_ctx->config->delay_before_vdev_stop; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9253 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9254 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9255 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9256 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9257 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9258 | cds_init_ini_config(cds_cfg); |
| 9259 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9260 | |
| 9261 | exit: |
| 9262 | qdf_mem_free(cds_cfg); |
| 9263 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9264 | } |
| 9265 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9266 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9267 | * hdd_update_user_config() - API to update user configuration |
| 9268 | * parameters to obj mgr which are used by multiple components |
| 9269 | * @hdd_ctx: HDD Context |
| 9270 | * |
| 9271 | * Return: 0 for Success, errno on failure |
| 9272 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9273 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9274 | { |
| 9275 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9276 | |
| 9277 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9278 | if (user_config == NULL) { |
| 9279 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9280 | return -ENOMEM; |
| 9281 | } |
| 9282 | |
| 9283 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9284 | user_config->dual_mac_feature_disable = |
| 9285 | hdd_ctx->config->dual_mac_feature_disable; |
| 9286 | user_config->indoor_channel_support = |
| 9287 | hdd_ctx->config->indoor_channel_support; |
| 9288 | user_config->is_11d_support_enabled = |
| 9289 | hdd_ctx->config->Is11dSupportEnabled; |
| 9290 | user_config->is_11h_support_enabled = |
| 9291 | hdd_ctx->config->Is11hSupportEnabled; |
| 9292 | user_config->optimize_chan_avoid_event = |
| 9293 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9294 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9295 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9296 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9297 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9298 | |
| 9299 | qdf_mem_free(user_config); |
| 9300 | return 0; |
| 9301 | } |
| 9302 | |
| 9303 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9304 | * hdd_init_thermal_info - Initialize thermal level |
| 9305 | * @hdd_ctx: HDD context |
| 9306 | * |
| 9307 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9308 | * which would be called when a configured thermal threshold is hit. |
| 9309 | * |
| 9310 | * Return: 0 on success and errno on failure |
| 9311 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9312 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9313 | { |
| 9314 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9315 | QDF_STATUS status; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9316 | |
| 9317 | thermal_param.smeThermalMgmtEnabled = |
| 9318 | hdd_ctx->config->thermalMitigationEnable; |
| 9319 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9320 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9321 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9322 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9323 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9324 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9325 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9326 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9327 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9328 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9329 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9330 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9331 | hdd_ctx->config->thermalTempMinLevel0; |
| 9332 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9333 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9334 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9335 | hdd_ctx->config->thermalTempMinLevel1; |
| 9336 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9337 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9338 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9339 | hdd_ctx->config->thermalTempMinLevel2; |
| 9340 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9341 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9342 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9343 | hdd_ctx->config->thermalTempMinLevel3; |
| 9344 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9345 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9346 | |
| 9347 | status = sme_init_thermal_info(hdd_ctx->hHal, thermal_param); |
| 9348 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9349 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9350 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9351 | |
| 9352 | sme_add_set_thermal_level_callback(hdd_ctx->hHal, |
| 9353 | hdd_set_thermal_level_cb); |
| 9354 | |
| 9355 | return 0; |
| 9356 | |
| 9357 | } |
| 9358 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9359 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9360 | /** |
| 9361 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9362 | * |
| 9363 | * Hold RTNL lock |
| 9364 | * |
| 9365 | * Return: True if held and false otherwise |
| 9366 | */ |
| 9367 | static inline bool hdd_hold_rtnl_lock(void) |
| 9368 | { |
| 9369 | rtnl_lock(); |
| 9370 | return true; |
| 9371 | } |
| 9372 | |
| 9373 | /** |
| 9374 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9375 | * |
| 9376 | * Release RTNL lock |
| 9377 | * |
| 9378 | * Return: None |
| 9379 | */ |
| 9380 | static inline void hdd_release_rtnl_lock(void) |
| 9381 | { |
| 9382 | rtnl_unlock(); |
| 9383 | } |
| 9384 | #else |
| 9385 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9386 | static inline void hdd_release_rtnl_lock(void) { } |
| 9387 | #endif |
| 9388 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9389 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9390 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9391 | /* MAX iwpriv command support */ |
| 9392 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9393 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9394 | #define MAX_PKTLOG_SIZE 16 |
| 9395 | |
| 9396 | /** |
| 9397 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9398 | * @hdd_ctx: hdd context |
| 9399 | * @set_value2: pktlog buffer size value |
| 9400 | * |
| 9401 | * |
| 9402 | * Return: 0 for success or error. |
| 9403 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9404 | 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] | 9405 | { |
| 9406 | struct sir_wifi_start_log start_log = { 0 }; |
| 9407 | QDF_STATUS status; |
| 9408 | |
| 9409 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9410 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9411 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9412 | start_log.user_triggered = 1; |
| 9413 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9414 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9415 | |
| 9416 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9417 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9418 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9419 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9420 | return -EINVAL; |
| 9421 | } |
| 9422 | |
| 9423 | return 0; |
| 9424 | } |
| 9425 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9426 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9427 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9428 | * @hdd_ctx: hdd context |
| 9429 | * |
| 9430 | * Return: 0 for success or error. |
| 9431 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9432 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9433 | { |
| 9434 | struct sir_wifi_start_log start_log; |
| 9435 | QDF_STATUS status; |
| 9436 | |
| 9437 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9438 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9439 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9440 | start_log.user_triggered = 1; |
| 9441 | start_log.size = 0; |
| 9442 | start_log.is_pktlog_buff_clear = true; |
| 9443 | |
| 9444 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9445 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9446 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9447 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9448 | return -EINVAL; |
| 9449 | } |
| 9450 | |
| 9451 | return 0; |
| 9452 | } |
| 9453 | |
| 9454 | |
| 9455 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9456 | * hdd_process_pktlog_command() - process pktlog command |
| 9457 | * @hdd_ctx: hdd context |
| 9458 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9459 | * @set_value2: pktlog buffer size value |
| 9460 | * |
| 9461 | * This function process pktlog command. |
| 9462 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9463 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9464 | * |
| 9465 | * Return: 0 for success or error. |
| 9466 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9467 | 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] | 9468 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9469 | { |
| 9470 | int ret; |
| 9471 | bool enable; |
| 9472 | uint8_t user_triggered = 0; |
| 9473 | |
| 9474 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9475 | if (0 != ret) |
| 9476 | return ret; |
| 9477 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9478 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9479 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9480 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9481 | hdd_err("invalid pktlog value %d", set_value); |
| 9482 | return -EINVAL; |
| 9483 | } |
| 9484 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9485 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9486 | if (set_value2 <= 0) { |
| 9487 | hdd_err("invalid pktlog size %d", set_value2); |
| 9488 | return -EINVAL; |
| 9489 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9490 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9491 | return -EINVAL; |
| 9492 | } |
| 9493 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9494 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9495 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9496 | } |
| 9497 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9498 | /* |
| 9499 | * set_value = 0 then disable packetlog |
| 9500 | * set_value = 1 enable packetlog forcefully |
| 9501 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9502 | * enable packetlog with AUTO type. |
| 9503 | */ |
| 9504 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9505 | true : false; |
| 9506 | |
| 9507 | if (1 == set_value) { |
| 9508 | enable = true; |
| 9509 | user_triggered = 1; |
| 9510 | } |
| 9511 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9512 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9513 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9514 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9515 | /** |
| 9516 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9517 | * @hdd_ctx: HDD context |
| 9518 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9519 | * @user_triggered: triggered through iwpriv |
| 9520 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9521 | * |
| 9522 | * Return: 0 on success; error number otherwise |
| 9523 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9524 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9525 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9526 | { |
| 9527 | struct sir_wifi_start_log start_log; |
| 9528 | QDF_STATUS status; |
| 9529 | |
| 9530 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9531 | start_log.verbose_level = |
| 9532 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9533 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9534 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9535 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9536 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9537 | /* |
| 9538 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9539 | * commands. Host uses this flag to decide whether to send pktlog |
| 9540 | * disable command to fw without sending pktlog enable command |
| 9541 | * previously. For eg, If vendor sends pktlog disable command without |
| 9542 | * sending pktlog enable command, then host discards the packet |
| 9543 | * but for iwpriv command, host will send it to fw. |
| 9544 | */ |
| 9545 | start_log.is_iwpriv_command = 1; |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9546 | status = sme_wifi_start_logger(hdd_ctx->hHal, start_log); |
| 9547 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9548 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9549 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9550 | return -EINVAL; |
| 9551 | } |
| 9552 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9553 | if (enable == true) |
| 9554 | hdd_ctx->is_pktlog_enabled = 1; |
| 9555 | else |
| 9556 | hdd_ctx->is_pktlog_enabled = 0; |
| 9557 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9558 | return 0; |
| 9559 | } |
| 9560 | #endif /* REMOVE_PKT_LOG */ |
| 9561 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9562 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9563 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9564 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9565 | * @dev: Device Pointer |
| 9566 | * @num: Number of Valid Mac address |
| 9567 | * |
| 9568 | * Return: Pointer to MAC address buffer |
| 9569 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9570 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9571 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9572 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9573 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9574 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9575 | |
| 9576 | /** |
| 9577 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9578 | * @hdd_ctx: HDD Context |
| 9579 | * @num: Number of random mac addresses needed |
| 9580 | * |
| 9581 | * Generate random addresses using bit manipulation on the base mac address |
| 9582 | * |
| 9583 | * Return: None |
| 9584 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9585 | 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] | 9586 | { |
| 9587 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9588 | uint32_t iter; |
| 9589 | struct hdd_config *ini = hdd_ctx->config; |
| 9590 | uint8_t *buf = NULL; |
| 9591 | uint8_t macaddr_b3, tmp_br3; |
| 9592 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9593 | |
| 9594 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9595 | buf = ini->intfMacAddr[iter].bytes; |
| 9596 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9597 | macaddr_b3 = buf[3]; |
| 9598 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9599 | INTF_MACADDR_MASK; |
| 9600 | macaddr_b3 += tmp_br3; |
| 9601 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9602 | buf[0] |= 0x02; |
| 9603 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9604 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9605 | } |
| 9606 | } |
| 9607 | |
| 9608 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9609 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9610 | * @hdd_ctx: HDD Context |
| 9611 | * |
| 9612 | * API to get mac addresses from platform driver and update the driver |
| 9613 | * structures and configure FW with the base mac address. |
| 9614 | * Return: int |
| 9615 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9616 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9617 | { |
| 9618 | uint32_t no_of_mac_addr, iter; |
| 9619 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9620 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9621 | uint8_t *addr, *buf; |
| 9622 | struct device *dev = hdd_ctx->parent_dev; |
| 9623 | struct hdd_config *ini = hdd_ctx->config; |
| 9624 | tSirMacAddr mac_addr; |
| 9625 | QDF_STATUS status; |
| 9626 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9627 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9628 | |
| 9629 | if (no_of_mac_addr == 0 || !addr) { |
| 9630 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9631 | return -EINVAL; |
| 9632 | } |
| 9633 | |
| 9634 | if (no_of_mac_addr > max_mac_addr) |
| 9635 | no_of_mac_addr = max_mac_addr; |
| 9636 | |
| 9637 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9638 | |
| 9639 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9640 | buf = ini->intfMacAddr[iter].bytes; |
| 9641 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9642 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9643 | } |
| 9644 | |
| 9645 | status = sme_set_custom_mac_addr(mac_addr); |
| 9646 | |
| 9647 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9648 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9649 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9650 | if (no_of_mac_addr < max_mac_addr) |
| 9651 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9652 | no_of_mac_addr); |
| 9653 | return 0; |
| 9654 | } |
| 9655 | |
| 9656 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9657 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9658 | * @hdd_ctx: HDD Context |
| 9659 | * |
| 9660 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9661 | * will generate its own MAC and update it to FW. |
| 9662 | * |
| 9663 | * Return: 0 for success |
| 9664 | * Non-zero error code for failure |
| 9665 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9666 | 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] | 9667 | { |
| 9668 | tSirMacAddr customMacAddr; |
| 9669 | QDF_STATUS status; |
| 9670 | |
| 9671 | qdf_mem_copy(&customMacAddr, |
| 9672 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9673 | sizeof(tSirMacAddr)); |
| 9674 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9675 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9676 | return -EAGAIN; |
| 9677 | return 0; |
| 9678 | } |
| 9679 | |
| 9680 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9681 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9682 | * @hdd_ctx: HDD Context |
| 9683 | * |
| 9684 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9685 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9686 | * wlan_mac.bin to update HW MAC addresses. |
| 9687 | * |
| 9688 | * Return: None |
| 9689 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9690 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9691 | { |
| 9692 | QDF_STATUS status; |
| 9693 | int ret; |
| 9694 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9695 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9696 | if (ret == 0) |
| 9697 | return; |
| 9698 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9699 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9700 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9701 | |
| 9702 | status = hdd_update_mac_config(hdd_ctx); |
| 9703 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9704 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9705 | return; |
| 9706 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9707 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9708 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9709 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9710 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9711 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9712 | if (ret != 0) { |
| 9713 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9714 | QDF_ASSERT(ret); |
| 9715 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9716 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9717 | } |
| 9718 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9719 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9720 | { |
| 9721 | int vdev_id = 0; |
| 9722 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9723 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9724 | int vpdev = PDEV_CMD; |
| 9725 | int ret; |
| 9726 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9727 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9728 | if (ret) |
| 9729 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9730 | |
| 9731 | return ret; |
| 9732 | } |
| 9733 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9734 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9735 | { |
| 9736 | int vdev_id = 0; |
| 9737 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9738 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9739 | int vpdev = PDEV_CMD; |
| 9740 | int ret; |
| 9741 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9742 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9743 | if (ret) |
| 9744 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9745 | ret); |
| 9746 | |
| 9747 | return ret; |
| 9748 | } |
| 9749 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9750 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9751 | { |
| 9752 | int vdev_id = 0; |
| 9753 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9754 | int value = hdd_ctx->config->ani_enabled; |
| 9755 | int vpdev = PDEV_CMD; |
| 9756 | int ret; |
| 9757 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9758 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9759 | if (ret) |
| 9760 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9761 | |
| 9762 | return ret; |
| 9763 | } |
| 9764 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9765 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9766 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9767 | * @hdd_ctx: HDD context |
| 9768 | * |
| 9769 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9770 | * |
| 9771 | * Return: 0 on success and errno on failure. |
| 9772 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9773 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9774 | { |
| 9775 | int ret; |
| 9776 | QDF_STATUS status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9777 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9778 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9779 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9780 | /* |
| 9781 | * Set 802.11p config |
| 9782 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9783 | * parameter is set in CSR when we init the channel list. This should |
| 9784 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9785 | * domain. |
| 9786 | */ |
| 9787 | hdd_set_dot11p_config(hdd_ctx); |
| 9788 | |
| 9789 | /* |
| 9790 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9791 | * The cfg download must occur before we update the SME config |
| 9792 | * since the SME config operation must access the cfg database |
| 9793 | */ |
| 9794 | status = hdd_set_sme_config(hdd_ctx); |
| 9795 | |
| 9796 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9797 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9798 | ret = qdf_status_to_os_return(status); |
| 9799 | goto out; |
| 9800 | } |
| 9801 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9802 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9803 | if (QDF_STATUS_SUCCESS != status) { |
| 9804 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9805 | ret = qdf_status_to_os_return(status); |
| 9806 | goto out; |
| 9807 | } |
| 9808 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9809 | 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] | 9810 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9811 | PDEV_CMD); |
| 9812 | if (0 != ret) { |
| 9813 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 9814 | goto out; |
| 9815 | } |
| 9816 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9817 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 9818 | if (ret) |
| 9819 | goto out; |
| 9820 | |
| 9821 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 9822 | if (ret) |
| 9823 | goto out; |
| 9824 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9825 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 9826 | if (ret) |
| 9827 | goto out; |
| 9828 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9829 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 9830 | hdd_ctx->config->arp_ac_category, |
| 9831 | PDEV_CMD); |
| 9832 | if (0 != ret) { |
| 9833 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 9834 | hdd_ctx->config->arp_ac_category, ret); |
| 9835 | goto out; |
| 9836 | } |
| 9837 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9838 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 9839 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9840 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9841 | ret = qdf_status_to_os_return(status); |
| 9842 | goto out; |
| 9843 | } |
| 9844 | |
| 9845 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 9846 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9847 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9848 | ret = -EINVAL; |
| 9849 | goto out; |
| 9850 | } |
| 9851 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9852 | /* |
| 9853 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 9854 | * Remove this once self sta is added as part of session open. |
| 9855 | */ |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 9856 | status = sme_cfg_set_str(hdd_ctx->hHal, WNI_CFG_STA_ID, |
| 9857 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9858 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9859 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 9860 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9861 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9862 | ret = -EINVAL; |
| 9863 | goto out; |
| 9864 | } |
| 9865 | |
| 9866 | hdd_init_channel_avoidance(hdd_ctx); |
| 9867 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 9868 | /* update enable sap mandatory chan list */ |
| 9869 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 9870 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9871 | out: |
| 9872 | return ret; |
| 9873 | } |
| 9874 | |
| 9875 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9876 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 9877 | * @context_ptr - hdd context pointer |
| 9878 | * @event_ptr - event structure pointer |
| 9879 | * |
| 9880 | * This is the p2p listen offload stop event handler, it sends vendor |
| 9881 | * event back to supplicant to notify the stop reason. |
| 9882 | * |
| 9883 | * Return: None |
| 9884 | */ |
| 9885 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 9886 | void *event_ptr) |
| 9887 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9888 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9889 | struct sir_p2p_lo_event *evt = event_ptr; |
| 9890 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9891 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9892 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9893 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9894 | |
| 9895 | if (hdd_ctx == NULL) { |
| 9896 | hdd_err("Invalid HDD context pointer"); |
| 9897 | return; |
| 9898 | } |
| 9899 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9900 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 9901 | if (!adapter) { |
| 9902 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 9903 | evt->vdev_id); |
| 9904 | return; |
| 9905 | } |
| 9906 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9907 | vendor_event = |
| 9908 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9909 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9910 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 9911 | GFP_KERNEL); |
| 9912 | |
| 9913 | if (!vendor_event) { |
| 9914 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 9915 | return; |
| 9916 | } |
| 9917 | |
| 9918 | if (nla_put_u32(vendor_event, |
| 9919 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 9920 | evt->reason_code)) { |
| 9921 | hdd_err("nla put failed"); |
| 9922 | kfree_skb(vendor_event); |
| 9923 | return; |
| 9924 | } |
| 9925 | |
| 9926 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 9927 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 9928 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 9929 | } |
| 9930 | |
| 9931 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9932 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 9933 | * @hdd_ctx: HDD context |
| 9934 | * |
| 9935 | * This function sends the adaptive dwell time config configuration to the |
| 9936 | * firmware via WMA |
| 9937 | * |
| 9938 | * Return: 0 - success, < 0 - failure |
| 9939 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9940 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 9941 | { |
| 9942 | QDF_STATUS status; |
| 9943 | struct adaptive_dwelltime_params dwelltime_params; |
| 9944 | |
| 9945 | dwelltime_params.is_enabled = |
| 9946 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 9947 | dwelltime_params.dwelltime_mode = |
| 9948 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 9949 | dwelltime_params.lpf_weight = |
| 9950 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 9951 | dwelltime_params.passive_mon_intval = |
| 9952 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 9953 | dwelltime_params.wifi_act_threshold = |
| 9954 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 9955 | |
| 9956 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->hHal, |
| 9957 | &dwelltime_params); |
| 9958 | |
| 9959 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 9960 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9961 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 9962 | return -EAGAIN; |
| 9963 | } |
| 9964 | return 0; |
| 9965 | } |
| 9966 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9967 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9968 | { |
| 9969 | QDF_STATUS status; |
| 9970 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 9971 | uint32_t i = 0; |
| 9972 | uint8_t count = 0, numentries = 0; |
| 9973 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9974 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 9975 | |
| 9976 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 9977 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 9978 | DISABLE_DBS_CXN_AND_SCAN) || |
| 9979 | (hdd_ctx->config->dual_mac_feature_disable == |
| 9980 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 9981 | return -EINVAL; |
| 9982 | |
| 9983 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 9984 | dbs_scan_config, &numentries, |
| 9985 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 9986 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 9987 | |
| 9988 | hdd_info("numentries %hu", numentries); |
| 9989 | if (!numentries) { |
| 9990 | hdd_info("Donot send scan_selection_config"); |
| 9991 | return 0; |
| 9992 | } |
| 9993 | |
| 9994 | /* hdd_set_fw_log_params */ |
| 9995 | dbs_scan_params.num_clients = 0; |
| 9996 | while (count < (numentries - 2)) { |
| 9997 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 9998 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 9999 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10000 | dbs_scan_config[count + 2]; |
| 10001 | dbs_scan_params.num_clients++; |
| 10002 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10003 | dbs_scan_params.module_id[i], |
| 10004 | dbs_scan_params.num_dbs_scans[i], |
| 10005 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10006 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10007 | i++; |
| 10008 | } |
| 10009 | |
| 10010 | dbs_scan_params.pdev_id = 0; |
| 10011 | |
| 10012 | hdd_debug("clients:%d pdev:%d", |
| 10013 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10014 | |
| 10015 | status = sme_set_dbs_scan_selection_config(hdd_ctx->hHal, |
| 10016 | &dbs_scan_params); |
| 10017 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10018 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10019 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10020 | return -EAGAIN; |
| 10021 | } |
| 10022 | return 0; |
| 10023 | } |
| 10024 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10025 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10026 | /** |
| 10027 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10028 | * @hdd_ctx: HDD context |
| 10029 | * |
| 10030 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10031 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10032 | * |
| 10033 | * Return: 0 on success and errno on failure. |
| 10034 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10035 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10036 | { |
| 10037 | QDF_STATUS status; |
| 10038 | |
| 10039 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 10040 | return 0; |
| 10041 | |
| 10042 | status = sme_set_auto_shutdown_cb(hdd_ctx->hHal, |
| 10043 | wlan_hdd_auto_shutdown_cb); |
| 10044 | if (status != QDF_STATUS_SUCCESS) |
| 10045 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10046 | status); |
| 10047 | |
| 10048 | return qdf_status_to_os_return(status); |
| 10049 | } |
| 10050 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10051 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10052 | { |
| 10053 | return 0; |
| 10054 | } |
| 10055 | #endif |
| 10056 | |
| 10057 | /** |
| 10058 | * hdd_features_init() - Init features |
| 10059 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10060 | * |
| 10061 | * Initialize features and their feature context after WLAN firmware is up. |
| 10062 | * |
| 10063 | * Return: 0 on success and errno on failure. |
| 10064 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10065 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10066 | { |
| 10067 | tSirTxPowerLimit hddtxlimit; |
| 10068 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10069 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10070 | int ret; |
| 10071 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10072 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10073 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10074 | /* FW capabilities received, Set the Dot11 mode */ |
| 10075 | sme_setdef_dot11mode(hdd_ctx->hHal); |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 10076 | sme_set_prefer_80MHz_over_160MHz(hdd_ctx->hHal, |
| 10077 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10078 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10079 | |
| 10080 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10081 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10082 | else |
| 10083 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10084 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10085 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10086 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10087 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10088 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10089 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10090 | sme_set_cts2self_for_p2p_go(hdd_ctx->hHal); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10091 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10092 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 10093 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10094 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10095 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10096 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10097 | |
| 10098 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10099 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10100 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10101 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10102 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10103 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10104 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10105 | if (ret) { |
| 10106 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10107 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10108 | } |
| 10109 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10110 | /** |
| 10111 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10112 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10113 | * device up. |
| 10114 | */ |
| 10115 | if (cds_is_driver_recovering()) { |
| 10116 | if (hdd_ctx->is_pktlog_enabled) |
| 10117 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 10118 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10119 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10120 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10121 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
| 10122 | status = sme_txpower_limit(hdd_ctx->hHal, &hddtxlimit); |
| 10123 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10124 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10125 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10126 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10127 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10128 | ret = hdd_register_cb(hdd_ctx); |
| 10129 | if (ret) { |
| 10130 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10131 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10132 | } |
| 10133 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10134 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 10135 | status = sme_enable_disable_chanavoidind_event( |
| 10136 | hdd_ctx->hHal, 0); |
| 10137 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10138 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10139 | goto deregister_cb; |
| 10140 | } |
| 10141 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10142 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10143 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10144 | band_pref_params.rssi_boost_threshold_5g = |
| 10145 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10146 | band_pref_params.rssi_boost_factor_5g = |
| 10147 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10148 | band_pref_params.max_rssi_boost_5g = |
| 10149 | hdd_ctx->config->max_rssi_boost_5g; |
| 10150 | band_pref_params.rssi_penalize_threshold_5g = |
| 10151 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10152 | band_pref_params.rssi_penalize_factor_5g = |
| 10153 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10154 | band_pref_params.max_rssi_penalize_5g = |
| 10155 | hdd_ctx->config->max_rssi_penalize_5g; |
| 10156 | sme_set_5g_band_pref(hdd_ctx->hHal, &band_pref_params); |
| 10157 | } |
| 10158 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10159 | /* register P2P Listen Offload event callback */ |
| 10160 | if (wma_is_p2p_lo_capable()) |
| 10161 | sme_register_p2p_lo_event(hdd_ctx->hHal, hdd_ctx, |
| 10162 | wlan_hdd_p2p_lo_event_callback); |
| 10163 | |
| 10164 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10165 | |
| 10166 | if (ret) |
| 10167 | goto deregister_cb; |
| 10168 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10169 | wlan_hdd_init_chan_info(hdd_ctx); |
| 10170 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10171 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10172 | return 0; |
| 10173 | |
| 10174 | deregister_cb: |
| 10175 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10176 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10177 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10178 | } |
| 10179 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10180 | /** |
| 10181 | * hdd_features_deinit() - Deinit features |
| 10182 | * @hdd_ctx: HDD context |
| 10183 | * |
| 10184 | * De-Initialize features and their feature context. |
| 10185 | * |
| 10186 | * Return: none. |
| 10187 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10188 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10189 | { |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10190 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10191 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10192 | } |
| 10193 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10194 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10195 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10196 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10197 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10198 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10199 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10200 | 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] | 10201 | { |
| 10202 | QDF_STATUS status; |
| 10203 | |
| 10204 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10205 | wlan_cfg80211_inform_bss_frame, |
| 10206 | SCAN_CB_TYPE_INFORM_BCN); |
| 10207 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10208 | hdd_err("failed with status code %08d [x%08x]", |
| 10209 | status, status); |
| 10210 | return status; |
| 10211 | } |
| 10212 | |
| 10213 | return QDF_STATUS_SUCCESS; |
| 10214 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10215 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10216 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10217 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10218 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10219 | * |
| 10220 | * Return: none. |
| 10221 | */ |
| 10222 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10223 | { |
| 10224 | QDF_STATUS status; |
| 10225 | |
| 10226 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10227 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10228 | vdev_id); |
| 10229 | /* |
| 10230 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10231 | * so this above callback is not implemented. |
| 10232 | * Hence this is not actual failure. Dont return failure |
| 10233 | */ |
| 10234 | if ((status != QDF_STATUS_SUCCESS) && |
| 10235 | (status != QDF_STATUS_E_INVAL)) { |
| 10236 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10237 | vdev_id, status); |
| 10238 | } |
| 10239 | } |
| 10240 | |
| 10241 | /** |
| 10242 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10243 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10244 | * |
| 10245 | * Return: none. |
| 10246 | */ |
| 10247 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10248 | { |
| 10249 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10250 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10251 | } |
| 10252 | |
| 10253 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10254 | * hdd_configure_cds() - Configure cds modules |
| 10255 | * @hdd_ctx: HDD context |
| 10256 | * @adapter: Primary adapter context |
| 10257 | * |
| 10258 | * Enable Cds modules after WLAN firmware is up. |
| 10259 | * |
| 10260 | * Return: 0 on success and errno on failure. |
| 10261 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10262 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10263 | { |
| 10264 | int ret; |
| 10265 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10266 | int set_value; |
| 10267 | uint32_t num_abg_tx_chains = 0; |
| 10268 | uint32_t num_11b_tx_chains = 0; |
| 10269 | uint32_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10270 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10271 | |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10272 | if (hdd_ctx->config->is_force_1x1) |
| 10273 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10274 | 1, PDEV_CMD); |
| 10275 | /* set chip power save failure detected callback */ |
| 10276 | sme_set_chip_pwr_save_fail_cb(hdd_ctx->hHal, |
| 10277 | hdd_chip_pwr_save_fail_detected_cb); |
| 10278 | |
| 10279 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10280 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10281 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10282 | set_value, PDEV_CMD); |
| 10283 | } |
| 10284 | |
| 10285 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10286 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10287 | sme_cli_set_command(0, |
| 10288 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10289 | set_value, PDEV_CMD); |
| 10290 | } |
| 10291 | |
| 10292 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10293 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10294 | sme_cli_set_command(0, |
| 10295 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10296 | set_value, PDEV_CMD); |
| 10297 | } |
| 10298 | |
| 10299 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10300 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10301 | if (!hdd_ctx->config->enable2x2) { |
| 10302 | if (num_11b_tx_chains > 1) |
| 10303 | num_11b_tx_chains = 1; |
| 10304 | if (num_11ag_tx_chains > 1) |
| 10305 | num_11ag_tx_chains = 1; |
| 10306 | } |
| 10307 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10308 | num_11b_tx_chains); |
| 10309 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10310 | num_11ag_tx_chains); |
| 10311 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10312 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10313 | |
| 10314 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10315 | if (ret) { |
| 10316 | hdd_err("Failed to pre-configure cds"); |
| 10317 | goto out; |
| 10318 | } |
| 10319 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10320 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10321 | * IPA module before configuring them to FW. Sequence required as crash |
| 10322 | * observed otherwise. |
| 10323 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10324 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10325 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10326 | hdd_err("Failed to setup pipes"); |
| 10327 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10328 | } |
| 10329 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10330 | /* |
| 10331 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10332 | * else |
| 10333 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10334 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10335 | |
| 10336 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10337 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10338 | goto out; |
| 10339 | } |
| 10340 | |
| 10341 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10342 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10343 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10344 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10345 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10346 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10347 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10348 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10349 | goto cds_disable; |
| 10350 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10351 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10352 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10353 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10354 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10355 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10356 | if (hdd_ctx->ol_enable) |
| 10357 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10358 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10359 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10360 | dp_cbs.hdd_ipa_set_mcc_mode_cb = hdd_ipa_set_mcc_mode; |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10361 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 10362 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10363 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10364 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10365 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10366 | goto cds_disable; |
| 10367 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10368 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10369 | wlan_hdd_send_mode_change_event); |
| 10370 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10371 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10372 | goto cds_disable; |
| 10373 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10374 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10375 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10376 | hdd_debug("enhance green ap is not enabled"); |
| 10377 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10378 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10379 | hdd_debug("Failed to set wow pulse"); |
| 10380 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10381 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10382 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10383 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10384 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10385 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10386 | |
| 10387 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10388 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10389 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10390 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10391 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10392 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10393 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10394 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10395 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10396 | out: |
| 10397 | return -EINVAL; |
| 10398 | } |
| 10399 | |
| 10400 | /** |
| 10401 | * hdd_deconfigure_cds() -De-Configure cds |
| 10402 | * @hdd_ctx: HDD context |
| 10403 | * |
| 10404 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10405 | * |
| 10406 | * Return: 0 on success and errno on failure. |
| 10407 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10408 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10409 | { |
| 10410 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10411 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10412 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10413 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10414 | |
| 10415 | /* De-init features */ |
| 10416 | hdd_features_deinit(hdd_ctx); |
| 10417 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10418 | /* De-register the SME callbacks */ |
| 10419 | hdd_deregister_cb(hdd_ctx); |
| 10420 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10421 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10422 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10423 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10424 | } |
| 10425 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10426 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10427 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10428 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10429 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10430 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10431 | } |
| 10432 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10433 | 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] | 10434 | hdd_err("Failed to disconnect pipes"); |
| 10435 | ret = -EINVAL; |
| 10436 | } |
| 10437 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10438 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10439 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10440 | } |
| 10441 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10442 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10443 | static void hdd_deregister_policy_manager_callback( |
| 10444 | struct wlan_objmgr_psoc *psoc) |
| 10445 | { |
| 10446 | if (QDF_STATUS_SUCCESS != |
| 10447 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10448 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10449 | } |
| 10450 | } |
| 10451 | #else |
| 10452 | static void hdd_deregister_policy_manager_callback( |
| 10453 | struct wlan_objmgr_psoc *psoc) |
| 10454 | { |
| 10455 | } |
| 10456 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10457 | |
| 10458 | /** |
| 10459 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10460 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10461 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10462 | * |
| 10463 | * This function maintains the driver state machine it will be invoked from |
| 10464 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10465 | * shall perform the stopping/closing of the modules. |
| 10466 | * |
| 10467 | * Return: 0 for success; non-zero for failure |
| 10468 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10469 | 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] | 10470 | { |
| 10471 | void *hif_ctx; |
| 10472 | qdf_device_t qdf_ctx; |
| 10473 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10474 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10475 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10476 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10477 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10478 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10479 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10480 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10481 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10482 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10483 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10484 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10485 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10486 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10487 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10488 | if (!qdf_ctx) { |
| 10489 | hdd_err("QDF device context NULL"); |
| 10490 | return -EINVAL; |
| 10491 | } |
| 10492 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10493 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10494 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10495 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10496 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10497 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10498 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10499 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10500 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10501 | |
| 10502 | cds_print_external_threads(); |
| 10503 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10504 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10505 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10506 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10507 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10508 | hdd_prevent_suspend_timeout( |
| 10509 | hdd_ctx->config->iface_change_wait_time, |
| 10510 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10511 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10512 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10513 | return 0; |
| 10514 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10515 | } |
| 10516 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10517 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10518 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10519 | /* free user wowl patterns */ |
| 10520 | hdd_free_user_wowl_ptrns(); |
| 10521 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10522 | switch (hdd_ctx->driver_status) { |
| 10523 | case DRIVER_MODULES_UNINITIALIZED: |
| 10524 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10525 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10526 | case DRIVER_MODULES_CLOSED: |
| 10527 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10528 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10529 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10530 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10531 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10532 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10533 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10534 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10535 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10536 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10537 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10538 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10539 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10540 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10541 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10542 | |
| 10543 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10544 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10545 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10546 | break; |
| 10547 | default: |
| 10548 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10549 | hdd_ctx->driver_status); |
| 10550 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10551 | ret = -EINVAL; |
| 10552 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10553 | } |
| 10554 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10555 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10556 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10557 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10558 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10559 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10560 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10561 | qdf_status); |
| 10562 | ret = -EINVAL; |
| 10563 | QDF_ASSERT(0); |
| 10564 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10565 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10566 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10567 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10568 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10569 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10570 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10571 | ret = -EINVAL; |
| 10572 | QDF_ASSERT(0); |
| 10573 | } |
| 10574 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10575 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10576 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10577 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10578 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10579 | QDF_ASSERT(0); |
| 10580 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10581 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10582 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10583 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10584 | if (ret) { |
| 10585 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10586 | QDF_ASSERT(0); |
| 10587 | } |
| 10588 | |
| 10589 | /* |
| 10590 | * Reset total mac phy during module stop such that during |
| 10591 | * next module start same psoc is used to populate new service |
| 10592 | * ready data |
| 10593 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10594 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10595 | if (tgt_hdl) |
| 10596 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10597 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10598 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10599 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10600 | if (!hif_ctx) { |
| 10601 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10602 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10603 | } |
| 10604 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10605 | if (hdd_ctx->target_hw_name) { |
| 10606 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10607 | hdd_ctx->target_hw_name = NULL; |
| 10608 | } |
| 10609 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10610 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10611 | |
| 10612 | ol_cds_free(); |
| 10613 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10614 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10615 | ret = pld_power_off(qdf_ctx->dev); |
| 10616 | if (ret) |
| 10617 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10618 | ret); |
| 10619 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10620 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10621 | /* many adapter resources are not freed by design in SSR case */ |
| 10622 | if (!is_recovery_stop) |
| 10623 | hdd_check_for_leaks(); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10624 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10625 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10626 | /* Once the firmware sequence is completed reset this flag */ |
| 10627 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10628 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10629 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10630 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10631 | done: |
| 10632 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10633 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10634 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10635 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10636 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10637 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10638 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10639 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10640 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10641 | } |
| 10642 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10643 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10644 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10645 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10646 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10647 | * @buf: buffer pointer |
| 10648 | * @size: size of buffer to be filled |
| 10649 | * |
| 10650 | * This function is used to dump state information of hdd layer |
| 10651 | * |
| 10652 | * Return: None |
| 10653 | */ |
| 10654 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10655 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10656 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10657 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10658 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10659 | uint16_t len = 0; |
| 10660 | char *buf = *buf_ptr; |
| 10661 | |
| 10662 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10663 | if (!hdd_ctx) { |
| 10664 | hdd_err("Failed to get hdd context "); |
| 10665 | return; |
| 10666 | } |
| 10667 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10668 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10669 | |
| 10670 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10671 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10672 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10673 | "\n is_scheduler_suspended %d", |
| 10674 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10675 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10676 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10677 | if (adapter->dev) |
| 10678 | len += scnprintf(buf + len, *size - len, |
| 10679 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10680 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10681 | "\n device_mode: %d", adapter->device_mode); |
| 10682 | switch (adapter->device_mode) { |
| 10683 | case QDF_STA_MODE: |
| 10684 | case QDF_P2P_CLIENT_MODE: |
| 10685 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10686 | len += scnprintf(buf + len, *size - len, |
| 10687 | "\n connState: %d", |
| 10688 | hdd_sta_ctx->conn_info.connState); |
| 10689 | break; |
| 10690 | |
| 10691 | default: |
| 10692 | break; |
| 10693 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10694 | } |
| 10695 | |
| 10696 | *size -= len; |
| 10697 | *buf_ptr += len; |
| 10698 | } |
| 10699 | |
| 10700 | /** |
| 10701 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10702 | * to print hdd state information |
| 10703 | * |
| 10704 | * Return: None |
| 10705 | */ |
| 10706 | static void hdd_register_debug_callback(void) |
| 10707 | { |
| 10708 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10709 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10710 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 10711 | static void hdd_register_debug_callback(void) |
| 10712 | { |
| 10713 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10714 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10715 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10716 | /* |
| 10717 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10718 | * |
| 10719 | * This function is used to create bug report lock |
| 10720 | * |
| 10721 | * Return: None |
| 10722 | */ |
| 10723 | static void wlan_init_bug_report_lock(void) |
| 10724 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 10725 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10726 | |
| 10727 | p_cds_context = cds_get_global_context(); |
| 10728 | if (!p_cds_context) { |
| 10729 | hdd_err("cds context is NULL"); |
| 10730 | return; |
| 10731 | } |
| 10732 | |
| 10733 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10734 | } |
| 10735 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10736 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10737 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10738 | { |
| 10739 | |
| 10740 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10741 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10742 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10743 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10744 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10745 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10746 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10747 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10748 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10749 | if (!config->enable_dp_trace) { |
| 10750 | hdd_err("dp trace is disabled from ini"); |
| 10751 | return; |
| 10752 | } |
| 10753 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10754 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10755 | &num_entries, sizeof(config_params)); |
| 10756 | |
| 10757 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10758 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10759 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10760 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10761 | else if (bw_compute_interval > 1000) { |
| 10762 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10763 | thresh_time_limit = 1; |
| 10764 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10765 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10766 | |
| 10767 | switch (num_entries) { |
| 10768 | case 4: |
| 10769 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10770 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10771 | case 3: |
| 10772 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10773 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10774 | case 2: |
| 10775 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10776 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10777 | case 1: |
| 10778 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10779 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10780 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10781 | 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] | 10782 | live_mode, thresh, thresh_time_limit, |
| 10783 | verbosity, proto_bitmap); |
| 10784 | }; |
| 10785 | |
| 10786 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10787 | verbosity, proto_bitmap); |
| 10788 | |
| 10789 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10790 | #endif |
| 10791 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10792 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10793 | * hdd_wlan_startup() - HDD init function |
| 10794 | * @dev: Pointer to the underlying device |
| 10795 | * |
| 10796 | * This is the driver startup code executed once a WLAN device has been detected |
| 10797 | * |
| 10798 | * Return: 0 for success, < 0 for failure |
| 10799 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10800 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10801 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10802 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10803 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10804 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10805 | bool rtnl_held; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10806 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10807 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10808 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10809 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10810 | |
| 10811 | if (IS_ERR(hdd_ctx)) |
| 10812 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10813 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 10814 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 10815 | DEFAULT_PSOC_ID); |
| 10816 | if (ret) { |
| 10817 | hdd_err("Psoc creation fails!"); |
| 10818 | QDF_BUG(0); |
| 10819 | goto err_hdd_free_context; |
| 10820 | } |
| 10821 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10822 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 10823 | #ifdef FEATURE_WLAN_CH_AVOID |
| 10824 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 10825 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10826 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10827 | osif_request_manager_init(); |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10828 | hdd_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 10829 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10830 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10831 | hdd_driver_memdump_init(); |
| 10832 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10833 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10834 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10835 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10836 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10837 | } |
| 10838 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 10839 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10840 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10841 | hdd_ctx->hHal = cds_get_context(QDF_MODULE_ID_SME); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10842 | |
| 10843 | if (NULL == hdd_ctx->hHal) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10844 | hdd_err("HAL context is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10845 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10846 | } |
| 10847 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10848 | ret = hdd_wiphy_init(hdd_ctx); |
| 10849 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10850 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10851 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10852 | } |
| 10853 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10854 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 10855 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 10856 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 10857 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10858 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 10859 | if (ret) { |
| 10860 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10861 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10862 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 10863 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10864 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 10865 | if (ret) { |
| 10866 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 10867 | goto err_unregister_netdev; |
| 10868 | } |
| 10869 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10870 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10871 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10872 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 10873 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10874 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10875 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10876 | } |
| 10877 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10878 | hdd_release_rtnl_lock(); |
| 10879 | rtnl_held = false; |
| 10880 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 10881 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 10882 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10883 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 10884 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 10885 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10886 | hdd_skip_acs_scan_timer_handler, |
| 10887 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10888 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 10889 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 10890 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10891 | #endif |
| 10892 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 10893 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10894 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 10895 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10896 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 10897 | if (hdd_ctx->rps) |
| 10898 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10899 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10900 | ret = hdd_register_notifiers(hdd_ctx); |
| 10901 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10902 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 10903 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 10904 | status = wlansap_global_init(); |
| 10905 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10906 | hdd_unregister_notifiers(hdd_ctx); |
| 10907 | goto err_close_adapters; |
| 10908 | } |
| 10909 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10910 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10911 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 10912 | else |
| 10913 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 10914 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10915 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10916 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10917 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10918 | hdd_prevent_suspend_timeout( |
| 10919 | hdd_ctx->config->iface_change_wait_time, |
| 10920 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 10921 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 10922 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10923 | goto success; |
| 10924 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 10925 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10926 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10927 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 10928 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10929 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10930 | if (rtnl_held) |
| 10931 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10932 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 10933 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10934 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 10935 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10936 | err_wiphy_unregister: |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10937 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10938 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10939 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10940 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10941 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10942 | err_memdump_deinit: |
| 10943 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 10944 | |
Jeff Johnson | ce0032c | 2017-01-20 07:18:27 -0800 | [diff] [blame] | 10945 | hdd_request_manager_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 10946 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 10947 | hdd_exit_netlink_services(hdd_ctx); |
| 10948 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 10949 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 10950 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10951 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 10952 | if (cds_is_fw_down()) |
| 10953 | hdd_err("Not setting the complete event as fw is down"); |
| 10954 | else |
| 10955 | hdd_start_complete(ret); |
| 10956 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 10957 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 10958 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 10959 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10960 | |
| 10961 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10962 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10963 | return 0; |
| 10964 | } |
| 10965 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 10966 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10967 | * hdd_wlan_update_target_info() - update target type info |
| 10968 | * @hdd_ctx: HDD context |
| 10969 | * @context: hif context |
| 10970 | * |
| 10971 | * Update target info received from firmware in hdd context |
| 10972 | * Return:None |
| 10973 | */ |
| 10974 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10975 | 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] | 10976 | { |
| 10977 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 10978 | |
| 10979 | if (!tgt_info) { |
| 10980 | hdd_err("Target info is Null"); |
| 10981 | return; |
| 10982 | } |
| 10983 | |
| 10984 | hdd_ctx->target_type = tgt_info->target_type; |
| 10985 | } |
| 10986 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 10987 | void hdd_get_nud_stats_cb(void *data, struct rsp_stats *rsp, void *context) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10988 | { |
| 10989 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10990 | int status; |
| 10991 | struct hdd_adapter *adapter = NULL; |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 10992 | struct hdd_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10993 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10994 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 10995 | |
| 10996 | if (!rsp) { |
| 10997 | hdd_err("data is null"); |
| 10998 | return; |
| 10999 | } |
| 11000 | |
| 11001 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11002 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11003 | return; |
| 11004 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11005 | request = hdd_request_get(context); |
| 11006 | if (!request) { |
| 11007 | hdd_err("obselete request"); |
| 11008 | return; |
| 11009 | } |
| 11010 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11011 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11012 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11013 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11014 | hdd_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11015 | return; |
| 11016 | } |
| 11017 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11018 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11019 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11020 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11021 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11022 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11023 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11024 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 11025 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 11026 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 11027 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11028 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11029 | 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] | 11030 | adapter->dad |= rsp->dad_detected; |
| 11031 | adapter->con_status = rsp->connect_status; |
| 11032 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11033 | /* Flag true indicates connectivity check stats present. */ |
| 11034 | if (rsp->connect_stats_present) { |
| 11035 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11036 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 11037 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11038 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11039 | rsp->icmpv4_rsp_recvd; |
| 11040 | } |
| 11041 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11042 | hdd_request_complete(request); |
| 11043 | hdd_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11044 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11045 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11046 | } |
| 11047 | |
| 11048 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11049 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11050 | * @hdd_ctx: HDD context |
| 11051 | * |
| 11052 | * Register the HDD callbacks to CDS/SME. |
| 11053 | * |
| 11054 | * Return: 0 for success or Error code for failure |
| 11055 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11056 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11057 | { |
| 11058 | QDF_STATUS status; |
| 11059 | int ret = 0; |
| 11060 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11061 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11062 | |
| 11063 | sme_register11d_scan_done_callback(hdd_ctx->hHal, hdd_11d_scan_done); |
| 11064 | |
| 11065 | sme_register_oem_data_rsp_callback(hdd_ctx->hHal, |
| 11066 | hdd_send_oem_data_rsp_msg); |
| 11067 | |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11068 | sme_register_mgmt_frame_ind_callback(hdd_ctx->hHal, |
| 11069 | hdd_indicate_mgmt_frame); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11070 | sme_set_tsfcb(hdd_ctx->hHal, hdd_get_tsf_cb, hdd_ctx); |
| 11071 | sme_nan_register_callback(hdd_ctx->hHal, |
| 11072 | wlan_hdd_cfg80211_nan_callback); |
| 11073 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 11074 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11075 | |
| 11076 | sme_ext_scan_register_callback(hdd_ctx->hHal, |
| 11077 | wlan_hdd_cfg80211_extscan_callback); |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11078 | sme_stats_ext2_register_callback(hdd_ctx->hHal, |
| 11079 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11080 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11081 | sme_set_rssi_threshold_breached_cb(hdd_ctx->hHal, |
| 11082 | hdd_rssi_threshold_breached); |
| 11083 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11084 | sme_set_link_layer_stats_ind_cb(hdd_ctx->hHal, |
| 11085 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11086 | |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 11087 | sme_rso_cmd_status_cb(hdd_ctx->hHal, wlan_hdd_rso_cmd_status_cb); |
| 11088 | |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11089 | sme_set_link_layer_ext_cb(hdd_ctx->hHal, |
| 11090 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11091 | |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11092 | status = sme_set_lost_link_info_cb(hdd_ctx->hHal, |
| 11093 | hdd_lost_link_info_cb); |
| 11094 | /* print error and not block the startup process */ |
| 11095 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11096 | hdd_err("set lost link info callback failed"); |
| 11097 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11098 | ret = hdd_register_data_stall_detect_cb(); |
| 11099 | if (ret) { |
| 11100 | hdd_err("Register data stall detect detect callback failed."); |
| 11101 | return ret; |
| 11102 | } |
| 11103 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11104 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11105 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 11106 | sme_register_set_connection_info_cb(hdd_ctx->hHal, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11107 | hdd_set_connection_in_progress, |
| 11108 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11109 | |
| 11110 | status = sme_congestion_register_callback(hdd_ctx->hHal, |
| 11111 | hdd_update_cca_info_cb); |
| 11112 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11113 | hdd_err("set congestion callback failed"); |
| 11114 | |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11115 | status = sme_set_bt_activity_info_cb(hdd_ctx->hHal, |
| 11116 | hdd_bt_activity_cb); |
| 11117 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11118 | hdd_err("set bt activity info callback failed"); |
| 11119 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11120 | status = sme_register_tx_queue_cb(hdd_ctx->hHal, |
| 11121 | hdd_tx_queue_cb); |
| 11122 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11123 | hdd_err("Register tx queue callback failed"); |
| 11124 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11125 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11126 | |
| 11127 | return ret; |
| 11128 | } |
| 11129 | |
| 11130 | /** |
| 11131 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11132 | * @hdd_ctx: HDD context |
| 11133 | * |
| 11134 | * De-Register the HDD callbacks to CDS/SME. |
| 11135 | * |
| 11136 | * Return: void |
| 11137 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11138 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11139 | { |
| 11140 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11141 | int ret; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11142 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11143 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11144 | |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11145 | sme_deregister_tx_queue_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11146 | status = sme_deregister_for_dcc_stats_event(hdd_ctx->hHal); |
| 11147 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11148 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11149 | status); |
| 11150 | |
| 11151 | sme_reset_link_layer_stats_ind_cb(hdd_ctx->hHal); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11152 | sme_reset_rssi_threshold_breached_cb(hdd_ctx->hHal); |
| 11153 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11154 | sme_stats_ext_register_callback(hdd_ctx->hHal, |
| 11155 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11156 | |
| 11157 | sme_nan_deregister_callback(hdd_ctx->hHal); |
| 11158 | status = sme_reset_tsfcb(hdd_ctx->hHal); |
| 11159 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11160 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11161 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11162 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11163 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11164 | if (ret) |
| 11165 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11166 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11167 | sme_deregister_oem_data_rsp_callback(hdd_ctx->hHal); |
| 11168 | sme_deregister11d_scan_done_callback(hdd_ctx->hHal); |
| 11169 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11170 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11171 | } |
| 11172 | |
| 11173 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11174 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11175 | * @adapter: Pointer to the HDD |
| 11176 | * @enable: bool value |
| 11177 | * |
| 11178 | * This to take counter measure to handle deauth req from HDD |
| 11179 | * |
| 11180 | * Return: None |
| 11181 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11182 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11183 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11184 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11185 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11186 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11187 | hdd_enter(); |
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 | /* Ignore request to deauth bcmc station */ |
| 11190 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11191 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11192 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11193 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11194 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11195 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11196 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11197 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11198 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11199 | } |
| 11200 | |
| 11201 | /** |
| 11202 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11203 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11204 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11205 | * |
| 11206 | * This to take counter measure to handle deauth req from HDD |
| 11207 | * |
| 11208 | * Return: None |
| 11209 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11210 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11211 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11212 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11213 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11214 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11215 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11216 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11217 | return; |
| 11218 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11219 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11220 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11221 | } |
| 11222 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11223 | /** |
| 11224 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11225 | * @hdd_ctx: HDD Context |
| 11226 | * |
| 11227 | * API to find if there is any STA or P2P-Client is connected |
| 11228 | * |
| 11229 | * Return: true if connected; false otherwise |
| 11230 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11231 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11232 | { |
| 11233 | return sme_is_sta_p2p_client_connected(hdd_ctx->hHal); |
| 11234 | } |
| 11235 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11236 | /** |
| 11237 | * wlan_hdd_disable_roaming() - disable roaming on all STAs except the input one |
| 11238 | * @adapter: HDD adapter pointer |
| 11239 | * |
| 11240 | * This function loop through each adapter and disable roaming on each STA |
| 11241 | * device mode except the input adapter. |
| 11242 | * |
| 11243 | * Note: On the input adapter roaming is not enabled yet hence no need to |
| 11244 | * disable. |
| 11245 | * |
| 11246 | * Return: None |
| 11247 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11248 | void wlan_hdd_disable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11249 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11250 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11251 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11252 | |
| 11253 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11254 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11255 | QDF_STA_MODE == adapter->device_mode && |
| 11256 | policy_mgr_is_sta_active_connection_exists( |
| 11257 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11258 | hdd_debug("Connect received on STA session Id(%d)", |
| 11259 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11260 | /* |
| 11261 | * Loop through adapter and disable roaming for each STA device |
| 11262 | * mode except the input adapter. |
| 11263 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11264 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11265 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11266 | adapter->session_id != adapterIdx->session_id) { |
| 11267 | hdd_debug("Disable Roaming on session Id(%d)", |
| 11268 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11269 | sme_stop_roaming(WLAN_HDD_GET_HAL_CTX |
| 11270 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11271 | adapterIdx->session_id, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11272 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11273 | } |
| 11274 | } |
| 11275 | } |
| 11276 | |
| 11277 | /** |
| 11278 | * wlan_hdd_enable_roaming() - enable roaming on all STAs except the input one |
| 11279 | * @adapter: HDD adapter pointer |
| 11280 | * |
| 11281 | * This function loop through each adapter and enable roaming on each STA |
| 11282 | * device mode except the input adapter. |
| 11283 | * Note: On the input adapter no need to enable roaming because link got |
| 11284 | * disconnected on this. |
| 11285 | * |
| 11286 | * Return: None |
| 11287 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11288 | void wlan_hdd_enable_roaming(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11289 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11290 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11291 | struct hdd_adapter *adapterIdx = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11292 | |
| 11293 | if (hdd_ctx->config->isFastRoamIniFeatureEnabled && |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11294 | hdd_ctx->config->isRoamOffloadScanEnabled && |
| 11295 | QDF_STA_MODE == adapter->device_mode && |
| 11296 | policy_mgr_is_sta_active_connection_exists( |
| 11297 | hdd_ctx->hdd_psoc)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11298 | hdd_debug("Disconnect received on STA session Id(%d)", |
| 11299 | adapter->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11300 | /* |
| 11301 | * Loop through adapter and enable roaming for each STA device |
| 11302 | * mode except the input adapter. |
| 11303 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11304 | hdd_for_each_adapter(hdd_ctx, adapterIdx) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11305 | if (QDF_STA_MODE == adapterIdx->device_mode && |
| 11306 | adapter->session_id != adapterIdx->session_id) { |
| 11307 | hdd_debug("Enabling Roaming on session Id(%d)", |
| 11308 | adapterIdx->session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11309 | sme_start_roaming(WLAN_HDD_GET_HAL_CTX |
| 11310 | (adapterIdx), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11311 | adapterIdx->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11312 | REASON_CONNECT); |
| 11313 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11314 | } |
| 11315 | } |
| 11316 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11317 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11318 | /** |
| 11319 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11320 | * @skb: sk buffer pointer |
| 11321 | * |
| 11322 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11323 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11324 | * |
| 11325 | * Return: None |
| 11326 | */ |
| 11327 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11328 | { |
| 11329 | #ifdef CNSS_GENL |
| 11330 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11331 | #else |
| 11332 | nl_srv_bcast(skb); |
| 11333 | #endif |
| 11334 | } |
| 11335 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11336 | 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] | 11337 | { |
| 11338 | struct sk_buff *skb; |
| 11339 | struct nlmsghdr *nlh; |
| 11340 | tAniMsgHdr *ani_hdr; |
| 11341 | void *nl_data = NULL; |
| 11342 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11343 | struct radio_index_tlv *radio_info; |
| 11344 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11345 | |
| 11346 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11347 | flags = GFP_ATOMIC; |
| 11348 | |
| 11349 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11350 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11351 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11352 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11353 | |
| 11354 | nlh = (struct nlmsghdr *)skb->data; |
| 11355 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11356 | nlh->nlmsg_flags = 0; |
| 11357 | nlh->nlmsg_seq = 0; |
| 11358 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11359 | |
| 11360 | ani_hdr = NLMSG_DATA(nlh); |
| 11361 | ani_hdr->type = type; |
| 11362 | |
| 11363 | switch (type) { |
| 11364 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11365 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11366 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11367 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11368 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11369 | ani_hdr->length = 0; |
| 11370 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11371 | break; |
| 11372 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11373 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11374 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11375 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11376 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11377 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11378 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11379 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11380 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11381 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11382 | ani_hdr->length = len; |
| 11383 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11384 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11385 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11386 | break; |
| 11387 | |
| 11388 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11389 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11390 | type); |
| 11391 | kfree_skb(skb); |
| 11392 | return; |
| 11393 | } |
| 11394 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11395 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11396 | * Add radio index at the end of the svc event in TLV format |
| 11397 | * to maintain the backward compatibility with userspace |
| 11398 | * applications. |
| 11399 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11400 | |
| 11401 | tlv_len = 0; |
| 11402 | |
| 11403 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11404 | < WLAN_NL_MAX_PAYLOAD) { |
| 11405 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11406 | sizeof(*ani_hdr) + len); |
| 11407 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11408 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11409 | radio_info->radio = radio; |
| 11410 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11411 | hdd_debug("Added radio index tlv - radio index %d", |
| 11412 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11413 | } |
| 11414 | |
| 11415 | nlh->nlmsg_len += tlv_len; |
| 11416 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11417 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11418 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11419 | } |
| 11420 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11421 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11422 | void wlan_hdd_auto_shutdown_cb(void) |
| 11423 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11424 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11425 | |
| 11426 | if (!hdd_ctx) |
| 11427 | return; |
| 11428 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11429 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11430 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11431 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11432 | } |
| 11433 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11434 | 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] | 11435 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11436 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11437 | bool ap_connected = false, sta_connected = false; |
| 11438 | tHalHandle hal_handle; |
| 11439 | |
| 11440 | hal_handle = hdd_ctx->hHal; |
| 11441 | if (hal_handle == NULL) |
| 11442 | return; |
| 11443 | |
| 11444 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11445 | return; |
| 11446 | |
| 11447 | if (enable == false) { |
| 11448 | if (sme_set_auto_shutdown_timer(hal_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11449 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11450 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11451 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11452 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11453 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11454 | return; |
| 11455 | } |
| 11456 | |
| 11457 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11458 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11459 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11460 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11461 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11462 | conn_info.connState == |
| 11463 | eConnectionState_Associated) { |
| 11464 | sta_connected = true; |
| 11465 | break; |
| 11466 | } |
| 11467 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11468 | |
| 11469 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11470 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11471 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11472 | ap_connected = true; |
| 11473 | break; |
| 11474 | } |
| 11475 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11476 | } |
| 11477 | } |
| 11478 | |
| 11479 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11480 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11481 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11482 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11483 | |
| 11484 | if (sme_set_auto_shutdown_timer(hal_handle, |
| 11485 | hdd_ctx->config->WlanAutoShutdown) |
| 11486 | != QDF_STATUS_SUCCESS) |
| 11487 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11488 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11489 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11490 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11491 | } |
| 11492 | #endif |
| 11493 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11494 | struct hdd_adapter * |
| 11495 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11496 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11497 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11498 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11499 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11500 | |
| 11501 | con_sap_adapter = NULL; |
| 11502 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11503 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11504 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11505 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11506 | adapter != this_sap_adapter) { |
| 11507 | if (check_start_bss) { |
| 11508 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11509 | &adapter->event_flags)) { |
| 11510 | con_sap_adapter = adapter; |
| 11511 | break; |
| 11512 | } |
| 11513 | } else { |
| 11514 | con_sap_adapter = adapter; |
| 11515 | break; |
| 11516 | } |
| 11517 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11518 | } |
| 11519 | |
| 11520 | return con_sap_adapter; |
| 11521 | } |
| 11522 | |
| 11523 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11524 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11525 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11526 | return adapter->device_mode == QDF_STA_MODE || |
| 11527 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11528 | } |
| 11529 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11530 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11531 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11532 | return adapter->device_mode == QDF_SAP_MODE || |
| 11533 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11534 | } |
| 11535 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11536 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11537 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11538 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11539 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11540 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11541 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11542 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11543 | conn_info.connState == eConnectionState_Associated) { |
| 11544 | return true; |
| 11545 | } |
| 11546 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11547 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11548 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11549 | return true; |
| 11550 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11551 | } |
| 11552 | |
| 11553 | return false; |
| 11554 | } |
| 11555 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11556 | 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] | 11557 | { |
| 11558 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11559 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11560 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11561 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11562 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11563 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11564 | return is_running; |
| 11565 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11566 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11567 | 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] | 11568 | { |
| 11569 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11570 | hdd_ctx->bus_bw_timer_running = true; |
| 11571 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11572 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11573 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11574 | } |
| 11575 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11576 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11577 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11578 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11579 | |
| 11580 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11581 | hdd_debug("Bandwidth compute timer already started"); |
| 11582 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11583 | } |
| 11584 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11585 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11586 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11587 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11588 | } |
| 11589 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11590 | 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] | 11591 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11592 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11593 | |
| 11594 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11595 | hdd_debug("Bandwidth compute timer already started"); |
| 11596 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11597 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11598 | |
| 11599 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11600 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11601 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11602 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11603 | } |
| 11604 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11605 | 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] | 11606 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11607 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11608 | |
| 11609 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11610 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11611 | hdd_ctx->bus_bw_timer_running = false; |
| 11612 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11613 | |
| 11614 | hdd_reset_tcp_delack(hdd_ctx); |
| 11615 | } |
| 11616 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11617 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11618 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11619 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11620 | |
| 11621 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11622 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11623 | return; |
| 11624 | } |
| 11625 | |
| 11626 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11627 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11628 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11629 | } |
| 11630 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11631 | 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] | 11632 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11633 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11634 | |
| 11635 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11636 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11637 | return; |
| 11638 | } |
| 11639 | |
| 11640 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11641 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11642 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11643 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11644 | } |
| 11645 | #endif |
| 11646 | |
| 11647 | /** |
| 11648 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11649 | * and sta's operating channel. |
| 11650 | * @sta_adapter: Describe the first argument to foobar. |
| 11651 | * @ap_adapter: Describe the second argument to foobar. |
| 11652 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11653 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11654 | * set this flag to true else false. |
| 11655 | * |
| 11656 | * This function checks the sap's operating channel and sta's operating channel. |
| 11657 | * if both are same then it will return false else it will restart the sap in |
| 11658 | * sta's channel and return true. |
| 11659 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11660 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11661 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11662 | QDF_STATUS |
| 11663 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11664 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11665 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11666 | tScanResultHandle *scan_cache, |
| 11667 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11668 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11669 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11670 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11671 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11672 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11673 | *concurrent_chnl_same = true; |
| 11674 | |
| 11675 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11676 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11677 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11678 | scan_cache, |
| 11679 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11680 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11681 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11682 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11683 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11684 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11685 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11686 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11687 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11688 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11689 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11690 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11691 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11692 | } |
| 11693 | } |
| 11694 | } else { |
| 11695 | /* |
| 11696 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11697 | * failed so we have to stop the SAP to avoid any channel |
| 11698 | * discrepancy between SAP's channel and STA's channel. |
| 11699 | * Return the status as failure so caller function could know |
| 11700 | * that scan look up is failed. |
| 11701 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11702 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11703 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11704 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11705 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11706 | } |
| 11707 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11708 | /** |
| 11709 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11710 | * @ap_adapter: SAP adapter |
| 11711 | * |
| 11712 | * This function will process the stopping of sap adapter. |
| 11713 | * |
| 11714 | * Return: None |
| 11715 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11716 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11717 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11718 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11719 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11720 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11721 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11722 | |
| 11723 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11724 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11725 | return; |
| 11726 | } |
| 11727 | |
| 11728 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11729 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11730 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11731 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11732 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11733 | mutex_lock(&hdd_ctx->sap_lock); |
| 11734 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11735 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11736 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11737 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11738 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11739 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11740 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11741 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11742 | qdf_stop_bss_event, |
| 11743 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11744 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11745 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11746 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11747 | return; |
| 11748 | } |
| 11749 | } |
| 11750 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11751 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11752 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11753 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11754 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11755 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11756 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11757 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11758 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11759 | } |
| 11760 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11761 | } |
| 11762 | |
| 11763 | /** |
| 11764 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11765 | * @ap_adapter: SAP adapter |
| 11766 | * |
| 11767 | * This function will process the starting of sap adapter. |
| 11768 | * |
| 11769 | * Return: None |
| 11770 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11771 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11772 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11773 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11774 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11775 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11776 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 11777 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11778 | |
| 11779 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11780 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11781 | return; |
| 11782 | } |
| 11783 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11784 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11785 | hdd_err("SoftAp role has not been enabled"); |
| 11786 | return; |
| 11787 | } |
| 11788 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11789 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11790 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11791 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11792 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11793 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11794 | mutex_lock(&hdd_ctx->sap_lock); |
| 11795 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11796 | goto end; |
| 11797 | |
| 11798 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11799 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11800 | goto end; |
| 11801 | } |
| 11802 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11803 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11804 | 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] | 11805 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11806 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11807 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11808 | goto end; |
| 11809 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11810 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11811 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11812 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11813 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11814 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11815 | goto end; |
| 11816 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11817 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11818 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11819 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11820 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11821 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11822 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11823 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11824 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11825 | true); |
| 11826 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11827 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11828 | |
| 11829 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11830 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11831 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11832 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 11833 | /* SAP context and beacon cleanup will happen during driver unload |
| 11834 | * in hdd_stop_adapter |
| 11835 | */ |
| 11836 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 11837 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11838 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11839 | |
| 11840 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11841 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 11842 | * mac scan config |
| 11843 | * @status: Status of set antenna mode |
| 11844 | * |
| 11845 | * Callback on setting the dual mac configuration |
| 11846 | * |
| 11847 | * Return: None |
| 11848 | */ |
| 11849 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 11850 | enum set_antenna_mode_status status) |
| 11851 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11852 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11853 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11854 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 11855 | |
| 11856 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11857 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 11858 | return; |
| 11859 | |
| 11860 | /* Signal the completion of set dual mac config */ |
| 11861 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 11862 | } |
| 11863 | |
| 11864 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11865 | * hdd_get_fw_version() - Get FW version |
| 11866 | * @hdd_ctx: pointer to HDD context. |
| 11867 | * @major_spid: FW version - major spid. |
| 11868 | * @minor_spid: FW version - minor spid |
| 11869 | * @ssid: FW version - ssid |
| 11870 | * @crmid: FW version - crmid |
| 11871 | * |
| 11872 | * This function is called to get the firmware build version stored |
| 11873 | * as part of the HDD context |
| 11874 | * |
| 11875 | * Return: None |
| 11876 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11877 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11878 | uint32_t *major_spid, uint32_t *minor_spid, |
| 11879 | uint32_t *siid, uint32_t *crmid) |
| 11880 | { |
| 11881 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 11882 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 11883 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 11884 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 11885 | } |
| 11886 | |
| 11887 | #ifdef QCA_CONFIG_SMP |
| 11888 | /** |
| 11889 | * wlan_hdd_get_cpu() - get cpu_index |
| 11890 | * |
| 11891 | * Return: cpu_index |
| 11892 | */ |
| 11893 | int wlan_hdd_get_cpu(void) |
| 11894 | { |
| 11895 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11896 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11897 | put_cpu(); |
| 11898 | return cpu_index; |
| 11899 | } |
| 11900 | #endif |
| 11901 | |
| 11902 | /** |
| 11903 | * hdd_get_fwpath() - get framework path |
| 11904 | * |
| 11905 | * This function is used to get the string written by |
| 11906 | * userspace to start the wlan driver |
| 11907 | * |
| 11908 | * Return: string |
| 11909 | */ |
| 11910 | const char *hdd_get_fwpath(void) |
| 11911 | { |
| 11912 | return fwpath.string; |
| 11913 | } |
| 11914 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11915 | static int hdd_qdf_print_init(void) |
| 11916 | { |
| 11917 | int qdf_print_idx; |
| 11918 | QDF_STATUS status; |
| 11919 | |
| 11920 | status = qdf_print_setup(); |
| 11921 | if (status != QDF_STATUS_SUCCESS) { |
| 11922 | pr_err("qdf_print_setup failed\n"); |
| 11923 | return -EINVAL; |
| 11924 | } |
| 11925 | |
| 11926 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 11927 | |
| 11928 | if (qdf_print_idx < 0) { |
| 11929 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 11930 | qdf_print_idx); |
| 11931 | return -EINVAL; |
| 11932 | } |
| 11933 | |
| 11934 | qdf_set_pidx(qdf_print_idx); |
| 11935 | |
| 11936 | return 0; |
| 11937 | } |
| 11938 | |
| 11939 | static void hdd_qdf_print_deinit(void) |
| 11940 | { |
| 11941 | int qdf_print_idx; |
| 11942 | |
| 11943 | qdf_print_idx = qdf_get_pidx(); |
| 11944 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 11945 | } |
| 11946 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11947 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11948 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11949 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11950 | * This function initilizes CDS global context with the help of cds_init. This |
| 11951 | * has to be the first function called after probe to get a valid global |
| 11952 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11953 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11954 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11955 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11956 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11957 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11958 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11959 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11960 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 11961 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 11962 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11963 | hdd_err("Failed to allocate CDS context"); |
| 11964 | ret = -ENOMEM; |
| 11965 | goto err_out; |
| 11966 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 11967 | |
| 11968 | wlan_init_bug_report_lock(); |
| 11969 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11970 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 11971 | wlan_logging_sock_init_svc(); |
| 11972 | #endif |
| 11973 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11974 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 11975 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 11976 | QDF_TIMER_TYPE_SW); |
| 11977 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11978 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 11979 | hdd_qdf_print_init(); |
| 11980 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11981 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11982 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11983 | err_out: |
| 11984 | return ret; |
| 11985 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11986 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 11987 | /** |
| 11988 | * hdd_deinit() - Deinitialize Driver |
| 11989 | * |
| 11990 | * This function frees CDS global context with the help of cds_deinit. This |
| 11991 | * has to be the last function call in remove callback to free the global |
| 11992 | * context. |
| 11993 | */ |
| 11994 | void hdd_deinit(void) |
| 11995 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 11996 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 11997 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 11998 | wlan_destroy_bug_report_lock(); |
| 11999 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12000 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 12001 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12002 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12003 | wlan_logging_sock_deinit_svc(); |
| 12004 | #endif |
| 12005 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12006 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12007 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12008 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12009 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12010 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12011 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12012 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12013 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12014 | struct file *file) |
| 12015 | { |
| 12016 | return 0; |
| 12017 | } |
| 12018 | |
| 12019 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12020 | const char __user *user_buf, |
| 12021 | size_t count, |
| 12022 | loff_t *f_pos) |
| 12023 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12024 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12025 | static const char wlan_off_str[] = "OFF"; |
| 12026 | static const char wlan_on_str[] = "ON"; |
| 12027 | int ret; |
| 12028 | unsigned long rc; |
| 12029 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12030 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12031 | pr_err("Failed to read buffer\n"); |
| 12032 | return -EINVAL; |
| 12033 | } |
| 12034 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12035 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12036 | pr_debug("Wifi turning off from UI\n"); |
| 12037 | goto exit; |
| 12038 | } |
| 12039 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12040 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 12041 | pr_info("Wifi Turning On from UI\n"); |
| 12042 | } |
| 12043 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12044 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12045 | pr_err("Invalid value received from framework"); |
| 12046 | goto exit; |
| 12047 | } |
| 12048 | |
| 12049 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12050 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12051 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12052 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12053 | if (!rc) { |
| 12054 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 12055 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12056 | return ret; |
| 12057 | } |
| 12058 | |
| 12059 | hdd_start_complete(0); |
| 12060 | } |
| 12061 | |
| 12062 | exit: |
| 12063 | return count; |
| 12064 | } |
| 12065 | |
| 12066 | |
| 12067 | const struct file_operations wlan_hdd_state_fops = { |
| 12068 | .owner = THIS_MODULE, |
| 12069 | .open = wlan_hdd_state_ctrl_param_open, |
| 12070 | .write = wlan_hdd_state_ctrl_param_write, |
| 12071 | }; |
| 12072 | |
| 12073 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12074 | { |
| 12075 | unsigned int wlan_hdd_state_major = 0; |
| 12076 | int ret; |
| 12077 | struct device *dev; |
| 12078 | |
| 12079 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12080 | |
| 12081 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12082 | if (ret) { |
| 12083 | pr_err("Failed to register qcwlanstate"); |
| 12084 | goto dev_alloc_err; |
| 12085 | } |
| 12086 | wlan_hdd_state_major = MAJOR(device); |
| 12087 | |
| 12088 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12089 | if (IS_ERR(class)) { |
| 12090 | pr_err("wlan_hdd_state class_create error"); |
| 12091 | goto class_err; |
| 12092 | } |
| 12093 | |
| 12094 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12095 | if (IS_ERR(dev)) { |
| 12096 | pr_err("wlan_hdd_statedevice_create error"); |
| 12097 | goto err_class_destroy; |
| 12098 | } |
| 12099 | |
| 12100 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12101 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12102 | if (ret) { |
| 12103 | pr_err("Failed to add cdev error"); |
| 12104 | goto cdev_add_err; |
| 12105 | } |
| 12106 | |
| 12107 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12108 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12109 | |
| 12110 | return 0; |
| 12111 | |
| 12112 | cdev_add_err: |
| 12113 | device_destroy(class, device); |
| 12114 | err_class_destroy: |
| 12115 | class_destroy(class); |
| 12116 | class_err: |
| 12117 | unregister_chrdev_region(device, dev_num); |
| 12118 | dev_alloc_err: |
| 12119 | return -ENODEV; |
| 12120 | } |
| 12121 | |
| 12122 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12123 | { |
| 12124 | cdev_del(&wlan_hdd_state_cdev); |
| 12125 | device_destroy(class, device); |
| 12126 | class_destroy(class); |
| 12127 | unregister_chrdev_region(device, dev_num); |
| 12128 | |
| 12129 | pr_info("Device node unregistered"); |
| 12130 | } |
| 12131 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12132 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12133 | * component_init - API to init cld component's |
| 12134 | * |
| 12135 | * Return: None |
| 12136 | */ |
| 12137 | static void component_init(void) |
| 12138 | { |
| 12139 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12140 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12141 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12142 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12143 | } |
| 12144 | |
| 12145 | /** |
| 12146 | * component_deinit - API to deinit cld component's |
| 12147 | * |
| 12148 | * Return: None |
| 12149 | */ |
| 12150 | static void component_deinit(void) |
| 12151 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12152 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12153 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12154 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12155 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12156 | } |
| 12157 | |
| 12158 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12159 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12160 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12161 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12162 | } |
| 12163 | |
| 12164 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12165 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12166 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12167 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12168 | } |
| 12169 | |
| 12170 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12171 | * __hdd_module_init - Module init helper |
| 12172 | * |
| 12173 | * Module init helper function used by both module and static driver. |
| 12174 | * |
| 12175 | * Return: 0 for success, errno on failure |
| 12176 | */ |
| 12177 | static int __hdd_module_init(void) |
| 12178 | { |
| 12179 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12180 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12181 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12182 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12183 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12184 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12185 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12186 | pld_init(); |
| 12187 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12188 | ret = hdd_init(); |
| 12189 | if (ret) { |
| 12190 | pr_err("hdd_init failed %x\n", ret); |
| 12191 | goto err_hdd_init; |
| 12192 | } |
| 12193 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12194 | dispatcher_init(); |
| 12195 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12196 | /* Ensure to call post objmgr init */ |
| 12197 | component_init(); |
| 12198 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12199 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12200 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12201 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12202 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12203 | ret = wlan_hdd_register_driver(); |
| 12204 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12205 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12206 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12207 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12208 | } |
| 12209 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12210 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12211 | if (ret) { |
| 12212 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12213 | goto out; |
| 12214 | } |
| 12215 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12216 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12217 | |
| 12218 | return 0; |
| 12219 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12220 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12221 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12222 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12223 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12224 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12225 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12226 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12227 | return ret; |
| 12228 | } |
| 12229 | |
| 12230 | /** |
| 12231 | * __hdd_module_exit - Module exit helper |
| 12232 | * |
| 12233 | * Module exit helper function used by both module and static driver. |
| 12234 | */ |
| 12235 | static void __hdd_module_exit(void) |
| 12236 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12237 | 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] | 12238 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12239 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12240 | QWLAN_VERSIONSTR); |
| 12241 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12242 | if (!hdd_wait_for_recovery_completion()) |
| 12243 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12244 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12245 | if (hdd_ctx) |
| 12246 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12247 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12248 | wlan_hdd_unregister_driver(); |
| 12249 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12250 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12251 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12252 | /* Ensure to call prior to objmgr deinit */ |
| 12253 | component_deinit(); |
| 12254 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12255 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12256 | |
| 12257 | hdd_sysfs_destroy_version_interface(); |
| 12258 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12259 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12260 | pld_deinit(); |
| 12261 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12262 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12263 | } |
| 12264 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12265 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12266 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12267 | * wlan_boot_cb() - Wlan boot callback |
| 12268 | * @kobj: object whose directory we're creating the link in. |
| 12269 | * @attr: attribute the user is interacting with |
| 12270 | * @buff: the buffer containing the user data |
| 12271 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12272 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12273 | * This callback is invoked when the fs is ready to start the |
| 12274 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12275 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12276 | * 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] | 12277 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12278 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12279 | struct kobj_attribute *attr, |
| 12280 | const char *buf, |
| 12281 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12282 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12283 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12284 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12285 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12286 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12287 | } |
| 12288 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12289 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12290 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12291 | return -EIO; |
| 12292 | } |
| 12293 | |
| 12294 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12295 | |
| 12296 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12297 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12298 | |
| 12299 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12300 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12301 | * |
| 12302 | * Return: None |
| 12303 | * |
| 12304 | */ |
| 12305 | static void hdd_sysfs_cleanup(void) |
| 12306 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12307 | /* remove from group */ |
| 12308 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12309 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12310 | wlan_loader->attr_group); |
| 12311 | |
| 12312 | /* unlink the object from parent */ |
| 12313 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12314 | |
| 12315 | /* free the object */ |
| 12316 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12317 | |
| 12318 | kfree(wlan_loader->attr_group); |
| 12319 | kfree(wlan_loader); |
| 12320 | |
| 12321 | wlan_loader = NULL; |
| 12322 | } |
| 12323 | |
| 12324 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12325 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12326 | * ready |
| 12327 | * |
| 12328 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12329 | * when the filesystem is ready. |
| 12330 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12331 | * QDF API cannot be used here since this function is called even before |
| 12332 | * initializing WLAN driver. |
| 12333 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12334 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12335 | */ |
| 12336 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12337 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12338 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12339 | |
| 12340 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12341 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12342 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12343 | |
| 12344 | wlan_loader->boot_wlan_obj = NULL; |
| 12345 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12346 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12347 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12348 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12349 | |
| 12350 | wlan_loader->loaded_state = 0; |
| 12351 | wlan_loader->attr_group->attrs = attrs; |
| 12352 | |
| 12353 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12354 | kernel_kobj); |
| 12355 | if (!wlan_loader->boot_wlan_obj) { |
| 12356 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12357 | goto error_return; |
| 12358 | } |
| 12359 | |
| 12360 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12361 | wlan_loader->attr_group); |
| 12362 | if (ret) { |
| 12363 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12364 | goto error_return; |
| 12365 | } |
| 12366 | |
| 12367 | return 0; |
| 12368 | |
| 12369 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12370 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12371 | |
| 12372 | return ret; |
| 12373 | } |
| 12374 | |
| 12375 | /** |
| 12376 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12377 | * |
| 12378 | * Return: 0 on success or errno on failure |
| 12379 | */ |
| 12380 | static int wlan_deinit_sysfs(void) |
| 12381 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12382 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12383 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12384 | return -EINVAL; |
| 12385 | } |
| 12386 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12387 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12388 | return 0; |
| 12389 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12390 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12391 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12392 | |
| 12393 | #ifdef MODULE |
| 12394 | /** |
| 12395 | * __hdd_module_init - Module init helper |
| 12396 | * |
| 12397 | * Module init helper function used by both module and static driver. |
| 12398 | * |
| 12399 | * Return: 0 for success, errno on failure |
| 12400 | */ |
| 12401 | static int hdd_module_init(void) |
| 12402 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12403 | if (__hdd_module_init()) { |
| 12404 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12405 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12406 | } |
| 12407 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12408 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12409 | } |
| 12410 | #else |
| 12411 | static int __init hdd_module_init(void) |
| 12412 | { |
| 12413 | int ret = -EINVAL; |
| 12414 | |
| 12415 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12416 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12417 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12418 | |
| 12419 | return ret; |
| 12420 | } |
| 12421 | #endif |
| 12422 | |
| 12423 | |
| 12424 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12425 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12426 | * hdd_module_exit() - Exit function |
| 12427 | * |
| 12428 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12429 | * |
| 12430 | * Return: None |
| 12431 | */ |
| 12432 | static void __exit hdd_module_exit(void) |
| 12433 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12434 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12435 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12436 | #else |
| 12437 | static void __exit hdd_module_exit(void) |
| 12438 | { |
| 12439 | __hdd_module_exit(); |
| 12440 | wlan_deinit_sysfs(); |
| 12441 | } |
| 12442 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12443 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12444 | static int fwpath_changed_handler(const char *kmessage, |
| 12445 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12446 | { |
| 12447 | return param_set_copystring(kmessage, kp); |
| 12448 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12449 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12450 | /** |
| 12451 | * is_con_mode_valid() check con mode is valid or not |
| 12452 | * @mode: global con mode |
| 12453 | * |
| 12454 | * Return: TRUE on success FALSE on failure |
| 12455 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12456 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12457 | { |
| 12458 | switch (mode) { |
| 12459 | case QDF_GLOBAL_MONITOR_MODE: |
| 12460 | case QDF_GLOBAL_FTM_MODE: |
| 12461 | case QDF_GLOBAL_EPPING_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12462 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12463 | return true; |
| 12464 | default: |
| 12465 | return false; |
| 12466 | } |
| 12467 | } |
| 12468 | |
| 12469 | /** |
| 12470 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12471 | * @mode: global con mode |
| 12472 | * |
| 12473 | * Return: adapter mode |
| 12474 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12475 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12476 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12477 | { |
| 12478 | |
| 12479 | switch (mode) { |
| 12480 | case QDF_GLOBAL_MISSION_MODE: |
| 12481 | return QDF_STA_MODE; |
| 12482 | case QDF_GLOBAL_MONITOR_MODE: |
| 12483 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12484 | case QDF_GLOBAL_EPPING_MODE: |
| 12485 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12486 | case QDF_GLOBAL_FTM_MODE: |
| 12487 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12488 | case QDF_GLOBAL_QVIT_MODE: |
| 12489 | return QDF_QVIT_MODE; |
| 12490 | default: |
| 12491 | return QDF_MAX_NO_OF_MODE; |
| 12492 | } |
| 12493 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12494 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12495 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12496 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12497 | { |
| 12498 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12499 | return; |
| 12500 | |
| 12501 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12502 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12503 | hdd_info("Release wakelock for monitor mode!"); |
| 12504 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12505 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 12506 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12507 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12508 | case QDF_GLOBAL_FTM_MODE: |
| 12509 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12510 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12511 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12512 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12513 | break; |
| 12514 | default: |
| 12515 | break; |
| 12516 | } |
| 12517 | } |
| 12518 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12519 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12520 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12521 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12522 | int driver_status; |
| 12523 | |
| 12524 | driver_status = hdd_ctx->driver_status; |
| 12525 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12526 | switch (curr_mode) { |
| 12527 | case QDF_GLOBAL_MISSION_MODE: |
| 12528 | case QDF_GLOBAL_MONITOR_MODE: |
| 12529 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12530 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12531 | hdd_close_all_adapters(hdd_ctx, false); |
| 12532 | break; |
| 12533 | case QDF_GLOBAL_EPPING_MODE: |
| 12534 | epping_disable(); |
| 12535 | epping_close(); |
| 12536 | break; |
| 12537 | default: |
| 12538 | return; |
| 12539 | } |
| 12540 | } |
| 12541 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12542 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12543 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12544 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12545 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12546 | int ret = 0; |
| 12547 | bool rtnl_held; |
| 12548 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12549 | QDF_STATUS status; |
| 12550 | |
| 12551 | if (!qdf_dev) { |
| 12552 | hdd_err("qdf device context is Null return!"); |
| 12553 | return -EINVAL; |
| 12554 | } |
| 12555 | |
| 12556 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12557 | switch (mode) { |
| 12558 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12559 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12560 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12561 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12562 | break; |
| 12563 | case QDF_GLOBAL_FTM_MODE: |
| 12564 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12565 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12566 | NET_NAME_UNKNOWN, rtnl_held); |
| 12567 | if (adapter == NULL) |
| 12568 | ret = -EINVAL; |
| 12569 | break; |
| 12570 | case QDF_GLOBAL_MONITOR_MODE: |
| 12571 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12572 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12573 | NET_NAME_UNKNOWN, rtnl_held); |
| 12574 | if (adapter == NULL) |
| 12575 | ret = -EINVAL; |
| 12576 | break; |
| 12577 | case QDF_GLOBAL_EPPING_MODE: |
| 12578 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12579 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12580 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12581 | ret = -EINVAL; |
| 12582 | break; |
| 12583 | } |
| 12584 | ret = epping_enable(qdf_dev->dev); |
| 12585 | if (ret) { |
| 12586 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12587 | epping_close(); |
| 12588 | } |
| 12589 | break; |
| 12590 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12591 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12592 | ret = -ENOTSUPP; |
| 12593 | break; |
| 12594 | } |
| 12595 | hdd_release_rtnl_lock(); |
| 12596 | rtnl_held = false; |
| 12597 | return ret; |
| 12598 | } |
| 12599 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12600 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12601 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12602 | * @kmessage: con mode name on which driver to be bring up |
| 12603 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12604 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12605 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12606 | * This function is invoked when user updates con mode using sys entry, |
| 12607 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12608 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12609 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12610 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12611 | static int __con_mode_handler(const char *kmessage, |
| 12612 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12613 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12614 | { |
| 12615 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12616 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12617 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12618 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12619 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12620 | hdd_info("con_mode handler: %s", kmessage); |
| 12621 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12622 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12623 | if (ret) |
| 12624 | return ret; |
| 12625 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12626 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12627 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12628 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12629 | if (ret) { |
| 12630 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12631 | goto reset_flags; |
| 12632 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12633 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12634 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12635 | if (!is_con_mode_valid(new_con_mode)) { |
| 12636 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12637 | ret = -EINVAL; |
| 12638 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12639 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12640 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12641 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12642 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12643 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12644 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12645 | ret = 0; |
| 12646 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12647 | } |
| 12648 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12649 | /* ensure adapters are stopped */ |
| 12650 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12651 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12652 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12653 | if (ret) { |
| 12654 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12655 | goto reset_flags; |
| 12656 | } |
| 12657 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 12658 | /* Cleanup present mode before switching to new mode */ |
| 12659 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12660 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12661 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12662 | |
| 12663 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12664 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12665 | if (ret) { |
| 12666 | hdd_err("Failed to register for new mode"); |
| 12667 | goto reset_flags; |
| 12668 | } |
| 12669 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12670 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12671 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12672 | hdd_err("invalid adapter"); |
| 12673 | ret = -EINVAL; |
| 12674 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12675 | } |
| 12676 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12677 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12678 | if (ret) { |
| 12679 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12680 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12681 | } |
| 12682 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12683 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12684 | struct hdd_adapter *adapter = |
| 12685 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 12686 | |
| 12687 | if (!adapter) { |
| 12688 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12689 | goto reset_flags; |
| 12690 | } |
| 12691 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12692 | if (hdd_start_adapter(adapter)) { |
| 12693 | hdd_err("Failed to start %s adapter", kmessage); |
| 12694 | ret = -EINVAL; |
| 12695 | goto reset_flags; |
| 12696 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12697 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12698 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12699 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12700 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12701 | } |
| 12702 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12703 | /* con_mode is a global module parameter */ |
| 12704 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12705 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12706 | ret = 0; |
| 12707 | |
| 12708 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12709 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12710 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12711 | return ret; |
| 12712 | } |
| 12713 | |
| 12714 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12715 | 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] | 12716 | { |
| 12717 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12718 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12719 | |
| 12720 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12721 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12722 | if (ret) |
| 12723 | return ret; |
| 12724 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 12725 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 12726 | hdd_warn("External threads are still active, can not change mode"); |
| 12727 | return -EAGAIN; |
| 12728 | } |
| 12729 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12730 | cds_ssr_protect(__func__); |
| 12731 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12732 | cds_ssr_unprotect(__func__); |
| 12733 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12734 | return ret; |
| 12735 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12736 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12737 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12738 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12739 | { |
| 12740 | int ret; |
| 12741 | |
| 12742 | ret = param_set_int(kmessage, kp); |
| 12743 | |
| 12744 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12745 | pr_err("Only FTM mode supported!"); |
| 12746 | return -ENOTSUPP; |
| 12747 | } |
| 12748 | |
| 12749 | hdd_set_conparam(con_mode_ftm); |
| 12750 | con_mode = con_mode_ftm; |
| 12751 | |
| 12752 | return ret; |
| 12753 | } |
| 12754 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12755 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12756 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12757 | { |
| 12758 | int ret; |
| 12759 | |
| 12760 | ret = param_set_int(kmessage, kp); |
| 12761 | |
| 12762 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12763 | pr_err("Only Monitor mode supported!"); |
| 12764 | return -ENOTSUPP; |
| 12765 | } |
| 12766 | |
| 12767 | hdd_set_conparam(con_mode_monitor); |
| 12768 | con_mode = con_mode_monitor; |
| 12769 | |
| 12770 | return ret; |
| 12771 | } |
| 12772 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12773 | /** |
| 12774 | * hdd_get_conparam() - driver exit point |
| 12775 | * |
| 12776 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12777 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12778 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12779 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12780 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12781 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12782 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12783 | } |
| 12784 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12785 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12786 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12787 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12788 | } |
| 12789 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12790 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12791 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12792 | * @hdd_ctx: HDD context |
| 12793 | * |
| 12794 | * Cleans up the pre cac interface, if it exists |
| 12795 | * |
| 12796 | * Return: None |
| 12797 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12798 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12799 | { |
| 12800 | uint8_t session_id; |
| 12801 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 12802 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12803 | |
| 12804 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->hHal, &session_id); |
| 12805 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12806 | hdd_err("failed to get pre cac vdev id"); |
| 12807 | return; |
| 12808 | } |
| 12809 | |
| 12810 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 12811 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 12812 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12813 | return; |
| 12814 | } |
| 12815 | |
| 12816 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 12817 | wlan_hdd_sap_pre_cac_failure, |
| 12818 | (void *)precac_adapter); |
| 12819 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 12820 | |
| 12821 | } |
| 12822 | |
| 12823 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12824 | * hdd_update_ol_config - API to update ol configuration parameters |
| 12825 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12826 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12827 | * Return: void |
| 12828 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12829 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12830 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12831 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12832 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12833 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12834 | if (!ol_ctx) |
| 12835 | return; |
| 12836 | |
| 12837 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 12838 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 12839 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 12840 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 12841 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12842 | |
| 12843 | ol_init_ini_config(ol_ctx, &cfg); |
| 12844 | } |
| 12845 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12846 | #ifdef FEATURE_RUNTIME_PM |
| 12847 | /** |
| 12848 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 12849 | * @hdd_ctx: hdd context |
| 12850 | * @cfg: pointer to the configuration memory being populated |
| 12851 | * |
| 12852 | * Return: void |
| 12853 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12854 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12855 | struct hif_config_info *cfg) |
| 12856 | { |
| 12857 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 12858 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 12859 | } |
| 12860 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12861 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12862 | struct hif_config_info *cfg) |
| 12863 | { |
| 12864 | } |
| 12865 | #endif |
| 12866 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12867 | /** |
| 12868 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 12869 | * @hdd_ctx: HDD Context |
| 12870 | * |
| 12871 | * Return: void |
| 12872 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12873 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12874 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 12875 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12876 | struct hif_config_info cfg; |
| 12877 | |
| 12878 | if (!scn) |
| 12879 | return; |
| 12880 | |
| 12881 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 12882 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12883 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 12884 | |
| 12885 | if (hdd_ctx->config->prevent_link_down) |
| 12886 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12887 | } |
| 12888 | |
| 12889 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12890 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 12891 | * datapath |
| 12892 | * @hdd_ctx: HDD Context |
| 12893 | * |
| 12894 | * Return: 0 for success/errno for failure |
| 12895 | */ |
| 12896 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 12897 | { |
| 12898 | struct cdp_config_params params; |
| 12899 | QDF_STATUS status; |
| 12900 | |
| 12901 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 12902 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 12903 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 12904 | params.tx_flow_stop_queue_threshold = |
| 12905 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 12906 | params.tx_flow_start_queue_offset = |
| 12907 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 12908 | #endif |
| 12909 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 12910 | params.napi_enable = hdd_ctx->napi_enable; |
| 12911 | params.tcp_udp_checksumoffload = |
| 12912 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 12913 | |
| 12914 | status = cdp_update_config_parameters( |
| 12915 | cds_get_context(QDF_MODULE_ID_SOC), |
| 12916 | ¶ms); |
| 12917 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12918 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 12919 | return status; |
| 12920 | } |
| 12921 | |
| 12922 | return 0; |
| 12923 | } |
| 12924 | |
| 12925 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12926 | * hdd_update_config() - Initialize driver per module ini parameters |
| 12927 | * @hdd_ctx: HDD Context |
| 12928 | * |
| 12929 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12930 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12931 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12932 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12933 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12934 | int ret; |
| 12935 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 12936 | hdd_update_ol_config(hdd_ctx); |
| 12937 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12938 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 12939 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 12940 | else |
| 12941 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 12942 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 12943 | |
| 12944 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12945 | } |
| 12946 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12947 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 12948 | /** |
| 12949 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 12950 | * @psoc_cfg: pmo psoc Configuration |
| 12951 | * @hdd_ctx: Pointer to hdd context |
| 12952 | * |
| 12953 | * Return: none |
| 12954 | */ |
| 12955 | static inline void hdd_ra_populate_pmo_config( |
| 12956 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12957 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12958 | { |
| 12959 | psoc_cfg->ra_ratelimit_interval = |
| 12960 | hdd_ctx->config->RArateLimitInterval; |
| 12961 | psoc_cfg->ra_ratelimit_enable = |
| 12962 | hdd_ctx->config->IsRArateLimitEnabled; |
| 12963 | } |
| 12964 | #else |
| 12965 | static inline void hdd_ra_populate_pmo_config( |
| 12966 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12967 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12968 | { |
| 12969 | } |
| 12970 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 12971 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12972 | /** |
| 12973 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 12974 | * @hdd_ctx: HDD context |
| 12975 | * |
| 12976 | * Return: void |
| 12977 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12978 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12979 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12980 | struct pmo_psoc_cfg psoc_cfg; |
| 12981 | QDF_STATUS status; |
| 12982 | |
| 12983 | /* |
| 12984 | * Value of hdd_ctx->wowEnable can be, |
| 12985 | * 0 - Disable both magic pattern match and pattern byte match. |
| 12986 | * 1 - Enable magic pattern match on all interfaces. |
| 12987 | * 2 - Enable pattern byte match on all interfaces. |
| 12988 | * 3 - Enable both magic patter and pattern byte match on |
| 12989 | * all interfaces. |
| 12990 | */ |
| 12991 | psoc_cfg.magic_ptrn_enable = |
| 12992 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 12993 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 12994 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12995 | psoc_cfg.apf_enable = hdd_ctx->config->bpf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12996 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Dustin Brown | 1224e21 | 2017-05-12 14:02:12 -0700 | [diff] [blame] | 12997 | psoc_cfg.hw_filter_mode = hdd_ctx->config->hw_filter_mode; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 12998 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 12999 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13000 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13001 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 13002 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13003 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13004 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13005 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13006 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 13007 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 13008 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13009 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 13010 | psoc_cfg.auto_power_save_fail_mode = |
| 13011 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13012 | |
| 13013 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13014 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 13015 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13016 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13017 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 13018 | if (QDF_IS_STATUS_ERROR(status)) |
| 13019 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 13020 | |
| 13021 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13022 | } |
| 13023 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13024 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13025 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 13026 | struct hdd_config *cfg) |
| 13027 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13028 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 13029 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13030 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 13031 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 13032 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 13033 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 13034 | pno_cfg->channel_prediction_full_scan = |
| 13035 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13036 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 13037 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 13038 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 13039 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13040 | } |
| 13041 | #else |
| 13042 | static inline void |
| 13043 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 13044 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13045 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13046 | } |
| 13047 | #endif |
| 13048 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13049 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 13050 | struct hdd_config *cfg) |
| 13051 | { |
| 13052 | uint8_t i = 0; |
| 13053 | |
| 13054 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 13055 | if (!ie_whitelist->white_list) |
| 13056 | return; |
| 13057 | |
| 13058 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 13059 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 13060 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 13061 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 13062 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 13063 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 13064 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 13065 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 13066 | |
| 13067 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 13068 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 13069 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 13070 | } |
| 13071 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13072 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 13073 | { |
| 13074 | uint8_t i, score; |
| 13075 | |
| 13076 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13077 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13078 | if (score > MAX_INDEX_SCORE) |
| 13079 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13080 | MAX_INDEX_SCORE, i); |
| 13081 | } |
| 13082 | |
| 13083 | return per_index_score; |
| 13084 | } |
| 13085 | |
| 13086 | /** |
| 13087 | * hdd_update_score_config - API to update candidate scoring related params |
| 13088 | * configuration parameters |
| 13089 | * @score_config: score config to update |
| 13090 | * @cfg: config params |
| 13091 | * |
| 13092 | * Return: 0 if success else err |
| 13093 | */ |
| 13094 | static void hdd_update_score_config( |
| 13095 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 13096 | { |
| 13097 | int total_weight; |
| 13098 | |
| 13099 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 13100 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 13101 | score_config->weight_cfg.vht_caps_weightage = |
| 13102 | cfg->vht_caps_weightage; |
| 13103 | score_config->weight_cfg.he_caps_weightage = |
| 13104 | cfg->he_caps_weightage; |
| 13105 | score_config->weight_cfg.chan_width_weightage = |
| 13106 | cfg->chan_width_weightage; |
| 13107 | score_config->weight_cfg.chan_band_weightage = |
| 13108 | cfg->chan_band_weightage; |
| 13109 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 13110 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13111 | cfg->beamforming_cap_weightage; |
| 13112 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 13113 | score_config->weight_cfg.channel_congestion_weightage = |
| 13114 | cfg->channel_congestion_weightage; |
| 13115 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 13116 | |
| 13117 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 13118 | score_config->weight_cfg.ht_caps_weightage + |
| 13119 | score_config->weight_cfg.vht_caps_weightage + |
| 13120 | score_config->weight_cfg.he_caps_weightage + |
| 13121 | score_config->weight_cfg.chan_width_weightage + |
| 13122 | score_config->weight_cfg.chan_band_weightage + |
| 13123 | score_config->weight_cfg.nss_weightage + |
| 13124 | score_config->weight_cfg.beamforming_cap_weightage + |
| 13125 | score_config->weight_cfg.pcl_weightage + |
| 13126 | score_config->weight_cfg.channel_congestion_weightage + |
| 13127 | score_config->weight_cfg.oce_wan_weightage; |
| 13128 | |
| 13129 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 13130 | hdd_err("total weight is greater than %d fallback to default values", |
| 13131 | BEST_CANDIDATE_MAX_WEIGHT); |
| 13132 | |
| 13133 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 13134 | score_config->weight_cfg.ht_caps_weightage = |
| 13135 | HT_CAPABILITY_WEIGHTAGE; |
| 13136 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 13137 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 13138 | score_config->weight_cfg.chan_width_weightage = |
| 13139 | CHAN_WIDTH_WEIGHTAGE; |
| 13140 | score_config->weight_cfg.chan_band_weightage = |
| 13141 | CHAN_BAND_WEIGHTAGE; |
| 13142 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 13143 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13144 | BEAMFORMING_CAP_WEIGHTAGE; |
| 13145 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 13146 | score_config->weight_cfg.channel_congestion_weightage = |
| 13147 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 13148 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 13149 | } |
| 13150 | |
| 13151 | score_config->bandwidth_weight_per_index = |
| 13152 | hdd_limit_max_per_index_score( |
| 13153 | cfg->bandwidth_weight_per_index); |
| 13154 | score_config->nss_weight_per_index = |
| 13155 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 13156 | score_config->band_weight_per_index = |
| 13157 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 13158 | |
| 13159 | score_config->rssi_score.best_rssi_threshold = |
| 13160 | cfg->best_rssi_threshold; |
| 13161 | score_config->rssi_score.good_rssi_threshold = |
| 13162 | cfg->good_rssi_threshold; |
| 13163 | score_config->rssi_score.bad_rssi_threshold = |
| 13164 | cfg->bad_rssi_threshold; |
| 13165 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 13166 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 13167 | score_config->rssi_score.good_rssi_bucket_size = |
| 13168 | cfg->good_rssi_bucket_size; |
| 13169 | score_config->rssi_score.bad_rssi_bucket_size = |
| 13170 | cfg->bad_rssi_bucket_size; |
| 13171 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 13172 | cfg->rssi_pref_5g_rssi_thresh; |
| 13173 | |
| 13174 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 13175 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 13176 | hdd_limit_max_per_index_score( |
| 13177 | cfg->esp_qbss_score_slots3_to_0); |
| 13178 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13179 | hdd_limit_max_per_index_score( |
| 13180 | cfg->esp_qbss_score_slots7_to_4); |
| 13181 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13182 | hdd_limit_max_per_index_score( |
| 13183 | cfg->esp_qbss_score_slots11_to_8); |
| 13184 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13185 | hdd_limit_max_per_index_score( |
| 13186 | cfg->esp_qbss_score_slots15_to_12); |
| 13187 | |
| 13188 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13189 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13190 | hdd_limit_max_per_index_score( |
| 13191 | cfg->oce_wan_score_slots3_to_0); |
| 13192 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13193 | hdd_limit_max_per_index_score( |
| 13194 | cfg->oce_wan_score_slots7_to_4); |
| 13195 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13196 | hdd_limit_max_per_index_score( |
| 13197 | cfg->oce_wan_score_slots11_to_8); |
| 13198 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13199 | hdd_limit_max_per_index_score( |
| 13200 | cfg->oce_wan_score_slots15_to_12); |
| 13201 | |
| 13202 | |
| 13203 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13204 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13205 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13206 | |
| 13207 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13208 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13209 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13210 | score_config->he_cap = 1; |
| 13211 | |
| 13212 | if (score_config->he_cap || |
| 13213 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13214 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13215 | score_config->vht_cap = 1; |
| 13216 | |
| 13217 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13218 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13219 | score_config->ht_cap = 1; |
| 13220 | |
| 13221 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13222 | score_config->vht_24G_cap = 1; |
| 13223 | |
| 13224 | if (cfg->enableTxBF) |
| 13225 | score_config->beamformee_cap = 1; |
| 13226 | |
| 13227 | } |
| 13228 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13229 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13230 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13231 | * @hdd_ctx: HDD context |
| 13232 | * |
| 13233 | * Return: 0 if success else err |
| 13234 | */ |
| 13235 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13236 | { |
| 13237 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13238 | struct hdd_config *cfg = hdd_ctx->config; |
| 13239 | struct dfs_user_config dfs_cfg; |
| 13240 | QDF_STATUS status; |
| 13241 | |
| 13242 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13243 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13244 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13245 | hdd_err("failed dfs psoc configuration"); |
| 13246 | return -EINVAL; |
| 13247 | } |
| 13248 | |
| 13249 | return 0; |
| 13250 | } |
| 13251 | |
| 13252 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13253 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13254 | * @hdd_ctx: HDD context |
| 13255 | * |
| 13256 | * Return: 0 if success else err |
| 13257 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13258 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13259 | { |
| 13260 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13261 | struct scan_user_cfg scan_cfg; |
| 13262 | struct hdd_config *cfg = hdd_ctx->config; |
| 13263 | QDF_STATUS status; |
| 13264 | |
| 13265 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13266 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13267 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13268 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13269 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13270 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13271 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13272 | /* convert to ms */ |
| 13273 | scan_cfg.scan_cache_aging_time = |
| 13274 | cfg->scanAgingTimeout * 1000; |
| 13275 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13276 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13277 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13278 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13279 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13280 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13281 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13282 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13283 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13284 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13285 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13286 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13287 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13288 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13289 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13290 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13291 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13292 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13293 | if (status != QDF_STATUS_SUCCESS) { |
| 13294 | hdd_err("failed pmo psoc configuration"); |
| 13295 | return -EINVAL; |
| 13296 | } |
| 13297 | |
| 13298 | return 0; |
| 13299 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13300 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13301 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13302 | { |
| 13303 | int ret; |
| 13304 | |
| 13305 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13306 | if (ret) |
| 13307 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13308 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13309 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13310 | if (ret) |
| 13311 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13312 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13313 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13314 | if (ret) |
| 13315 | return ret; |
| 13316 | |
| 13317 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13318 | if (ret) |
| 13319 | return ret; |
| 13320 | |
| 13321 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13322 | |
| 13323 | return ret; |
| 13324 | } |
| 13325 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13326 | /** |
| 13327 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13328 | * @mode : cfg80211 DFS mode |
| 13329 | * |
| 13330 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13331 | */ |
| 13332 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13333 | { |
| 13334 | switch (mode) { |
| 13335 | case DFS_MODE_ENABLE: |
| 13336 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13337 | case DFS_MODE_DISABLE: |
| 13338 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13339 | case DFS_MODE_DEPRIORITIZE: |
| 13340 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13341 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13342 | hdd_debug("ACS dfs mode is NONE"); |
| 13343 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13344 | } |
| 13345 | } |
| 13346 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13347 | /** |
| 13348 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13349 | * @hddctx: pointer to hdd context |
| 13350 | * @set_value: enable/disable |
| 13351 | * |
| 13352 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13353 | * Host(even though it is duplicate). When Host send vendor command |
| 13354 | * disable,FW doesn't perform any action. Whenever any change in |
| 13355 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13356 | * |
| 13357 | * return - 0 on success, appropriate error values on failure. |
| 13358 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13359 | 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] | 13360 | { |
| 13361 | QDF_STATUS status; |
| 13362 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13363 | if (0 != wlan_hdd_validate_context(hddctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13364 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13365 | |
| 13366 | if (!hddctx->config->goptimize_chan_avoid_event) { |
| 13367 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13368 | return -EINVAL; |
| 13369 | } |
| 13370 | |
| 13371 | status = sme_enable_disable_chanavoidind_event(hddctx->hHal, set_value); |
| 13372 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13373 | hdd_err("Failed to send chan avoid command to SME"); |
| 13374 | return -EINVAL; |
| 13375 | } |
| 13376 | return 0; |
| 13377 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13378 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13379 | /** |
| 13380 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13381 | * @value: value to set |
| 13382 | * |
| 13383 | * This function will set the passed value to roaming in progress flag. |
| 13384 | * |
| 13385 | * Return: None |
| 13386 | */ |
| 13387 | void hdd_set_roaming_in_progress(bool value) |
| 13388 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13389 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13390 | |
| 13391 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13392 | if (!hdd_ctx) { |
| 13393 | hdd_err("HDD context is NULL"); |
| 13394 | return; |
| 13395 | } |
| 13396 | |
| 13397 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13398 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13399 | } |
| 13400 | |
| 13401 | /** |
| 13402 | * hdd_is_roaming_in_progress() - check if roaming is in progress |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13403 | * @adapter - HDD adapter |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13404 | * |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13405 | * 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] | 13406 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13407 | bool hdd_is_roaming_in_progress(struct hdd_adapter *adapter) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13408 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13409 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13410 | bool ret_status = false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13411 | |
| 13412 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13413 | if (!hdd_ctx) { |
| 13414 | hdd_err("HDD context is NULL"); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13415 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13416 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13417 | hdd_debug("dev mode = %d, roaming_in_progress = %d", |
| 13418 | adapter->device_mode, hdd_ctx->roaming_in_progress); |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13419 | ret_status = ((adapter->device_mode == QDF_STA_MODE) && |
| 13420 | hdd_ctx->roaming_in_progress); |
| 13421 | |
| 13422 | return ret_status; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13423 | } |
| 13424 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13425 | /** |
| 13426 | * hdd_is_connection_in_progress() - check if connection is in |
| 13427 | * progress |
| 13428 | * @session_id: session id |
| 13429 | * @reason: scan reject reason |
| 13430 | * |
| 13431 | * Go through each adapter and check if Connection is in progress |
| 13432 | * |
| 13433 | * Return: true if connection is in progress else false |
| 13434 | */ |
| 13435 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13436 | enum scan_reject_states *reason) |
| 13437 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13438 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13439 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13440 | uint8_t sta_id = 0; |
| 13441 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13442 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13443 | |
| 13444 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13445 | if (!hdd_ctx) { |
| 13446 | hdd_err("HDD context is NULL"); |
| 13447 | return false; |
| 13448 | } |
| 13449 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13450 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 13451 | hdd_debug("Adapter with device mode %s(%d) exists", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13452 | hdd_device_mode_to_string(adapter->device_mode), |
| 13453 | adapter->device_mode); |
| 13454 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13455 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13456 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13457 | && (eConnectionState_Connecting == |
| 13458 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13459 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13460 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13461 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13462 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13463 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13464 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13465 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13466 | } |
| 13467 | return true; |
| 13468 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13469 | /* |
| 13470 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13471 | * hdd_is_roaming_in_progress is for LFR3 |
| 13472 | */ |
| 13473 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13474 | sme_neighbor_middle_of_roaming( |
| 13475 | WLAN_HDD_GET_HAL_CTX(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13476 | adapter->session_id)) || |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13477 | hdd_is_roaming_in_progress(adapter)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13478 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13479 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13480 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13481 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13482 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13483 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13484 | } |
| 13485 | return true; |
| 13486 | } |
| 13487 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13488 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13489 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13490 | hdd_sta_ctx = |
| 13491 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13492 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13493 | hdd_sta_ctx->conn_info.connState) |
| 13494 | && sme_is_sta_key_exchange_in_progress( |
| 13495 | hdd_ctx->hHal, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13496 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13497 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13498 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13499 | " is in middle of WPS/EAPOL exchange.", |
| 13500 | MAC_ADDR_ARRAY(sta_mac)); |
| 13501 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13502 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13503 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13504 | } |
| 13505 | return true; |
| 13506 | } |
| 13507 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13508 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13509 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13510 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13511 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13512 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13513 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13514 | continue; |
| 13515 | |
| 13516 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13517 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13518 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13519 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13520 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13521 | MAC_ADDR_ARRAY(sta_mac)); |
| 13522 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13523 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13524 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13525 | } |
| 13526 | return true; |
| 13527 | } |
| 13528 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13529 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13530 | return true; |
| 13531 | } |
| 13532 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13533 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13534 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13535 | return false; |
| 13536 | } |
| 13537 | |
| 13538 | /** |
| 13539 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13540 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13541 | * |
| 13542 | * Return: None |
| 13543 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13544 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13545 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13546 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13547 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13548 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13549 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 13550 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13551 | void *sap_ctx; |
| 13552 | |
| 13553 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13554 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13555 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13556 | |
| 13557 | mutex_lock(&hdd_ctx->sap_lock); |
| 13558 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13559 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13560 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13561 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13562 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13563 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13564 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13565 | qdf_stop_bss_event, |
| 13566 | SME_CMD_TIMEOUT_VALUE); |
| 13567 | |
| 13568 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13569 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13570 | goto end; |
| 13571 | } |
| 13572 | } |
| 13573 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13574 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13575 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13576 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13577 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13578 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13579 | |
| 13580 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13581 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13582 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13583 | eUPDATE_IE_ALL); |
| 13584 | goto end; |
| 13585 | } |
| 13586 | |
| 13587 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13588 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13589 | sap_config, |
| 13590 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13591 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13592 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13593 | eUPDATE_IE_ALL); |
| 13594 | goto end; |
| 13595 | } |
| 13596 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13597 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13598 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13599 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13600 | SME_CMD_TIMEOUT_VALUE); |
| 13601 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13602 | eUPDATE_IE_ALL); |
| 13603 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13604 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13605 | goto end; |
| 13606 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13607 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13608 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13609 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13610 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13611 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13612 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13613 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13614 | ap_adapter->device_mode, |
| 13615 | true); |
| 13616 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13617 | } |
| 13618 | end: |
| 13619 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13620 | } |
| 13621 | |
| 13622 | /** |
| 13623 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13624 | * with non dfs acs |
| 13625 | * |
| 13626 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13627 | * |
| 13628 | * Return: None |
| 13629 | */ |
| 13630 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13631 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13632 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13633 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 13634 | struct cds_context *cds_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13635 | |
| 13636 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13637 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13638 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13639 | return; |
| 13640 | } |
| 13641 | |
| 13642 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13643 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13644 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13645 | return; |
| 13646 | } |
| 13647 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13648 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13649 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13650 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13651 | return; |
| 13652 | } |
| 13653 | |
| 13654 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13655 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13656 | &ap_adapter->event_flags) && |
| 13657 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13658 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13659 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13660 | 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] | 13661 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13662 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13663 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13664 | acs_cfg.acs_mode = true; |
| 13665 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13666 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13667 | } |
| 13668 | } |
| 13669 | |
| 13670 | /** |
| 13671 | * hdd_set_connection_in_progress() - to set the connection in |
| 13672 | * progress flag |
| 13673 | * @value: value to set |
| 13674 | * |
| 13675 | * This function will set the passed value to connection in progress flag. |
| 13676 | * If value is previously being set to true then no need to set it again. |
| 13677 | * |
| 13678 | * Return: true if value is being set correctly and false otherwise. |
| 13679 | */ |
| 13680 | bool hdd_set_connection_in_progress(bool value) |
| 13681 | { |
| 13682 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13683 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13684 | |
| 13685 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13686 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13687 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13688 | return false; |
| 13689 | } |
| 13690 | |
| 13691 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13692 | /* |
| 13693 | * if the value is set to true previously and if someone is |
| 13694 | * trying to make it true again then it could be some race |
| 13695 | * condition being triggered. Avoid this situation by returning |
| 13696 | * false |
| 13697 | */ |
| 13698 | if (hdd_ctx->connection_in_progress && value) |
| 13699 | status = false; |
| 13700 | else |
| 13701 | hdd_ctx->connection_in_progress = value; |
| 13702 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13703 | return status; |
| 13704 | } |
| 13705 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13706 | 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] | 13707 | { |
| 13708 | if (!adapter) { |
| 13709 | hdd_err("Invalid adapter"); |
| 13710 | return -EINVAL; |
| 13711 | } |
| 13712 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13713 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13714 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13715 | set_value, VDEV_CMD); |
| 13716 | return 0; |
| 13717 | |
| 13718 | } |
| 13719 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13720 | 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] | 13721 | { |
| 13722 | if (!adapter) { |
| 13723 | hdd_err("Invalid adapter"); |
| 13724 | return -EINVAL; |
| 13725 | } |
| 13726 | |
| 13727 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13728 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13729 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13730 | set_value, VDEV_CMD); |
| 13731 | return 0; |
| 13732 | } |
| 13733 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13734 | 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] | 13735 | *psoc, uint8_t vdev_id) |
| 13736 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13737 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13738 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13739 | |
| 13740 | /* |
| 13741 | * Currently PSOC is not being used. But this logic will |
| 13742 | * change once we have the converged implementation of |
| 13743 | * HDD context per PSOC in place. This would break if |
| 13744 | * multiple vdev objects reuse the vdev id. |
| 13745 | */ |
| 13746 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13747 | if (!adapter) |
| 13748 | hdd_err("Get adapter by vdev id failed"); |
| 13749 | |
| 13750 | return adapter; |
| 13751 | } |
| 13752 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13753 | 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] | 13754 | int8_t *rssi, int8_t *snr) |
| 13755 | { |
| 13756 | QDF_STATUS status; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13757 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13758 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13759 | roam_profile = hdd_roam_profile(adapter); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13760 | 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] | 13761 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13762 | if (QDF_STATUS_SUCCESS != status) { |
| 13763 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13764 | return -EINVAL; |
| 13765 | } |
| 13766 | |
| 13767 | return 0; |
| 13768 | } |
| 13769 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13770 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13771 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13772 | * @adapter - HDD adapter |
| 13773 | * @tos - type of service |
| 13774 | * @status - status of the traffic |
| 13775 | * |
| 13776 | * Return: 0 on success and non zero value on failure |
| 13777 | */ |
| 13778 | |
| 13779 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13780 | bool is_tos_active) |
| 13781 | { |
| 13782 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13783 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13784 | uint32_t max_off_chan_time = 0; |
| 13785 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13786 | int ret; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13787 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13788 | |
| 13789 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13790 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13791 | |
| 13792 | if (ret < 0) { |
| 13793 | hdd_err("failed to set limit off chan params"); |
| 13794 | return ret; |
| 13795 | } |
| 13796 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13797 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13798 | |
| 13799 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13800 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13801 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13802 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13803 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13804 | if (adapter->active_ac) { |
| 13805 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13806 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13807 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 13808 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13809 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13810 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13811 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13812 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 13813 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13814 | PM_LATENCY); |
| 13815 | } else { |
| 13816 | /*ignore this command if only BE/BK is active */ |
| 13817 | is_tos_active = false; |
| 13818 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13819 | hdd_ctx->config->conc_system_pref); |
| 13820 | } |
| 13821 | } else { |
| 13822 | /* No active tos */ |
| 13823 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13824 | hdd_ctx->config->conc_system_pref); |
| 13825 | } |
| 13826 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13827 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13828 | is_tos_active, max_off_chan_time, |
| 13829 | hdd_ctx->config->nRestTimeConc, true); |
| 13830 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13831 | hdd_err("failed to set limit off chan params"); |
| 13832 | ret = -EINVAL; |
| 13833 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13834 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13835 | return ret; |
| 13836 | } |
| 13837 | |
| 13838 | /** |
| 13839 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 13840 | * @adapter - HDD adapter |
| 13841 | * |
| 13842 | * Return: 0 on success and non zero value on failure |
| 13843 | */ |
| 13844 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 13845 | { |
| 13846 | struct hdd_context *hdd_ctx; |
| 13847 | int ret; |
| 13848 | QDF_STATUS status; |
| 13849 | tHalHandle hal = WLAN_HDD_GET_HAL_CTX(adapter); |
| 13850 | |
| 13851 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13852 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13853 | if (ret < 0) |
| 13854 | return ret; |
| 13855 | |
| 13856 | /* set the system preferece to default */ |
| 13857 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 13858 | hdd_ctx->config->conc_system_pref); |
| 13859 | |
| 13860 | /* clear the bitmap */ |
| 13861 | adapter->active_ac = 0; |
| 13862 | |
| 13863 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13864 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13865 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13866 | status = sme_send_limit_off_channel_params(hal, adapter->session_id, |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13867 | false, 0, 0, false); |
| 13868 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13869 | hdd_err("failed to reset limit off chan params"); |
| 13870 | ret = -EINVAL; |
| 13871 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13872 | |
| 13873 | return ret; |
| 13874 | } |
| 13875 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13876 | /** |
| 13877 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 13878 | * @drv_op: Enum indicating driver op |
| 13879 | * |
| 13880 | * Return: none |
| 13881 | */ |
| 13882 | void hdd_start_driver_ops_timer(int drv_op) |
| 13883 | { |
| 13884 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 13885 | switch (drv_op) { |
| 13886 | case eHDD_DRV_OP_PROBE: |
| 13887 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 13888 | break; |
| 13889 | case eHDD_DRV_OP_REMOVE: |
| 13890 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 13891 | break; |
| 13892 | case eHDD_DRV_OP_SHUTDOWN: |
| 13893 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 13894 | break; |
| 13895 | case eHDD_DRV_OP_REINIT: |
| 13896 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 13897 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 13898 | case eHDD_DRV_OP_IFF_UP: |
| 13899 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 13900 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13901 | } |
| 13902 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13903 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13904 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
| 13905 | HDD_OPS_INACTIVITY_TIMEOUT); |
| 13906 | } |
| 13907 | |
| 13908 | /** |
| 13909 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 13910 | * |
| 13911 | * Return: none |
| 13912 | */ |
| 13913 | void hdd_stop_driver_ops_timer(void) |
| 13914 | { |
| 13915 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 13916 | } |
| 13917 | |
| 13918 | /** |
| 13919 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 13920 | * inactivity timer |
| 13921 | * |
| 13922 | * Return: None |
| 13923 | */ |
| 13924 | void hdd_drv_ops_inactivity_handler(void) |
| 13925 | { |
| 13926 | hdd_err("%s: %d Sec timer expired while in .%s", |
| 13927 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 13928 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 13929 | if (hdd_drv_ops_task) { |
| 13930 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 13931 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 13932 | } else { |
| 13933 | hdd_err("hdd_drv_ops_task is null"); |
| 13934 | } |
| 13935 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13936 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 13937 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 13938 | sizeof("shutdown"))) |
| 13939 | QDF_BUG(0); |
| 13940 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 13941 | if (cds_is_fw_down()) { |
| 13942 | hdd_err("FW is down"); |
| 13943 | return; |
| 13944 | } |
| 13945 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13946 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 13947 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 13948 | else |
| 13949 | QDF_BUG(0); |
| 13950 | } |
| 13951 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13952 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 13953 | { |
| 13954 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13955 | |
| 13956 | if (!hdd_ctx) |
| 13957 | return; |
| 13958 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 13959 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 13960 | } |
| 13961 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13962 | /** |
| 13963 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 13964 | * @struct hdd_context *hdd_ctx |
| 13965 | * @struct hdd_adapter *padapter |
| 13966 | * @bool enble |
| 13967 | * |
| 13968 | * Return: none |
| 13969 | */ |
| 13970 | void hdd_set_rx_mode_rps(bool enable) |
| 13971 | { |
| 13972 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 13973 | struct hdd_context *hdd_ctx; |
| 13974 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13975 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 13976 | if (!cds_cfg) |
| 13977 | return; |
| 13978 | |
| 13979 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13980 | if (!hdd_ctx) |
| 13981 | return; |
| 13982 | |
| 13983 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 13984 | if (!adapter) |
| 13985 | return; |
| 13986 | |
| 13987 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 13988 | if (enable && !cds_cfg->rps_enabled) |
| 13989 | hdd_send_rps_ind(adapter); |
| 13990 | else if (!enable && cds_cfg->rps_enabled) |
| 13991 | hdd_send_rps_disable_ind(adapter); |
| 13992 | } |
| 13993 | } |
| 13994 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 13995 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 13996 | { |
| 13997 | struct hdd_adapter *adapter = NULL; |
| 13998 | |
| 13999 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 14000 | if ((adapter->device_mode == QDF_STA_MODE || |
| 14001 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 14002 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 14003 | &adapter->event_flags)){ |
| 14004 | return true; |
| 14005 | } |
| 14006 | } |
| 14007 | |
| 14008 | return false; |
| 14009 | } |
| 14010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14011 | /* Register the module init/exit functions */ |
| 14012 | module_init(hdd_module_init); |
| 14013 | module_exit(hdd_module_exit); |
| 14014 | |
| 14015 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14016 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14017 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14018 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14019 | static const struct kernel_param_ops con_mode_ops = { |
| 14020 | .set = con_mode_handler, |
| 14021 | .get = param_get_int, |
| 14022 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14023 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14024 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14025 | .set = con_mode_handler_ftm, |
| 14026 | .get = param_get_int, |
| 14027 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14028 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14029 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14030 | .set = con_mode_handler_monitor, |
| 14031 | .get = param_get_int, |
| 14032 | }; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14033 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14034 | static const struct kernel_param_ops fwpath_ops = { |
| 14035 | .set = fwpath_changed_handler, |
| 14036 | .get = param_get_string, |
| 14037 | }; |
| 14038 | |
| 14039 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14040 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14041 | |
| 14042 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 14043 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14044 | |
| 14045 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 14046 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14047 | |
| 14048 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 14049 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14050 | |
| 14051 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14052 | |
| 14053 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14054 | |
| 14055 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |