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 */ |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame^] | 27 | #include "cfg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 28 | #include <wlan_hdd_includes.h> |
| 29 | #include <cds_api.h> |
| 30 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 31 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 32 | #include <linux/etherdevice.h> |
| 33 | #include <linux/firmware.h> |
| 34 | #include <wlan_hdd_tx_rx.h> |
| 35 | #include <wni_api.h> |
| 36 | #include <wlan_hdd_cfg.h> |
| 37 | #include <wlan_ptt_sock_svc.h> |
| 38 | #include <dbglog_host.h> |
| 39 | #include <wlan_logging_sock_svc.h> |
| 40 | #include <wlan_hdd_wowl.h> |
| 41 | #include <wlan_hdd_misc.h> |
| 42 | #include <wlan_hdd_wext.h> |
| 43 | #include "wlan_hdd_trace.h" |
| 44 | #include "wlan_hdd_ioctl.h" |
| 45 | #include "wlan_hdd_ftm.h" |
| 46 | #include "wlan_hdd_power.h" |
| 47 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 48 | #include "wlan_hdd_scan.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 | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 133 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 134 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 135 | #include "qc_sap_ioctl.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 136 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 137 | #ifdef CNSS_GENL |
| 138 | #include <net/cnss_nl.h> |
| 139 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 140 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 141 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 142 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 143 | #ifdef MODULE |
| 144 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 145 | #else |
| 146 | #define WLAN_MODULE_NAME "wlan" |
| 147 | #endif |
| 148 | |
| 149 | #ifdef TIMER_MANAGER |
| 150 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 151 | #else |
| 152 | #define TIMER_MANAGER_STR "" |
| 153 | #endif |
| 154 | |
| 155 | #ifdef MEMORY_DEBUG |
| 156 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 157 | #else |
| 158 | #define MEMORY_DEBUG_STR "" |
| 159 | #endif |
| 160 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 161 | #ifdef PANIC_ON_BUG |
| 162 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 163 | #else |
| 164 | #define PANIC_ON_BUG_STR "" |
| 165 | #endif |
| 166 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 167 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 168 | int wlan_start_ret_val; |
| 169 | static DECLARE_COMPLETION(wlan_start_comp); |
| 170 | static unsigned int dev_num = 1; |
| 171 | static struct cdev wlan_hdd_state_cdev; |
| 172 | static struct class *class; |
| 173 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 174 | #ifndef MODULE |
| 175 | static struct gwlan_loader *wlan_loader; |
| 176 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 177 | struct kobj_attribute *attr, |
| 178 | const char *buf, size_t count); |
| 179 | struct gwlan_loader { |
| 180 | bool loaded_state; |
| 181 | struct kobject *boot_wlan_obj; |
| 182 | struct attribute_group *attr_group; |
| 183 | }; |
| 184 | |
| 185 | static struct kobj_attribute wlan_boot_attribute = |
| 186 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 187 | |
| 188 | static struct attribute *attrs[] = { |
| 189 | &wlan_boot_attribute.attr, |
| 190 | NULL, |
| 191 | }; |
| 192 | |
| 193 | #define MODULE_INITIALIZED 1 |
| 194 | #endif |
| 195 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 196 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 197 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 198 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 199 | |
| 200 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 201 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 202 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 204 | /* the Android framework expects this param even though we don't use it */ |
| 205 | #define BUF_LEN 20 |
| 206 | static char fwpath_buffer[BUF_LEN]; |
| 207 | static struct kparam_string fwpath = { |
| 208 | .string = fwpath_buffer, |
| 209 | .maxlen = BUF_LEN, |
| 210 | }; |
| 211 | |
| 212 | static char *country_code; |
| 213 | static int enable_11d = -1; |
| 214 | static int enable_dfs_chan_scan = -1; |
| 215 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 216 | /* |
| 217 | * spinlock for synchronizing asynchronous request/response |
| 218 | * (full description of use in wlan_hdd_main.h) |
| 219 | */ |
| 220 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 221 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 222 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 223 | #define WLAN_NLINK_CESIUM 30 |
| 224 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 225 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 226 | |
| 227 | #define WOW_MAX_FILTER_LISTS 1 |
| 228 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 229 | #define WOW_MIN_PATTERN_SIZE 6 |
| 230 | #define WOW_MAX_PATTERN_SIZE 64 |
| 231 | |
| 232 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 233 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 234 | .flags = WIPHY_WOWLAN_ANY | |
| 235 | WIPHY_WOWLAN_MAGIC_PKT | |
| 236 | WIPHY_WOWLAN_DISCONNECT | |
| 237 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 238 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 239 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 240 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 241 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 242 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 243 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 244 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 245 | }; |
| 246 | #endif |
| 247 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 248 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 249 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 250 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 251 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 252 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 253 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 261 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 262 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 263 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 264 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 265 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 266 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 267 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 268 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 269 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 283 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 284 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 285 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 286 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 287 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 288 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame^] | 289 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 292 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 293 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 294 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 295 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 296 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 297 | }; |
| 298 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 299 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 300 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 301 | |
| 302 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 303 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 304 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 305 | #endif |
| 306 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 307 | void hdd_start_complete(int ret) |
| 308 | { |
| 309 | wlan_start_ret_val = ret; |
| 310 | |
| 311 | complete(&wlan_start_comp); |
| 312 | } |
| 313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 314 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 315 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 316 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 317 | * |
| 318 | * Return: none |
| 319 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 320 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 321 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 322 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 323 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 324 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 325 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 326 | } |
| 327 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 328 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 329 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 330 | enum netif_action_type action) |
| 331 | { |
| 332 | if (!adapter->tx_flow_timer_initialized) |
| 333 | return; |
| 334 | |
| 335 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 336 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 337 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 338 | QDF_STATUS status = |
| 339 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 340 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 341 | |
| 342 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 343 | hdd_err("Failed to start tx_flow_control_timer"); |
| 344 | else |
| 345 | adapter-> |
| 346 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 347 | |
| 348 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 349 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 350 | } |
| 351 | } |
| 352 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 353 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 354 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 355 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 356 | * @vdev_id: vdev_id |
| 357 | * @action: action type |
| 358 | * @reason: reason type |
| 359 | * |
| 360 | * Return: none |
| 361 | */ |
| 362 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 363 | enum netif_action_type action, enum netif_reason_type reason) |
| 364 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 365 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 366 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 367 | |
| 368 | if (!hdd_ctx) { |
| 369 | hdd_err("hdd ctx is NULL"); |
| 370 | return; |
| 371 | } |
| 372 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 373 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 374 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 378 | * Store WLAN driver version and timestamp info in global variables such that |
| 379 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 380 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 381 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 382 | #ifdef BUILD_TAG |
| 383 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 384 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 385 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 386 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 387 | |
| 388 | /** |
| 389 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 390 | * @device_mode: device mode |
| 391 | * |
| 392 | * This utility function helps log string conversion of device mode. |
| 393 | * |
| 394 | * Return: string conversion of device mode, if match found; |
| 395 | * "Unknown" otherwise. |
| 396 | */ |
| 397 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 398 | { |
| 399 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 400 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 401 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 402 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 403 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 404 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 405 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 406 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 407 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 408 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 409 | default: |
| 410 | return "Unknown"; |
| 411 | } |
| 412 | } |
| 413 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 414 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 415 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 416 | * @hdd_ctx: HDD context |
| 417 | * @chan_list: buf hold returned chan list |
| 418 | * @chan_num: input buf size and output returned chan num |
| 419 | * |
| 420 | * This function helps get current available chan list from regulatory |
| 421 | * module. It excludes the "disabled" and "invalid" channels. |
| 422 | * |
| 423 | * Return: 0 for success. |
| 424 | */ |
| 425 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 426 | uint8_t *chan_list, |
| 427 | uint32_t *chan_num) |
| 428 | { |
| 429 | int i = 0, j = 0; |
| 430 | struct regulatory_channel *cur_chan_list; |
| 431 | struct wlan_objmgr_pdev *pdev; |
| 432 | |
| 433 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 434 | return -EINVAL; |
| 435 | |
| 436 | pdev = hdd_ctx->hdd_pdev; |
| 437 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 438 | sizeof(struct regulatory_channel)); |
| 439 | if (!cur_chan_list) |
| 440 | return -ENOMEM; |
| 441 | |
| 442 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 443 | QDF_STATUS_SUCCESS) { |
| 444 | qdf_mem_free(cur_chan_list); |
| 445 | return -EINVAL; |
| 446 | } |
| 447 | |
| 448 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 449 | uint32_t ch = cur_chan_list[i].chan_num; |
| 450 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 451 | ch); |
| 452 | |
| 453 | if (state != CHANNEL_STATE_DISABLE && |
| 454 | state != CHANNEL_STATE_INVALID && |
| 455 | j < *chan_num) { |
| 456 | chan_list[j] = (uint8_t)ch; |
| 457 | j++; |
| 458 | } |
| 459 | } |
| 460 | *chan_num = j; |
| 461 | qdf_mem_free(cur_chan_list); |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 466 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 467 | * @adapter: HDD adapter |
| 468 | * @chan_number: Channel number |
| 469 | * @chan_bw: Bandwidth |
| 470 | * |
| 471 | * Checks if the given bandwidth is valid for the given channel number. |
| 472 | * |
| 473 | * Return: 0 for success, non-zero for failure |
| 474 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 475 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 476 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 477 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 478 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 479 | uint8_t chan[NUM_CHANNELS]; |
| 480 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 481 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 482 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 483 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 484 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 485 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 486 | if (!mac_handle) { |
| 487 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 488 | return -EINVAL; |
| 489 | } |
| 490 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 491 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 492 | &len); |
| 493 | if (ret) { |
| 494 | hdd_err("error %d in getting valid channel list", ret); |
| 495 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | for (i = 0; i < len; i++) { |
| 499 | if (chan[i] == chan_number) { |
| 500 | found = true; |
| 501 | break; |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | if (found == false) { |
| 506 | hdd_err("Channel not in driver's valid channel list"); |
| 507 | return -EOPNOTSUPP; |
| 508 | } |
| 509 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 510 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 511 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 512 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 513 | return -EINVAL; |
| 514 | } |
| 515 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 516 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 517 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 518 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 519 | return -EINVAL; |
| 520 | } |
| 521 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 522 | (chan_bw != CH_WIDTH_MAX)) { |
| 523 | hdd_err("Only BW20 possible on channel 14"); |
| 524 | return -EINVAL; |
| 525 | } |
| 526 | } |
| 527 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 528 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 529 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 530 | (chan_bw != CH_WIDTH_MAX)) { |
| 531 | hdd_err("Only BW20 possible on channel 165"); |
| 532 | return -EINVAL; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | return 0; |
| 537 | } |
| 538 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 539 | /** |
| 540 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 541 | * |
| 542 | * Block the unloading of the driver (or) interface up until the |
| 543 | * cds recovery is completed |
| 544 | * |
| 545 | * Return: true for recovery completion else false |
| 546 | */ |
| 547 | static bool hdd_wait_for_recovery_completion(void) |
| 548 | { |
| 549 | int retry = 0; |
| 550 | |
| 551 | /* Wait for recovery to complete */ |
| 552 | while (cds_is_driver_recovering()) { |
| 553 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 554 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 555 | |
| 556 | if (g_is_system_reboot_triggered) { |
| 557 | hdd_info("System Reboot happening ignore unload!!"); |
| 558 | return false; |
| 559 | } |
| 560 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 561 | msleep(1000); |
| 562 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 563 | hdd_err("SSR never completed, error"); |
| 564 | /* |
| 565 | * Trigger the bug_on in the internal builds, in the |
| 566 | * customer builds self-recovery will be enabled |
| 567 | * in those cases just return error. |
| 568 | */ |
| 569 | if (cds_is_self_recovery_enabled()) |
| 570 | return false; |
| 571 | QDF_BUG(0); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | hdd_info("Recovery completed successfully!"); |
| 576 | return true; |
| 577 | } |
| 578 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 579 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 581 | unsigned long state, void *data) |
| 582 | { |
| 583 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 584 | struct netdev_notifier_info *dev_notif_info = data; |
| 585 | struct net_device *dev = dev_notif_info->dev; |
| 586 | #else |
| 587 | struct net_device *dev = data; |
| 588 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 589 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 590 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 591 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 592 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 593 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 594 | /* Make sure that this callback corresponds to our device. */ |
| 595 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 596 | return NOTIFY_DONE; |
| 597 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 598 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 600 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 601 | return NOTIFY_DONE; |
| 602 | } |
| 603 | |
| 604 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 605 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 606 | return NOTIFY_DONE; |
| 607 | } |
| 608 | |
| 609 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 610 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 611 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 612 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 613 | return NOTIFY_DONE; |
| 614 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 615 | |
| 616 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 617 | hdd_err("%s: Driver module is closed", __func__); |
| 618 | return NOTIFY_DONE; |
| 619 | } |
| 620 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 621 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 622 | return NOTIFY_DONE; |
| 623 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 624 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 625 | dev->name, state); |
| 626 | |
| 627 | switch (state) { |
| 628 | case NETDEV_REGISTER: |
| 629 | break; |
| 630 | |
| 631 | case NETDEV_UNREGISTER: |
| 632 | break; |
| 633 | |
| 634 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 635 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 636 | break; |
| 637 | |
| 638 | case NETDEV_DOWN: |
| 639 | break; |
| 640 | |
| 641 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 642 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 643 | complete(&adapter->linkup_event_var); |
| 644 | break; |
| 645 | |
| 646 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 647 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 648 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 649 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 650 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 651 | } |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 652 | cds_flush_work(&adapter->scan_block_work); |
| 653 | /* Need to clean up blocked scan request */ |
| 654 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 655 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 656 | /* |
| 657 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 658 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 659 | * flag after which driver does not send the cfg80211_scan_done. |
| 660 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 661 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 662 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | break; |
| 664 | |
| 665 | default: |
| 666 | break; |
| 667 | } |
| 668 | |
| 669 | return NOTIFY_DONE; |
| 670 | } |
| 671 | |
| 672 | /** |
| 673 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 674 | * @nb: pointer to notifier block |
| 675 | * @state: state |
| 676 | * @ndev: ndev pointer |
| 677 | * |
| 678 | * Return: 0 on success, error number otherwise. |
| 679 | */ |
| 680 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 681 | unsigned long state, |
| 682 | void *ndev) |
| 683 | { |
| 684 | int ret; |
| 685 | |
| 686 | cds_ssr_protect(__func__); |
| 687 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 688 | cds_ssr_unprotect(__func__); |
| 689 | |
| 690 | return ret; |
| 691 | } |
| 692 | |
| 693 | struct notifier_block hdd_netdev_notifier = { |
| 694 | .notifier_call = hdd_netdev_notifier_call, |
| 695 | }; |
| 696 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 697 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 698 | unsigned long msg_type, void *_unused) |
| 699 | { |
| 700 | switch (msg_type) { |
| 701 | case SYS_DOWN: |
| 702 | case SYS_HALT: |
| 703 | case SYS_POWER_OFF: |
| 704 | g_is_system_reboot_triggered = true; |
| 705 | hdd_info("reboot, reason: %ld", msg_type); |
| 706 | break; |
| 707 | default: |
| 708 | break; |
| 709 | } |
| 710 | |
| 711 | return NOTIFY_OK; |
| 712 | } |
| 713 | |
| 714 | struct notifier_block system_reboot_notifier = { |
| 715 | .notifier_call = system_reboot_notifier_call, |
| 716 | }; |
| 717 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 718 | /* variable to hold the insmod parameters */ |
| 719 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 720 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 721 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 722 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 723 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 724 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 725 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 726 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 727 | /** |
| 728 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 729 | * @ch_width: NL channel width |
| 730 | * |
| 731 | * Converts the NL channel width to the driver's internal representation |
| 732 | * |
| 733 | * Return: Converted channel width. In case of non matching NL channel width, |
| 734 | * CH_WIDTH_MAX will be returned. |
| 735 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 736 | 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] | 737 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 738 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 739 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 740 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 741 | switch (ch_width) { |
| 742 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 743 | case NL80211_CHAN_WIDTH_20: |
| 744 | return CH_WIDTH_20MHZ; |
| 745 | case NL80211_CHAN_WIDTH_40: |
| 746 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 747 | case NL80211_CHAN_WIDTH_80: |
| 748 | return CH_WIDTH_80MHZ; |
| 749 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 750 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 751 | return CH_WIDTH_80P80MHZ; |
| 752 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 753 | return CH_WIDTH_160MHZ; |
| 754 | else |
| 755 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 756 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 757 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 758 | return CH_WIDTH_160MHZ; |
| 759 | else |
| 760 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 761 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 762 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 763 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 764 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 765 | default: |
| 766 | hdd_err("Invalid channel width %d, setting to default", |
| 767 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 768 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 769 | } |
| 770 | } |
| 771 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 772 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 773 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 774 | { |
| 775 | uint8_t opclass = 0; |
| 776 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 777 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 778 | return opclass; |
| 779 | } |
| 780 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 782 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 783 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 784 | * @bitmask: Bitmask of log levels to be enabled |
| 785 | * |
| 786 | * Called immediately after the cfg.ini is read in order to configure |
| 787 | * the desired trace levels. |
| 788 | * |
| 789 | * Return: None |
| 790 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 791 | 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] | 792 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 793 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 794 | int qdf_print_idx = -1; |
| 795 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 796 | /* |
| 797 | * if the bitmask is the default value, then a bitmask was not |
| 798 | * specified in cfg.ini, so leave the logging level alone (it |
| 799 | * will remain at the "compiled in" default value) |
| 800 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 801 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 802 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 804 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 805 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 806 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 807 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 808 | QDF_TRACE_LEVEL_NONE, 0); |
| 809 | |
| 810 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 811 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 812 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 813 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 814 | while (0 != bitmask) { |
| 815 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 816 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 817 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 818 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 819 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 821 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 822 | level++; |
| 823 | bitmask >>= 1; |
| 824 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 825 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | } |
| 827 | |
| 828 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 829 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 830 | * @hdd_ctx: HDD context pointer |
| 831 | * |
| 832 | * Return: 0 if the context is valid. Error code otherwise |
| 833 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 834 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 835 | { |
| 836 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 837 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 838 | return -ENODEV; |
| 839 | } |
| 840 | |
| 841 | if (cds_is_driver_recovering()) { |
| 842 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 843 | (void *)_RET_IP_, cds_get_driver_state()); |
| 844 | return -EAGAIN; |
| 845 | } |
| 846 | |
| 847 | if (hdd_ctx->start_modules_in_progress || |
| 848 | hdd_ctx->stop_modules_in_progress) { |
| 849 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 850 | (void *)_RET_IP_); |
| 851 | return -EAGAIN; |
| 852 | } |
| 853 | |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | |
| 858 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 859 | * wlan_hdd_validate_context() - check the HDD context |
| 860 | * @hdd_ctx: HDD context pointer |
| 861 | * |
| 862 | * Return: 0 if the context is valid. Error code otherwise |
| 863 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 864 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 865 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 866 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 867 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 868 | return -ENODEV; |
| 869 | } |
| 870 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 871 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 872 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 873 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 874 | return -EAGAIN; |
| 875 | } |
| 876 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 877 | if (cds_is_load_or_unload_in_progress()) { |
| 878 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 879 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 880 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 881 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 882 | |
| 883 | if (hdd_ctx->start_modules_in_progress || |
| 884 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 885 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 886 | (void *)_RET_IP_); |
| 887 | return -EAGAIN; |
| 888 | } |
| 889 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 890 | if (cds_is_driver_in_bad_state()) { |
| 891 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 892 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 893 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 894 | } |
| 895 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 896 | if (cds_is_fw_down()) { |
| 897 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 898 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 899 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 900 | } |
| 901 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 902 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 903 | hdd_debug("con_mode_handler is in progress Ignore!!!"); |
| 904 | return -EAGAIN; |
| 905 | } |
| 906 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 907 | return 0; |
| 908 | } |
| 909 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 910 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 911 | { |
| 912 | if (!adapter) { |
| 913 | hdd_err("adapter is null"); |
| 914 | return -EINVAL; |
| 915 | } |
| 916 | |
| 917 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Mahesh Kumar Kalikot Veetil | 4442754 | 2018-06-08 12:29:36 -0700 | [diff] [blame] | 918 | hdd_err("bad adapter magic"); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 919 | return -EINVAL; |
| 920 | } |
| 921 | |
| 922 | if (!adapter->dev) { |
| 923 | hdd_err("adapter net_device is null"); |
| 924 | return -EINVAL; |
| 925 | } |
| 926 | |
| 927 | if (!(adapter->dev->flags & IFF_UP)) { |
| 928 | hdd_info("adapter net_device is not up"); |
| 929 | return -EAGAIN; |
| 930 | } |
| 931 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 932 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 933 | hdd_info("adapter session is not open"); |
| 934 | return -EAGAIN; |
| 935 | } |
| 936 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 937 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 938 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 939 | return -EINVAL; |
| 940 | } |
| 941 | |
| 942 | return 0; |
| 943 | } |
| 944 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 945 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 946 | * wlan_hdd_validate_modules_state() - Check modules status |
| 947 | * @hdd_ctx: HDD context pointer |
| 948 | * |
| 949 | * Check's the driver module's state and returns true if the |
| 950 | * modules are enabled returns false if modules are closed. |
| 951 | * |
| 952 | * Return: True if modules are enabled or false. |
| 953 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 954 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 955 | { |
| 956 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 957 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 958 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 959 | hdd_info("Modules not enabled, Present status: %d", |
| 960 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 961 | return false; |
| 962 | } |
| 963 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 964 | return true; |
| 965 | } |
| 966 | |
| 967 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 968 | * 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] | 969 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | * |
| 971 | * This function sets the IBSS power save config parameters to WMA |
| 972 | * which will send it to firmware if FW supports IBSS power save |
| 973 | * before vdev start. |
| 974 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 975 | * 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] | 976 | * on failure. |
| 977 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 978 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 979 | { |
| 980 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 981 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 982 | |
| 983 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 984 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 985 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | } |
| 987 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 988 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 989 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 990 | hdd_ctx->config->ibssATIMWinSize, |
| 991 | VDEV_CMD); |
| 992 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 993 | hdd_err("WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 994 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 995 | } |
| 996 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 997 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 998 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 999 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1000 | VDEV_CMD); |
| 1001 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1002 | hdd_err("WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED failed %d", |
| 1003 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1004 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1005 | } |
| 1006 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1007 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1008 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1009 | hdd_ctx->config-> |
| 1010 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1011 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1012 | hdd_err("WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED failed %d", |
| 1013 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1014 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | } |
| 1016 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1017 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1018 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1019 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1020 | VDEV_CMD); |
| 1021 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1022 | hdd_err("WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1023 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1024 | } |
| 1025 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1026 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1027 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1028 | hdd_ctx->config->ibssInactivityCount, |
| 1029 | VDEV_CMD); |
| 1030 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1031 | hdd_err("WMA_VDEV_IBSS_SET_INACTIVITY_TIME failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1032 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1033 | } |
| 1034 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1035 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1036 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1037 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1038 | VDEV_CMD); |
| 1039 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1040 | hdd_err("WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME failed %d", |
| 1041 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1042 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1043 | } |
| 1044 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1045 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1046 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1047 | hdd_ctx->config->ibssPsWarmupTime, |
| 1048 | VDEV_CMD); |
| 1049 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1050 | hdd_err("WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS failed %d", |
| 1051 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1052 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1053 | } |
| 1054 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1055 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1056 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1057 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1058 | VDEV_CMD); |
| 1059 | if (0 != ret) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1060 | hdd_err("WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW failed %d", |
| 1061 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1062 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1063 | } |
| 1064 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1065 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1066 | } |
| 1067 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1068 | #ifdef FEATURE_RUNTIME_PM |
| 1069 | /** |
| 1070 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1071 | * @hdd_ctx: HDD context |
| 1072 | * |
| 1073 | * Return: None |
| 1074 | */ |
| 1075 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1076 | { |
| 1077 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1078 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1079 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1080 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1081 | |
| 1082 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1083 | } |
| 1084 | |
| 1085 | /** |
| 1086 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1087 | * @hdd_ctx: HDD Context |
| 1088 | * |
| 1089 | * Return: None |
| 1090 | */ |
| 1091 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1092 | { |
| 1093 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1094 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1095 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1096 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1097 | |
| 1098 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1099 | } |
| 1100 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1101 | #else /* FEATURE_RUNTIME_PM */ |
| 1102 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1103 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1104 | #endif /* FEATURE_RUNTIME_PM */ |
| 1105 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1106 | #define INTF_MACADDR_MASK 0x7 |
| 1107 | |
| 1108 | /** |
| 1109 | * hdd_update_macaddr() - update mac address |
| 1110 | * @config: hdd configuration |
| 1111 | * @hw_macaddr: mac address |
| 1112 | * |
| 1113 | * Mac address for multiple virtual interface is found as following |
| 1114 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1115 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1116 | * define the mac address for the remaining interfaces and locally |
| 1117 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1118 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1119 | * interface). |
| 1120 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1121 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1122 | * |
| 1123 | * Return: None |
| 1124 | */ |
| 1125 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1126 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1127 | { |
| 1128 | int8_t i; |
| 1129 | uint8_t macaddr_b3, tmp_br3; |
| 1130 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1131 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1132 | QDF_MAC_ADDR_SIZE); |
| 1133 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1134 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1135 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1136 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1137 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1138 | INTF_MACADDR_MASK; |
| 1139 | macaddr_b3 += tmp_br3; |
| 1140 | |
| 1141 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1142 | * mac address range before collision |
| 1143 | */ |
| 1144 | macaddr_b3 ^= (1 << 7); |
| 1145 | |
| 1146 | /* Set locally administered bit */ |
| 1147 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1148 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1149 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1150 | MAC_ADDRESS_STR, i, |
| 1151 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1152 | } |
| 1153 | } |
| 1154 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1155 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1156 | { |
| 1157 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1158 | struct tdls_start_params tdls_cfg; |
| 1159 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1160 | struct hdd_config *cfg = hdd_ctx->config; |
| 1161 | QDF_STATUS status; |
| 1162 | |
| 1163 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1164 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1165 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1166 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1167 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1168 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1169 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1170 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1171 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1172 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1173 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1174 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1175 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1176 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1177 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1178 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1179 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1180 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1181 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1182 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1183 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1184 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1185 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1186 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1187 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1188 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1189 | (cfg->fTDLSExternalControl ? |
| 1190 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1191 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1192 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1193 | |
| 1194 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1195 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1196 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1197 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1198 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1199 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1200 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1201 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1202 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1203 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1204 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1205 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1206 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1207 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1208 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1209 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1210 | |
| 1211 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1212 | if (status != QDF_STATUS_SUCCESS) { |
| 1213 | hdd_err("failed pmo psoc configuration"); |
| 1214 | return -EINVAL; |
| 1215 | } |
| 1216 | |
| 1217 | hdd_ctx->tdls_umac_comp_active = true; |
| 1218 | /* enable napier specific tdls data path */ |
| 1219 | hdd_ctx->tdls_nap_active = true; |
| 1220 | |
| 1221 | return 0; |
| 1222 | } |
| 1223 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1224 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | struct wma_tgt_services *cfg) |
| 1226 | { |
| 1227 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1228 | |
| 1229 | /* Set up UAPSD */ |
| 1230 | config->apUapsdEnabled &= cfg->uapsd; |
| 1231 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1232 | /* 11AX mode support */ |
| 1233 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1234 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1235 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1236 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1237 | /* 11AC mode support */ |
| 1238 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1239 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1240 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | |
| 1242 | /* ARP offload: override user setting if invalid */ |
| 1243 | config->fhostArpOffload &= cfg->arp_offload; |
| 1244 | |
| 1245 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1246 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1247 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1248 | if (cfg->pno_offload) |
| 1249 | config->PnoOffload = true; |
| 1250 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1251 | #ifdef FEATURE_WLAN_TDLS |
| 1252 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1253 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1254 | cfg->en_tdls_offchan; |
| 1255 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1256 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1257 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1259 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1260 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1261 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1263 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1264 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1265 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1266 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1267 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1268 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1269 | |
| 1270 | } |
| 1271 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1272 | /** |
| 1273 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1274 | * @hdd_ctx: HDD context |
| 1275 | * |
| 1276 | * Sets the Nss per vdev type based on INI |
| 1277 | * |
| 1278 | * Return: None |
| 1279 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1280 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1281 | { |
| 1282 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1283 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1284 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1285 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1286 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1287 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1288 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1289 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1290 | cfg_ini->vdev_type_nss_5g); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1291 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1292 | mac_handle = hdd_ctx->mac_handle; |
| 1293 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1294 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1295 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1296 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1297 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1300 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1301 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1302 | * @hdd_ctx: HDD context |
| 1303 | * |
| 1304 | * Updates wiphy vhtcap fields |
| 1305 | * |
| 1306 | * Return: None |
| 1307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1308 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1309 | { |
| 1310 | struct ieee80211_supported_band *band_5g = |
| 1311 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1312 | uint32_t val; |
| 1313 | |
| 1314 | if (!band_5g) { |
| 1315 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1316 | return; |
| 1317 | } |
| 1318 | |
| 1319 | val = hdd_ctx->config->txBFCsnValue; |
| 1320 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1321 | |
| 1322 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1323 | band_5g->vht_cap.cap |= |
| 1324 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1325 | |
| 1326 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1327 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1328 | } |
| 1329 | |
| 1330 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1331 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1332 | * @hdd_ctx: HDD context |
| 1333 | * |
| 1334 | * Sets the DBS capability as per INI and firmware capability |
| 1335 | * |
| 1336 | * Return: None |
| 1337 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1338 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1339 | { |
| 1340 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1341 | uint8_t hw_dbs_capable = 0; |
| 1342 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1343 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1344 | ((cfg_ini->dual_mac_feature_disable == |
| 1345 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1346 | (cfg_ini->dual_mac_feature_disable == |
| 1347 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1348 | hw_dbs_capable = 1; |
| 1349 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1350 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1351 | } |
| 1352 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1353 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1354 | struct wma_tgt_ht_cap *cfg) |
| 1355 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1356 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1357 | uint32_t value, val32; |
| 1358 | uint16_t val16; |
| 1359 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1360 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1361 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1362 | uint8_t enable_tx_stbc; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1363 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | |
| 1365 | /* check and update RX STBC */ |
| 1366 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1367 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1368 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1369 | mac_handle = hdd_ctx->mac_handle; |
| 1370 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1371 | /* get the MPDU density */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1372 | status = sme_cfg_get_int(mac_handle, WNI_CFG_MPDU_DENSITY, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1373 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1374 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1375 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1376 | value = 0; |
| 1377 | } |
| 1378 | |
| 1379 | /* |
| 1380 | * MPDU density: |
| 1381 | * override user's setting if value is larger |
| 1382 | * than the one supported by target |
| 1383 | */ |
| 1384 | if (value > cfg->mpdu_density) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1385 | status = sme_cfg_set_int(mac_handle, WNI_CFG_MPDU_DENSITY, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1386 | cfg->mpdu_density); |
| 1387 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1388 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1389 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | } |
| 1391 | |
| 1392 | /* get the HT capability info */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1393 | status = sme_cfg_get_int(mac_handle, WNI_CFG_HT_CAP_INFO, &val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1394 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1395 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1396 | return; |
| 1397 | } |
| 1398 | val16 = (uint16_t) val32; |
| 1399 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1400 | |
| 1401 | /* Set the LDPC capability */ |
| 1402 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1403 | |
| 1404 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1405 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1406 | |
| 1407 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1408 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1409 | |
| 1410 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1411 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1412 | |
| 1413 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1414 | |
| 1415 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1416 | pconfig->enable2x2 = 1; |
| 1417 | } else { |
| 1418 | pconfig->enable2x2 = 0; |
| 1419 | enable_tx_stbc = 0; |
| 1420 | |
| 1421 | /* 1x1 */ |
| 1422 | /* Update Rx Highest Long GI data Rate */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1423 | if (sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1424 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1425 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1426 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1427 | 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] | 1428 | } |
| 1429 | |
| 1430 | /* Update Tx Highest Long GI data Rate */ |
| 1431 | if (sme_cfg_set_int |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1432 | (mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1433 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1434 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1435 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1436 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | } |
| 1438 | } |
| 1439 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1440 | enable_tx_stbc = 0; |
| 1441 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1442 | |
| 1443 | val32 = val16; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1444 | status = sme_cfg_set_int(mac_handle, WNI_CFG_HT_CAP_INFO, val32); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1445 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1446 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1447 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1448 | value = SIZE_OF_SUPPORTED_MCS_SET; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1449 | if (sme_cfg_get_str(mac_handle, WNI_CFG_SUPPORTED_MCS_SET, mcs_set, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1450 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1451 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1452 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1453 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1454 | if (pconfig->enable2x2) { |
| 1455 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1456 | mcs_set[value] = |
| 1457 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1458 | |
| 1459 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1460 | sme_cfg_set_str(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1461 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1462 | mcs_set, |
| 1463 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1464 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1465 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1466 | } |
| 1467 | } |
| 1468 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1469 | } |
| 1470 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1471 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1472 | struct wma_tgt_vht_cap *cfg) |
| 1473 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1474 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1475 | uint32_t value = 0; |
| 1476 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1477 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1478 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1479 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1480 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1481 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1482 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1483 | struct wma_caps_per_phy caps_per_phy; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1484 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1485 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1486 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1487 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1488 | return; |
| 1489 | } |
| 1490 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1491 | mac_handle = hdd_ctx->mac_handle; |
| 1492 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | /* Get the current MPDU length */ |
| 1494 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1495 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1496 | &value); |
| 1497 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1498 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1499 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | value = 0; |
| 1501 | } |
| 1502 | |
| 1503 | /* |
| 1504 | * VHT max MPDU length: |
| 1505 | * override if user configured value is too high |
| 1506 | * that the target cannot support |
| 1507 | */ |
| 1508 | if (value > cfg->vht_max_mpdu) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1509 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1510 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1511 | cfg->vht_max_mpdu); |
| 1512 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1513 | if (status == QDF_STATUS_E_FAILURE) |
| 1514 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1515 | } |
| 1516 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1517 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_BASIC_MCS_SET, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1518 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1519 | |
| 1520 | if (pconfig->enable2x2) |
| 1521 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1522 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1523 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_BASIC_MCS_SET, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1524 | QDF_STATUS_E_FAILURE) { |
| 1525 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1526 | } |
| 1527 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1528 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_RX_MCS_MAP, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1529 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1530 | if (pconfig->enable2x2) |
| 1531 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1532 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1533 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_RX_MCS_MAP, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1534 | QDF_STATUS_E_FAILURE) { |
| 1535 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1536 | } |
| 1537 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1538 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TX_MCS_MAP, &temp); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1539 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1540 | if (pconfig->enable2x2) |
| 1541 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1542 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1543 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1544 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1545 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1546 | if (sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TX_MCS_MAP, temp) == |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1547 | QDF_STATUS_E_FAILURE) { |
| 1548 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1549 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1550 | /* Get the current RX LDPC setting */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1551 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1552 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1553 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1554 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1555 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1556 | value = 0; |
| 1557 | } |
| 1558 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1559 | /* Set HW RX LDPC capability */ |
| 1560 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1561 | if (hw_rx_ldpc_enabled != value) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1562 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1563 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1564 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1566 | if (status == QDF_STATUS_E_FAILURE) |
| 1567 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | } |
| 1569 | |
| 1570 | /* Get current GI 80 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1571 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1572 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1573 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1574 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1575 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1576 | value = 0; |
| 1577 | } |
| 1578 | |
| 1579 | /* set the Guard interval 80MHz */ |
| 1580 | if (value && !cfg->vht_short_gi_80) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1581 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1582 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1583 | cfg->vht_short_gi_80); |
| 1584 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1585 | if (status == QDF_STATUS_E_FAILURE) |
| 1586 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1587 | } |
| 1588 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1589 | /* Get VHT TX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1590 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1591 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1592 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1593 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1594 | value = 0; |
| 1595 | } |
| 1596 | |
| 1597 | /* VHT TX STBC cap */ |
| 1598 | if (value && !cfg->vht_tx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1599 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1600 | cfg->vht_tx_stbc); |
| 1601 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1602 | if (status == QDF_STATUS_E_FAILURE) |
| 1603 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | } |
| 1605 | |
| 1606 | /* Get VHT RX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1607 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_RXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1609 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1610 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1611 | value = 0; |
| 1612 | } |
| 1613 | |
| 1614 | /* VHT RX STBC cap */ |
| 1615 | if (value && !cfg->vht_rx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1616 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_RXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1617 | cfg->vht_rx_stbc); |
| 1618 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1619 | if (status == QDF_STATUS_E_FAILURE) |
| 1620 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1621 | } |
| 1622 | |
| 1623 | /* Get VHT SU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1624 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | &value); |
| 1626 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1627 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1628 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1629 | value = 0; |
| 1630 | } |
| 1631 | |
| 1632 | /* set VHT SU Beamformer cap */ |
| 1633 | if (value && !cfg->vht_su_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1634 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1636 | cfg->vht_su_bformer); |
| 1637 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1638 | if (status == QDF_STATUS_E_FAILURE) |
| 1639 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1640 | } |
| 1641 | |
| 1642 | /* check and update SU BEAMFORMEE capabality */ |
| 1643 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1644 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1645 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1646 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1647 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1648 | pconfig->enableTxBF); |
| 1649 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1650 | if (status == QDF_STATUS_E_FAILURE) |
| 1651 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | |
| 1653 | /* Get VHT MU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1654 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1655 | &value); |
| 1656 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1657 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1658 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1659 | value = 0; |
| 1660 | } |
| 1661 | |
| 1662 | /* set VHT MU Beamformer cap */ |
| 1663 | if (value && !cfg->vht_mu_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1664 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1665 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1666 | cfg->vht_mu_bformer); |
| 1667 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1668 | if (status == QDF_STATUS_E_FAILURE) |
| 1669 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1670 | } |
| 1671 | |
| 1672 | /* Get VHT MU Beamformee cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1673 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1674 | &value); |
| 1675 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1676 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1677 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1678 | value = 0; |
| 1679 | } |
| 1680 | |
| 1681 | /* set VHT MU Beamformee cap */ |
| 1682 | if (value && !cfg->vht_mu_bformee) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1683 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1684 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1685 | cfg->vht_mu_bformee); |
| 1686 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1687 | if (status == QDF_STATUS_E_FAILURE) |
| 1688 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1689 | } |
| 1690 | |
| 1691 | /* Get VHT MAX AMPDU Len exp */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1692 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | &value); |
| 1694 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1695 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1696 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1697 | value = 0; |
| 1698 | } |
| 1699 | |
| 1700 | /* |
| 1701 | * VHT max AMPDU len exp: |
| 1702 | * override if user configured value is too high |
| 1703 | * that the target cannot support. |
| 1704 | * Even though Rome publish ampdu_len=7, it can |
| 1705 | * only support 4 because of some h/w bug. |
| 1706 | */ |
| 1707 | |
| 1708 | if (value > cfg->vht_max_ampdu_len_exp) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1709 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1710 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1711 | cfg->vht_max_ampdu_len_exp); |
| 1712 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1713 | if (status == QDF_STATUS_E_FAILURE) |
| 1714 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1715 | } |
| 1716 | |
| 1717 | /* Get VHT TXOP PS CAP */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1718 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TXOP_PS, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1719 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1720 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1721 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | value = 0; |
| 1723 | } |
| 1724 | |
| 1725 | /* set VHT TXOP PS cap */ |
| 1726 | if (value && !cfg->vht_txop_ps) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1727 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXOP_PS, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1728 | cfg->vht_txop_ps); |
| 1729 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1730 | if (status == QDF_STATUS_E_FAILURE) |
| 1731 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1732 | } |
| 1733 | |
| 1734 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1735 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1736 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1737 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1738 | else |
| 1739 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1740 | |
| 1741 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1742 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1743 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1744 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1745 | VHT_CAP_160_AND_80P80_SUPP); |
| 1746 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1747 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1748 | band_5g->vht_cap.cap |= |
| 1749 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1750 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1751 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1752 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1753 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1754 | VHT_CAP_160_SUPP); |
| 1755 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1756 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1757 | band_5g->vht_cap.cap |= |
| 1758 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1759 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1760 | } |
| 1761 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1762 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1763 | /* Get the current GI 160 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1764 | status = sme_cfg_get_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1765 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1766 | &value); |
| 1767 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1768 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1769 | value = 0; |
| 1770 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1771 | /* set the Guard interval 160MHz */ |
| 1772 | if (value && !cfg->vht_short_gi_160) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1773 | status = sme_cfg_set_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1774 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1775 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1776 | |
| 1777 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1778 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1779 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1780 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1781 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1782 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1783 | hdd_debug("VHT RxLDPC capability is set"); |
| 1784 | } else { |
| 1785 | /* |
| 1786 | * Get the RX LDPC capability for the NON DBS |
| 1787 | * hardware mode for 5G band |
| 1788 | */ |
| 1789 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1790 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1791 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1792 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1793 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1794 | hdd_debug("VHT RX LDPC capability is set"); |
| 1795 | } |
| 1796 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1797 | |
| 1798 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1799 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1800 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1801 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1802 | |
| 1803 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1804 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1805 | |
| 1806 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1807 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1808 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1809 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1810 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1811 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1812 | |
| 1813 | band_5g->vht_cap.cap |= |
| 1814 | (cfg->vht_max_ampdu_len_exp << |
| 1815 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1816 | |
| 1817 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1818 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1819 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1820 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1821 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1822 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1823 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1824 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1825 | |
| 1826 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1827 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1828 | |
| 1829 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1830 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1831 | /** |
| 1832 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1833 | * @hdd_ctx: Pointer to the HDD context |
| 1834 | * |
| 1835 | * Auto-generate mac address using device serial number. |
| 1836 | * Keep the first 3 bytes of OUI as before and replace |
| 1837 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1838 | * |
| 1839 | * Return: 0 for success |
| 1840 | * Non zero failure code for errors |
| 1841 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1842 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1843 | { |
| 1844 | unsigned int serialno = 0; |
| 1845 | struct qdf_mac_addr mac_addr = { |
| 1846 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1847 | }; |
| 1848 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1849 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1850 | if (serialno == 0) |
| 1851 | return -EINVAL; |
| 1852 | |
| 1853 | serialno &= 0x00ffffff; |
| 1854 | |
| 1855 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1856 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1857 | mac_addr.bytes[5] = serialno & 0xff; |
| 1858 | |
| 1859 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1860 | return 0; |
| 1861 | } |
| 1862 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1863 | /** |
| 1864 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1865 | * configuration to cfg_ini in HDD |
| 1866 | * @hdd_ctx: Pointer to hdd_ctx |
| 1867 | * @cfg: target configuration |
| 1868 | * |
| 1869 | * Return: None |
| 1870 | */ |
| 1871 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1872 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1873 | struct wma_tgt_cfg *cfg) |
| 1874 | { |
| 1875 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1876 | } |
| 1877 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1878 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1879 | struct wma_tgt_cfg *cfg) |
| 1880 | { |
| 1881 | } |
| 1882 | #endif |
| 1883 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1884 | 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] | 1885 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1886 | int ret; |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1887 | struct hdd_context *hdd_ctx = (struct hdd_context *)hdd_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1888 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1889 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1890 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1891 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1892 | mac_handle_t mac_handle; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1893 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1894 | if (!hdd_ctx) { |
| 1895 | hdd_err("HDD context is NULL"); |
| 1896 | return; |
| 1897 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1898 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1899 | if (ret) { |
| 1900 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1901 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1902 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1903 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1904 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1905 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1906 | hdd_err("dispatcher pdev open failed"); |
| 1907 | QDF_BUG(0); |
| 1908 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1909 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1910 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1911 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1912 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1913 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1914 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1915 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1916 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1917 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1918 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1919 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1920 | hdd_softap_hard_start_xmit); |
| 1921 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1922 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1923 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1924 | if (cds_cfg) { |
| 1925 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1926 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1927 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1928 | cds_cfg->sub_20_channel_width = |
| 1929 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1930 | } else { |
| 1931 | cds_cfg->sub_20_channel_width = |
| 1932 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1933 | } |
| 1934 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1935 | |
| 1936 | /* first store the INI band capability */ |
| 1937 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1938 | |
| 1939 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1940 | hdd_ctx->is_fils_roaming_supported = |
| 1941 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1942 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1943 | hdd_ctx->config->is_11k_offload_supported = |
| 1944 | cfg->services.is_11k_offload_supported; |
| 1945 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1946 | /* |
| 1947 | * now overwrite the target band capability with INI |
| 1948 | * setting if INI setting is a subset |
| 1949 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1950 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1951 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1952 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1953 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1954 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1955 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1956 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1957 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1958 | } |
| 1959 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1960 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1961 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1962 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1963 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1964 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1965 | } |
| 1966 | |
| 1967 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1968 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 1969 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1970 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1971 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1972 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1973 | static struct qdf_mac_addr default_mac_addr = { |
| 1974 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 1975 | }; |
| 1976 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 1977 | &default_mac_addr)) { |
| 1978 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 1979 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 1980 | MAC_ADDRESS_STR, |
| 1981 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1982 | intfMacAddr[0].bytes)); |
| 1983 | } else { |
| 1984 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 1985 | MAC_ADDRESS_STR, |
| 1986 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 1987 | intfMacAddr[0].bytes)); |
| 1988 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 1989 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1990 | } |
| 1991 | |
| 1992 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1993 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1994 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1995 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1996 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1997 | sizeof(cfg->hw_bd_info)); |
| 1998 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1999 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2000 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2001 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2002 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2003 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2004 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2005 | |
| 2006 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2007 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2008 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2009 | if (cfg->services.en_11ax) { |
| 2010 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2011 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2012 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 2013 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2014 | |
| 2015 | hdd_update_vdev_nss(hdd_ctx); |
| 2016 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2017 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 2018 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 2019 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2020 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2021 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2022 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2023 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2024 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 2025 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2026 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2027 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2028 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2029 | |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 2030 | hdd_ctx->apf_enabled = (cfg->apf_enabled && |
| 2031 | hdd_ctx->config->apf_packet_filter_enable); |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2032 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2033 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2034 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2035 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2036 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2037 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2038 | hdd_ctx->config->txBFCsnValue = |
| 2039 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2040 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2041 | mac_handle = hdd_ctx->mac_handle; |
| 2042 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2043 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2044 | hdd_ctx->config->txBFCsnValue); |
| 2045 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2046 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2047 | |
| 2048 | |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 2049 | hdd_debug("Target APF %d Host APF %d 8ss fw support %d txBFCsnValue %d", |
| 2050 | cfg->apf_enabled, hdd_ctx->config->apf_packet_filter_enable, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2051 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2052 | |
| 2053 | /* |
| 2054 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2055 | */ |
| 2056 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2057 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2058 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2059 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2060 | /* |
| 2061 | * This needs to be done after HDD pdev is created and stored since |
| 2062 | * it will access the HDD pdev object lock. |
| 2063 | */ |
| 2064 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2065 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2066 | /* Configure NAN datapath features */ |
| 2067 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2068 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2069 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2070 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2071 | cfg->obss_detection_offloaded); |
| 2072 | if (QDF_IS_STATUS_ERROR(status)) |
| 2073 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2074 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2075 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2076 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2077 | cfg->obss_color_collision_offloaded); |
| 2078 | if (QDF_IS_STATUS_ERROR(status)) |
| 2079 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2080 | } |
| 2081 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2082 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2083 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2084 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2085 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2086 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2087 | if (!hdd_ctx) { |
| 2088 | hdd_info("Couldn't get hdd_ctx"); |
| 2089 | return true; |
| 2090 | } |
| 2091 | |
| 2092 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2093 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2094 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2095 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2096 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2097 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2098 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2099 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2100 | |
| 2101 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2102 | QDF_P2P_GO_MODE == adapter->device_mode) && |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2103 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2104 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2105 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2106 | true; |
| 2107 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2108 | adapter->session_id); |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2109 | cdp_fc_vdev_flush(cds_get_context(QDF_MODULE_ID_SOC), |
| 2110 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2111 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2112 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2113 | |
| 2114 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2115 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2116 | |
| 2117 | /** |
| 2118 | * hdd_is_valid_mac_address() - validate MAC address |
| 2119 | * @pMacAddr: Pointer to the input MAC address |
| 2120 | * |
| 2121 | * This function validates whether the given MAC address is valid or not |
| 2122 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2123 | * where X is the hexa decimal digit character and separated by ':' |
| 2124 | * This algorithm works even if MAC address is not separated by ':' |
| 2125 | * |
| 2126 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2127 | * digits and a separator colon : appears in the input string only after |
| 2128 | * an even number of hex digits. |
| 2129 | * |
| 2130 | * Return: 1 for valid and 0 for invalid |
| 2131 | */ |
| 2132 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2133 | { |
| 2134 | int xdigit = 0; |
| 2135 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2136 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2137 | while (*pMacAddr) { |
| 2138 | if (isxdigit(*pMacAddr)) { |
| 2139 | xdigit++; |
| 2140 | } else if (':' == *pMacAddr) { |
| 2141 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2142 | break; |
| 2143 | |
| 2144 | ++separator; |
| 2145 | } else { |
| 2146 | /* Invalid MAC found */ |
| 2147 | return 0; |
| 2148 | } |
| 2149 | ++pMacAddr; |
| 2150 | } |
| 2151 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2152 | } |
| 2153 | |
| 2154 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2155 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2156 | * @dev: Handle to struct net_device to be updated. |
| 2157 | * |
| 2158 | * Return: None |
| 2159 | */ |
| 2160 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2161 | { |
| 2162 | dev->header_ops = NULL; |
| 2163 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2164 | dev->hard_header_len = ETH_HLEN; |
| 2165 | dev->mtu = ETH_DATA_LEN; |
| 2166 | dev->addr_len = ETH_ALEN; |
| 2167 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2168 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2169 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2170 | |
| 2171 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2172 | } |
| 2173 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2174 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2175 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2176 | * __hdd__mon_open() - HDD Open function |
| 2177 | * @dev: Pointer to net_device structure |
| 2178 | * |
| 2179 | * This is called in response to ifconfig up |
| 2180 | * |
| 2181 | * Return: 0 for success; non-zero for failure |
| 2182 | */ |
| 2183 | static int __hdd_mon_open(struct net_device *dev) |
| 2184 | { |
| 2185 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2186 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2187 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2188 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2189 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2190 | |
| 2191 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2192 | if (ret) |
| 2193 | return ret; |
| 2194 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2195 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2196 | |
| 2197 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2198 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2199 | if (ret) { |
| 2200 | hdd_err("Failed to start WLAN modules return"); |
| 2201 | return ret; |
| 2202 | } |
| 2203 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2204 | |
| 2205 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2206 | ret = hdd_start_adapter(adapter); |
| 2207 | if (ret) { |
| 2208 | hdd_err("Failed to start adapter :%d", |
| 2209 | adapter->device_mode); |
| 2210 | return ret; |
| 2211 | } |
| 2212 | hdd_err("hdd_start_adapters() successful !"); |
| 2213 | } |
| 2214 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2215 | } |
| 2216 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2217 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2218 | |
| 2219 | if (!ret) |
| 2220 | ret = hdd_enable_monitor_mode(dev); |
| 2221 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2222 | return ret; |
| 2223 | } |
| 2224 | |
| 2225 | /** |
| 2226 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2227 | * @dev: Pointer to net_device structure |
| 2228 | * |
| 2229 | * This is called in response to ifconfig up |
| 2230 | * |
| 2231 | * Return: 0 for success; non-zero for failure |
| 2232 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2233 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2234 | { |
| 2235 | int ret; |
| 2236 | |
| 2237 | cds_ssr_protect(__func__); |
| 2238 | ret = __hdd_mon_open(dev); |
| 2239 | cds_ssr_unprotect(__func__); |
| 2240 | |
| 2241 | return ret; |
| 2242 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2243 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2244 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2245 | static QDF_STATUS |
| 2246 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2247 | { |
| 2248 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2249 | QDF_STATUS status; |
| 2250 | uint32_t channel_select_logic_conc; |
| 2251 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2252 | |
| 2253 | if (!hdd_ctx) { |
| 2254 | hdd_err("HDD context is NULL"); |
| 2255 | return QDF_STATUS_E_FAILURE; |
| 2256 | } |
| 2257 | |
| 2258 | |
| 2259 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2260 | return QDF_STATUS_SUCCESS; |
| 2261 | |
| 2262 | cfg.scan_config = 0; |
| 2263 | cfg.fw_mode_config = 0; |
| 2264 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2265 | |
| 2266 | channel_select_logic_conc = hdd_ctx->config-> |
| 2267 | channel_select_logic_conc; |
| 2268 | |
| 2269 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2270 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2271 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2272 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2273 | &cfg.fw_mode_config, |
| 2274 | hdd_ctx->config->dual_mac_feature_disable, |
| 2275 | channel_select_logic_conc); |
| 2276 | |
| 2277 | if (status != QDF_STATUS_SUCCESS) { |
| 2278 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2279 | status); |
| 2280 | return status; |
| 2281 | } |
| 2282 | } |
| 2283 | |
| 2284 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2285 | cfg.scan_config, cfg.fw_mode_config); |
| 2286 | |
| 2287 | status = sme_soc_set_dual_mac_config(cfg); |
| 2288 | if (status != QDF_STATUS_SUCCESS) { |
| 2289 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2290 | return status; |
| 2291 | } |
| 2292 | |
| 2293 | return QDF_STATUS_SUCCESS; |
| 2294 | } |
| 2295 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2296 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2297 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2298 | * @adapter: pointer to HDD adapter |
| 2299 | * |
| 2300 | * This function is called to start the device specific adapter for |
| 2301 | * the mode passed in the adapter's device_mode. |
| 2302 | * |
| 2303 | * Return: 0 for success; non-zero for failure |
| 2304 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2305 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2306 | { |
| 2307 | |
| 2308 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2309 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2310 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2311 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2312 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2313 | |
| 2314 | switch (device_mode) { |
| 2315 | case QDF_P2P_CLIENT_MODE: |
| 2316 | case QDF_P2P_DEVICE_MODE: |
| 2317 | case QDF_OCB_MODE: |
| 2318 | case QDF_STA_MODE: |
| 2319 | case QDF_MONITOR_MODE: |
| 2320 | ret = hdd_start_station_adapter(adapter); |
| 2321 | if (ret) |
| 2322 | goto err_start_adapter; |
| 2323 | break; |
| 2324 | case QDF_P2P_GO_MODE: |
| 2325 | case QDF_SAP_MODE: |
| 2326 | ret = hdd_start_ap_adapter(adapter); |
| 2327 | if (ret) |
| 2328 | goto err_start_adapter; |
| 2329 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2330 | case QDF_IBSS_MODE: |
| 2331 | /* |
| 2332 | * For IBSS interface is initialized as part of |
| 2333 | * hdd_init_station_mode() |
| 2334 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2335 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2336 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2337 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2338 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2339 | default: |
| 2340 | hdd_err("Invalid session type %d", device_mode); |
| 2341 | QDF_ASSERT(0); |
| 2342 | goto err_start_adapter; |
| 2343 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2344 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2345 | if (hdd_set_fw_params(adapter)) |
| 2346 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2347 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2348 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2349 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2350 | if (ret < 0) { |
| 2351 | hdd_err("Failed to register frames - ret %d", ret); |
| 2352 | goto err_start_adapter; |
| 2353 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2354 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2355 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2356 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2357 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2358 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2359 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2360 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2361 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2362 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2363 | err_start_adapter: |
| 2364 | return -EINVAL; |
| 2365 | } |
| 2366 | |
| 2367 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2368 | * hdd_enable_power_management() - API to Enable Power Management |
| 2369 | * |
| 2370 | * API invokes Bus Interface Layer power management functionality |
| 2371 | * |
| 2372 | * Return: None |
| 2373 | */ |
| 2374 | static void hdd_enable_power_management(void) |
| 2375 | { |
| 2376 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2377 | |
| 2378 | if (!hif_ctx) { |
| 2379 | hdd_err("Bus Interface Context is Invalid"); |
| 2380 | return; |
| 2381 | } |
| 2382 | |
| 2383 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2384 | } |
| 2385 | |
| 2386 | /** |
| 2387 | * hdd_disable_power_management() - API to disable Power Management |
| 2388 | * |
| 2389 | * API disable Bus Interface Layer Power management functionality |
| 2390 | * |
| 2391 | * Return: None |
| 2392 | */ |
| 2393 | static void hdd_disable_power_management(void) |
| 2394 | { |
| 2395 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2396 | |
| 2397 | if (!hif_ctx) { |
| 2398 | hdd_err("Bus Interface Context is Invalid"); |
| 2399 | return; |
| 2400 | } |
| 2401 | |
| 2402 | hif_disable_power_management(hif_ctx); |
| 2403 | } |
| 2404 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2405 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2406 | { |
| 2407 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2408 | size_t target_hw_name_len; |
| 2409 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2410 | uint8_t *buf; |
| 2411 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2412 | |
| 2413 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2414 | if (!hif_sc) { |
| 2415 | hdd_err("HIF context is NULL"); |
| 2416 | return; |
| 2417 | } |
| 2418 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2419 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2420 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2421 | &target_hw_name); |
| 2422 | |
| 2423 | if (hdd_ctx->target_hw_name) |
| 2424 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2425 | |
| 2426 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2427 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2428 | if (hdd_ctx->target_hw_name) |
| 2429 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2430 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2431 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2432 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2433 | if (buf) { |
| 2434 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2435 | hdd_info("%s", buf); |
| 2436 | qdf_mem_free(buf); |
| 2437 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2438 | } |
| 2439 | |
| 2440 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2441 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2442 | * @hdd_ctx: Pointer to hdd context |
| 2443 | * |
| 2444 | * Return: none |
| 2445 | */ |
| 2446 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2447 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2448 | { |
| 2449 | uint8_t num_entries = 0; |
| 2450 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2451 | uint8_t *tx_sched_wrr_ac; |
| 2452 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2453 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2454 | |
| 2455 | if (NULL == hdd_ctx) |
| 2456 | return; |
| 2457 | |
| 2458 | if (NULL == hdd_ctx->config) { |
| 2459 | /* Do nothing if hdd_ctx is invalid */ |
| 2460 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2461 | return; |
| 2462 | } |
| 2463 | |
| 2464 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2465 | |
| 2466 | if (!cds_ctx) { |
| 2467 | hdd_err("Invalid CDS Context"); |
| 2468 | return; |
| 2469 | } |
| 2470 | |
| 2471 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2472 | switch (i) { |
| 2473 | case OL_TX_WMM_AC_BE: |
| 2474 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2475 | break; |
| 2476 | case OL_TX_WMM_AC_BK: |
| 2477 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2478 | break; |
| 2479 | case OL_TX_WMM_AC_VI: |
| 2480 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2481 | break; |
| 2482 | case OL_TX_WMM_AC_VO: |
| 2483 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2484 | break; |
| 2485 | default: |
| 2486 | tx_sched_wrr_ac = NULL; |
| 2487 | break; |
| 2488 | } |
| 2489 | |
| 2490 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2491 | tx_sched_wrr_param, |
| 2492 | &num_entries, |
| 2493 | sizeof(tx_sched_wrr_param)); |
| 2494 | |
| 2495 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2496 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2497 | tx_sched_wrr_param[0]; |
| 2498 | cds_ctx->ac_specs[i].credit_threshold = |
| 2499 | tx_sched_wrr_param[1]; |
| 2500 | cds_ctx->ac_specs[i].send_limit = |
| 2501 | tx_sched_wrr_param[2]; |
| 2502 | cds_ctx->ac_specs[i].credit_reserve = |
| 2503 | tx_sched_wrr_param[3]; |
| 2504 | cds_ctx->ac_specs[i].discard_weight = |
| 2505 | tx_sched_wrr_param[4]; |
| 2506 | } |
| 2507 | |
| 2508 | num_entries = 0; |
| 2509 | } |
| 2510 | } |
| 2511 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2512 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2513 | const size_t version_len, uint8_t *version) |
| 2514 | { |
| 2515 | uint32_t size; |
| 2516 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2517 | |
| 2518 | if (!hdd_ctx) { |
| 2519 | hdd_err("Invalid context, HDD context is null"); |
| 2520 | return 0; |
| 2521 | } |
| 2522 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2523 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2524 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2525 | return 0; |
| 2526 | } |
| 2527 | |
| 2528 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2529 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2530 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2531 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2532 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2533 | |
| 2534 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2535 | "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] | 2536 | QWLAN_VERSIONSTR, |
| 2537 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2538 | hdd_ctx->target_hw_name, |
| 2539 | hdd_ctx->hw_bd_info.bdf_version, |
| 2540 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2541 | hdd_ctx->hw_bd_info.customer_id, |
| 2542 | hdd_ctx->hw_bd_info.project_id, |
| 2543 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2544 | |
| 2545 | return size; |
| 2546 | } |
| 2547 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2548 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2549 | struct sap_config *sap_config) |
| 2550 | { |
| 2551 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2552 | int ret; |
| 2553 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2554 | |
| 2555 | if (!sap_config) { |
| 2556 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2557 | hdd_err("Target does not support 11ax"); |
| 2558 | return -EIO; |
| 2559 | } |
| 2560 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2561 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2562 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2563 | sap_config->SapHw_mode, sap_config->channel); |
| 2564 | return -EIO; |
| 2565 | } |
| 2566 | |
| 2567 | if (set_value != 0xff) { |
| 2568 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2569 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2570 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2571 | |
| 2572 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2573 | } else { |
| 2574 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2575 | QCA_WLAN_HE_LTF_AUTO); |
| 2576 | } |
| 2577 | |
| 2578 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2579 | set_value, rix, preamble, nss); |
| 2580 | |
| 2581 | ret = wma_cli_set_command(adapter->session_id, |
| 2582 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2583 | set_value, VDEV_CMD); |
| 2584 | |
| 2585 | return ret; |
| 2586 | } |
| 2587 | |
| 2588 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2589 | { |
| 2590 | int set_value; |
| 2591 | |
| 2592 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2593 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2594 | else |
| 2595 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2596 | |
| 2597 | return set_value; |
| 2598 | } |
| 2599 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2600 | #ifdef IPA_OFFLOAD |
| 2601 | /** |
| 2602 | * hdd_update_ipa_component_config() - update ipa config |
| 2603 | * @hdd_ctx: Pointer to hdd context |
| 2604 | * |
| 2605 | * Return: none |
| 2606 | */ |
| 2607 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2608 | { |
| 2609 | struct hdd_config *cfg = hdd_ctx->config; |
| 2610 | struct wlan_ipa_config ipa_cfg; |
| 2611 | |
| 2612 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2613 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2614 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2615 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2616 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2617 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2618 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2619 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2620 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2621 | |
| 2622 | ucfg_ipa_update_config(&ipa_cfg); |
| 2623 | } |
| 2624 | #else |
| 2625 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2626 | { |
| 2627 | } |
| 2628 | #endif |
| 2629 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2630 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2631 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2632 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2633 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2634 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2635 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2636 | |
| 2637 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2638 | if (!adapter) { |
| 2639 | hdd_err("Adapter is NULL"); |
| 2640 | return PM_MAX_NUM_OF_MODE; |
| 2641 | } |
| 2642 | |
| 2643 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2644 | adapter->device_mode); |
| 2645 | } |
| 2646 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2647 | static void hdd_register_policy_manager_callback( |
| 2648 | struct wlan_objmgr_psoc *psoc) |
| 2649 | { |
| 2650 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2651 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2652 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2653 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2654 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2655 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2656 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2657 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2658 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2659 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2660 | if (QDF_STATUS_SUCCESS != |
| 2661 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2662 | hdd_err("HDD callback registration with policy manager failed"); |
| 2663 | } |
| 2664 | } |
| 2665 | #else |
| 2666 | static void hdd_register_policy_manager_callback( |
| 2667 | struct wlan_objmgr_psoc *psoc) |
| 2668 | { |
| 2669 | } |
| 2670 | #endif |
| 2671 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2672 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2673 | { |
| 2674 | struct nan_callbacks cb_obj = {0}; |
| 2675 | |
| 2676 | cb_obj.ndi_open = hdd_ndi_open; |
| 2677 | cb_obj.ndi_close = hdd_ndi_close; |
| 2678 | cb_obj.ndi_start = hdd_ndi_start; |
| 2679 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2680 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2681 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2682 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2683 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2684 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2685 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2686 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2687 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2688 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2689 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2690 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2691 | /** |
| 2692 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2693 | * @hdd_ctx: the global HDD context |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2694 | * |
| 2695 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2696 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2697 | * |
| 2698 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2699 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2700 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2701 | * fixed. |
| 2702 | * |
| 2703 | * Return: None |
| 2704 | */ |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2705 | static void hdd_check_for_leaks(struct hdd_context *hdd_ctx) |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2706 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2707 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2708 | |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2709 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 2946296 | 2018-06-18 14:02:00 -0700 | [diff] [blame] | 2710 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2711 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2712 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2713 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2714 | } |
| 2715 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2716 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2717 | #else |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2718 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx) { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2719 | |
| 2720 | #define hdd_debug_domain_set(domain) |
| 2721 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2722 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2723 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2724 | * hdd_update_country_code - Update country code |
| 2725 | * @hdd_ctx: HDD context |
| 2726 | * |
| 2727 | * Update country code based on module parameter country_code |
| 2728 | * |
| 2729 | * Return: 0 on success and errno on failure |
| 2730 | */ |
| 2731 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2732 | { |
| 2733 | if (!country_code) |
| 2734 | return 0; |
| 2735 | |
| 2736 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2737 | } |
| 2738 | |
| 2739 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2740 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2741 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2742 | * @reinit: flag to indicate from SSR or normal path |
| 2743 | * |
| 2744 | * This function maintains the driver state machine it will be invoked from |
| 2745 | * startup, reinit and change interface. Depending on the driver state shall |
| 2746 | * perform the opening of the modules. |
| 2747 | * |
| 2748 | * Return: 0 for success; non-zero for failure |
| 2749 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2750 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2751 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2752 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2753 | qdf_device_t qdf_dev; |
| 2754 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2755 | bool unint = false; |
| 2756 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2757 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2758 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2759 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2760 | |
| 2761 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2762 | if (!qdf_dev) { |
| 2763 | hdd_err("QDF Device Context is Invalid return"); |
| 2764 | return -EINVAL; |
| 2765 | } |
| 2766 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2767 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2768 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2769 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2770 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2771 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2772 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2773 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2774 | return 0; |
| 2775 | } |
| 2776 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2777 | hdd_ctx->start_modules_in_progress = true; |
| 2778 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2779 | switch (hdd_ctx->driver_status) { |
| 2780 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2781 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2782 | unint = true; |
| 2783 | /* Fall through dont add break here */ |
| 2784 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2785 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2786 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2787 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2788 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | if (!reinit && !unint) { |
| 2790 | ret = pld_power_on(qdf_dev->dev); |
| 2791 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2792 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2793 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2794 | goto release_lock; |
| 2795 | } |
| 2796 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2797 | |
| 2798 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2799 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2800 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2801 | qdf_dev->bus_type, |
| 2802 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2803 | HIF_ENABLE_TYPE_PROBE); |
| 2804 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2805 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2806 | goto power_down; |
| 2807 | } |
| 2808 | |
| 2809 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2810 | if (!hif_ctx) { |
| 2811 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2812 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2813 | goto power_down; |
| 2814 | } |
| 2815 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2816 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2817 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2818 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2819 | status); |
| 2820 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2821 | goto hif_close; |
| 2822 | } |
| 2823 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2824 | hdd_update_ipa_component_config(hdd_ctx); |
| 2825 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2826 | ret = hdd_update_config(hdd_ctx); |
| 2827 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2828 | hdd_err("Failed to update configuration; errno: %d", |
| 2829 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2830 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2831 | } |
| 2832 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2833 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2834 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2835 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2836 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2837 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2838 | ret = qdf_status_to_os_return(status); |
| 2839 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2840 | } |
| 2841 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2842 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2843 | cds_set_rx_thread_cpu_mask( |
| 2844 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2845 | |
| 2846 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2847 | ret = hdd_update_components_config(hdd_ctx); |
| 2848 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2849 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2850 | ret); |
| 2851 | goto close; |
| 2852 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2853 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2854 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2855 | hdd_err("Failed to Open cds post open; status: %d", |
| 2856 | status); |
| 2857 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2858 | goto close; |
| 2859 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2860 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2861 | /* |
| 2862 | * NAN compoenet requires certian operations like, open adapter, |
| 2863 | * close adapter, etc. to be initiated by HDD, for those |
| 2864 | * register HDD callbacks with UMAC's NAN componenet. |
| 2865 | */ |
| 2866 | hdd_nan_register_callbacks(hdd_ctx); |
| 2867 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2868 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2869 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2870 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2871 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2872 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2873 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2874 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2875 | } |
| 2876 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2877 | hdd_register_policy_manager_callback( |
| 2878 | hdd_ctx->hdd_psoc); |
| 2879 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2880 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2881 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2882 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2883 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2884 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2885 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2886 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2887 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2888 | break; |
| 2889 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2890 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2891 | /* Fall through dont add break here */ |
| 2892 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2893 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2894 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2895 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2896 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2897 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2898 | break; |
| 2899 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2900 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2901 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2902 | if (ret) { |
| 2903 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2904 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2905 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2906 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2907 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2908 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2909 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2910 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2911 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2912 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2913 | default: |
| 2914 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2915 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2916 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2917 | goto release_lock; |
| 2918 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2919 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2920 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2921 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2922 | ret = hdd_update_country_code(hdd_ctx); |
| 2923 | if (ret) |
| 2924 | hdd_err("Failed to update command line country code!"); |
| 2925 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2926 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2927 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2928 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2929 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2930 | return 0; |
| 2931 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2932 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2933 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2934 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2935 | cds_txrx_free: |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2936 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 2937 | |
| 2938 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2939 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 2940 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
| 2941 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2942 | } |
| 2943 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2944 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2945 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2946 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2947 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2948 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2949 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2950 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2951 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2952 | deinit_config: |
| 2953 | cds_deinit_ini_config(); |
| 2954 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2955 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2956 | ol_cds_free(); |
| 2957 | |
| 2958 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2959 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2960 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2961 | power_down: |
| 2962 | if (!reinit && !unint) |
| 2963 | pld_power_off(qdf_dev->dev); |
| 2964 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2965 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2966 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 2967 | if (hdd_ctx->target_hw_name) { |
| 2968 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2969 | hdd_ctx->target_hw_name = NULL; |
| 2970 | } |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2971 | /* many adapter resources are not freed by design in SSR case */ |
| 2972 | if (!reinit) |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2973 | hdd_check_for_leaks(hdd_ctx); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2974 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2975 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2976 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2977 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2978 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2979 | } |
| 2980 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2981 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2982 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 2983 | { |
| 2984 | int ret = os_if_wifi_pos_register_nl(); |
| 2985 | |
| 2986 | if (ret) |
| 2987 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 2988 | |
| 2989 | return ret; |
| 2990 | } |
| 2991 | |
| 2992 | static int hdd_deactivate_wifi_pos(void) |
| 2993 | { |
| 2994 | int ret = os_if_wifi_pos_deregister_nl(); |
| 2995 | |
| 2996 | if (ret) |
| 2997 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 2998 | |
| 2999 | return ret; |
| 3000 | } |
| 3001 | |
| 3002 | /** |
| 3003 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3004 | * @hdd_ctx: hdd context |
| 3005 | * |
| 3006 | * Return: status of operation |
| 3007 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3008 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3009 | { |
| 3010 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3011 | struct hdd_config *cfg = hdd_ctx->config; |
| 3012 | |
| 3013 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3014 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3015 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3016 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3017 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3018 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 3019 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 3020 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 3021 | } |
| 3022 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3023 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3024 | { |
| 3025 | return oem_activate_service(hdd_ctx); |
| 3026 | } |
| 3027 | |
| 3028 | static int hdd_deactivate_wifi_pos(void) |
| 3029 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3030 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3031 | } |
| 3032 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3033 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3034 | { |
| 3035 | } |
| 3036 | #endif |
| 3037 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3038 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3039 | * __hdd_open() - HDD Open function |
| 3040 | * @dev: Pointer to net_device structure |
| 3041 | * |
| 3042 | * This is called in response to ifconfig up |
| 3043 | * |
| 3044 | * Return: 0 for success; non-zero for failure |
| 3045 | */ |
| 3046 | static int __hdd_open(struct net_device *dev) |
| 3047 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3048 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3049 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3050 | int ret; |
| 3051 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3052 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3053 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3054 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3055 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3056 | /* Nothing to be done if device is unloading */ |
| 3057 | if (cds_is_driver_unloading()) { |
| 3058 | hdd_err("Driver is unloading can not open the hdd"); |
| 3059 | return -EBUSY; |
| 3060 | } |
| 3061 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3062 | if (cds_is_driver_recovering()) { |
| 3063 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3064 | return -EBUSY; |
| 3065 | } |
| 3066 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3067 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3068 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3069 | return -EBUSY; |
| 3070 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3071 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3072 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3073 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 3074 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3075 | /* |
| 3076 | * This scenario can be hit in cases where in the wlan driver after |
| 3077 | * registering the netdevices and there is a failure in driver |
| 3078 | * initialization. So return error gracefully because the netdevices |
| 3079 | * will be de-registered as part of the load failure. |
| 3080 | */ |
| 3081 | |
| 3082 | if (!cds_is_driver_loaded()) { |
| 3083 | hdd_err("Failed to start the wlan driver!!"); |
| 3084 | ret = -EIO; |
| 3085 | goto err_hdd_hdd_init_deinit_lock; |
| 3086 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3087 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3088 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 3089 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3090 | if (ret) { |
| 3091 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3092 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3093 | } |
| 3094 | |
| 3095 | |
| 3096 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3097 | ret = hdd_start_adapter(adapter); |
| 3098 | if (ret) { |
| 3099 | hdd_err("Failed to start adapter :%d", |
| 3100 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3101 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3102 | } |
| 3103 | } |
| 3104 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3105 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3106 | 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] | 3107 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3108 | /* Enable TX queues only when we are connected */ |
| 3109 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3110 | WLAN_START_ALL_NETIF_QUEUE, |
| 3111 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3112 | } |
| 3113 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3114 | /* Enable carrier and transmit queues for NDI */ |
| 3115 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3116 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3117 | wlan_hdd_netif_queue_control(adapter, |
| 3118 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3119 | WLAN_CONTROL_PATH); |
| 3120 | } |
| 3121 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3122 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3123 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3124 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3125 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3126 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3127 | return ret; |
| 3128 | } |
| 3129 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3130 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3131 | /** |
| 3132 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3133 | * @dev: Pointer to net_device structure |
| 3134 | * |
| 3135 | * This is called in response to ifconfig up |
| 3136 | * |
| 3137 | * Return: 0 for success; non-zero for failure |
| 3138 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3139 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3140 | { |
| 3141 | int ret; |
| 3142 | |
| 3143 | cds_ssr_protect(__func__); |
| 3144 | ret = __hdd_open(dev); |
| 3145 | cds_ssr_unprotect(__func__); |
| 3146 | |
| 3147 | return ret; |
| 3148 | } |
| 3149 | |
| 3150 | /** |
| 3151 | * __hdd_stop() - HDD stop function |
| 3152 | * @dev: Pointer to net_device structure |
| 3153 | * |
| 3154 | * This is called in response to ifconfig down |
| 3155 | * |
| 3156 | * Return: 0 for success; non-zero for failure |
| 3157 | */ |
| 3158 | static int __hdd_stop(struct net_device *dev) |
| 3159 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3160 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3161 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3162 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3163 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3165 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3166 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3167 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3168 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3169 | |
| 3170 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3171 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3172 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3173 | |
| 3174 | /* Nothing to be done if the interface is not opened */ |
| 3175 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3176 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3177 | return -ENODEV; |
| 3178 | } |
| 3179 | |
| 3180 | /* Make sure the interface is marked as closed */ |
| 3181 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3182 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3183 | mac_handle = hdd_ctx->mac_handle; |
| 3184 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3185 | hdd_debug("Disabling Auto Power save timer"); |
| 3186 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3187 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3188 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3189 | |
| 3190 | /* |
| 3191 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3192 | * be called on that interface |
| 3193 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3194 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3195 | hdd_device_mode_to_string(adapter->device_mode), |
| 3196 | adapter->device_mode); |
| 3197 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3198 | wlan_hdd_netif_queue_control(adapter, |
| 3199 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3200 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3201 | |
| 3202 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3203 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3204 | * bursty in nature and depends on the need to transfer. The service |
| 3205 | * layer may down the interface after the usage and up again when |
| 3206 | * required. In some sense, the NDI is expected to be available |
| 3207 | * (like SAP) iface until NDI delete request is issued by the service |
| 3208 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3209 | * interface (NDI). |
| 3210 | */ |
| 3211 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3212 | return 0; |
| 3213 | |
| 3214 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3215 | * The interface is marked as down for outside world (aka kernel) |
| 3216 | * But the driver is pretty much alive inside. The driver needs to |
| 3217 | * tear down the existing connection on the netdev (session) |
| 3218 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3219 | * for this interface. The call also needs to wait until the above |
| 3220 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3221 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3223 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3224 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3225 | |
| 3226 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3227 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3228 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3229 | |
| 3230 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3231 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3232 | * this is the last cli iface, flush the scan database. |
| 3233 | */ |
| 3234 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3235 | sme_scan_flush_result(mac_handle); |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3236 | |
| 3237 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3238 | * Find if any iface is up. If any iface is up then can't put device to |
| 3239 | * sleep/power save mode |
| 3240 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3241 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3242 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3243 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3244 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3245 | hdd_prevent_suspend_timeout( |
| 3246 | hdd_ctx->config->iface_change_wait_time, |
| 3247 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3248 | } |
| 3249 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3250 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | return 0; |
| 3252 | } |
| 3253 | |
| 3254 | /** |
| 3255 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3256 | * @dev: pointer to net_device structure |
| 3257 | * |
| 3258 | * This is called in response to ifconfig down |
| 3259 | * |
| 3260 | * Return: 0 for success and error number for failure |
| 3261 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3262 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3263 | { |
| 3264 | int ret; |
| 3265 | |
| 3266 | cds_ssr_protect(__func__); |
| 3267 | ret = __hdd_stop(dev); |
| 3268 | cds_ssr_unprotect(__func__); |
| 3269 | |
| 3270 | return ret; |
| 3271 | } |
| 3272 | |
| 3273 | /** |
| 3274 | * __hdd_uninit() - HDD uninit function |
| 3275 | * @dev: Pointer to net_device structure |
| 3276 | * |
| 3277 | * This is called during the netdev unregister to uninitialize all data |
| 3278 | * associated with the device |
| 3279 | * |
| 3280 | * Return: None |
| 3281 | */ |
| 3282 | static void __hdd_uninit(struct net_device *dev) |
| 3283 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3284 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3285 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3286 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3287 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3288 | |
| 3289 | do { |
| 3290 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3291 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3292 | break; |
| 3293 | } |
| 3294 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3295 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3296 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3297 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3298 | break; |
| 3299 | } |
| 3300 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3301 | if (dev != adapter->dev) |
| 3302 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3303 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3304 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3305 | |
| 3306 | /* after uninit our adapter structure will no longer be valid */ |
| 3307 | adapter->dev = NULL; |
| 3308 | adapter->magic = 0; |
| 3309 | } while (0); |
| 3310 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3311 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3312 | } |
| 3313 | |
| 3314 | /** |
| 3315 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3316 | * @dev: pointer to net_device structure |
| 3317 | * |
| 3318 | * This is called during the netdev unregister to uninitialize all data |
| 3319 | * associated with the device |
| 3320 | * |
| 3321 | * Return: none |
| 3322 | */ |
| 3323 | static void hdd_uninit(struct net_device *dev) |
| 3324 | { |
| 3325 | cds_ssr_protect(__func__); |
| 3326 | __hdd_uninit(dev); |
| 3327 | cds_ssr_unprotect(__func__); |
| 3328 | } |
| 3329 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3330 | static int hdd_open_cesium_nl_sock(void) |
| 3331 | { |
| 3332 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3333 | struct netlink_kernel_cfg cfg = { |
| 3334 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3335 | .input = NULL |
| 3336 | }; |
| 3337 | #endif |
| 3338 | int ret = 0; |
| 3339 | |
| 3340 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3341 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3342 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3343 | THIS_MODULE, |
| 3344 | #endif |
| 3345 | &cfg); |
| 3346 | #else |
| 3347 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3348 | WLAN_NLINK_MCAST_GRP_ID, |
| 3349 | NULL, NULL, THIS_MODULE); |
| 3350 | #endif |
| 3351 | |
| 3352 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3353 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3354 | ret = -ECONNREFUSED; |
| 3355 | } |
| 3356 | |
| 3357 | return ret; |
| 3358 | } |
| 3359 | |
| 3360 | static void hdd_close_cesium_nl_sock(void) |
| 3361 | { |
| 3362 | if (NULL != cesium_nl_srv_sock) { |
| 3363 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3364 | cesium_nl_srv_sock = NULL; |
| 3365 | } |
| 3366 | } |
| 3367 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3368 | /** |
| 3369 | * __hdd_set_mac_address() - set the user specified mac address |
| 3370 | * @dev: Pointer to the net device. |
| 3371 | * @addr: Pointer to the sockaddr. |
| 3372 | * |
| 3373 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3374 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3375 | * |
| 3376 | * Return: 0 for success, non zero for failure |
| 3377 | */ |
| 3378 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3379 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3380 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3381 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3382 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3383 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3384 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3385 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3386 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3387 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3388 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3389 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3390 | if (netif_running(dev)) { |
| 3391 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3392 | return -EBUSY; |
| 3393 | } |
| 3394 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3395 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3396 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3397 | if (0 != ret) |
| 3398 | return ret; |
| 3399 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3400 | qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3401 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3402 | if (adapter_temp) { |
| 3403 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3404 | return 0; |
| 3405 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3406 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3407 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3408 | return -EINVAL; |
| 3409 | } |
| 3410 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3411 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3412 | hdd_err("MAC is all zero"); |
| 3413 | return -EINVAL; |
| 3414 | } |
| 3415 | |
| 3416 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3417 | hdd_err("MAC is Broadcast"); |
| 3418 | return -EINVAL; |
| 3419 | } |
| 3420 | |
| 3421 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3422 | hdd_err("MAC is Multicast"); |
| 3423 | return -EINVAL; |
| 3424 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3425 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3426 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3427 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3428 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3429 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3430 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3431 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3432 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3433 | } |
| 3434 | |
| 3435 | /** |
| 3436 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3437 | * function from SSR |
| 3438 | * @dev: pointer to net_device structure |
| 3439 | * @addr: Pointer to the sockaddr |
| 3440 | * |
| 3441 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3442 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3443 | * |
| 3444 | * Return: 0 for success. |
| 3445 | */ |
| 3446 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3447 | { |
| 3448 | int ret; |
| 3449 | |
| 3450 | cds_ssr_protect(__func__); |
| 3451 | ret = __hdd_set_mac_address(dev, addr); |
| 3452 | cds_ssr_unprotect(__func__); |
| 3453 | |
| 3454 | return ret; |
| 3455 | } |
| 3456 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3457 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3458 | { |
| 3459 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3460 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3461 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3462 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3463 | break; |
| 3464 | } |
| 3465 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3466 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3467 | return NULL; |
| 3468 | |
| 3469 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3470 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3471 | } |
| 3472 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3473 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3474 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3475 | { |
| 3476 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3477 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3478 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | if (!memcmp(releaseAddr, |
| 3480 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3481 | 6)) { |
| 3482 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3483 | break; |
| 3484 | } |
| 3485 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3486 | } |
| 3487 | |
| 3488 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3489 | /** |
| 3490 | * __hdd_set_multicast_list() - set the multicast address list |
| 3491 | * @dev: Pointer to the WLAN device. |
| 3492 | * @skb: Pointer to OS packet (sk_buff). |
| 3493 | * |
| 3494 | * This funciton sets the multicast address list. |
| 3495 | * |
| 3496 | * Return: None |
| 3497 | */ |
| 3498 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3499 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3500 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3501 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3502 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3503 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3504 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3505 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3506 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3507 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3508 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3509 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3510 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3511 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3512 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3513 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3514 | goto out; |
| 3515 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3516 | errno = hdd_validate_adapter(adapter); |
| 3517 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3518 | goto out; |
| 3519 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3520 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3521 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3522 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3523 | } |
| 3524 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3525 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3526 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3527 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3528 | goto out; |
| 3529 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3530 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3531 | /* Delete already configured multicast address list */ |
| 3532 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3533 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3534 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3535 | pmo_mc_list_change_notify); |
| 3536 | } |
| 3537 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3539 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3540 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3541 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3542 | } else { |
| 3543 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3544 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3545 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3546 | pmo_ucfg_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3547 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3548 | pmo_mc_list_change_notify); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3549 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3550 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3551 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3552 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3553 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3554 | if (i == mc_count) |
| 3555 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3556 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3557 | 0, ETH_ALEN); |
| 3558 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3559 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3560 | hdd_debug("mlist[%d] = %pM", i, |
| 3561 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3562 | i++; |
| 3563 | } |
| 3564 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3565 | |
| 3566 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3567 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3568 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3569 | |
| 3570 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3571 | if (errno) { |
| 3572 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3573 | adapter->session_id, errno); |
| 3574 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3575 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3576 | |
| 3577 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3578 | |
| 3579 | free_req: |
| 3580 | qdf_mem_free(mc_list_request); |
| 3581 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3582 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3583 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3584 | } |
| 3585 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3586 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | /** |
| 3588 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3589 | * @dev: pointer to net_device |
| 3590 | * |
| 3591 | * Return: none |
| 3592 | */ |
| 3593 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3594 | { |
| 3595 | cds_ssr_protect(__func__); |
| 3596 | __hdd_set_multicast_list(dev); |
| 3597 | cds_ssr_unprotect(__func__); |
| 3598 | } |
| 3599 | #endif |
| 3600 | |
| 3601 | /** |
| 3602 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3603 | * @dev: Pointer to the WLAN device. |
| 3604 | * @skb: Pointer to OS packet (sk_buff). |
| 3605 | * |
| 3606 | * This function is registered with the Linux OS for network |
| 3607 | * core to decide which queue to use first. |
| 3608 | * |
| 3609 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3610 | */ |
| 3611 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3612 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3613 | , void *accel_priv |
| 3614 | #endif |
| 3615 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3616 | , select_queue_fallback_t fallback |
| 3617 | #endif |
| 3618 | ) |
| 3619 | { |
| 3620 | return hdd_wmm_select_queue(dev, skb); |
| 3621 | } |
| 3622 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3623 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3624 | .ndo_open = hdd_open, |
| 3625 | .ndo_stop = hdd_stop, |
| 3626 | .ndo_uninit = hdd_uninit, |
| 3627 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3628 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3629 | .ndo_get_stats = hdd_get_stats, |
| 3630 | .ndo_do_ioctl = hdd_ioctl, |
| 3631 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3632 | .ndo_select_queue = hdd_select_queue, |
| 3633 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3634 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | #endif |
| 3636 | }; |
| 3637 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3638 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3639 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3640 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3641 | .ndo_open = hdd_mon_open, |
| 3642 | .ndo_stop = hdd_stop, |
| 3643 | .ndo_get_stats = hdd_get_stats, |
| 3644 | }; |
| 3645 | |
| 3646 | /** |
| 3647 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3648 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3649 | * Return: None |
| 3650 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3651 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3652 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3653 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3654 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3655 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3656 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3657 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3658 | #else |
| 3659 | void hdd_set_station_ops(struct net_device *dev) |
| 3660 | { |
| 3661 | dev->netdev_ops = &wlan_drv_ops; |
| 3662 | } |
| 3663 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3664 | |
| 3665 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3666 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3667 | * @hdd_ctx: global hdd context |
| 3668 | * @macAddr: mac address to assign to the interface |
| 3669 | * @name: User-visible name of the interface |
| 3670 | * |
| 3671 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3672 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3673 | * |
| 3674 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3675 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3676 | 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] | 3677 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3678 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3679 | const char *name) |
| 3680 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3681 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3682 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3683 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3684 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3685 | /* |
| 3686 | * cfg80211 initialization and registration.... |
| 3687 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3688 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3689 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3690 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3691 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3692 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3693 | hdd_mon_mode_ether_setup : ether_setup), |
| 3694 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3695 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3696 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | |
| 3698 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3699 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3700 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3701 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3702 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3703 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3704 | sizeof(sta_ctx->conn_info.staId), |
| 3705 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3706 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3707 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3708 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3709 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3710 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3711 | qdf_status = qdf_event_create( |
| 3712 | &adapter->qdf_session_open_event); |
| 3713 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3714 | hdd_err("Session open QDF event init failed!"); |
| 3715 | free_netdev(adapter->dev); |
| 3716 | return NULL; |
| 3717 | } |
| 3718 | |
| 3719 | qdf_status = qdf_event_create( |
| 3720 | &adapter->qdf_session_close_event); |
| 3721 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3722 | hdd_err("Session close QDF event init failed!"); |
| 3723 | free_netdev(adapter->dev); |
| 3724 | return NULL; |
| 3725 | } |
| 3726 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3728 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3729 | init_completion(&adapter->linkup_event_var); |
| 3730 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3731 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3732 | init_completion(&adapter->sta_authorized_event); |
| 3733 | init_completion(&adapter->offchannel_tx_event); |
| 3734 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3735 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3736 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | |
| 3738 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3739 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3740 | adapter->disconnection_in_progress = false; |
Yeshwanth Sriram Guntuka | 4fe30bd | 2018-06-13 11:41:42 +0530 | [diff] [blame] | 3741 | adapter->send_mode_change = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3742 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3743 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3744 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3745 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3746 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3747 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3748 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3749 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | |
| 3751 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3752 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3753 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3754 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3755 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3756 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3757 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3758 | hdd_set_station_ops(adapter->dev); |
| 3759 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3760 | hdd_dev_setup_destructor(dev); |
| 3761 | dev->ieee80211_ptr = &adapter->wdev; |
| 3762 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3763 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3764 | adapter->wdev.netdev = dev; |
| 3765 | /* set dev's parent to underlying device */ |
| 3766 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3767 | hdd_wmm_init(adapter); |
| 3768 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3769 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3770 | } |
| 3771 | |
| 3772 | return adapter; |
| 3773 | } |
| 3774 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3775 | 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] | 3776 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3777 | struct net_device *dev = adapter->dev; |
| 3778 | int ret; |
| 3779 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3780 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3781 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3782 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3783 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3784 | |
| 3785 | ret = dev_alloc_name(dev, dev->name); |
| 3786 | if (ret < 0) { |
| 3787 | hdd_err( |
| 3788 | "unable to get dev name: %s, err = 0x%x", |
| 3789 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3790 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3791 | } |
| 3792 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3793 | |
| 3794 | ret = register_netdevice(dev); |
| 3795 | if (ret) { |
| 3796 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3797 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3798 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | } |
| 3800 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3801 | ret = register_netdev(dev); |
| 3802 | if (ret) { |
| 3803 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3804 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3805 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | } |
| 3807 | } |
| 3808 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3809 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3810 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3811 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3812 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3813 | } |
| 3814 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3815 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3816 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3817 | struct hdd_adapter *adapter; |
| 3818 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3819 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3820 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3821 | if (!hdd_ctx) { |
| 3822 | hdd_err("Invalid HDD_CTX"); |
| 3823 | return QDF_STATUS_E_FAILURE; |
| 3824 | } |
| 3825 | |
| 3826 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3827 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3828 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3829 | return QDF_STATUS_E_INVAL; |
| 3830 | } |
| 3831 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3832 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3833 | hdd_debug("session %d opened", adapter->session_id); |
| 3834 | |
| 3835 | return QDF_STATUS_SUCCESS; |
| 3836 | } |
| 3837 | |
| 3838 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3839 | { |
| 3840 | struct hdd_adapter *adapter; |
| 3841 | struct hdd_context *hdd_ctx; |
| 3842 | |
| 3843 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3844 | if (!hdd_ctx) { |
| 3845 | hdd_err("Invalid HDD_CTX"); |
| 3846 | return QDF_STATUS_E_FAILURE; |
| 3847 | } |
| 3848 | |
| 3849 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3850 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3851 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3852 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3853 | } |
| 3854 | |
| 3855 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3856 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3857 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3858 | } |
| 3859 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3860 | /* |
| 3861 | * For NAN Data interface, the close session results in the final |
| 3862 | * indication to the userspace |
| 3863 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3864 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3865 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3867 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3868 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3869 | /* |
| 3870 | * We can be blocked while waiting for scheduled work to be |
| 3871 | * flushed, and the adapter structure can potentially be freed, in |
| 3872 | * which case the magic will have been reset. So make sure the |
| 3873 | * magic is still good, and hence the adapter structure is still |
| 3874 | * valid, before signaling completion |
| 3875 | */ |
| 3876 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3877 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3878 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3879 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3880 | } |
| 3881 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3882 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3883 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3884 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3885 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3886 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3887 | if (QDF_IS_STATUS_ERROR(status)) |
| 3888 | return qdf_status_to_os_return(status); |
| 3889 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3890 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3891 | if (QDF_IS_STATUS_ERROR(status)) |
| 3892 | return qdf_status_to_os_return(status); |
| 3893 | |
| 3894 | if (wma_capability_enhanced_mcast_filter()) |
| 3895 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3896 | else |
| 3897 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3898 | |
| 3899 | return qdf_status_to_os_return(status); |
| 3900 | } |
| 3901 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3902 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3903 | { |
| 3904 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3905 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3906 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3907 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3908 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3909 | vdev_id = adapter->session_id; |
| 3910 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3911 | |
| 3912 | /* vdev created sanity check */ |
| 3913 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3914 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3915 | return -EINVAL; |
| 3916 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3917 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 3918 | ucfg_scan_set_vdev_del_in_progress(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3919 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3920 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3921 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3922 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3923 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3924 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3925 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3926 | errno = qdf_status_to_os_return(status); |
| 3927 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3928 | } |
| 3929 | |
| 3930 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3931 | status = qdf_wait_for_event_completion( |
| 3932 | &adapter->qdf_session_close_event, |
| 3933 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3934 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3935 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3936 | hdd_ndp_session_end_handler(adapter); |
| 3937 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3938 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3939 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3940 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3941 | errno = -ETIMEDOUT; |
| 3942 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3943 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3944 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3945 | errno = -EINVAL; |
| 3946 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3947 | } else { |
| 3948 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3949 | errno = -EINVAL; |
| 3950 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3951 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3952 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3953 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3954 | release_vdev: |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 3955 | ucfg_scan_clear_vdev_del_in_progress(adapter->hdd_vdev); |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3956 | /* |
| 3957 | * In SSR or driver unloading case, directly exit may cause objects |
| 3958 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3959 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3960 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3961 | return errno; |
| 3962 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3963 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3964 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3965 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 3966 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3967 | return errno; |
| 3968 | } |
| 3969 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3970 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3971 | |
| 3972 | return 0; |
| 3973 | } |
| 3974 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3975 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 3976 | struct sme_session_params *session_param, |
| 3977 | csr_roam_completeCallback callback, |
| 3978 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3979 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3980 | uint32_t type; |
| 3981 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3982 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3983 | |
| 3984 | /* determine vdev (sub)type */ |
| 3985 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3986 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3987 | hdd_err("failed to get vdev type: %d", status); |
| 3988 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3989 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3990 | session_param->sme_session_id = adapter->session_id; |
| 3991 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 3992 | session_param->type_of_persona = type; |
| 3993 | session_param->subtype_of_persona = sub_type; |
| 3994 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 3995 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 3996 | session_param->callback = callback; |
| 3997 | session_param->callback_ctx = callback_ctx; |
| 3998 | |
| 3999 | return 0; |
| 4000 | } |
| 4001 | |
| 4002 | int hdd_vdev_create(struct hdd_adapter *adapter, |
| 4003 | csr_roam_completeCallback callback, void *ctx) |
| 4004 | { |
| 4005 | QDF_STATUS status; |
| 4006 | int errno; |
| 4007 | struct hdd_context *hdd_ctx; |
| 4008 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4009 | |
| 4010 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4011 | |
| 4012 | /* do vdev create via objmgr */ |
| 4013 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4014 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4015 | if (errno) { |
| 4016 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4017 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4018 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4019 | |
| 4020 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4021 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4022 | if (QDF_STATUS_SUCCESS != status) { |
| 4023 | hdd_err("failed to reinit session open event"); |
| 4024 | return -EINVAL; |
| 4025 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4026 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4027 | callback, ctx); |
| 4028 | if (errno) { |
| 4029 | hdd_err("failed to populating SME params"); |
| 4030 | goto objmgr_vdev_destroy_procedure; |
| 4031 | } |
| 4032 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4033 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4034 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4035 | hdd_err("failed to open sme session: %d", status); |
| 4036 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4037 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4041 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 4042 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 4043 | if (QDF_STATUS_SUCCESS != status) { |
| 4044 | if (adapter->qdf_session_open_event.force_set) { |
| 4045 | /* |
| 4046 | * SSR/PDR has caused shutdown, which has forcefully |
| 4047 | * set the event. Return without the closing session. |
| 4048 | */ |
| 4049 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4050 | hdd_err("Session open event forcefully set"); |
| 4051 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4052 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4053 | |
| 4054 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4055 | hdd_err("Session failed to open within timeout period"); |
| 4056 | else |
| 4057 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4058 | status); |
| 4059 | errno = -ETIMEDOUT; |
| 4060 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4061 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4062 | } |
| 4063 | |
| 4064 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4065 | errno = hdd_vdev_ready(adapter); |
| 4066 | if (errno) { |
| 4067 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4068 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4069 | } |
| 4070 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4071 | if (adapter->device_mode == QDF_STA_MODE) { |
| 4072 | hdd_debug("setting RTT mac randomization param: %d", |
| 4073 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 4074 | errno = sme_cli_set_command(adapter->session_id, |
| 4075 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 4076 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 4077 | VDEV_CMD); |
| 4078 | if (0 != errno) |
| 4079 | hdd_err("RTT mac randomization param set failed %d", |
| 4080 | errno); |
| 4081 | } |
| 4082 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4083 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4084 | |
| 4085 | return 0; |
| 4086 | |
| 4087 | /* |
| 4088 | * Due to legacy constraints, we need to destroy in the same order as |
| 4089 | * create. So, split error handling into 2 cases to accommodate. |
| 4090 | */ |
| 4091 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4092 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4093 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4094 | |
| 4095 | return errno; |
| 4096 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4097 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4098 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4099 | |
| 4100 | return errno; |
| 4101 | } |
| 4102 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4103 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4104 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4105 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4106 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4107 | QDF_STATUS status; |
| 4108 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4109 | mac_handle_t mac_handle; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4110 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4111 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4112 | mac_handle = hdd_ctx->mac_handle; |
| 4113 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
| 4114 | sme_set_pdev_ht_vht_ies(mac_handle, hdd_ctx->config->enable2x2); |
| 4115 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4116 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4117 | hdd_roam_profile_init(adapter); |
| 4118 | hdd_register_wext(adapter->dev); |
| 4119 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4120 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4121 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4122 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4123 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4124 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4125 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4126 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4127 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4128 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4129 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4130 | hdd_ctx->config->OperatingChannel; |
| 4131 | |
| 4132 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4133 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4134 | |
| 4135 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4136 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4137 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4138 | status, status); |
| 4139 | goto error_init_txrx; |
| 4140 | } |
| 4141 | |
| 4142 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4143 | |
| 4144 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4145 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4146 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4147 | status, status); |
| 4148 | goto error_wmm_init; |
| 4149 | } |
| 4150 | |
| 4151 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4152 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4153 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4154 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4155 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4156 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4157 | if (ret_val) |
| 4158 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4159 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4160 | /* |
| 4161 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4162 | * during that time, then as part of SSR init, do not enable |
| 4163 | * the LRO again. Keep the LRO state same as before SSR. |
| 4164 | */ |
| 4165 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4166 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4167 | |
| 4168 | /* rcpi info initialization */ |
| 4169 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4170 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4171 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4172 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4173 | error_wmm_init: |
| 4174 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4175 | hdd_deinit_tx_rx(adapter); |
| 4176 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4177 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4178 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4180 | return status; |
| 4181 | } |
| 4182 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4183 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4184 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4185 | * @hdd_ctx: global hdd context |
| 4186 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4187 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4188 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4189 | * |
| 4190 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4191 | * |
| 4192 | * Return: None. |
| 4193 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4194 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4195 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4196 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4197 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4198 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4199 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4200 | if (adapter->dev) { |
| 4201 | if (rtnl_held) |
| 4202 | adapter->dev->wireless_handlers = NULL; |
| 4203 | else { |
| 4204 | rtnl_lock(); |
| 4205 | adapter->dev->wireless_handlers = NULL; |
| 4206 | rtnl_unlock(); |
| 4207 | } |
| 4208 | } |
| 4209 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4210 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4211 | hdd_deinit_tx_rx(adapter); |
| 4212 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4213 | } |
| 4214 | |
| 4215 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4216 | hdd_wmm_adapter_close(adapter); |
| 4217 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4218 | } |
| 4219 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4220 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4221 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4222 | } |
| 4223 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4224 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4225 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4226 | bool rtnl_held) |
| 4227 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4228 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4229 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4230 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4231 | case QDF_STA_MODE: |
| 4232 | case QDF_P2P_CLIENT_MODE: |
| 4233 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4234 | case QDF_IBSS_MODE: |
| 4235 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4236 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4237 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4238 | break; |
| 4239 | } |
| 4240 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4241 | case QDF_SAP_MODE: |
| 4242 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4243 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4244 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4245 | break; |
| 4246 | } |
| 4247 | |
| 4248 | default: |
| 4249 | break; |
| 4250 | } |
| 4251 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4252 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4253 | } |
| 4254 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4255 | 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] | 4256 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4257 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4258 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4259 | |
| 4260 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4261 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4262 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4263 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4264 | return; |
| 4265 | } |
| 4266 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4267 | hdd_nud_deinit_tracking(adapter); |
| 4268 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
| 4269 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4270 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4271 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4272 | /* |
| 4273 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4274 | * the driver is almost closed and cannot handle either control |
| 4275 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4276 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4277 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4278 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4279 | * the interface is closed and restricts any operations on that |
| 4280 | */ |
| 4281 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4282 | |
| 4283 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4284 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4285 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4286 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4287 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4288 | /* |
| 4289 | * Note that the adapter is no longer valid at this point |
| 4290 | * since the memory has been reclaimed |
| 4291 | */ |
| 4292 | } |
| 4293 | } |
| 4294 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4295 | 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] | 4296 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4297 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4298 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4299 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4300 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4301 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4302 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4303 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4304 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4306 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4307 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4308 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4309 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4310 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4311 | /** |
| 4312 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4313 | * @hdd_ctx: HDD Context |
| 4314 | * @adapter: HDD Adapter |
| 4315 | * |
| 4316 | * This function set the FW Debug log level based on the INI. |
| 4317 | * |
| 4318 | * Return: None |
| 4319 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4320 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4321 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4322 | { |
| 4323 | uint8_t count = 0, numentries = 0, |
| 4324 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4325 | uint32_t value = 0; |
| 4326 | int ret; |
| 4327 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4328 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4329 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4330 | 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] | 4331 | return; |
| 4332 | } |
| 4333 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4334 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4335 | hdd_ctx->fw_log_settings.dl_type = |
| 4336 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4337 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4338 | WMI_DBGLOG_TYPE, |
| 4339 | hdd_ctx->config->enableFwLogType, |
| 4340 | DBG_CMD); |
| 4341 | if (ret != 0) |
| 4342 | hdd_err("Failed to enable FW log type ret %d", |
| 4343 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4344 | |
| 4345 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4346 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4347 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4348 | WMI_DBGLOG_LOG_LEVEL, |
| 4349 | hdd_ctx->config->enableFwLogLevel, |
| 4350 | DBG_CMD); |
| 4351 | if (ret != 0) |
| 4352 | hdd_err("Failed to enable FW log level ret %d", |
| 4353 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4354 | |
| 4355 | hdd_string_to_u8_array( |
| 4356 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4357 | moduleloglevel, |
| 4358 | &numentries, |
| 4359 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4360 | |
| 4361 | while (count < numentries) { |
| 4362 | /* |
| 4363 | * FW module log level input string looks like |
| 4364 | * below: |
| 4365 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4366 | * <Log Level>,... |
| 4367 | * For example: |
| 4368 | * gFwDebugModuleLoglevel= |
| 4369 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4370 | * Above input string means : |
| 4371 | * For FW module ID 1 enable log level 0 |
| 4372 | * For FW module ID 2 enable log level 1 |
| 4373 | * For FW module ID 3 enable log level 2 |
| 4374 | * For FW module ID 4 enable log level 3 |
| 4375 | * For FW module ID 5 enable log level 4 |
| 4376 | * For FW module ID 6 enable log level 5 |
| 4377 | * For FW module ID 7 enable log level 6 |
| 4378 | */ |
| 4379 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4380 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4381 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4382 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4383 | moduleloglevel[count], |
| 4384 | moduleloglevel[count + 1]); |
| 4385 | return; |
| 4386 | } |
| 4387 | |
| 4388 | value = moduleloglevel[count] << 16; |
| 4389 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4390 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4391 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4392 | value, DBG_CMD); |
| 4393 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4394 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4395 | value, ret); |
| 4396 | |
| 4397 | count += 2; |
| 4398 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4399 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4400 | } |
| 4401 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4402 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4403 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4404 | { |
| 4405 | } |
| 4406 | |
| 4407 | #endif |
| 4408 | |
| 4409 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4410 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4411 | * @adapter: HDD adapter |
| 4412 | * |
| 4413 | * Return: 0 on success or errno on failure |
| 4414 | */ |
| 4415 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4416 | { |
| 4417 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4418 | QDF_STATUS status; |
| 4419 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4420 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4421 | |
| 4422 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4423 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4424 | hdd_ctx->config->txchainmask1x1, |
| 4425 | hdd_ctx->config->rxchainmask1x1); |
| 4426 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4427 | hdd_ctx->config->dual_mac_feature_disable, |
| 4428 | hdd_ctx->config->tx_chain_mask_2g, |
| 4429 | hdd_ctx->config->rx_chain_mask_2g); |
| 4430 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4431 | hdd_ctx->config->tx_chain_mask_5g, |
| 4432 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4433 | hdd_debug("enable_bt_chain_separation %d", |
| 4434 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4435 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4436 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4437 | HW_MODE_DBS_NONE, |
| 4438 | CDS_BAND_ALL); |
| 4439 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4440 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4441 | return qdf_status_to_os_return(status); |
| 4442 | } |
| 4443 | |
| 4444 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4445 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4446 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4447 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
| 4448 | hdd_info("firmware not capable. skip chain mask programming"); |
| 4449 | return 0; |
| 4450 | } |
| 4451 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4452 | if (hdd_ctx->config->enable2x2 && |
| 4453 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4454 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4455 | return 0; |
| 4456 | } |
| 4457 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4458 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4459 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4460 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4461 | hdd_ctx->config->dual_mac_feature_disable); |
| 4462 | return 0; |
| 4463 | } |
| 4464 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4465 | if (hdd_ctx->lte_coex_ant_share) { |
| 4466 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4467 | return 0; |
| 4468 | } |
| 4469 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4470 | if (hdd_ctx->config->txchainmask1x1) { |
| 4471 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4472 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4473 | hdd_ctx->config->txchainmask1x1, |
| 4474 | PDEV_CMD); |
| 4475 | if (ret_val) |
| 4476 | goto error; |
| 4477 | } |
| 4478 | |
| 4479 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4480 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4481 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4482 | hdd_ctx->config->rxchainmask1x1, |
| 4483 | PDEV_CMD); |
| 4484 | if (ret_val) |
| 4485 | goto error; |
| 4486 | } |
| 4487 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4488 | if (hdd_ctx->config->txchainmask1x1 || |
| 4489 | hdd_ctx->config->rxchainmask1x1) { |
| 4490 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4491 | return 0; |
| 4492 | } |
| 4493 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4494 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4495 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4496 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4497 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4498 | if (0 != ret_val) |
| 4499 | goto error; |
| 4500 | } |
| 4501 | |
| 4502 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4503 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4504 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4505 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4506 | if (0 != ret_val) |
| 4507 | goto error; |
| 4508 | } |
| 4509 | |
| 4510 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4511 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4512 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4513 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4514 | if (0 != ret_val) |
| 4515 | goto error; |
| 4516 | } |
| 4517 | |
| 4518 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4519 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4520 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4521 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4522 | if (0 != ret_val) |
| 4523 | goto error; |
| 4524 | } |
| 4525 | |
| 4526 | return 0; |
| 4527 | |
| 4528 | error: |
| 4529 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4530 | return -EINVAL; |
| 4531 | } |
| 4532 | |
| 4533 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4534 | * hdd_set_fw_params() - Set parameters to firmware |
| 4535 | * @adapter: HDD adapter |
| 4536 | * |
| 4537 | * This function Sets various parameters to fw once the |
| 4538 | * adapter is started. |
| 4539 | * |
| 4540 | * Return: 0 on success or errno on failure |
| 4541 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4542 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4543 | { |
| 4544 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4545 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4546 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4547 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4548 | |
| 4549 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4550 | if (!hdd_ctx) |
| 4551 | return -EINVAL; |
| 4552 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4553 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4554 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4555 | return 0; |
| 4556 | } |
| 4557 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4558 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4559 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4560 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4561 | if (ret) { |
| 4562 | hdd_err("Failed to set LPRx"); |
| 4563 | goto error; |
| 4564 | } |
| 4565 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4566 | |
| 4567 | ret = sme_cli_set_command( |
| 4568 | adapter->session_id, |
| 4569 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4570 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4571 | PDEV_CMD); |
| 4572 | if (ret) { |
| 4573 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4574 | goto error; |
| 4575 | } |
| 4576 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4577 | ret = sme_cli_set_command( |
| 4578 | adapter->session_id, |
| 4579 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4580 | hdd_ctx->config->enable_tx_sch_delay, |
| 4581 | PDEV_CMD); |
| 4582 | if (ret) { |
| 4583 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4584 | goto error; |
| 4585 | } |
| 4586 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4587 | ret = sme_cli_set_command( |
| 4588 | adapter->session_id, |
| 4589 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4590 | hdd_ctx->config->enable_secondary_rate, |
| 4591 | PDEV_CMD); |
| 4592 | if (ret) { |
| 4593 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4594 | goto error; |
| 4595 | } |
| 4596 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4597 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4598 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4599 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4600 | hdd_ctx->config->upper_brssi_thresh); |
| 4601 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4602 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4603 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4604 | hdd_ctx->config->lower_brssi_thresh); |
| 4605 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4606 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4607 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4608 | hdd_ctx->config->enable_dtim_1chrx); |
| 4609 | } |
| 4610 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4611 | if (hdd_ctx->config->enable2x2) { |
| 4612 | hdd_debug("configuring 2x2 mode fw params"); |
| 4613 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4614 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4615 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4616 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4617 | PDEV_CMD); |
| 4618 | if (ret) { |
| 4619 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4620 | ret); |
| 4621 | goto error; |
| 4622 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4623 | |
| 4624 | if (hdd_configure_chain_mask(adapter)) |
| 4625 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4626 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4627 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4628 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4629 | hdd_debug("configuring 1x1 mode fw params"); |
| 4630 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4631 | /* |
| 4632 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4633 | * we are passing two value |
| 4634 | * as param_id << 29 | param_value. |
| 4635 | * Below param_value = 0(disable) |
| 4636 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4637 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4638 | WMI_STA_SMPS_PARAM_CMDID, |
| 4639 | HDD_DTIM_1CHAIN_RX_ID << |
| 4640 | HDD_SMPS_PARAM_VALUE_S, |
| 4641 | VDEV_CMD); |
| 4642 | if (ret) { |
| 4643 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4644 | goto error; |
| 4645 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4646 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4647 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4648 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4649 | |
| 4650 | if (hdd_configure_chain_mask(adapter)) |
| 4651 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4652 | } |
| 4653 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4654 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4655 | WMI_PDEV_PARAM_HYST_EN, |
| 4656 | hdd_ctx->config->enableMemDeepSleep, |
| 4657 | PDEV_CMD); |
| 4658 | if (ret) { |
| 4659 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4660 | goto error; |
| 4661 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4662 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4663 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4664 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4665 | hdd_ctx->config->rts_profile, |
| 4666 | VDEV_CMD); |
| 4667 | if (ret) { |
| 4668 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4669 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4670 | } |
| 4671 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4672 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4673 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4674 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4675 | GEN_VDEV_PARAM_AMSDU, |
| 4676 | hdd_ctx->config->max_amsdu_num, |
| 4677 | GEN_CMD); |
| 4678 | if (ret != 0) { |
| 4679 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4680 | goto error; |
| 4681 | } |
| 4682 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4683 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4684 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4685 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4686 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4687 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4688 | error: |
| 4689 | return -EINVAL; |
| 4690 | } |
| 4691 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4692 | /** |
| 4693 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4694 | * @hdd_ctx: global hdd context |
| 4695 | * @session_type: type of the interface to be created |
| 4696 | * @iface_name: User-visible name of the interface |
| 4697 | * @macAddr: MAC address to assign to the interface |
| 4698 | * @name_assign_type: the name of assign type of the netdev |
| 4699 | * @rtnl_held: the rtnl lock hold flag |
| 4700 | * |
| 4701 | * This function open and setup the hdd adpater according to the device |
| 4702 | * type request, assign the name, the mac address assigned, and then prepared |
| 4703 | * the hdd related parameters, queue, lock and ready to start. |
| 4704 | * |
| 4705 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4706 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4707 | 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] | 4708 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4709 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4710 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4711 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4712 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4713 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4714 | |
| 4715 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4716 | /* |
| 4717 | * Max limit reached on the number of vdevs configured by the |
| 4718 | * host. Return error |
| 4719 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4720 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4721 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4722 | return NULL; |
| 4723 | } |
| 4724 | |
| 4725 | if (macAddr == NULL) { |
| 4726 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4727 | 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] | 4728 | return NULL; |
| 4729 | } |
| 4730 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4731 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4732 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4733 | " already exists", |
| 4734 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4735 | return NULL; |
| 4736 | } |
| 4737 | |
| 4738 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4739 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4740 | /* Reset locally administered bit if the device mode is STA */ |
| 4741 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4742 | hdd_info("locally administered bit reset in sta mode: " |
| 4743 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4744 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4745 | case QDF_P2P_CLIENT_MODE: |
| 4746 | case QDF_P2P_DEVICE_MODE: |
| 4747 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4748 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4749 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4750 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4751 | name_assign_type, |
| 4752 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | |
| 4754 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4755 | hdd_err("failed to allocate adapter for session %d", |
| 4756 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4757 | return NULL; |
| 4758 | } |
| 4759 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4760 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4761 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4762 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4763 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4764 | else if (QDF_MONITOR_MODE == session_type) |
| 4765 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4766 | else |
| 4767 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4768 | |
| 4769 | adapter->device_mode = session_type; |
| 4770 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4771 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4772 | /* |
| 4773 | * Workqueue which gets scheduled in IPv4 notification |
| 4774 | * callback |
| 4775 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4776 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4778 | |
| 4779 | #ifdef WLAN_NS_OFFLOAD |
| 4780 | /* |
| 4781 | * Workqueue which gets scheduled in IPv6 |
| 4782 | * notification callback. |
| 4783 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4784 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4785 | hdd_ipv6_notifier_work_queue); |
| 4786 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4787 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4788 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4789 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4790 | |
| 4791 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4792 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4793 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4794 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4795 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4796 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4797 | hdd_nud_init_tracking(adapter); |
| 4798 | |
| 4799 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4800 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4801 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4802 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4803 | case QDF_P2P_GO_MODE: |
| 4804 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4805 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4806 | name_assign_type, |
| 4807 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4809 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4810 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4811 | return NULL; |
| 4812 | } |
| 4813 | |
| 4814 | adapter->wdev.iftype = |
| 4815 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4816 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4817 | NL80211_IFTYPE_P2P_GO; |
| 4818 | adapter->device_mode = session_type; |
| 4819 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4820 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4821 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4822 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4823 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4824 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4825 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4826 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4827 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4828 | |
| 4829 | /* |
| 4830 | * Workqueue which gets scheduled in IPv4 notification |
| 4831 | * callback |
| 4832 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4833 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4834 | hdd_ipv4_notifier_work_queue); |
| 4835 | |
| 4836 | #ifdef WLAN_NS_OFFLOAD |
| 4837 | /* |
| 4838 | * Workqueue which gets scheduled in IPv6 |
| 4839 | * notification callback. |
| 4840 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4841 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4842 | hdd_ipv6_notifier_work_queue); |
| 4843 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4845 | case QDF_FTM_MODE: |
| 4846 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4847 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4848 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4849 | if (NULL == adapter) { |
| 4850 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4851 | return NULL; |
| 4852 | } |
| 4853 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4854 | adapter->device_mode = session_type; |
| 4855 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4856 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4857 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4858 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4859 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4860 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4861 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4862 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4863 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4864 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4865 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4866 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4867 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4868 | return NULL; |
| 4869 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4870 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4871 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 4872 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 4873 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4874 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4875 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4876 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4877 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4878 | } |
| 4879 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4880 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4881 | if (NULL != adapter) { |
| 4882 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4883 | adapter = NULL; |
| 4884 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4885 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4886 | return NULL; |
| 4887 | } |
| 4888 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4889 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4890 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4891 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4892 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4893 | /* Adapter successfully added. Increment the vdev count */ |
| 4894 | hdd_ctx->current_intf_count++; |
| 4895 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4896 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4897 | hdd_ctx->current_intf_count); |
| 4898 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4899 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4900 | } |
| 4901 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4902 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4903 | hdd_err("Interface %s wow debug_fs init failed", |
| 4904 | netdev_name(adapter->dev)); |
| 4905 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 4906 | hdd_register_hl_netdev_fc_timer(adapter, |
| 4907 | hdd_tx_resume_timer_expired_handler); |
| 4908 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4909 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4910 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4911 | |
| 4912 | return adapter; |
| 4913 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4914 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4915 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4916 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4917 | |
| 4918 | return NULL; |
| 4919 | } |
| 4920 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4921 | #ifdef MSM_PLATFORM |
| 4922 | static inline |
| 4923 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4924 | { |
| 4925 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4926 | } |
| 4927 | #else |
| 4928 | static inline |
| 4929 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4930 | { |
| 4931 | } |
| 4932 | #endif |
| 4933 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4934 | 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] | 4935 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4936 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4937 | /* |
| 4938 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4939 | * |
| 4940 | * The reason is to fix one race condition between |
| 4941 | * bus bandwidth work and cleaning up an adapter. |
| 4942 | * Under some conditions, it is possible for the bus bandwidth |
| 4943 | * work to access a particularly destroyed adapter, leading to |
| 4944 | * use-after-free. |
| 4945 | */ |
| 4946 | hdd_debug("wait for bus bw work to flush"); |
| 4947 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4948 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4949 | |
Min Liu | ef92ef5 | 2018-06-25 18:08:54 +0800 | [diff] [blame] | 4950 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 4951 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 4952 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4953 | /* cleanup adapter */ |
| 4954 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4955 | adapter->device_mode); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4956 | hdd_remove_adapter(hdd_ctx, adapter); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 4957 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4958 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4959 | /* conditionally restart the bw timer */ |
| 4960 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4961 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4962 | /* Adapter removed. Decrement vdev count */ |
| 4963 | if (hdd_ctx->current_intf_count != 0) |
| 4964 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 4965 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4966 | /* Fw will take care incase of concurrency */ |
| 4967 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4968 | } |
| 4969 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4970 | /** |
| 4971 | * hdd_close_all_adapters - Close all open adapters |
| 4972 | * @hdd_ctx: Hdd context |
| 4973 | * rtnl_held: True if RTNL lock held |
| 4974 | * |
| 4975 | * Close all open adapters. |
| 4976 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 4977 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4978 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4979 | 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] | 4980 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4981 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4982 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4983 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4984 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4985 | |
| 4986 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4987 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 4988 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4989 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4990 | adapter->mac_addr.bytes); |
| 4991 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4992 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4993 | /* Adapter removed. Decrement vdev count */ |
| 4994 | if (hdd_ctx->current_intf_count != 0) |
| 4995 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4996 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4997 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4998 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4999 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5000 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5001 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5002 | } |
| 5003 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5004 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5005 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5006 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5007 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5008 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5009 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5010 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5011 | case QDF_STA_MODE: |
| 5012 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5013 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5014 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5015 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5016 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5017 | break; |
| 5018 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5019 | case QDF_SAP_MODE: |
| 5020 | case QDF_P2P_GO_MODE: |
| 5021 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5022 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5023 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5024 | break; |
| 5025 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5026 | case QDF_FTM_MODE: |
| 5027 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | default: |
| 5029 | /* |
| 5030 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5031 | * for these kind of devices |
| 5032 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5033 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5034 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5035 | return; |
| 5036 | } |
| 5037 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5038 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5039 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5040 | updateIE.ieBufferlength = 0; |
| 5041 | updateIE.pAdditionIEBuffer = NULL; |
| 5042 | updateIE.append = true; |
| 5043 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5044 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5045 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5046 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5047 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5048 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5049 | } |
| 5050 | } |
| 5051 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5052 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5053 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5054 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5055 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5056 | } |
| 5057 | |
| 5058 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5059 | struct hdd_adapter *adapter, |
| 5060 | enum hdd_adapter_stop_flag_t flag) |
| 5061 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5062 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5063 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5064 | union iwreq_data wrqu; |
| 5065 | tSirUpdateIE updateIE; |
| 5066 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5067 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5068 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5069 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5070 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5072 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5073 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5074 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5075 | hdd_nud_ignore_tracking(adapter, true); |
| 5076 | hdd_nud_reset_tracking(adapter); |
| 5077 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5078 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5079 | wlan_hdd_netif_queue_control(adapter, |
| 5080 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5081 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5082 | /* |
| 5083 | * if this is the last active connection check & stop the |
| 5084 | * opportunistic timer first |
| 5085 | */ |
| 5086 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 5087 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 5088 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5089 | adapter->device_mode), NULL) == 1)) || |
| 5090 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 5091 | policy_mgr_check_and_stop_opportunistic_timer( |
| 5092 | hdd_ctx->hdd_psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5093 | |
| 5094 | mac_handle = hdd_ctx->mac_handle; |
| 5095 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5096 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5097 | case QDF_STA_MODE: |
| 5098 | case QDF_P2P_CLIENT_MODE: |
| 5099 | case QDF_IBSS_MODE: |
| 5100 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5101 | case QDF_NDI_MODE: |
| 5102 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 5103 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5104 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 5105 | hdd_is_connecting( |
| 5106 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5107 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5108 | roam_profile = hdd_roam_profile(adapter); |
| 5109 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5110 | if (QDF_NDI_MODE == adapter->device_mode) |
| 5111 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5112 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5113 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5114 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5115 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5116 | eCSR_BSS_TYPE_START_IBSS) |
| 5117 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5118 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5119 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5120 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 5121 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5122 | qdf_ret_status = |
| 5123 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 5124 | hdd_debug("Send disconnected event to userspace"); |
| 5125 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5126 | adapter->dev, true, |
| 5127 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 5128 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5129 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5130 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5131 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5132 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5133 | /* success implies disconnect command got |
| 5134 | * queued up successfully |
| 5135 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5136 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5137 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5138 | rc = wait_for_completion_timeout( |
| 5139 | &adapter->disconnect_comp_var, |
| 5140 | msecs_to_jiffies |
| 5141 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5142 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5143 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5144 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5145 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5146 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5147 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5148 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5149 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5150 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5151 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5152 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5153 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5154 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5155 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5156 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | |
| 5158 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5159 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5160 | #endif |
| 5161 | |
| 5162 | hdd_deregister_tx_flow_control(adapter); |
| 5163 | |
| 5164 | #ifdef WLAN_NS_OFFLOAD |
| 5165 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5166 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5167 | #endif |
| 5168 | #endif |
| 5169 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5170 | if (adapter->device_mode == QDF_STA_MODE) |
| 5171 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5172 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5173 | |
| 5174 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5175 | hdd_err("Error: Can't disconnect adapter"); |
| 5176 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5177 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5178 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5179 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5180 | break; |
| 5181 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5182 | case QDF_MONITOR_MODE: |
| 5183 | wlan_hdd_scan_abort(adapter); |
| 5184 | hdd_deregister_tx_flow_control(adapter); |
| 5185 | hdd_vdev_destroy(adapter); |
| 5186 | break; |
| 5187 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5188 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5189 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5190 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5191 | sap_config = &adapter->session.ap.sap_config; |
| 5192 | if (sap_config) |
| 5193 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5194 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5195 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5196 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5197 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5198 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5199 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5200 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5201 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5202 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5203 | cds_flush_delayed_work( |
| 5204 | &adapter->acs_pending_work); |
| 5205 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5206 | } |
| 5207 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5208 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5209 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5211 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5212 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5213 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5214 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5215 | |
| 5216 | hdd_deregister_tx_flow_control(adapter); |
| 5217 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5218 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5219 | mutex_lock(&hdd_ctx->sap_lock); |
| 5220 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5221 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5222 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5223 | |
| 5224 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5225 | status = wlansap_stop_bss( |
| 5226 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5227 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5228 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5229 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5230 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5231 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5232 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5233 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5234 | qdf_wait_for_event_completion( |
| 5235 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5236 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5237 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5238 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5239 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5240 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5241 | } |
| 5242 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5243 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5244 | } |
| 5245 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5246 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5247 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5248 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5249 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5250 | adapter->device_mode, |
| 5251 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5252 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5253 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5254 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5255 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5256 | updateIE.ieBufferlength = 0; |
| 5257 | updateIE.pAdditionIEBuffer = NULL; |
| 5258 | updateIE.append = false; |
| 5259 | updateIE.notify = false; |
| 5260 | /* Probe bcn reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5261 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5262 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5263 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5264 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5265 | } |
| 5266 | /* Assoc resp reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5267 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | &updateIE, |
| 5269 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5270 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5271 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | } |
| 5273 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5274 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5275 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5276 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5277 | qdf_mem_free(adapter->session.ap.beacon); |
| 5278 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5279 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5280 | /* |
| 5281 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5282 | */ |
| 5283 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5284 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5285 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5286 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5287 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5288 | #endif |
| 5289 | |
| 5290 | #ifdef WLAN_NS_OFFLOAD |
| 5291 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5292 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5293 | #endif |
| 5294 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5295 | |
| 5296 | hdd_vdev_destroy(adapter); |
| 5297 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5298 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5299 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5300 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5301 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5302 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5303 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5304 | hdd_deregister_tx_flow_control(adapter); |
| 5305 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5306 | break; |
| 5307 | default: |
| 5308 | break; |
| 5309 | } |
| 5310 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5311 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5312 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5313 | if (adapter->scan_info.default_scan_ies) { |
| 5314 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5315 | adapter->scan_info.default_scan_ies = NULL; |
| 5316 | } |
| 5317 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5318 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5319 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5320 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5321 | } |
| 5322 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5323 | /** |
| 5324 | * hdd_deinit_all_adapters - deinit all adapters |
| 5325 | * @hdd_ctx: HDD context |
| 5326 | * @rtnl_held: True if RTNL lock held |
| 5327 | * |
| 5328 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5329 | 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] | 5330 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5331 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5332 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5333 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5334 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5335 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5336 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5337 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5338 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5339 | } |
| 5340 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5341 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5342 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5343 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5344 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5345 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5346 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5347 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5348 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5349 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5350 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5351 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5352 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5353 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5354 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5355 | } |
| 5356 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5357 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5358 | struct hdd_adapter *adapter) |
| 5359 | { |
| 5360 | switch (adapter->device_mode) { |
| 5361 | case QDF_STA_MODE: |
| 5362 | case QDF_P2P_CLIENT_MODE: |
| 5363 | case QDF_IBSS_MODE: |
| 5364 | case QDF_P2P_DEVICE_MODE: |
| 5365 | case QDF_NDI_MODE: |
| 5366 | wlan_hdd_scan_abort(adapter); |
| 5367 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5368 | if (adapter->device_mode == QDF_STA_MODE) |
| 5369 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5370 | adapter->dev); |
| 5371 | break; |
| 5372 | case QDF_P2P_GO_MODE: |
| 5373 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5374 | break; |
| 5375 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5376 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5377 | wlan_hdd_undo_acs(adapter); |
| 5378 | break; |
| 5379 | default: |
| 5380 | break; |
| 5381 | } |
| 5382 | } |
| 5383 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5384 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5385 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5386 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5387 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5388 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5389 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5390 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5391 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5393 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5394 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5395 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5396 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5397 | hdd_device_mode_to_string(adapter->device_mode), |
| 5398 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5399 | |
| 5400 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5401 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5402 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5403 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5404 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5405 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5406 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5407 | if (hdd_ctx->config->sap_internal_restart && |
| 5408 | adapter->device_mode == QDF_SAP_MODE) { |
| 5409 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5410 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5411 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5412 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5413 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5414 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5415 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5416 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5417 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5418 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5419 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5420 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5421 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5422 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5423 | |
| 5424 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5425 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5426 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5427 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5428 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5429 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5430 | hdd_wmm_adapter_close(adapter); |
| 5431 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5432 | } |
| 5433 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5434 | if (adapter->device_mode == QDF_STA_MODE) |
| 5435 | hdd_clear_fils_connection_info(adapter); |
| 5436 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5437 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5438 | /* |
| 5439 | * If adapter is SAP, set session ID to invalid |
| 5440 | * since SAP session will be cleanup during SSR. |
| 5441 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5442 | wlansap_set_invalid_session( |
| 5443 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5444 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5445 | wlansap_cleanup_cac_timer( |
| 5446 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5447 | } |
| 5448 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5449 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5450 | if (adapter->device_mode == QDF_STA_MODE || |
| 5451 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5452 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5453 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5454 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5455 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5456 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5457 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5458 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5459 | if (adapter->sta_info[sta_id].in_use) { |
| 5460 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5461 | sta_id); |
| 5462 | hdd_softap_deregister_sta(adapter, |
| 5463 | sta_id); |
| 5464 | adapter->sta_info[sta_id].in_use = 0; |
| 5465 | } |
| 5466 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5467 | } |
| 5468 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5469 | hdd_nud_reset_tracking(adapter); |
| 5470 | hdd_nud_ignore_tracking(adapter, true); |
| 5471 | hdd_set_disconnect_status(adapter, false); |
| 5472 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5473 | hdd_softap_deinit_tx_rx(adapter); |
| 5474 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5475 | /* Destroy vdev which will be recreated during reinit. */ |
| 5476 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5477 | } |
| 5478 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5479 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5480 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5481 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5482 | } |
| 5483 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5484 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5485 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5486 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5487 | bool close_modules = true; |
| 5488 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5489 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5490 | hdd_info("FTM mode, don't close the module"); |
| 5491 | return false; |
| 5492 | } |
| 5493 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5494 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5495 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5496 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5497 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5498 | close_modules = false; |
| 5499 | break; |
| 5500 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5501 | } |
| 5502 | |
| 5503 | return close_modules; |
| 5504 | } |
| 5505 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5506 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5507 | { |
| 5508 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5509 | return true; |
| 5510 | else |
| 5511 | return false; |
| 5512 | } |
| 5513 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5514 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5515 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5516 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5517 | struct ieee80211_channel *channel, |
| 5518 | const u8 *bssid, const u8 *ssid, |
| 5519 | size_t ssid_len) |
| 5520 | { |
| 5521 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5522 | ssid, ssid_len, |
| 5523 | WLAN_CAPABILITY_ESS, |
| 5524 | WLAN_CAPABILITY_ESS); |
| 5525 | } |
| 5526 | #else |
| 5527 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5528 | struct ieee80211_channel *channel, |
| 5529 | const u8 *bssid, const u8 *ssid, |
| 5530 | size_t ssid_len) |
| 5531 | { |
| 5532 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5533 | ssid, ssid_len, |
| 5534 | IEEE80211_BSS_TYPE_ESS, |
| 5535 | IEEE80211_PRIVACY_ANY); |
| 5536 | } |
| 5537 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5538 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5539 | #if defined CFG80211_CONNECT_BSS || \ |
| 5540 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5541 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5542 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5543 | /** |
| 5544 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5545 | * @timeout_reason: reason for connect timeout |
| 5546 | * |
| 5547 | * This function is used to convert host timeout |
| 5548 | * reason enum to kernel specific enum. |
| 5549 | * |
| 5550 | * Return: nl timeout enum |
| 5551 | */ |
| 5552 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5553 | tSirResultCodes timeout_reason) |
| 5554 | { |
| 5555 | switch (timeout_reason) { |
| 5556 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5557 | return NL80211_TIMEOUT_SCAN; |
| 5558 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5559 | return NL80211_TIMEOUT_AUTH; |
| 5560 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5561 | return NL80211_TIMEOUT_ASSOC; |
| 5562 | default: |
| 5563 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5564 | } |
| 5565 | } |
| 5566 | |
| 5567 | /** |
| 5568 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5569 | * @dev: network device |
| 5570 | * @bssid: bssid to which we want to associate |
| 5571 | * @timeout_reason: reason for connect timeout |
| 5572 | * |
| 5573 | * This API is used to send connection timeout reason to supplicant |
| 5574 | * |
| 5575 | * Return: void |
| 5576 | */ |
| 5577 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5578 | const u8 *bssid, |
| 5579 | tSirResultCodes timeout_reason) |
| 5580 | { |
| 5581 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5582 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5583 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5584 | |
| 5585 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5586 | nl_timeout_reason); |
| 5587 | } |
| 5588 | |
| 5589 | /** |
| 5590 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5591 | * @dev: network device |
| 5592 | * @bssid: bssid to which we want to associate |
| 5593 | * @req_ie: Request Information Element |
| 5594 | * @req_ie_len: len of the req IE |
| 5595 | * @resp_ie: Response IE |
| 5596 | * @resp_ie_len: len of ht response IE |
| 5597 | * @status: status |
| 5598 | * @gfp: Kernel Flag |
| 5599 | * @timeout_reason: reason for connect timeout |
| 5600 | * |
| 5601 | * Return: void |
| 5602 | */ |
| 5603 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5604 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5605 | size_t req_ie_len, const u8 *resp_ie, |
| 5606 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5607 | tSirResultCodes timeout_reason) |
| 5608 | { |
| 5609 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5610 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5611 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5612 | |
| 5613 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5614 | resp_ie, resp_ie_len, status, gfp, |
| 5615 | nl_timeout_reason); |
| 5616 | } |
| 5617 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5618 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5619 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5620 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5621 | const u8 *bssid, |
| 5622 | tSirResultCodes timeout_reason) |
| 5623 | { |
| 5624 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5625 | } |
| 5626 | #endif |
| 5627 | |
| 5628 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5629 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5630 | size_t req_ie_len, const u8 *resp_ie, |
| 5631 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5632 | tSirResultCodes timeout_reason) |
| 5633 | { |
| 5634 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5635 | resp_ie, resp_ie_len, status, gfp); |
| 5636 | } |
| 5637 | #endif |
| 5638 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5639 | /** |
| 5640 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5641 | * @dev: network device |
| 5642 | * @bssid: bssid to which we want to associate |
| 5643 | * @req_ie: Request Information Element |
| 5644 | * @req_ie_len: len of the req IE |
| 5645 | * @resp_ie: Response IE |
| 5646 | * @resp_ie_len: len of ht response IE |
| 5647 | * @status: status |
| 5648 | * @gfp: Kernel Flag |
| 5649 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5650 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5651 | * |
| 5652 | * The API is a wrapper to send connection status to supplicant |
| 5653 | * |
| 5654 | * Return: Void |
| 5655 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5656 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5657 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5658 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5659 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5660 | size_t req_ie_len, const u8 *resp_ie, |
| 5661 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5662 | bool connect_timeout, |
| 5663 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5664 | { |
| 5665 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5666 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5667 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5668 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5669 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5670 | } |
| 5671 | #else |
| 5672 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5673 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5674 | size_t req_ie_len, const u8 *resp_ie, |
| 5675 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5676 | bool connect_timeout, |
| 5677 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5678 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5679 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5680 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5681 | } |
| 5682 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5683 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5684 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5685 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5686 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5687 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5688 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5689 | /** |
| 5690 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5691 | * @fils_params: connect response to supplicant |
| 5692 | * @fils_kek: FILS kek |
| 5693 | * @fils_kek_len: FILS kek length |
| 5694 | * @pmk: FILS PMK |
| 5695 | * @pmk_len: FILS PMK length |
| 5696 | * @pmkid: PMKID |
| 5697 | * @fils_seq_num: FILS Seq number |
| 5698 | * |
| 5699 | * Return: None |
| 5700 | */ |
| 5701 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5702 | *fils_params, const uint8_t *fils_kek, |
| 5703 | size_t fils_kek_len, const uint8_t *pmk, |
| 5704 | size_t pmk_len, const uint8_t *pmkid, |
| 5705 | uint16_t fils_seq_num) |
| 5706 | { |
| 5707 | /* Increament seq number to be used for next FILS */ |
| 5708 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5709 | fils_params->update_erp_next_seq_num = true; |
| 5710 | fils_params->fils_kek = fils_kek; |
| 5711 | fils_params->fils_kek_len = fils_kek_len; |
| 5712 | fils_params->pmk = pmk; |
| 5713 | fils_params->pmk_len = pmk_len; |
| 5714 | fils_params->pmkid = pmkid; |
| 5715 | } |
| 5716 | #else |
| 5717 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5718 | *fils_params, const uint8_t |
| 5719 | *fils_kek, size_t fils_kek_len, |
| 5720 | const uint8_t *pmk, size_t pmk_len, |
| 5721 | const uint8_t *pmkid, |
| 5722 | uint16_t fils_seq_num) |
| 5723 | { } |
| 5724 | #endif |
| 5725 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5726 | void hdd_update_hlp_info(struct net_device *dev, |
| 5727 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5728 | { |
| 5729 | struct sk_buff *skb; |
| 5730 | uint16_t skb_len; |
| 5731 | struct llc_snap_hdr_t *llc_hdr; |
| 5732 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5733 | uint8_t *hlp_data; |
| 5734 | uint16_t hlp_data_len; |
| 5735 | struct fils_join_rsp_params *roam_fils_params |
| 5736 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5737 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5738 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5739 | if (!roam_fils_params) { |
| 5740 | hdd_err("FILS Roam Param NULL"); |
| 5741 | return; |
| 5742 | } |
| 5743 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5744 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5745 | hdd_err("FILS HLP Data NULL, len %d", |
| 5746 | roam_fils_params->hlp_data_len); |
| 5747 | return; |
| 5748 | } |
| 5749 | |
| 5750 | hlp_data = roam_fils_params->hlp_data; |
| 5751 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5752 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5753 | /* Calculate skb length */ |
| 5754 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5755 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5756 | if (skb == NULL) { |
| 5757 | hdd_err("HLP packet nbuf alloc fails"); |
| 5758 | return; |
| 5759 | } |
| 5760 | |
| 5761 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5762 | QDF_MAC_ADDR_SIZE); |
| 5763 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5764 | QDF_MAC_ADDR_SIZE); |
| 5765 | |
| 5766 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5767 | if (IS_SNAP(llc_hdr)) { |
| 5768 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5769 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5770 | } |
| 5771 | |
| 5772 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5773 | |
| 5774 | /* |
| 5775 | * This HLP packet is formed from HLP info encapsulated |
| 5776 | * in assoc response frame which is AEAD encrypted. |
| 5777 | * Hence, this checksum validation can be set unnecessary. |
| 5778 | * i.e. network layer need not worry about checksum. |
| 5779 | */ |
| 5780 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5781 | |
| 5782 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5783 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5784 | hdd_err("Sending HLP packet fails"); |
| 5785 | return; |
| 5786 | } |
| 5787 | hdd_debug("send HLP packet to netif successfully"); |
| 5788 | } |
| 5789 | |
| 5790 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5791 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5792 | * @dev: network device |
| 5793 | * @bssid: bssid to which we want to associate |
| 5794 | * @bss: cfg80211 bss info |
| 5795 | * @roam_info: information about connected bss |
| 5796 | * @req_ie: Request Information Element |
| 5797 | * @req_ie_len: len of the req IE |
| 5798 | * @resp_ie: Response IE |
| 5799 | * @resp_ie_len: len of ht response IE |
| 5800 | * @status: status |
| 5801 | * @gfp: allocation flags |
| 5802 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5803 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5804 | * |
| 5805 | * This API is used as wrapper to send FILS key/sequence number |
| 5806 | * params etc. to supplicant in case of FILS connection |
| 5807 | * |
| 5808 | * Return: None |
| 5809 | */ |
| 5810 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5811 | struct cfg80211_bss *bss, |
| 5812 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5813 | const u8 *req_ie, size_t req_ie_len, |
| 5814 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5815 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5816 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5817 | { |
| 5818 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5819 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5820 | struct fils_join_rsp_params *roam_fils_params = |
| 5821 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5822 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5823 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5824 | |
| 5825 | if (!roam_fils_params) { |
| 5826 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5827 | } else { |
| 5828 | fils_params.status = status; |
| 5829 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5830 | fils_params.timeout_reason = |
| 5831 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5832 | fils_params.req_ie = req_ie; |
| 5833 | fils_params.req_ie_len = req_ie_len; |
| 5834 | fils_params.resp_ie = resp_ie; |
| 5835 | fils_params.resp_ie_len = resp_ie_len; |
| 5836 | fils_params.bss = bss; |
| 5837 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5838 | roam_fils_params->kek_len, |
| 5839 | roam_fils_params->fils_pmk, |
| 5840 | roam_fils_params->fils_pmk_len, |
| 5841 | roam_fils_params->fils_pmkid, |
| 5842 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5843 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5844 | } |
| 5845 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5846 | fils_params.status, |
| 5847 | fils_params.fils_erp_next_seq_num); |
| 5848 | |
| 5849 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5850 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5851 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5852 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5853 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5854 | /* Clear all the FILS key info */ |
| 5855 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5856 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5857 | if (roam_fils_params) |
| 5858 | qdf_mem_free(roam_fils_params); |
| 5859 | roam_info->fils_join_rsp = NULL; |
| 5860 | } |
| 5861 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5862 | static inline void |
| 5863 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5864 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5865 | const u8 *req_ie, size_t req_ie_len, |
| 5866 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5867 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5868 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5869 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5870 | #endif |
| 5871 | #endif |
| 5872 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5873 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5874 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5875 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5876 | /** |
| 5877 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5878 | * supplicant. |
| 5879 | * @dev: network device |
| 5880 | * @bssid: bssid to which we want to associate |
| 5881 | * @bss: cfg80211 bss info |
| 5882 | * @roam_info: information about connected bss |
| 5883 | * @req_ie: Request Information Element |
| 5884 | * @req_ie_len: len of the req IE |
| 5885 | * @resp_ie: Response IE |
| 5886 | * @resp_ie_len: len of ht response IE |
| 5887 | * @status: status |
| 5888 | * @gfp: allocation flags |
| 5889 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5890 | * @timeout_reason: reason for connect timeout |
| 5891 | * |
| 5892 | * The API is a wrapper to send connection status to supplicant |
| 5893 | * |
| 5894 | * Return: 0 if success else failure |
| 5895 | */ |
| 5896 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5897 | const u8 *bssid, |
| 5898 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5899 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5900 | size_t req_ie_len, const u8 *resp_ie, |
| 5901 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5902 | bool connect_timeout, |
| 5903 | tSirResultCodes timeout_reason) |
| 5904 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5905 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5906 | if (!roam_info || !roam_info->is_fils_connection) |
| 5907 | return -EINVAL; |
| 5908 | |
| 5909 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5910 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5911 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5912 | return 0; |
| 5913 | } |
| 5914 | #else |
| 5915 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5916 | const u8 *bssid, |
| 5917 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5918 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5919 | size_t req_ie_len, const u8 *resp_ie, |
| 5920 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5921 | bool connect_timeout, |
| 5922 | tSirResultCodes timeout_reason) |
| 5923 | { |
| 5924 | return -EINVAL; |
| 5925 | } |
| 5926 | #endif |
| 5927 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5928 | /** |
| 5929 | * hdd_connect_result() - API to send connection status to supplicant |
| 5930 | * @dev: network device |
| 5931 | * @bssid: bssid to which we want to associate |
| 5932 | * @roam_info: information about connected bss |
| 5933 | * @req_ie: Request Information Element |
| 5934 | * @req_ie_len: len of the req IE |
| 5935 | * @resp_ie: Response IE |
| 5936 | * @resp_ie_len: len of ht response IE |
| 5937 | * @status: status |
| 5938 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5939 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5940 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5941 | * |
| 5942 | * The API is a wrapper to send connection status to supplicant |
| 5943 | * and allow runtime suspend |
| 5944 | * |
| 5945 | * Return: Void |
| 5946 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5947 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5948 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5949 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5950 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5951 | bool connect_timeout, |
| 5952 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5953 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5954 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5955 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5956 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5957 | |
| 5958 | if (WLAN_STATUS_SUCCESS == status) { |
| 5959 | struct ieee80211_channel *chan; |
| 5960 | int freq; |
| 5961 | int chan_no = roam_info->pBssDesc->channelId; |
| 5962 | |
| 5963 | if (chan_no <= 14) |
| 5964 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5965 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5966 | else |
| 5967 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 5968 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5969 | |
| 5970 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 5971 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 5972 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 5973 | roam_info->u.pConnectedProfile->SSID.length); |
| 5974 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5975 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5976 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 5977 | roam_info, req_ie, req_ie_len, resp_ie, |
| 5978 | resp_ie_len, status, gfp, connect_timeout, |
| 5979 | timeout_reason) != 0) { |
| 5980 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 5981 | req_ie_len, resp_ie, resp_ie_len, |
| 5982 | status, gfp, connect_timeout, timeout_reason); |
| 5983 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5984 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5985 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 5986 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5987 | } |
| 5988 | #else |
| 5989 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5990 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5991 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5992 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5993 | bool connect_timeout, |
| 5994 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5995 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5996 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 5997 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 5998 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5999 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6000 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6001 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6002 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6003 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6004 | } |
| 6005 | #endif |
| 6006 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6007 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6008 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6009 | uint32_t bandwidth) |
| 6010 | { |
| 6011 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6012 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6013 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6014 | QDF_STATUS status; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6015 | struct qdf_mac_addr bssid; |
| 6016 | struct csr_roam_profile roam_profile; |
| 6017 | struct ch_params ch_params; |
| 6018 | |
| 6019 | if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) { |
| 6020 | hdd_err("Not supported, device is not in monitor mode"); |
| 6021 | return -EINVAL; |
| 6022 | } |
| 6023 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6024 | /* Validate Channel */ |
| 6025 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6026 | hdd_err("Channel %d Not supported", chan); |
| 6027 | return -EINVAL; |
| 6028 | } |
| 6029 | |
| 6030 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6031 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6032 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6033 | return -EINVAL; |
| 6034 | } |
| 6035 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6036 | (bandwidth != CH_WIDTH_MAX)) { |
| 6037 | hdd_err("Only BW20 possible on channel 14"); |
| 6038 | return -EINVAL; |
| 6039 | } |
| 6040 | } |
| 6041 | |
| 6042 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6043 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6044 | (bandwidth != CH_WIDTH_MAX)) { |
| 6045 | hdd_err("Only BW20 possible on channel 165"); |
| 6046 | return -EINVAL; |
| 6047 | } |
| 6048 | } |
| 6049 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6050 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6051 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6052 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6053 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6054 | roam_profile.phyMode = ch_info->phy_mode; |
| 6055 | roam_profile.ch_params.ch_width = bandwidth; |
| 6056 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
| 6057 | |
| 6058 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6059 | QDF_MAC_ADDR_SIZE); |
| 6060 | |
| 6061 | ch_params.ch_width = bandwidth; |
| 6062 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 6063 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6064 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6065 | return -EINVAL; |
| 6066 | } |
| 6067 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6068 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6069 | hdd_err("Failed to change hw mode"); |
| 6070 | return -EINVAL; |
| 6071 | } |
| 6072 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6073 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6074 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6075 | &roam_profile); |
| 6076 | if (status) { |
| 6077 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6078 | status); |
| 6079 | } |
| 6080 | |
| 6081 | adapter->mon_chan = chan; |
| 6082 | adapter->mon_bandwidth = bandwidth; |
| 6083 | return qdf_status_to_os_return(status); |
| 6084 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6085 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6086 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6087 | #ifdef MSM_PLATFORM |
| 6088 | /** |
| 6089 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6090 | * @adapter: pointer to adapter |
| 6091 | * |
| 6092 | * This function calls cfg80211 API to stop P2P GO |
| 6093 | * |
| 6094 | * Return: None |
| 6095 | */ |
| 6096 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6097 | { |
| 6098 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6099 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6100 | } |
| 6101 | |
| 6102 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6103 | { |
| 6104 | } |
| 6105 | #else |
| 6106 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6107 | { |
| 6108 | } |
| 6109 | |
| 6110 | /** |
| 6111 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6112 | * @adapter: pointer to adapter |
| 6113 | * |
| 6114 | * This function calls cfg80211 API to delete STA |
| 6115 | * |
| 6116 | * Return: None |
| 6117 | */ |
| 6118 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6119 | { |
| 6120 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6121 | |
| 6122 | hdd_debug("[SSR] send restart supplicant"); |
| 6123 | /* event supplicant to restart */ |
| 6124 | cfg80211_del_sta(adapter->dev, |
| 6125 | (const u8 *)&bcast_mac.bytes[0], |
| 6126 | GFP_KERNEL); |
| 6127 | } |
| 6128 | #endif |
| 6129 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6130 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6131 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6132 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6133 | eConnectionState connState; |
| 6134 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6135 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6136 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6137 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6138 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6139 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6140 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6141 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 6142 | hdd_device_mode_to_string(adapter->device_mode), |
| 6143 | adapter->device_mode); |
| 6144 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6145 | hdd_wmm_init(adapter); |
| 6146 | |
| 6147 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6148 | case QDF_STA_MODE: |
| 6149 | case QDF_P2P_CLIENT_MODE: |
| 6150 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6151 | |
| 6152 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6153 | ->conn_info.connState; |
| 6154 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6155 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6156 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6157 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6158 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6159 | /* Indicate disconnect event to supplicant |
| 6160 | * if associated previously |
| 6161 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6162 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6163 | eConnectionState_IbssConnected == connState || |
| 6164 | eConnectionState_NotConnected == connState || |
| 6165 | eConnectionState_IbssDisconnected == connState || |
| 6166 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6167 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6168 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6169 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6170 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6171 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6172 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6173 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6174 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6175 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6176 | |
| 6177 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6178 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6179 | adapter->dev, false, |
| 6180 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6181 | } else if (eConnectionState_Connecting == connState) { |
| 6182 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6183 | * Indicate connect failure to supplicant if we |
| 6184 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6185 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6186 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6187 | NULL, 0, NULL, 0, |
| 6188 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6189 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6190 | } |
| 6191 | |
| 6192 | hdd_register_tx_flow_control(adapter, |
| 6193 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6194 | hdd_tx_resume_cb, |
| 6195 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6196 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6197 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6198 | break; |
| 6199 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6200 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6201 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6202 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6204 | break; |
| 6205 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6206 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6207 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6208 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6209 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6210 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6211 | hdd_set_mon_rx_cb(adapter->dev); |
| 6212 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6213 | adapter->mon_bandwidth); |
| 6214 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6215 | default: |
| 6216 | break; |
| 6217 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6218 | /* |
| 6219 | * Action frame registered in one adapter which will |
| 6220 | * applicable to all interfaces |
| 6221 | */ |
| 6222 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6223 | } |
| 6224 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6225 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6226 | if (!hdd_is_interface_up(adapter)) |
| 6227 | continue; |
| 6228 | |
| 6229 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6230 | hdd_stop_p2p_go(adapter); |
| 6231 | } |
| 6232 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6233 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6234 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6235 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6236 | } |
| 6237 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6238 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6239 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6240 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6241 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6242 | qdf_list_node_t *node; |
| 6243 | |
| 6244 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6245 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6246 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6247 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6248 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6249 | |
| 6250 | if (QDF_IS_STATUS_ERROR(status)) |
| 6251 | return status; |
| 6252 | |
| 6253 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6254 | |
| 6255 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6256 | } |
| 6257 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6258 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6259 | struct hdd_adapter *current_adapter, |
| 6260 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6261 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6262 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6263 | qdf_list_node_t *node; |
| 6264 | |
| 6265 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6266 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6267 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6268 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6269 | ¤t_adapter->node, |
| 6270 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6271 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6272 | |
| 6273 | if (QDF_IS_STATUS_ERROR(status)) |
| 6274 | return status; |
| 6275 | |
| 6276 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6277 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6278 | return status; |
| 6279 | } |
| 6280 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6281 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6282 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6283 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6284 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6285 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6286 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6287 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6288 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6289 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6290 | return status; |
| 6291 | } |
| 6292 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6293 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6294 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6295 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6296 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6297 | qdf_list_node_t *node; |
| 6298 | |
| 6299 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6300 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6301 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6302 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6303 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6304 | |
| 6305 | if (QDF_IS_STATUS_ERROR(status)) |
| 6306 | return status; |
| 6307 | |
| 6308 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6309 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6310 | return status; |
| 6311 | } |
| 6312 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6313 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6314 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6315 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6316 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6317 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6318 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6319 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6320 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6321 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6322 | return status; |
| 6323 | } |
| 6324 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6325 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6326 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6327 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6328 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6329 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6330 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6331 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6332 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6333 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6334 | return status; |
| 6335 | } |
| 6336 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6337 | 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] | 6338 | tSirMacAddr macAddr) |
| 6339 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6340 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6341 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6342 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6343 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6344 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6345 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6346 | } |
| 6347 | |
| 6348 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6349 | } |
| 6350 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6351 | 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] | 6352 | uint32_t vdev_id) |
| 6353 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6354 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6355 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6356 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6357 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6358 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | } |
| 6360 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6361 | return NULL; |
| 6362 | } |
| 6363 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6364 | /** |
| 6365 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6366 | * the sessionid |
| 6367 | * @hdd_ctx: hdd context. |
| 6368 | * @sme_session_id: sme session is for the adapter to get. |
| 6369 | * |
| 6370 | * This function is used to get the adapter with provided session id |
| 6371 | * |
| 6372 | * Return: adapter pointer if found |
| 6373 | * |
| 6374 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6375 | struct hdd_adapter * |
| 6376 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6377 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6378 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6379 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6380 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6381 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6382 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6383 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6384 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6385 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6386 | return NULL; |
| 6387 | } |
| 6388 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6389 | 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] | 6390 | const char *iface_name) |
| 6391 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6392 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6393 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6394 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6395 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6396 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6397 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6398 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6399 | return NULL; |
| 6400 | } |
| 6401 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6402 | /** |
| 6403 | * hdd_get_adapter() - to get adapter matching the mode |
| 6404 | * @hdd_ctx: hdd context |
| 6405 | * @mode: adapter mode |
| 6406 | * |
| 6407 | * This routine will return the pointer to adapter matching |
| 6408 | * with the passed mode. |
| 6409 | * |
| 6410 | * Return: pointer to adapter or null |
| 6411 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6412 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6413 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6414 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6415 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6416 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6417 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6418 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6419 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6420 | } |
| 6421 | |
| 6422 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6423 | } |
| 6424 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6425 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6426 | { |
| 6427 | struct hdd_context *hdd_ctx; |
| 6428 | struct hdd_adapter *adapter; |
| 6429 | |
| 6430 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6431 | if (!hdd_ctx) { |
| 6432 | hdd_err("Invalid HDD context"); |
| 6433 | return QDF_MAX_NO_OF_MODE; |
| 6434 | } |
| 6435 | |
| 6436 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6437 | if (!adapter) { |
| 6438 | hdd_err("Invalid HDD adapter"); |
| 6439 | return QDF_MAX_NO_OF_MODE; |
| 6440 | } |
| 6441 | |
| 6442 | return adapter->device_mode; |
| 6443 | } |
| 6444 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6445 | /** |
| 6446 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6447 | * @hdd_ctx: Pointer to the HDD context. |
| 6448 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6449 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6450 | * QDF_STA_MODE, |
| 6451 | * QDF_P2P_CLIENT_MODE, |
| 6452 | * QDF_SAP_MODE, |
| 6453 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6454 | * |
| 6455 | * This API returns the operating channel of the requested device mode |
| 6456 | * |
| 6457 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6458 | * not connected. |
| 6459 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6460 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6461 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6462 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6463 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6464 | uint8_t operatingChannel = 0; |
| 6465 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6466 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | if (mode == adapter->device_mode) { |
| 6468 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6469 | case QDF_STA_MODE: |
| 6470 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6471 | if (hdd_conn_is_connected |
| 6472 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6473 | (adapter))) { |
| 6474 | operatingChannel = |
| 6475 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6476 | (adapter))->conn_info. |
| 6477 | operationChannel; |
| 6478 | } |
| 6479 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6480 | case QDF_SAP_MODE: |
| 6481 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6482 | /* softap connection info */ |
| 6483 | if (test_bit |
| 6484 | (SOFTAP_BSS_STARTED, |
| 6485 | &adapter->event_flags)) |
| 6486 | operatingChannel = |
| 6487 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6488 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6489 | break; |
| 6490 | default: |
| 6491 | break; |
| 6492 | } |
| 6493 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6494 | /* Found the device of interest. break the loop */ |
| 6495 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6496 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6497 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6498 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6499 | return operatingChannel; |
| 6500 | } |
| 6501 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6502 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6503 | hdd_ctx) |
| 6504 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6505 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6507 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6509 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6510 | if (adapter->device_mode == QDF_STA_MODE || |
| 6511 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6512 | adapter->device_mode == QDF_IBSS_MODE || |
| 6513 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6514 | adapter->device_mode == QDF_SAP_MODE || |
| 6515 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6516 | hdd_unregister_wext(adapter->dev); |
| 6517 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6518 | } |
| 6519 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6520 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6521 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6522 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6523 | } |
| 6524 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6525 | 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] | 6526 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6527 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6528 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6529 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6530 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6531 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6532 | if (adapter->device_mode == QDF_STA_MODE || |
| 6533 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6534 | adapter->device_mode == QDF_IBSS_MODE || |
| 6535 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6536 | adapter->device_mode == QDF_SAP_MODE || |
| 6537 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6538 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6539 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6540 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6541 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6542 | } |
| 6543 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6544 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6545 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6546 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | } |
| 6548 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6549 | /** |
| 6550 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6551 | * adapters |
| 6552 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6553 | * |
| 6554 | * return: QDF_STATUS_SUCCESS |
| 6555 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6556 | 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] | 6557 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6558 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6559 | int err; |
| 6560 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6561 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6562 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6563 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6564 | if (adapter->device_mode == QDF_STA_MODE || |
| 6565 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6566 | adapter->device_mode == QDF_IBSS_MODE || |
| 6567 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6568 | adapter->device_mode == QDF_SAP_MODE || |
| 6569 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6570 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6571 | if (err) |
| 6572 | hdd_err("Unable to stop scheduled scan"); |
| 6573 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6574 | } |
| 6575 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6576 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6577 | |
| 6578 | return QDF_STATUS_SUCCESS; |
| 6579 | } |
| 6580 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6581 | #ifdef WLAN_NS_OFFLOAD |
| 6582 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6583 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6584 | * @hdd_ctx: Pointer to hdd context |
| 6585 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6586 | * Unregister for IPv6 address change notifications. |
| 6587 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6588 | * Return: None |
| 6589 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6590 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | { |
| 6592 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6593 | } |
| 6594 | |
| 6595 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6596 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6597 | * @hdd_ctx: Pointer to hdd context |
| 6598 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6599 | * Register for IPv6 address change notifications. |
| 6600 | * |
| 6601 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6602 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6603 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6604 | { |
| 6605 | int ret; |
| 6606 | |
| 6607 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6608 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6609 | if (ret) { |
| 6610 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6611 | goto out; |
| 6612 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6613 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6614 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6615 | out: |
| 6616 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6617 | } |
| 6618 | #else |
| 6619 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6620 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6621 | * @hdd_ctx: Pointer to hdd context |
| 6622 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6623 | * Unregister for IPv6 address change notifications. |
| 6624 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6625 | * Return: None |
| 6626 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6627 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6628 | { |
| 6629 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6631 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6632 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6633 | * @hdd_ctx: Pointer to hdd context |
| 6634 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6635 | * Register for IPv6 address change notifications. |
| 6636 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | * Return: None |
| 6638 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6639 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6640 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6641 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6642 | } |
| 6643 | #endif |
| 6644 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6645 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6646 | { |
| 6647 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6648 | adapter->disconnection_in_progress = status; |
| 6649 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6650 | hdd_debug("setting disconnection status: %d", status); |
| 6651 | } |
| 6652 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6653 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6654 | * hdd_register_notifiers - Register netdev notifiers. |
| 6655 | * @hdd_ctx: HDD context |
| 6656 | * |
| 6657 | * Register netdev notifiers like IPv4 and IPv6. |
| 6658 | * |
| 6659 | * Return: 0 on success and errno on failure |
| 6660 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6661 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6662 | { |
| 6663 | int ret; |
| 6664 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6665 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6666 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6667 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6668 | |
| 6669 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6670 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6671 | if (ret) { |
| 6672 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6673 | goto unregister_ip6_notifier; |
| 6674 | } |
| 6675 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6676 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6677 | if (ret) { |
| 6678 | hdd_err("Failed to register netevent notifier: %d", |
| 6679 | ret); |
| 6680 | goto unregister_inetaddr_notifier; |
| 6681 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6682 | return 0; |
| 6683 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6684 | unregister_inetaddr_notifier: |
| 6685 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6686 | unregister_ip6_notifier: |
| 6687 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6688 | out: |
| 6689 | return ret; |
| 6690 | |
| 6691 | } |
| 6692 | |
| 6693 | /** |
| 6694 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6695 | * @hdd_ctx: HDD context |
| 6696 | * |
| 6697 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6698 | * |
| 6699 | * Return: None. |
| 6700 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6701 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6702 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6703 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6704 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6705 | |
| 6706 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6707 | } |
| 6708 | |
| 6709 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6710 | * hdd_exit_netlink_services - Exit netlink services |
| 6711 | * @hdd_ctx: HDD context |
| 6712 | * |
| 6713 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6714 | * nl service. |
| 6715 | * |
| 6716 | * Return: None. |
| 6717 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6718 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6719 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6720 | spectral_scan_deactivate_service(); |
| 6721 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6722 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6723 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6724 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6725 | |
| 6726 | nl_srv_exit(); |
| 6727 | } |
| 6728 | |
| 6729 | /** |
| 6730 | * hdd_init_netlink_services- Init netlink services |
| 6731 | * @hdd_ctx: HDD context |
| 6732 | * |
| 6733 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6734 | * nl service. |
| 6735 | * |
| 6736 | * Return: 0 on success and errno on failure. |
| 6737 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6738 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6739 | { |
| 6740 | int ret; |
| 6741 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6742 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6743 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6744 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6745 | goto out; |
| 6746 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6747 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6748 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6749 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6750 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6751 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6752 | goto err_nl_srv; |
| 6753 | } |
| 6754 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6755 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6756 | |
| 6757 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6758 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6759 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6760 | |
| 6761 | ret = cnss_diag_activate_service(); |
| 6762 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6763 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6764 | goto err_close_cesium; |
| 6765 | } |
| 6766 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6767 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6768 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6769 | return 0; |
| 6770 | |
| 6771 | err_close_cesium: |
| 6772 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6773 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6774 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6775 | err_nl_srv: |
| 6776 | nl_srv_exit(); |
| 6777 | out: |
| 6778 | return ret; |
| 6779 | } |
| 6780 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6781 | /** |
| 6782 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6783 | * @hdd_ctx: HDD context. |
| 6784 | * |
| 6785 | * Destroy RX wakelock. |
| 6786 | * |
| 6787 | * Return: None. |
| 6788 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6789 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6790 | { |
| 6791 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6792 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6793 | |
| 6794 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6795 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6796 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6797 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6798 | * Create RX wakelock. |
| 6799 | * |
| 6800 | * Return: None. |
| 6801 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6802 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6803 | { |
| 6804 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6805 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6806 | |
| 6807 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6808 | * hdd_context_deinit() - Deinitialize HDD context |
| 6809 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6810 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6811 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6812 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6813 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6814 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6815 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6816 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6817 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6818 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6819 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6820 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6821 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6822 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6823 | hdd_sap_context_destroy(hdd_ctx); |
| 6824 | |
| 6825 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6826 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6827 | hdd_scan_context_destroy(hdd_ctx); |
| 6828 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6829 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6830 | |
Nachiket Kukade | 177b5b0 | 2018-05-22 20:52:17 +0530 | [diff] [blame] | 6831 | hdd_apf_context_destroy(); |
| 6832 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6833 | return 0; |
| 6834 | } |
| 6835 | |
| 6836 | /** |
| 6837 | * hdd_context_destroy() - Destroy HDD context |
| 6838 | * @hdd_ctx: HDD context to be destroyed. |
| 6839 | * |
| 6840 | * Free config and HDD context as well as destroy all the resources. |
| 6841 | * |
| 6842 | * Return: None |
| 6843 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6844 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6845 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6846 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6847 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6848 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6849 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6850 | hdd_context_deinit(hdd_ctx); |
| 6851 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6852 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6853 | hdd_ctx->config = NULL; |
| 6854 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame^] | 6855 | cfg_release(); |
| 6856 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6857 | wiphy_free(hdd_ctx->wiphy); |
| 6858 | } |
| 6859 | |
| 6860 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6861 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6862 | * |
| 6863 | * This function is used to destroy bug report lock |
| 6864 | * |
| 6865 | * Return: None |
| 6866 | */ |
| 6867 | static void wlan_destroy_bug_report_lock(void) |
| 6868 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 6869 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6870 | |
| 6871 | p_cds_context = cds_get_global_context(); |
| 6872 | if (!p_cds_context) { |
| 6873 | hdd_err("cds context is NULL"); |
| 6874 | return; |
| 6875 | } |
| 6876 | |
| 6877 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6878 | } |
| 6879 | |
| 6880 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6881 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6882 | * @hdd_ctx: Pointer to the HDD Context |
| 6883 | * |
| 6884 | * This is the driver exit point (invoked during rmmod) |
| 6885 | * |
| 6886 | * Return: None |
| 6887 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6888 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6889 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6890 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6891 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6892 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6893 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6894 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6895 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6896 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6897 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6898 | |
| 6899 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6900 | if (QDF_TIMER_STATE_RUNNING == |
| 6901 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6902 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6903 | } |
| 6904 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6905 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6906 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6907 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6908 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6909 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6910 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6911 | hdd_ctx->last_acs_channel_list = NULL; |
| 6912 | hdd_ctx->num_of_channels = 0; |
| 6913 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6915 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6916 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6917 | driver_status = hdd_ctx->driver_status; |
| 6918 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6919 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6920 | /* |
| 6921 | * Powersave Offload Case |
| 6922 | * Disable Idle Power Save Mode |
| 6923 | */ |
| 6924 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6925 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6926 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6927 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6928 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6929 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6930 | /* |
| 6931 | * Cancel any outstanding scan requests. We are about to close |
| 6932 | * all of our adapters, but an adapter structure is what SME |
| 6933 | * passes back to our callback function. Hence if there |
| 6934 | * are any outstanding scan requests then there is a |
| 6935 | * race condition between when the adapter is closed and |
| 6936 | * when the callback is invoked. We try to resolve that |
| 6937 | * race condition here by canceling any outstanding scans |
| 6938 | * before we close the adapters. |
| 6939 | * Note that the scans may be cancelled in an asynchronous |
| 6940 | * manner, so ideally there needs to be some kind of |
| 6941 | * synchronization. Rather than introduce a new |
| 6942 | * synchronization here, we will utilize the fact that we are |
| 6943 | * about to Request Full Power, and since that is synchronized, |
| 6944 | * the expectation is that by the time Request Full Power has |
| 6945 | * completed, all scans will be cancelled |
| 6946 | */ |
| 6947 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6948 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6949 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6950 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6951 | } |
| 6952 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6953 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6954 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6955 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 6956 | qdf_dp_trace_deinit(); |
| 6957 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 6958 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 6959 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 6960 | hdd_driver_memdump_deinit(); |
| 6961 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 6962 | qdf_nbuf_deinit_replenish_timer(); |
| 6963 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6964 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 6965 | hdd_info("Release wakelock for monitor mode!"); |
| 6966 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 6967 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 6968 | } |
| 6969 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 6970 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 6971 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 6972 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 6973 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 6974 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6975 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 6976 | hdd_close_all_adapters(hdd_ctx, false); |
| 6977 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 6978 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6979 | /* |
| 6980 | * If there is re_init failure wiphy would have already de-registered |
| 6981 | * check the wiphy status before un-registering again |
| 6982 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 6983 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 6984 | wiphy_unregister(wiphy); |
| 6985 | wlan_hdd_cfg80211_deinit(wiphy); |
| 6986 | hdd_lpass_notify_stop(hdd_ctx); |
| 6987 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 6988 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6989 | hdd_exit_netlink_services(hdd_ctx); |
| 6990 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 6991 | #ifdef FEATURE_WLAN_CH_AVOID |
| 6992 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 6993 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6994 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 6995 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 6996 | if (driver_status) |
| 6997 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 6998 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6999 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7000 | } |
| 7001 | |
| 7002 | void __hdd_wlan_exit(void) |
| 7003 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7004 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7005 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7006 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7008 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7009 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7010 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7011 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | return; |
| 7013 | } |
| 7014 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7015 | /* Do all the cleanup before deregistering the driver */ |
| 7016 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 7017 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7018 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7019 | } |
| 7020 | |
| 7021 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7022 | /** |
| 7023 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7024 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7025 | * |
| 7026 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7027 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7028 | * scan information. |
| 7029 | * |
| 7030 | * Return: void |
| 7031 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7032 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7033 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7034 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7035 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7037 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7038 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7039 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7040 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7041 | hdd_ctx->last_acs_channel_list = NULL; |
| 7042 | hdd_ctx->num_of_channels = 0; |
| 7043 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7044 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7045 | mac_handle = hdd_ctx->mac_handle; |
| 7046 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7047 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7048 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7049 | } |
| 7050 | #endif |
| 7051 | |
| 7052 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7053 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 7054 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7055 | { |
| 7056 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7057 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7058 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7059 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7060 | |
| 7061 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7062 | |
| 7063 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7064 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7065 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7066 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7067 | mac_handle = hdd_ctx->mac_handle; |
| 7068 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7069 | return -EINVAL; |
| 7070 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7071 | qdf_status = sme_notify_ht2040_mode(mac_handle, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7072 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7073 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7074 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7075 | return -EINVAL; |
| 7076 | } |
| 7077 | |
| 7078 | return 0; |
| 7079 | } |
| 7080 | #endif |
| 7081 | |
| 7082 | /** |
| 7083 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7084 | * @state: state |
| 7085 | * |
| 7086 | * This function notifies FW with modem power status |
| 7087 | * |
| 7088 | * Return: 0 if successful, error number otherwise |
| 7089 | */ |
| 7090 | int hdd_wlan_notify_modem_power_state(int state) |
| 7091 | { |
| 7092 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7093 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7094 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7095 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7096 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7097 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7098 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7099 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7100 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7101 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7102 | mac_handle = hdd_ctx->mac_handle; |
| 7103 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7104 | return -EINVAL; |
| 7105 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7106 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7107 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7108 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7109 | state); |
| 7110 | return -EINVAL; |
| 7111 | } |
| 7112 | return 0; |
| 7113 | } |
| 7114 | |
| 7115 | /** |
| 7116 | * |
| 7117 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7118 | * @adapter - Pointer to the HDD |
| 7119 | * |
| 7120 | * Return: None |
| 7121 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7122 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7123 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7124 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7125 | |
| 7126 | /* |
| 7127 | * Send ready indication to the HDD. This will kick off the MAC |
| 7128 | * into a 'running' state and should kick off an initial scan. |
| 7129 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7130 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7131 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7132 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7133 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7134 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7135 | } |
| 7136 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7137 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | } |
| 7139 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7140 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7141 | { |
| 7142 | struct hdd_adapter *adapter; |
| 7143 | |
| 7144 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7145 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7146 | return adapter; |
| 7147 | } |
| 7148 | |
| 7149 | return NULL; |
| 7150 | } |
| 7151 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7152 | /* wake lock APIs for HDD */ |
| 7153 | void hdd_prevent_suspend(uint32_t reason) |
| 7154 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7155 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7156 | } |
| 7157 | |
| 7158 | void hdd_allow_suspend(uint32_t reason) |
| 7159 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7160 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7161 | } |
| 7162 | |
| 7163 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7164 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7165 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7166 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | } |
| 7168 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7169 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7170 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7171 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7172 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7173 | hdd_ctx->reg.alpha2, |
| 7174 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7175 | } |
| 7176 | |
| 7177 | /** |
| 7178 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7179 | * @hdd_ctx: Pointer to the hdd context |
| 7180 | * |
| 7181 | * HDD function to know if hardware supports 5GHz |
| 7182 | * |
| 7183 | * Return: true if hardware supports 5GHz |
| 7184 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7185 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7186 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7187 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7188 | return true; |
| 7189 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7190 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7191 | return true; |
| 7192 | else |
| 7193 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7194 | } |
| 7195 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7196 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7197 | { |
| 7198 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7199 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7200 | |
| 7201 | wiphy = hdd_ctx->wiphy; |
| 7202 | |
| 7203 | /* |
| 7204 | * The channel information in |
| 7205 | * wiphy needs to be initialized before wiphy registration |
| 7206 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7207 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7208 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7209 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7210 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7211 | } |
| 7212 | |
| 7213 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7214 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7215 | #else |
| 7216 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7217 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7218 | WIPHY_WOWLAN_DISCONNECT | |
| 7219 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7220 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7221 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7222 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7223 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7224 | |
| 7225 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7226 | WOW_MAX_FILTERS_PER_LIST); |
| 7227 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7228 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7229 | #endif |
| 7230 | |
| 7231 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7232 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7233 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7234 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7235 | return ret_val; |
| 7236 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7237 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7238 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7239 | * has support for processing user cell_base hints when wiphy is |
| 7240 | * self managed or check the backport flag for the same. |
| 7241 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7242 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7243 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7244 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7245 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7246 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7247 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7248 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7249 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7250 | } |
| 7251 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7252 | #ifdef MSM_PLATFORM |
| 7253 | /** |
| 7254 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7255 | * @hdd_ctx - handle to hdd context |
| 7256 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7257 | * |
| 7258 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7259 | * Stats show up in wlan driver logs. |
| 7260 | * |
| 7261 | * Returns: None |
| 7262 | */ |
| 7263 | static inline |
| 7264 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7265 | bool data_in_interval) |
| 7266 | { |
| 7267 | static u32 counter; |
| 7268 | static bool data_in_time_period; |
| 7269 | ol_txrx_pdev_handle pdev; |
| 7270 | |
| 7271 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7272 | return; |
| 7273 | |
| 7274 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7275 | if (!pdev) { |
| 7276 | hdd_err("pdev is NULL"); |
| 7277 | return; |
| 7278 | } |
| 7279 | |
| 7280 | counter++; |
| 7281 | if (data_in_interval) |
| 7282 | data_in_time_period = data_in_interval; |
| 7283 | |
| 7284 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7285 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7286 | if (data_in_time_period) { |
| 7287 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7288 | CDP_TXRX_PATH_STATS, |
| 7289 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7290 | wlan_hdd_display_netif_queue_history |
| 7291 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7292 | qdf_dp_trace_dump_stats(); |
| 7293 | } |
| 7294 | counter = 0; |
| 7295 | data_in_time_period = false; |
| 7296 | } |
| 7297 | } |
| 7298 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7299 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7300 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7301 | * @hdd_ctx: pointer to struct hdd_context |
| 7302 | * |
| 7303 | * Return: none |
| 7304 | */ |
| 7305 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7306 | { |
| 7307 | struct hdd_adapter *adapter; |
| 7308 | |
| 7309 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7310 | hdd_send_rps_disable_ind(adapter); |
| 7311 | } |
| 7312 | |
| 7313 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7314 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7315 | * @hdd_ctx - handle to hdd context |
| 7316 | * @tx_packets - transmit packet count |
| 7317 | * @rx_packets - receive packet count |
| 7318 | * |
| 7319 | * The function controls the bus bandwidth and dynamic control of |
| 7320 | * tcp delayed ack configuration |
| 7321 | * |
| 7322 | * Returns: None |
| 7323 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7324 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7325 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7326 | const uint64_t tx_packets, |
| 7327 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7328 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7329 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7330 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7331 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7332 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7333 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7334 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7335 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7336 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7337 | uint16_t index = 0; |
| 7338 | bool vote_level_change = false; |
| 7339 | bool rx_level_change = false; |
| 7340 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7341 | bool rxthread_high_tput_req = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7342 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7343 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7344 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7345 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7346 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7347 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7348 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7349 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7350 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7351 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7352 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7353 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7354 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7355 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7356 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7357 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7358 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7359 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7360 | if (hdd_ctx->hbw_requested) { |
| 7361 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7362 | hdd_ctx->hbw_requested = false; |
| 7363 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7364 | if (hdd_ctx->dynamic_rps) |
| 7365 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7366 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7367 | if (!hdd_ctx->hbw_requested) { |
| 7368 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7369 | hdd_ctx->hbw_requested = true; |
| 7370 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7371 | if (hdd_ctx->dynamic_rps) |
| 7372 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7373 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7374 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7375 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7376 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7377 | tx_packets, |
| 7378 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7379 | |
| 7380 | if (rx_packets < hdd_ctx->config->busBandwidthLowThreshold) |
| 7381 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7382 | else |
| 7383 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
| 7384 | |
Manjunathappa Prakash | 5f5ed13 | 2018-06-05 20:51:30 -0700 | [diff] [blame] | 7385 | qdf_dp_trace_apply_tput_policy(next_vote_level); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7386 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7387 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7388 | /* |
| 7389 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7390 | * perf core is also required for udp. |
| 7391 | */ |
| 7392 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7393 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7394 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7395 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7396 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7397 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7398 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7399 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7400 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7401 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7402 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7403 | |
| 7404 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7405 | /* |
| 7406 | * Takes care to set Rx_thread affinity for below case |
| 7407 | * 1)LRO/GRO not supported ROME case |
| 7408 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7409 | * 3)For UDP cases |
| 7410 | */ |
| 7411 | if (avg_no_rx_offload_pkts > |
| 7412 | hdd_ctx->config->busBandwidthHighThreshold) |
| 7413 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7414 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7415 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7416 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7417 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7418 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7419 | rxthread_high_tput_req); |
| 7420 | |
| 7421 | /* fine-tuning parameters for RX Flows */ |
| 7422 | if (avg_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7423 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7424 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7425 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7426 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7427 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7428 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7429 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7430 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7431 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7432 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7433 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7434 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7435 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7436 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7437 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7438 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7439 | /* Send throughput indication only if it is enabled. |
| 7440 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7441 | * to default delayed ack. Note that this will disable the |
| 7442 | * dynamic delayed ack mechanism across the system |
| 7443 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7444 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7445 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7446 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7447 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7448 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7449 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7450 | rx_tp_data.level = next_rx_level; |
| 7451 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7452 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7453 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7454 | } |
| 7455 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7456 | /* fine-tuning parameters for TX Flows */ |
| 7457 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7458 | hdd_ctx->prev_tx = tx_packets; |
| 7459 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7460 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7461 | else |
| 7462 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7463 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7464 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7465 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7466 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7467 | next_tx_level, temp_tx); |
| 7468 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7469 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7470 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7471 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7472 | &next_tx_level, |
| 7473 | sizeof(next_tx_level)); |
| 7474 | } |
| 7475 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7476 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7477 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7478 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7479 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7480 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7481 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7482 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7483 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7484 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7485 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7486 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7487 | |
| 7488 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7489 | } |
| 7490 | |
| 7491 | #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] | 7492 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7493 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7494 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7495 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7496 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7497 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7498 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7499 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7500 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7501 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7502 | bool connected = false; |
| 7503 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7504 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7505 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7506 | return; |
| 7507 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7508 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7509 | goto restart_timer; |
| 7510 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7511 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7512 | /* |
| 7513 | * Validate magic so we don't end up accessing |
| 7514 | * an invalid adapter. |
| 7515 | */ |
| 7516 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7517 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7518 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7519 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7520 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7521 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7522 | != eConnectionState_Associated) { |
| 7523 | |
| 7524 | continue; |
| 7525 | } |
| 7526 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7527 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7528 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7529 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7530 | |
| 7531 | continue; |
| 7532 | } |
| 7533 | |
| 7534 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7535 | adapter->prev_tx_packets); |
| 7536 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7537 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7538 | |
| 7539 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7540 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7541 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7542 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7543 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7544 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7545 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7546 | &fwd_tx_packets, &fwd_rx_packets); |
| 7547 | if (ret == A_OK) { |
| 7548 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7549 | fwd_tx_packets, |
| 7550 | adapter->prev_fwd_tx_packets); |
| 7551 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7552 | fwd_tx_packets, |
| 7553 | adapter->prev_fwd_rx_packets); |
| 7554 | } |
| 7555 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7556 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7557 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7558 | con_sap_adapter = adapter; |
| 7559 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7560 | total_rx += adapter->stats.rx_packets; |
| 7561 | total_tx += adapter->stats.tx_packets; |
| 7562 | |
| 7563 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7564 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7565 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7566 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7567 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7568 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7569 | connected = true; |
| 7570 | } |
| 7571 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7572 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7573 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7574 | return; |
| 7575 | } |
| 7576 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7577 | /* add intra bss forwarded tx and rx packets */ |
| 7578 | tx_packets += fwd_tx_packets_diff; |
| 7579 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7580 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7581 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->hdd_pdev)) { |
| 7582 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7583 | &ipa_rx_packets); |
| 7584 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7585 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7586 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7587 | if (con_sap_adapter) { |
| 7588 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7589 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7590 | } |
| 7591 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7592 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
| 7593 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
| 7594 | } |
| 7595 | |
| 7596 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7597 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7598 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7599 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7600 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7601 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7602 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7603 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7604 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7605 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7606 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7607 | /** |
| 7608 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7609 | * @arg: Argument of timer function |
| 7610 | * |
| 7611 | * Schedule a workqueue in this function where all the processing is done. |
| 7612 | * |
| 7613 | * Return: None. |
| 7614 | */ |
| 7615 | static void __hdd_bus_bw_cbk(void *arg) |
| 7616 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7617 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7618 | |
| 7619 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7620 | return; |
| 7621 | |
| 7622 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7623 | } |
| 7624 | |
| 7625 | /** |
| 7626 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7627 | * @arg: Argument of timer function |
| 7628 | * |
| 7629 | * Return: None. |
| 7630 | */ |
| 7631 | static void hdd_bus_bw_cbk(void *arg) |
| 7632 | { |
| 7633 | cds_ssr_protect(__func__); |
| 7634 | __hdd_bus_bw_cbk(arg); |
| 7635 | cds_ssr_unprotect(__func__); |
| 7636 | } |
| 7637 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7638 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7639 | { |
| 7640 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7641 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7642 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7643 | hdd_ctx->bus_bw_timer_running = false; |
| 7644 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7645 | qdf_timer_init(NULL, |
| 7646 | &hdd_ctx->bus_bw_timer, |
| 7647 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7648 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7649 | |
| 7650 | return 0; |
| 7651 | } |
| 7652 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7653 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7654 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7655 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7656 | hdd_reset_tcp_delack(hdd_ctx); |
| 7657 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7658 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7659 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7660 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7661 | hdd_ctx->bus_bw_timer_running = false; |
| 7662 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7663 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7664 | |
| 7665 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7666 | { |
| 7667 | if (hdd_ctx) |
| 7668 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7669 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7670 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7671 | #endif |
| 7672 | |
| 7673 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7674 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7675 | * @hdd_ctx: hdd context |
| 7676 | * |
| 7677 | * Return: 0 for success or error code |
| 7678 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7679 | 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] | 7680 | { |
| 7681 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7682 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7683 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7684 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7685 | return -ENOMEM; |
| 7686 | } |
| 7687 | return 0; |
| 7688 | } |
| 7689 | |
| 7690 | /** |
| 7691 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7692 | * @hdd_ctx: hdd context |
| 7693 | * |
| 7694 | * Return: none |
| 7695 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7696 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7697 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7698 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7699 | return; |
| 7700 | |
| 7701 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7702 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7703 | } |
| 7704 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7705 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7706 | { |
| 7707 | switch (level) { |
| 7708 | /* initialize the wlan sub system */ |
| 7709 | case WLAN_SVC_TP_NONE: |
| 7710 | return "NONE"; |
| 7711 | case WLAN_SVC_TP_LOW: |
| 7712 | return "LOW"; |
| 7713 | case WLAN_SVC_TP_MEDIUM: |
| 7714 | return "MED"; |
| 7715 | case WLAN_SVC_TP_HIGH: |
| 7716 | return "HIGH"; |
| 7717 | default: |
| 7718 | return "INVAL"; |
| 7719 | } |
| 7720 | } |
| 7721 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7722 | |
| 7723 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7724 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7725 | * @hdd_ctx: hdd context |
| 7726 | * |
| 7727 | * Return: none |
| 7728 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7729 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7730 | { |
| 7731 | int i; |
| 7732 | |
| 7733 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7734 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7735 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7736 | 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] | 7737 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7738 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7739 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7740 | hdd_debug("Enable TCP DEL ACK: %d", |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7741 | hdd_ctx->en_tcp_delack_no_lro); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7742 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7743 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7744 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7745 | 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] | 7746 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7747 | #endif |
| 7748 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7749 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7750 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7751 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7752 | 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] | 7753 | |
| 7754 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7755 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7756 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7757 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7758 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7759 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7760 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7761 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7762 | hdd_ctx->hdd_txrx_hist[i]. |
| 7763 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7764 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7765 | hdd_ctx->hdd_txrx_hist[i]. |
| 7766 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7767 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7768 | hdd_ctx->hdd_txrx_hist[i]. |
| 7769 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7770 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7771 | } |
| 7772 | |
| 7773 | /** |
| 7774 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7775 | * @hdd_ctx: hdd context |
| 7776 | * |
| 7777 | * Return: none |
| 7778 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7779 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7780 | { |
| 7781 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7782 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7783 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7784 | } |
| 7785 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7786 | /* length of the netif queue log needed per adapter */ |
| 7787 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7788 | |
| 7789 | /** |
| 7790 | * |
| 7791 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7792 | * @hdd_ctx: hdd context |
| 7793 | * |
| 7794 | * Return: none |
| 7795 | */ |
| 7796 | static void |
| 7797 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7798 | { |
| 7799 | int adapter_num = 0; |
| 7800 | int i; |
| 7801 | int bytes_written; |
| 7802 | u32 tbytes; |
| 7803 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7804 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7805 | char *comb_log_str; |
| 7806 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7807 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7808 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7809 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7810 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7811 | if (!comb_log_str) { |
| 7812 | hdd_err("failed to alloc comb_log_str"); |
| 7813 | return; |
| 7814 | } |
| 7815 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7816 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7817 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7818 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7819 | curr_time = qdf_system_ticks(); |
| 7820 | total = curr_time - adapter->start_time; |
| 7821 | delta = curr_time - adapter->last_time; |
| 7822 | |
| 7823 | if (adapter->pause_map) { |
| 7824 | pause = adapter->total_pause_time + delta; |
| 7825 | unpause = adapter->total_unpause_time; |
| 7826 | } else { |
| 7827 | unpause = adapter->total_unpause_time + delta; |
| 7828 | pause = adapter->total_pause_time; |
| 7829 | } |
| 7830 | |
| 7831 | tbytes = 0; |
| 7832 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7833 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7834 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7835 | continue; |
| 7836 | tbytes += |
| 7837 | snprintf( |
| 7838 | &temp_str[tbytes], |
| 7839 | (tbytes >= sizeof(temp_str) ? |
| 7840 | 0 : sizeof(temp_str) - tbytes), |
| 7841 | "%d(%d,%d) ", |
| 7842 | i, |
| 7843 | adapter->queue_oper_stats[i]. |
| 7844 | pause_count, |
| 7845 | adapter->queue_oper_stats[i]. |
| 7846 | unpause_count); |
| 7847 | } |
| 7848 | if (tbytes >= sizeof(temp_str)) |
| 7849 | hdd_warn("log truncated"); |
| 7850 | |
| 7851 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7852 | bytes_written >= comb_log_str_size ? 0 : |
| 7853 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7854 | "[%d %d] (%d) %u/%ums %s|", |
| 7855 | adapter->session_id, adapter->device_mode, |
| 7856 | adapter->pause_map, |
| 7857 | qdf_system_ticks_to_msecs(pause), |
| 7858 | qdf_system_ticks_to_msecs(total), |
| 7859 | temp_str); |
| 7860 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7861 | adapter_num++; |
| 7862 | } |
| 7863 | |
| 7864 | /* using QDF_TRACE to avoid printing function name */ |
| 7865 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7866 | "STATS |%s", comb_log_str); |
| 7867 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7868 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7869 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7870 | |
| 7871 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7872 | } |
| 7873 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7874 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7875 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7876 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7877 | * |
| 7878 | * Return: none |
| 7879 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7880 | void |
| 7881 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7882 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7883 | { |
| 7884 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7885 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7886 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7887 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7889 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7890 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7891 | return; |
| 7892 | } |
| 7893 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7894 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7895 | hdd_debug("Netif queue operation statistics:"); |
| 7896 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7897 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7898 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7899 | curr_time = qdf_system_ticks(); |
| 7900 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7901 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7902 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7903 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7904 | unpause = adapter->total_unpause_time; |
| 7905 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7906 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7907 | pause = adapter->total_pause_time; |
| 7908 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7909 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7910 | qdf_system_ticks_to_msecs(total), |
| 7911 | qdf_system_ticks_to_msecs(pause), |
| 7912 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7913 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7914 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7915 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7916 | qdf_time_t pause_delta = 0; |
| 7917 | |
| 7918 | if (adapter->pause_map & (1 << i)) |
| 7919 | pause_delta = delta; |
| 7920 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7921 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7922 | hdd_debug("%s: %d: %d: %ums", |
| 7923 | hdd_reason_type_to_string(i), |
| 7924 | adapter->queue_oper_stats[i].pause_count, |
| 7925 | adapter->queue_oper_stats[i].unpause_count, |
| 7926 | qdf_system_ticks_to_msecs( |
| 7927 | adapter->queue_oper_stats[i].total_pause_time + |
| 7928 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7929 | } |
| 7930 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7931 | hdd_debug("Netif queue operation history:"); |
| 7932 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7933 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7934 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7935 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7936 | |
| 7937 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7938 | /* using hdd_log to avoid printing function name */ |
| 7939 | if (adapter->queue_oper_history[i].time == 0) |
| 7940 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7941 | hdd_debug("%d: %u: %s: %s: %x", |
| 7942 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7943 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7944 | hdd_action_type_to_string( |
| 7945 | adapter->queue_oper_history[i].netif_action), |
| 7946 | hdd_reason_type_to_string( |
| 7947 | adapter->queue_oper_history[i].netif_reason), |
| 7948 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7949 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7950 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7951 | } |
| 7952 | |
| 7953 | /** |
| 7954 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 7955 | * @hdd_ctx: hdd context |
| 7956 | * |
| 7957 | * Return: none |
| 7958 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7959 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7960 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7961 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7962 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7963 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7964 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7965 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7966 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7967 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7968 | adapter->history_index = 0; |
| 7969 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 7970 | adapter->total_pause_time = 0; |
| 7971 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7972 | } |
| 7973 | } |
| 7974 | |
| 7975 | /** |
| 7976 | * hdd_11d_scan_done() - callback for 11d scan completion of flushing results |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7977 | * @mac_handle: MAC handle |
| 7978 | * @context: Pointer to the context |
| 7979 | * @session_id: Session ID |
| 7980 | * @scan_id: Scan ID |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7981 | * @status: Status |
| 7982 | * |
| 7983 | * This is the callback to be executed when 11d scan is completed to flush out |
| 7984 | * the scan results |
| 7985 | * |
| 7986 | * 11d scan is done during driver load and is a passive scan on all |
| 7987 | * channels supported by the device, 11d scans may find some APs on |
| 7988 | * frequencies which are forbidden to be used in the regulatory domain |
| 7989 | * the device is operating in. If these APs are notified to the supplicant |
| 7990 | * it may try to connect to these APs, thus flush out all the scan results |
| 7991 | * which are present in SME after 11d scan is done. |
| 7992 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7993 | * Return: QDF_STATUS_SUCCESS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7994 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7995 | static QDF_STATUS hdd_11d_scan_done(mac_handle_t mac_handle, void *context, |
| 7996 | uint8_t session_id, uint32_t scan_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7997 | eCsrScanStatus status) |
| 7998 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7999 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8000 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8001 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8002 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8003 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8004 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8005 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8006 | } |
| 8007 | |
| 8008 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8009 | /** |
| 8010 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8011 | * @hdd_ctx: hdd global context |
| 8012 | * |
| 8013 | * Return: none |
| 8014 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8015 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8016 | { |
| 8017 | uint8_t i; |
| 8018 | |
| 8019 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8020 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8021 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8022 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8023 | } |
| 8024 | } |
| 8025 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8026 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8027 | { |
| 8028 | } |
| 8029 | #endif |
| 8030 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8031 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8032 | /** |
| 8033 | * 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] | 8034 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8035 | * @enable: enable or disable this behaviour |
| 8036 | * |
| 8037 | * Return: int |
| 8038 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8039 | 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] | 8040 | { |
| 8041 | struct hdd_config *pcfg_ini = phddctx->config; |
| 8042 | struct wow_pulse_mode wow_pulse_set_info; |
| 8043 | QDF_STATUS status; |
| 8044 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8045 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8046 | |
| 8047 | if (false == phddctx->config->wow_pulse_support) |
| 8048 | return 0; |
| 8049 | |
| 8050 | /* prepare the request to send to SME */ |
| 8051 | if (enable == true) { |
| 8052 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8053 | wow_pulse_set_info.wow_pulse_pin = |
| 8054 | pcfg_ini->wow_pulse_pin; |
| 8055 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8056 | pcfg_ini->wow_pulse_interval_low; |
| 8057 | wow_pulse_set_info.wow_pulse_interval_high = |
| 8058 | pcfg_ini->wow_pulse_interval_high; |
| 8059 | } else { |
| 8060 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8061 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8062 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8063 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8064 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8065 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8066 | wow_pulse_set_info.wow_pulse_enable, |
| 8067 | wow_pulse_set_info.wow_pulse_pin, |
| 8068 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8069 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8070 | |
| 8071 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8072 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8073 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8074 | return -EIO; |
| 8075 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8076 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8077 | return 0; |
| 8078 | } |
| 8079 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8080 | 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] | 8081 | { |
| 8082 | return 0; |
| 8083 | } |
| 8084 | #endif |
| 8085 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8086 | #ifdef WLAN_FEATURE_FASTPATH |
| 8087 | /** |
| 8088 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8089 | * @hdd_cfg: hdd config |
| 8090 | * @context: lower layer context |
| 8091 | * |
| 8092 | * Return: none |
| 8093 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8094 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8095 | void *context) |
| 8096 | { |
| 8097 | if (hdd_cfg->fastpath_enable) |
| 8098 | hif_enable_fastpath(context); |
| 8099 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8100 | #endif |
| 8101 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8102 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8103 | /** |
| 8104 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8105 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8106 | * @level: thermal level |
| 8107 | * |
| 8108 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8109 | * than 0, and restore the original data path when throttle level is 0 |
| 8110 | * |
| 8111 | * Return: none |
| 8112 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8113 | 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] | 8114 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8115 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8116 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8117 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8118 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8119 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8120 | else |
| 8121 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8122 | 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] | 8123 | } |
| 8124 | |
| 8125 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8126 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8127 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8128 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8129 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8130 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8131 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8132 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8133 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8134 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8135 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8136 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8137 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8138 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8139 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8140 | struct sir_pcl_list pcl; |
| 8141 | QDF_STATUS status; |
| 8142 | uint32_t i, j; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8143 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8144 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8145 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 8146 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8147 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8148 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8149 | if (!hdd_ctx) { |
| 8150 | hdd_err("invalid HDD context"); |
| 8151 | return INVALID_CHANNEL_ID; |
| 8152 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8153 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8154 | mac_handle = hdd_ctx->mac_handle; |
| 8155 | if (!mac_handle) { |
| 8156 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8157 | return INVALID_CHANNEL_ID; |
| 8158 | } |
| 8159 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8160 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 8161 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8162 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8163 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8164 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8165 | hdd_err("Get PCL failed"); |
| 8166 | return INVALID_CHANNEL_ID; |
| 8167 | } |
| 8168 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8169 | /* |
| 8170 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8171 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8172 | * try to choose a safe channel from acs range. |
| 8173 | */ |
| 8174 | if (!pcl.pcl_len) |
| 8175 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8176 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8177 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8178 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8179 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8180 | |
| 8181 | /* PCL already takes unsafe channel into account */ |
| 8182 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8183 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8184 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8185 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8186 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8187 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8188 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8189 | return pcl.pcl_list[i]; |
| 8190 | } |
| 8191 | } |
| 8192 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8193 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8194 | |
| 8195 | /* Try for safe channel from all valid channel */ |
| 8196 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 8197 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8198 | &pcl.pcl_len); |
| 8199 | if (ret) { |
| 8200 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8201 | return INVALID_CHANNEL_ID; |
| 8202 | } |
| 8203 | |
| 8204 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8205 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8206 | found = false; |
| 8207 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 8208 | if (pcl.pcl_list[i] == |
| 8209 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8210 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8211 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8212 | break; |
| 8213 | } |
| 8214 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8215 | |
| 8216 | if (found) |
| 8217 | continue; |
| 8218 | |
| 8219 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8220 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8221 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8222 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8223 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8224 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8225 | } |
| 8226 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8227 | |
| 8228 | return INVALID_CHANNEL_ID; |
| 8229 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8230 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8231 | |
| 8232 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8233 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8234 | * @adapter: AP adapter |
| 8235 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8236 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8237 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8238 | * Moves the SAP interface by invoking the function which |
| 8239 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8240 | * |
| 8241 | * Return: None |
| 8242 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8243 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8244 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8245 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8246 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8247 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8248 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8249 | |
| 8250 | if (!adapter) { |
| 8251 | hdd_err("invalid adapter"); |
| 8252 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8253 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8254 | |
| 8255 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8256 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8257 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8258 | if (!mac_handle) { |
| 8259 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8260 | return; |
| 8261 | } |
| 8262 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8263 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8264 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8265 | hdd_ap_ctx->sap_config.channel = channel; |
Himanshu Agarwal | f5c5b10 | 2018-05-22 20:13:57 +0530 | [diff] [blame] | 8266 | hdd_ap_ctx->sap_config.ch_params.ch_width = CH_WIDTH_MAX; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8267 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8268 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8269 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8270 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 8271 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8272 | hdd_ap_ctx->sap_config.channel, |
| 8273 | hdd_ap_ctx->sap_config.sec_ch, |
| 8274 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8275 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8276 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8277 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8278 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8279 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8280 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8281 | 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] | 8282 | { |
| 8283 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8284 | int status; |
| 8285 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8286 | |
| 8287 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8288 | |
| 8289 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8290 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8291 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8292 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8293 | } |
| 8294 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8295 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8296 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8297 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8298 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8299 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8300 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8301 | hdd_err("failed to start external acs timer"); |
| 8302 | return -ENOSPC; |
| 8303 | } |
| 8304 | /* Update config to application */ |
| 8305 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8306 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8307 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8308 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8309 | } |
| 8310 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8311 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8312 | /** |
| 8313 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8314 | * @hdd_ctx: hdd context pointer |
| 8315 | * |
| 8316 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8317 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8318 | * sap. User space on LTE coex indication restart driver. |
| 8319 | * |
| 8320 | * Return - none |
| 8321 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8322 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8323 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8324 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8325 | uint32_t i; |
| 8326 | bool found = false; |
| 8327 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8328 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8329 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8330 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8331 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8332 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8333 | adapter->device_mode, |
| 8334 | adapter->session.ap.sap_config. |
| 8335 | acs_cfg.acs_mode); |
| 8336 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8337 | } |
| 8338 | |
| 8339 | found = false; |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8340 | /* |
| 8341 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8342 | * is set, no need to move SAP. |
| 8343 | */ |
| 8344 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->hdd_psoc, |
| 8345 | adapter->session.ap.operating_channel) && |
| 8346 | hdd_ctxt->config->sta_sap_scc_on_lte_coex_chan) |
| 8347 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8348 | else { |
| 8349 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8350 | if (adapter->session.ap.operating_channel == |
| 8351 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8352 | found = true; |
| 8353 | hdd_debug("operating ch:%d is unsafe", |
| 8354 | adapter->session.ap.operating_channel); |
| 8355 | break; |
| 8356 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8357 | } |
| 8358 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8359 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8360 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8361 | adapter->session.ap.operating_channel); |
| 8362 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8363 | } |
| 8364 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8365 | if (hdd_ctxt->config->vendor_acs_support && |
| 8366 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8367 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8368 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8369 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8370 | } else |
| 8371 | restart_chan = |
| 8372 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8373 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8374 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8375 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8376 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8377 | /* |
| 8378 | * SAP restart due to unsafe channel. While |
| 8379 | * restarting the SAP, make sure to clear |
| 8380 | * acs_channel, channel to reset to |
| 8381 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8382 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8383 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8384 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8385 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8386 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8387 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8388 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8389 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8390 | hdd_debug("driver to start sap: %d", |
| 8391 | hdd_ctxt->config->sap_internal_restart); |
| 8392 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8393 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8394 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8395 | else |
| 8396 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8397 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8398 | } |
| 8399 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8400 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8401 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8402 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8403 | * @hdd_ctx: HDD global context |
| 8404 | * |
| 8405 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8406 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8407 | * down to the lower layers. Then subscribe to subsequent channel |
| 8408 | * avoidance events. |
| 8409 | * |
| 8410 | * Return: None |
| 8411 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8412 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8413 | { |
| 8414 | uint16_t unsafe_channel_count; |
| 8415 | int index; |
| 8416 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8417 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8418 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8419 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8420 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8421 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8422 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8423 | hdd_ctx->unsafe_channel_count); |
| 8424 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8425 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8426 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8427 | |
| 8428 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8429 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8430 | hdd_ctx->unsafe_channel_list[index]); |
| 8431 | |
| 8432 | } |
| 8433 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8434 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8435 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8436 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8437 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8438 | { |
| 8439 | uint8_t restart_chan; |
| 8440 | |
| 8441 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8442 | if (!restart_chan) { |
| 8443 | hdd_alert("fail to restart SAP"); |
| 8444 | return; |
| 8445 | } |
| 8446 | |
| 8447 | /* SAP restart due to unsafe channel. While restarting |
| 8448 | * the SAP, make sure to clear acs_channel, channel to |
| 8449 | * reset to 0. Otherwise these settings will override |
| 8450 | * the ACS while restart. |
| 8451 | */ |
| 8452 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8453 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8454 | |
| 8455 | hdd_debug("sending coex indication"); |
| 8456 | |
| 8457 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8458 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8459 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8460 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8461 | |
| 8462 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8463 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8464 | { |
| 8465 | uint32_t size; |
| 8466 | uint16_t *unsafe_list; |
| 8467 | uint16_t chan_count; |
| 8468 | |
| 8469 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8470 | return -EINVAL; |
| 8471 | |
| 8472 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8473 | NUM_CHANNELS); |
| 8474 | if (chan_count) { |
| 8475 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8476 | unsafe_list = qdf_mem_malloc(size); |
| 8477 | if (!unsafe_list) { |
| 8478 | hdd_err("No memory for unsafe chan list size%d", |
| 8479 | size); |
| 8480 | return -ENOMEM; |
| 8481 | } |
| 8482 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8483 | } else { |
| 8484 | unsafe_list = NULL; |
| 8485 | } |
| 8486 | |
| 8487 | *local_unsafe_list = unsafe_list; |
| 8488 | *local_unsafe_list_count = chan_count; |
| 8489 | |
| 8490 | return 0; |
| 8491 | } |
| 8492 | |
| 8493 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8494 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8495 | { |
| 8496 | int i, j; |
| 8497 | |
| 8498 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8499 | return true; |
| 8500 | if (local_unsafe_list_count == 0) |
| 8501 | return false; |
| 8502 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8503 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8504 | if (local_unsafe_list[i] == |
| 8505 | hdd_ctx->unsafe_channel_list[j]) |
| 8506 | break; |
| 8507 | if (j >= local_unsafe_list_count) |
| 8508 | break; |
| 8509 | } |
| 8510 | if (i >= local_unsafe_list_count) { |
| 8511 | hdd_info("unsafe chan list same"); |
| 8512 | return false; |
| 8513 | } |
| 8514 | |
| 8515 | return true; |
| 8516 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8517 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8518 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8519 | { |
| 8520 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8521 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8522 | 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] | 8523 | { |
| 8524 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8525 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8526 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8527 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8528 | { |
| 8529 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8530 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8531 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8532 | |
| 8533 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8534 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8535 | * user space |
| 8536 | * @frame_ind: Management frame data to be informed. |
| 8537 | * |
| 8538 | * This function is used to indicate management frame to |
| 8539 | * user space |
| 8540 | * |
| 8541 | * Return: None |
| 8542 | * |
| 8543 | */ |
| 8544 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8545 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8546 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8547 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8548 | int i; |
| 8549 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8550 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8551 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8552 | return; |
| 8553 | |
| 8554 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8555 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8556 | adapter = |
| 8557 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8558 | if (adapter) |
| 8559 | break; |
| 8560 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8561 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8562 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8563 | if ((NULL != adapter) && |
| 8564 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8565 | __hdd_indicate_mgmt_frame(adapter, |
| 8566 | frame_ind->frame_len, |
| 8567 | frame_ind->frameBuf, |
| 8568 | frame_ind->frameType, |
| 8569 | frame_ind->rxChan, |
| 8570 | frame_ind->rxRssi); |
| 8571 | } |
| 8572 | } |
| 8573 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8574 | } else { |
| 8575 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8576 | frame_ind->sessionId); |
| 8577 | } |
| 8578 | |
| 8579 | if ((NULL != adapter) && |
| 8580 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8581 | __hdd_indicate_mgmt_frame(adapter, |
| 8582 | frame_ind->frame_len, |
| 8583 | frame_ind->frameBuf, |
| 8584 | frame_ind->frameType, |
| 8585 | frame_ind->rxChan, |
| 8586 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8587 | } |
| 8588 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8589 | void hdd_acs_response_timeout_handler(void *context) |
| 8590 | { |
| 8591 | struct hdd_external_acs_timer_context *timer_context = |
| 8592 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8593 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8594 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8595 | uint8_t reason; |
| 8596 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8597 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8598 | if (!timer_context) { |
| 8599 | hdd_err("invlaid timer context"); |
| 8600 | return; |
| 8601 | } |
| 8602 | adapter = timer_context->adapter; |
| 8603 | reason = timer_context->reason; |
| 8604 | |
| 8605 | |
| 8606 | if ((!adapter) || |
| 8607 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8608 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8609 | return; |
| 8610 | } |
| 8611 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8612 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8613 | return; |
| 8614 | |
| 8615 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8616 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8617 | else |
| 8618 | return; |
| 8619 | |
| 8620 | hdd_err("ACS timeout happened for %s reason %d", |
| 8621 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8622 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8623 | switch (reason) { |
| 8624 | /* SAP init case */ |
| 8625 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8626 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8627 | false); |
| 8628 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8629 | break; |
| 8630 | /* DFS detected on current channel */ |
| 8631 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8632 | wlan_sap_update_next_channel( |
| 8633 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8634 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8635 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8636 | break; |
| 8637 | /* LTE coex event on current channel */ |
| 8638 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8639 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8640 | break; |
| 8641 | default: |
| 8642 | hdd_info("invalid reason for timer invoke"); |
| 8643 | |
| 8644 | } |
| 8645 | } |
| 8646 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8647 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8648 | * hdd_override_ini_config - Override INI config |
| 8649 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8650 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8651 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8652 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8653 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8654 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8655 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8656 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8657 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8658 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8659 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8660 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8661 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8662 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8663 | if (0 == enable_11d || 1 == enable_11d) { |
| 8664 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8665 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8666 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8667 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8668 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8669 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8670 | hdd_debug("IpaConfig override to %d", |
| 8671 | hdd_ctx->config->IpaConfig); |
| 8672 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8673 | |
| 8674 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8675 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8676 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8677 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8678 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8679 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8680 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8681 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8682 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8683 | /** |
| 8684 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8685 | * @hdd_ctx - HDD context |
| 8686 | * |
| 8687 | * Set trace level for each module based on INI config. |
| 8688 | * |
| 8689 | * Return: None |
| 8690 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8691 | 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] | 8692 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8693 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8694 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8695 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8696 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8697 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8698 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8699 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8700 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8701 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8702 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8703 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8704 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8705 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8706 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8707 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8708 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8709 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8710 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8711 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8712 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8713 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8714 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8715 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8716 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8717 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8718 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8719 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8720 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8721 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8722 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8723 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8724 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8725 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8726 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8727 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8728 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8729 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8730 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8731 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8732 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8733 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8734 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8735 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8736 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8737 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8738 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8739 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8740 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8741 | } |
| 8742 | |
| 8743 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8744 | * hdd_context_init() - Initialize HDD context |
| 8745 | * @hdd_ctx: HDD context. |
| 8746 | * |
| 8747 | * Initialize HDD context along with all the feature specific contexts. |
| 8748 | * |
| 8749 | * return: 0 on success and errno on failure. |
| 8750 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8751 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8752 | { |
| 8753 | int ret; |
| 8754 | |
| 8755 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8756 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8757 | |
| 8758 | hdd_init_ll_stats_ctx(); |
| 8759 | |
| 8760 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8761 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8762 | |
Nachiket Kukade | 177b5b0 | 2018-05-22 20:52:17 +0530 | [diff] [blame] | 8763 | hdd_apf_context_init(); |
| 8764 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8765 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8766 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8767 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8768 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8769 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8770 | |
| 8771 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8772 | |
| 8773 | ret = hdd_scan_context_init(hdd_ctx); |
| 8774 | if (ret) |
| 8775 | goto list_destroy; |
| 8776 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8777 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8778 | |
| 8779 | ret = hdd_sap_context_init(hdd_ctx); |
| 8780 | if (ret) |
| 8781 | goto scan_destroy; |
| 8782 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8783 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8784 | |
| 8785 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8786 | |
| 8787 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8788 | hdd_ctx->config); |
| 8789 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8790 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8791 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8792 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8793 | "monitor_mode_wakelock"); |
| 8794 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8795 | return 0; |
| 8796 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8797 | sap_destroy: |
| 8798 | hdd_sap_context_destroy(hdd_ctx); |
| 8799 | |
| 8800 | scan_destroy: |
| 8801 | hdd_scan_context_destroy(hdd_ctx); |
| 8802 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8803 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8804 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8805 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8806 | return ret; |
| 8807 | } |
| 8808 | |
| 8809 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8810 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8811 | * @hdd_ctx: pointer to hdd context |
| 8812 | * |
| 8813 | * Return: status of initialization |
| 8814 | * 0 - success |
| 8815 | * negative value - failure |
| 8816 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8817 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8818 | { |
| 8819 | int ret; |
| 8820 | |
| 8821 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8822 | return 0; |
| 8823 | |
| 8824 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8825 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8826 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8827 | return -EINVAL; |
| 8828 | } |
| 8829 | |
| 8830 | /* parse ini string probe req oui */ |
| 8831 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8832 | if (ret) { |
| 8833 | hdd_err("parsing error: disable ie whitelisting"); |
| 8834 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8835 | } |
| 8836 | |
| 8837 | return ret; |
| 8838 | } |
| 8839 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8840 | /** |
| 8841 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8842 | * @priv: pointer to hdd context |
| 8843 | * |
| 8844 | * This function is invoked when the timer waiting for the interface change |
| 8845 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8846 | * |
| 8847 | * Return: void |
| 8848 | */ |
| 8849 | static void hdd_iface_change_callback(void *priv) |
| 8850 | { |
| 8851 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8852 | int ret; |
| 8853 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8854 | |
| 8855 | if (status) |
| 8856 | return; |
| 8857 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8858 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8859 | hdd_debug("Interface change timer expired close the modules!"); |
| 8860 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8861 | if (ret) |
| 8862 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8863 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8864 | } |
| 8865 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8866 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8867 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8868 | { |
| 8869 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8870 | wlan_logging_to_console); |
| 8871 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8872 | } |
| 8873 | #else |
| 8874 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8875 | { } |
| 8876 | #endif |
| 8877 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8878 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8879 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8880 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8881 | * |
| 8882 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8883 | * wiphy allocation and then context is initialized. |
| 8884 | * |
| 8885 | * Return: HDD context on success and ERR_PTR on failure |
| 8886 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8887 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8888 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8889 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8890 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8891 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8892 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8893 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8894 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8895 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8896 | if (hdd_ctx == NULL) { |
| 8897 | ret = -ENOMEM; |
| 8898 | goto err_out; |
| 8899 | } |
| 8900 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8901 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8902 | hdd_iface_change_callback, |
| 8903 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8904 | |
| 8905 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8906 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8907 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8908 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8909 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8910 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8911 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8912 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8913 | ret = -ENOMEM; |
| 8914 | goto err_free_hdd_context; |
| 8915 | } |
| 8916 | |
| 8917 | /* Read and parse the qcom_cfg.ini file */ |
| 8918 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8919 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8920 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8921 | WLAN_INI_FILE); |
| 8922 | ret = -EINVAL; |
| 8923 | goto err_free_config; |
| 8924 | } |
| 8925 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame^] | 8926 | status = cfg_parse(WLAN_INI_FILE); |
| 8927 | if (QDF_IS_STATUS_ERROR(status)) |
| 8928 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 8929 | WLAN_INI_FILE, status); |
| 8930 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8931 | ie_whitelist_attrs_init(hdd_ctx); |
| 8932 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8933 | hdd_debug("setting timer multiplier: %u", |
| 8934 | hdd_ctx->config->timer_multiplier); |
| 8935 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8936 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8937 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8938 | if (hdd_ctx->config->fhostNSOffload) |
| 8939 | hdd_ctx->ns_offload_enable = true; |
| 8940 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8941 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8942 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8943 | hdd_override_ini_config(hdd_ctx); |
| 8944 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8945 | ret = hdd_context_init(hdd_ctx); |
| 8946 | |
| 8947 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8948 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8949 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8950 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8951 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8952 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8953 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8954 | goto skip_multicast_logging; |
| 8955 | |
| 8956 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8957 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8958 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8959 | if (ret) |
| 8960 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8961 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8962 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8963 | if (ret) |
| 8964 | goto err_deinit_txrx_histogram; |
| 8965 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8966 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8967 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8968 | skip_multicast_logging: |
| 8969 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8970 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8971 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8972 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8973 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8974 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8975 | return hdd_ctx; |
| 8976 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8977 | err_deinit_txrx_histogram: |
| 8978 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8979 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8980 | err_deinit_hdd_context: |
| 8981 | hdd_context_deinit(hdd_ctx); |
| 8982 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8983 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8984 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8985 | |
| 8986 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8987 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 8988 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8989 | |
| 8990 | err_out: |
| 8991 | return ERR_PTR(ret); |
| 8992 | } |
| 8993 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 8994 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 8995 | /** |
| 8996 | * hdd_open_p2p_interface - Open P2P interface |
| 8997 | * @hdd_ctx: HDD context |
| 8998 | * @rtnl_held: True if RTNL lock held |
| 8999 | * |
| 9000 | * Open P2P interface during probe. This function called to open the P2P |
| 9001 | * interface at probe along with STA interface. |
| 9002 | * |
| 9003 | * Return: 0 on success and errno on failure |
| 9004 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9005 | 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] | 9006 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9007 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9008 | uint8_t *p2p_dev_addr; |
| 9009 | |
| 9010 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 9011 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9012 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9013 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9014 | sizeof(tSirMacAddr)); |
| 9015 | |
| 9016 | /* |
| 9017 | * Generate the P2P Device Address. This consists of |
| 9018 | * the device's primary MAC address with the locally |
| 9019 | * administered bit set. |
| 9020 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9021 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9022 | } else { |
| 9023 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 9024 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9025 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9026 | return -ENOSPC; |
| 9027 | } |
| 9028 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9029 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 9030 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9031 | } |
| 9032 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9033 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9034 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9035 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9036 | |
| 9037 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9038 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9039 | return -ENOSPC; |
| 9040 | } |
| 9041 | |
| 9042 | return 0; |
| 9043 | } |
| 9044 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9045 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9046 | bool rtnl_held) |
| 9047 | { |
| 9048 | return 0; |
| 9049 | } |
| 9050 | #endif |
| 9051 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9052 | 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] | 9053 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9054 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9055 | int ret = 0; |
| 9056 | |
| 9057 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 9058 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9059 | NET_NAME_UNKNOWN, rtnl_held); |
| 9060 | if (adapter == NULL) { |
| 9061 | hdd_err("Failed to open 802.11p interface"); |
| 9062 | ret = -ENOSPC; |
| 9063 | } |
| 9064 | |
| 9065 | return ret; |
| 9066 | } |
| 9067 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9068 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9069 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9070 | * @adapter: HDD adapter |
| 9071 | * |
| 9072 | * This function initializes the adapter for the station mode. |
| 9073 | * |
| 9074 | * Return: 0 on success or errno on failure. |
| 9075 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9076 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9077 | { |
| 9078 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9079 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9080 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9081 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9082 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9083 | hdd_err("session is already opened, %d", |
| 9084 | adapter->session_id); |
| 9085 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9086 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9087 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9088 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9089 | if (ret) { |
| 9090 | hdd_err("failed to create vdev: %d", ret); |
| 9091 | return ret; |
| 9092 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9093 | status = hdd_init_station_mode(adapter); |
| 9094 | |
| 9095 | if (QDF_STATUS_SUCCESS != status) { |
| 9096 | hdd_err("Error Initializing station mode: %d", status); |
| 9097 | return qdf_status_to_os_return(status); |
| 9098 | } |
| 9099 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9100 | hdd_register_tx_flow_control(adapter, |
| 9101 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9102 | hdd_tx_resume_cb, |
| 9103 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9104 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9105 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9106 | return 0; |
| 9107 | } |
| 9108 | |
| 9109 | /** |
| 9110 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9111 | * @adapter: HDD adapter |
| 9112 | * |
| 9113 | * This function initializes the adapter for the AP mode. |
| 9114 | * |
| 9115 | * Return: 0 on success errno on failure. |
| 9116 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9117 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9118 | { |
| 9119 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9120 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9121 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9122 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9123 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9124 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9125 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9126 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9127 | hdd_err("session is already opened, %d", |
| 9128 | adapter->session_id); |
| 9129 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9130 | } |
| 9131 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9132 | * In SSR case no need to create new sap context. |
| 9133 | * Otherwise create sap context first and then create |
| 9134 | * vdev as while creating the vdev, driver needs to |
| 9135 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9136 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9137 | if (adapter->session.ap.sap_context) { |
| 9138 | is_ssr = true; |
| 9139 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9140 | hdd_err("sap creation failed"); |
| 9141 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9142 | } |
| 9143 | |
| 9144 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9145 | adapter->session.ap.sap_context); |
| 9146 | if (ret) { |
| 9147 | hdd_err("failed to create vdev, status:%d", ret); |
| 9148 | hdd_sap_destroy_ctx(adapter); |
| 9149 | return ret; |
| 9150 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9151 | |
| 9152 | if (adapter->device_mode == QDF_SAP_MODE) |
| 9153 | sme_cli_set_command(adapter->session_id, |
| 9154 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 9155 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 9156 | WMI_FW_AP_RTT_RESPR), |
| 9157 | VDEV_CMD); |
| 9158 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9159 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9160 | |
| 9161 | if (QDF_STATUS_SUCCESS != status) { |
| 9162 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9163 | return qdf_status_to_os_return(status); |
| 9164 | } |
| 9165 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9166 | hdd_register_tx_flow_control(adapter, |
| 9167 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9168 | hdd_softap_tx_resume_cb, |
| 9169 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9170 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9171 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9172 | return 0; |
| 9173 | } |
| 9174 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9175 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 9176 | bool rtnl_held) |
| 9177 | { |
| 9178 | struct hdd_adapter *adapter; |
| 9179 | |
| 9180 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 9181 | hdd_ctx->config->enableConcurrentSTA, |
| 9182 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9183 | NET_NAME_UNKNOWN, rtnl_held); |
| 9184 | |
| 9185 | if (!adapter) |
| 9186 | return -ENOSPC; |
| 9187 | |
| 9188 | return 0; |
| 9189 | } |
| 9190 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9191 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9192 | * hdd_open_interfaces - Open all required interfaces |
| 9193 | * hdd_ctx: HDD context |
| 9194 | * rtnl_held: True if RTNL lock is held |
| 9195 | * |
| 9196 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 9197 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9198 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9199 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9200 | 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] | 9201 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9202 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9203 | int ret; |
| 9204 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9205 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9206 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9207 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9208 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 9209 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 9210 | |
| 9211 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 9212 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9213 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9214 | if (!adapter) { |
| 9215 | hdd_err("open adapter failed"); |
| 9216 | return -ENOSPC; |
| 9217 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9218 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9219 | return 0; |
| 9220 | } |
| 9221 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9222 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9223 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9224 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9225 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9226 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9227 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9228 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9229 | |
| 9230 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9231 | return -ENOSPC; |
| 9232 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9233 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 9234 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 9235 | if (ret) |
| 9236 | hdd_err("Cannot create concurrent STA interface"); |
| 9237 | } |
| 9238 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9239 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9240 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9241 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9242 | |
| 9243 | /* Open 802.11p Interface */ |
| 9244 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9245 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9246 | if (ret) |
| 9247 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9248 | } |
| 9249 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9250 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9251 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9252 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9253 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9254 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9255 | } |
| 9256 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9257 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9258 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9259 | /** |
| 9260 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9261 | * @cds_cfg: CDS Configuration |
| 9262 | * @hdd_ctx: Pointer to hdd context |
| 9263 | * |
| 9264 | * Return: none |
| 9265 | */ |
| 9266 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9267 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9268 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9269 | { |
| 9270 | cds_cfg->tx_flow_stop_queue_th = |
| 9271 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9272 | cds_cfg->tx_flow_start_queue_offset = |
| 9273 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 9274 | } |
| 9275 | #else |
| 9276 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9277 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9278 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9279 | { |
| 9280 | } |
| 9281 | #endif |
| 9282 | |
| 9283 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9284 | /** |
| 9285 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9286 | * @cds_cfg: CDS Configuration |
| 9287 | * @hdd_ctx: Pointer to hdd context |
| 9288 | * |
| 9289 | * Return: none |
| 9290 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9291 | 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] | 9292 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9293 | { |
| 9294 | cds_cfg->ra_ratelimit_interval = |
| 9295 | hdd_ctx->config->RArateLimitInterval; |
| 9296 | cds_cfg->is_ra_ratelimit_enabled = |
| 9297 | hdd_ctx->config->IsRArateLimitEnabled; |
| 9298 | } |
| 9299 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9300 | 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] | 9301 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9302 | { |
| 9303 | } |
| 9304 | #endif |
| 9305 | |
| 9306 | /** |
| 9307 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9308 | * @hdd_ctx: HDD Context |
| 9309 | * |
| 9310 | * Return: 0 for Success, errno on failure |
| 9311 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9312 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9313 | { |
| 9314 | struct cds_config_info *cds_cfg; |
| 9315 | |
| 9316 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9317 | if (!cds_cfg) { |
| 9318 | hdd_err("failed to allocate cds config"); |
| 9319 | return -ENOMEM; |
| 9320 | } |
| 9321 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9322 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 9323 | if (!hdd_ctx->config->nMaxPsPoll || |
| 9324 | !hdd_ctx->config->enablePowersaveOffload) { |
| 9325 | cds_cfg->powersave_offload_enabled = |
| 9326 | hdd_ctx->config->enablePowersaveOffload; |
| 9327 | } else { |
| 9328 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9329 | PS_QPOWER_NODEEPSLEEP) || |
| 9330 | (hdd_ctx->config->enablePowersaveOffload == |
| 9331 | PS_LEGACY_NODEEPSLEEP)) |
| 9332 | cds_cfg->powersave_offload_enabled = |
| 9333 | PS_LEGACY_NODEEPSLEEP; |
| 9334 | else |
| 9335 | cds_cfg->powersave_offload_enabled = |
| 9336 | PS_LEGACY_DEEPSLEEP; |
| 9337 | hdd_info("Qpower disabled in cds config, %d", |
| 9338 | cds_cfg->powersave_offload_enabled); |
| 9339 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9340 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9341 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9342 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9343 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9344 | |
| 9345 | /* |
| 9346 | * Copy the DFS Phyerr Filtering Offload status. |
| 9347 | * This parameter reflects the value of the |
| 9348 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9349 | */ |
| 9350 | cds_cfg->dfs_phyerr_filter_offload = |
| 9351 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9352 | if (hdd_ctx->config->ssdp) |
| 9353 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9354 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9355 | cds_cfg->force_target_assert_enabled = |
| 9356 | hdd_ctx->config->crash_inject_enabled; |
| 9357 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9358 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9359 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9360 | |
| 9361 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9362 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9363 | |
| 9364 | cds_cfg->ap_disable_intrabss_fwd = |
| 9365 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9366 | |
| 9367 | cds_cfg->dfs_pri_multiplier = |
| 9368 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9369 | cds_cfg->reorder_offload = |
| 9370 | hdd_ctx->config->reorderOffloadSupport; |
| 9371 | |
| 9372 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9373 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9374 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9375 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9376 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9377 | hdd_ctx->config->IpaUcTxBufCount); |
| 9378 | hdd_ctx->config->IpaUcTxBufCount = |
| 9379 | rounddown_pow_of_two( |
| 9380 | hdd_ctx->config->IpaUcTxBufCount); |
| 9381 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9382 | hdd_err("Failed to round down IpaUcTxBufCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9383 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9384 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9385 | hdd_debug("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9386 | hdd_ctx->config->IpaUcTxBufCount); |
| 9387 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9388 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9389 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9390 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9391 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9392 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9393 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9394 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9395 | rounddown_pow_of_two( |
| 9396 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9397 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9398 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9399 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9400 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9401 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9402 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9403 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9404 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9405 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9406 | cds_cfg->uc_tx_partition_base = |
| 9407 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9408 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9409 | |
| 9410 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9411 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9412 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9413 | cds_cfg->ce_classify_enabled = |
| 9414 | hdd_ctx->config->ce_classify_enabled; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9415 | cds_cfg->apf_packet_filter_enable = |
| 9416 | hdd_ctx->config->apf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9417 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9418 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9419 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9420 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9421 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9422 | cds_cfg->max_msdus_per_rxinorderind = |
| 9423 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9424 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9425 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9426 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9427 | cds_cfg->active_mc_bc_apf_mode = hdd_ctx->config->active_mc_bc_apf_mode; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 9428 | cds_cfg->auto_power_save_fail_mode = |
| 9429 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9430 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9431 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9432 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9433 | cds_cfg->delay_before_vdev_stop = |
| 9434 | hdd_ctx->config->delay_before_vdev_stop; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9435 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9436 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9437 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9438 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9439 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9440 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9441 | cds_init_ini_config(cds_cfg); |
| 9442 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9443 | |
| 9444 | exit: |
| 9445 | qdf_mem_free(cds_cfg); |
| 9446 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9447 | } |
| 9448 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9449 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9450 | * hdd_update_user_config() - API to update user configuration |
| 9451 | * parameters to obj mgr which are used by multiple components |
| 9452 | * @hdd_ctx: HDD Context |
| 9453 | * |
| 9454 | * Return: 0 for Success, errno on failure |
| 9455 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9456 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9457 | { |
| 9458 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9459 | |
| 9460 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9461 | if (user_config == NULL) { |
| 9462 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9463 | return -ENOMEM; |
| 9464 | } |
| 9465 | |
| 9466 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9467 | user_config->dual_mac_feature_disable = |
| 9468 | hdd_ctx->config->dual_mac_feature_disable; |
| 9469 | user_config->indoor_channel_support = |
| 9470 | hdd_ctx->config->indoor_channel_support; |
| 9471 | user_config->is_11d_support_enabled = |
| 9472 | hdd_ctx->config->Is11dSupportEnabled; |
| 9473 | user_config->is_11h_support_enabled = |
| 9474 | hdd_ctx->config->Is11hSupportEnabled; |
| 9475 | user_config->optimize_chan_avoid_event = |
| 9476 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9477 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9478 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9479 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9480 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9481 | |
| 9482 | qdf_mem_free(user_config); |
| 9483 | return 0; |
| 9484 | } |
| 9485 | |
| 9486 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9487 | * hdd_init_thermal_info - Initialize thermal level |
| 9488 | * @hdd_ctx: HDD context |
| 9489 | * |
| 9490 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9491 | * which would be called when a configured thermal threshold is hit. |
| 9492 | * |
| 9493 | * Return: 0 on success and errno on failure |
| 9494 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9495 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9496 | { |
| 9497 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9498 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9499 | mac_handle_t mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9500 | |
| 9501 | thermal_param.smeThermalMgmtEnabled = |
| 9502 | hdd_ctx->config->thermalMitigationEnable; |
| 9503 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9504 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9505 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9506 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9507 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9508 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9509 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9510 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9511 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9512 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9513 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9514 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9515 | hdd_ctx->config->thermalTempMinLevel0; |
| 9516 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9517 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9518 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9519 | hdd_ctx->config->thermalTempMinLevel1; |
| 9520 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9521 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9522 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9523 | hdd_ctx->config->thermalTempMinLevel2; |
| 9524 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9525 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9526 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9527 | hdd_ctx->config->thermalTempMinLevel3; |
| 9528 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9529 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9530 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9531 | mac_handle = hdd_ctx->mac_handle; |
| 9532 | status = sme_init_thermal_info(mac_handle, thermal_param); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9533 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9534 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9535 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9536 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9537 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9538 | hdd_set_thermal_level_cb); |
| 9539 | |
| 9540 | return 0; |
| 9541 | |
| 9542 | } |
| 9543 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9544 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9545 | /** |
| 9546 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9547 | * |
| 9548 | * Hold RTNL lock |
| 9549 | * |
| 9550 | * Return: True if held and false otherwise |
| 9551 | */ |
| 9552 | static inline bool hdd_hold_rtnl_lock(void) |
| 9553 | { |
| 9554 | rtnl_lock(); |
| 9555 | return true; |
| 9556 | } |
| 9557 | |
| 9558 | /** |
| 9559 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9560 | * |
| 9561 | * Release RTNL lock |
| 9562 | * |
| 9563 | * Return: None |
| 9564 | */ |
| 9565 | static inline void hdd_release_rtnl_lock(void) |
| 9566 | { |
| 9567 | rtnl_unlock(); |
| 9568 | } |
| 9569 | #else |
| 9570 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9571 | static inline void hdd_release_rtnl_lock(void) { } |
| 9572 | #endif |
| 9573 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9574 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9575 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9576 | /* MAX iwpriv command support */ |
| 9577 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9578 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9579 | #define MAX_PKTLOG_SIZE 16 |
| 9580 | |
| 9581 | /** |
| 9582 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9583 | * @hdd_ctx: hdd context |
| 9584 | * @set_value2: pktlog buffer size value |
| 9585 | * |
| 9586 | * |
| 9587 | * Return: 0 for success or error. |
| 9588 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9589 | 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] | 9590 | { |
| 9591 | struct sir_wifi_start_log start_log = { 0 }; |
| 9592 | QDF_STATUS status; |
| 9593 | |
| 9594 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9595 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9596 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9597 | start_log.user_triggered = 1; |
| 9598 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9599 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9600 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9601 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9602 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9603 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9604 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9605 | return -EINVAL; |
| 9606 | } |
| 9607 | |
| 9608 | return 0; |
| 9609 | } |
| 9610 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9611 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9612 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9613 | * @hdd_ctx: hdd context |
| 9614 | * |
| 9615 | * Return: 0 for success or error. |
| 9616 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9617 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9618 | { |
| 9619 | struct sir_wifi_start_log start_log; |
| 9620 | QDF_STATUS status; |
| 9621 | |
| 9622 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9623 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9624 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9625 | start_log.user_triggered = 1; |
| 9626 | start_log.size = 0; |
| 9627 | start_log.is_pktlog_buff_clear = true; |
| 9628 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9629 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9630 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9631 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9632 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9633 | return -EINVAL; |
| 9634 | } |
| 9635 | |
| 9636 | return 0; |
| 9637 | } |
| 9638 | |
| 9639 | |
| 9640 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9641 | * hdd_process_pktlog_command() - process pktlog command |
| 9642 | * @hdd_ctx: hdd context |
| 9643 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9644 | * @set_value2: pktlog buffer size value |
| 9645 | * |
| 9646 | * This function process pktlog command. |
| 9647 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9648 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9649 | * |
| 9650 | * Return: 0 for success or error. |
| 9651 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9652 | 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] | 9653 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9654 | { |
| 9655 | int ret; |
| 9656 | bool enable; |
| 9657 | uint8_t user_triggered = 0; |
| 9658 | |
| 9659 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9660 | if (0 != ret) |
| 9661 | return ret; |
| 9662 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9663 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9664 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9665 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9666 | hdd_err("invalid pktlog value %d", set_value); |
| 9667 | return -EINVAL; |
| 9668 | } |
| 9669 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9670 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9671 | if (set_value2 <= 0) { |
| 9672 | hdd_err("invalid pktlog size %d", set_value2); |
| 9673 | return -EINVAL; |
| 9674 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9675 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9676 | return -EINVAL; |
| 9677 | } |
| 9678 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9679 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9680 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9681 | } |
| 9682 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9683 | /* |
| 9684 | * set_value = 0 then disable packetlog |
| 9685 | * set_value = 1 enable packetlog forcefully |
| 9686 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9687 | * enable packetlog with AUTO type. |
| 9688 | */ |
| 9689 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9690 | true : false; |
| 9691 | |
| 9692 | if (1 == set_value) { |
| 9693 | enable = true; |
| 9694 | user_triggered = 1; |
| 9695 | } |
| 9696 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9697 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9698 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9699 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9700 | /** |
| 9701 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9702 | * @hdd_ctx: HDD context |
| 9703 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9704 | * @user_triggered: triggered through iwpriv |
| 9705 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9706 | * |
| 9707 | * Return: 0 on success; error number otherwise |
| 9708 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9709 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9710 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9711 | { |
| 9712 | struct sir_wifi_start_log start_log; |
| 9713 | QDF_STATUS status; |
| 9714 | |
| 9715 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9716 | start_log.verbose_level = |
| 9717 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9718 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9719 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9720 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9721 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9722 | /* |
| 9723 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9724 | * commands. Host uses this flag to decide whether to send pktlog |
| 9725 | * disable command to fw without sending pktlog enable command |
| 9726 | * previously. For eg, If vendor sends pktlog disable command without |
| 9727 | * sending pktlog enable command, then host discards the packet |
| 9728 | * but for iwpriv command, host will send it to fw. |
| 9729 | */ |
| 9730 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9731 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9732 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9733 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9734 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9735 | return -EINVAL; |
| 9736 | } |
| 9737 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9738 | if (enable == true) |
| 9739 | hdd_ctx->is_pktlog_enabled = 1; |
| 9740 | else |
| 9741 | hdd_ctx->is_pktlog_enabled = 0; |
| 9742 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9743 | return 0; |
| 9744 | } |
| 9745 | #endif /* REMOVE_PKT_LOG */ |
| 9746 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9747 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9748 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9749 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9750 | * @dev: Device Pointer |
| 9751 | * @num: Number of Valid Mac address |
| 9752 | * |
| 9753 | * Return: Pointer to MAC address buffer |
| 9754 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9755 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9756 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9757 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9758 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9759 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9760 | |
| 9761 | /** |
| 9762 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9763 | * @hdd_ctx: HDD Context |
| 9764 | * @num: Number of random mac addresses needed |
| 9765 | * |
| 9766 | * Generate random addresses using bit manipulation on the base mac address |
| 9767 | * |
| 9768 | * Return: None |
| 9769 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9770 | 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] | 9771 | { |
| 9772 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9773 | uint32_t iter; |
| 9774 | struct hdd_config *ini = hdd_ctx->config; |
| 9775 | uint8_t *buf = NULL; |
| 9776 | uint8_t macaddr_b3, tmp_br3; |
| 9777 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9778 | |
| 9779 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9780 | buf = ini->intfMacAddr[iter].bytes; |
| 9781 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9782 | macaddr_b3 = buf[3]; |
| 9783 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9784 | INTF_MACADDR_MASK; |
| 9785 | macaddr_b3 += tmp_br3; |
| 9786 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9787 | buf[0] |= 0x02; |
| 9788 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9789 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9790 | } |
| 9791 | } |
| 9792 | |
| 9793 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9794 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9795 | * @hdd_ctx: HDD Context |
| 9796 | * |
| 9797 | * API to get mac addresses from platform driver and update the driver |
| 9798 | * structures and configure FW with the base mac address. |
| 9799 | * Return: int |
| 9800 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9801 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9802 | { |
| 9803 | uint32_t no_of_mac_addr, iter; |
| 9804 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9805 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9806 | uint8_t *addr, *buf; |
| 9807 | struct device *dev = hdd_ctx->parent_dev; |
| 9808 | struct hdd_config *ini = hdd_ctx->config; |
| 9809 | tSirMacAddr mac_addr; |
| 9810 | QDF_STATUS status; |
| 9811 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9812 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9813 | |
| 9814 | if (no_of_mac_addr == 0 || !addr) { |
| 9815 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9816 | return -EINVAL; |
| 9817 | } |
| 9818 | |
| 9819 | if (no_of_mac_addr > max_mac_addr) |
| 9820 | no_of_mac_addr = max_mac_addr; |
| 9821 | |
| 9822 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9823 | |
| 9824 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9825 | buf = ini->intfMacAddr[iter].bytes; |
| 9826 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9827 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9828 | } |
| 9829 | |
| 9830 | status = sme_set_custom_mac_addr(mac_addr); |
| 9831 | |
| 9832 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9833 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9834 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9835 | if (no_of_mac_addr < max_mac_addr) |
| 9836 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9837 | no_of_mac_addr); |
| 9838 | return 0; |
| 9839 | } |
| 9840 | |
| 9841 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9842 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9843 | * @hdd_ctx: HDD Context |
| 9844 | * |
| 9845 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9846 | * will generate its own MAC and update it to FW. |
| 9847 | * |
| 9848 | * Return: 0 for success |
| 9849 | * Non-zero error code for failure |
| 9850 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9851 | 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] | 9852 | { |
| 9853 | tSirMacAddr customMacAddr; |
| 9854 | QDF_STATUS status; |
| 9855 | |
| 9856 | qdf_mem_copy(&customMacAddr, |
| 9857 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9858 | sizeof(tSirMacAddr)); |
| 9859 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9860 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9861 | return -EAGAIN; |
| 9862 | return 0; |
| 9863 | } |
| 9864 | |
| 9865 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9866 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9867 | * @hdd_ctx: HDD Context |
| 9868 | * |
| 9869 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9870 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9871 | * wlan_mac.bin to update HW MAC addresses. |
| 9872 | * |
| 9873 | * Return: None |
| 9874 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9875 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9876 | { |
| 9877 | QDF_STATUS status; |
| 9878 | int ret; |
| 9879 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9880 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9881 | if (ret == 0) |
| 9882 | return; |
| 9883 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9884 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9885 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9886 | |
| 9887 | status = hdd_update_mac_config(hdd_ctx); |
| 9888 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9889 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9890 | return; |
| 9891 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9892 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9893 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9894 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9895 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9896 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9897 | if (ret != 0) { |
| 9898 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9899 | QDF_ASSERT(ret); |
| 9900 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9901 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9902 | } |
| 9903 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9904 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9905 | { |
| 9906 | int vdev_id = 0; |
| 9907 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9908 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9909 | int vpdev = PDEV_CMD; |
| 9910 | int ret; |
| 9911 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9912 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9913 | if (ret) |
| 9914 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9915 | |
| 9916 | return ret; |
| 9917 | } |
| 9918 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9919 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9920 | { |
| 9921 | int vdev_id = 0; |
| 9922 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9923 | int value = hdd_ctx->config->alternative_chainmask_enabled; |
| 9924 | int vpdev = PDEV_CMD; |
| 9925 | int ret; |
| 9926 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9927 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9928 | if (ret) |
| 9929 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9930 | ret); |
| 9931 | |
| 9932 | return ret; |
| 9933 | } |
| 9934 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9935 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9936 | { |
| 9937 | int vdev_id = 0; |
| 9938 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9939 | int value = hdd_ctx->config->ani_enabled; |
| 9940 | int vpdev = PDEV_CMD; |
| 9941 | int ret; |
| 9942 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9943 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9944 | if (ret) |
| 9945 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9946 | |
| 9947 | return ret; |
| 9948 | } |
| 9949 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9950 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9951 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9952 | * @hdd_ctx: HDD context |
| 9953 | * |
| 9954 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9955 | * |
| 9956 | * Return: 0 on success and errno on failure. |
| 9957 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9958 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9959 | { |
| 9960 | int ret; |
| 9961 | QDF_STATUS status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9962 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9963 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9964 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 9965 | /* Register HL netdev flow control callback */ |
| 9966 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9967 | /* |
| 9968 | * Set 802.11p config |
| 9969 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9970 | * parameter is set in CSR when we init the channel list. This should |
| 9971 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9972 | * domain. |
| 9973 | */ |
| 9974 | hdd_set_dot11p_config(hdd_ctx); |
| 9975 | |
| 9976 | /* |
| 9977 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9978 | * The cfg download must occur before we update the SME config |
| 9979 | * since the SME config operation must access the cfg database |
| 9980 | */ |
| 9981 | status = hdd_set_sme_config(hdd_ctx); |
| 9982 | |
| 9983 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9984 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9985 | ret = qdf_status_to_os_return(status); |
| 9986 | goto out; |
| 9987 | } |
| 9988 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 9989 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 9990 | if (QDF_STATUS_SUCCESS != status) { |
| 9991 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 9992 | ret = qdf_status_to_os_return(status); |
| 9993 | goto out; |
| 9994 | } |
| 9995 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9996 | 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] | 9997 | hdd_ctx->config->tx_chain_mask_1ss, |
| 9998 | PDEV_CMD); |
| 9999 | if (0 != ret) { |
| 10000 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10001 | goto out; |
| 10002 | } |
| 10003 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10004 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10005 | if (ret) |
| 10006 | goto out; |
| 10007 | |
| 10008 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10009 | if (ret) |
| 10010 | goto out; |
| 10011 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10012 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10013 | if (ret) |
| 10014 | goto out; |
| 10015 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10016 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10017 | hdd_ctx->config->arp_ac_category, |
| 10018 | PDEV_CMD); |
| 10019 | if (0 != ret) { |
| 10020 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 10021 | hdd_ctx->config->arp_ac_category, ret); |
| 10022 | goto out; |
| 10023 | } |
| 10024 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10025 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10026 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10027 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10028 | ret = qdf_status_to_os_return(status); |
| 10029 | goto out; |
| 10030 | } |
| 10031 | |
| 10032 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10033 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10034 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10035 | ret = -EINVAL; |
| 10036 | goto out; |
| 10037 | } |
| 10038 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10039 | /* |
| 10040 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 10041 | * Remove this once self sta is added as part of session open. |
| 10042 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10043 | status = sme_cfg_set_str(hdd_ctx->mac_handle, WNI_CFG_STA_ID, |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10044 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 10045 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10046 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10047 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10048 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10049 | ret = -EINVAL; |
| 10050 | goto out; |
| 10051 | } |
| 10052 | |
| 10053 | hdd_init_channel_avoidance(hdd_ctx); |
| 10054 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 10055 | /* update enable sap mandatory chan list */ |
| 10056 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 10057 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10058 | out: |
| 10059 | return ret; |
| 10060 | } |
| 10061 | |
| 10062 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10063 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 10064 | * @context_ptr - hdd context pointer |
| 10065 | * @event_ptr - event structure pointer |
| 10066 | * |
| 10067 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10068 | * event back to supplicant to notify the stop reason. |
| 10069 | * |
| 10070 | * Return: None |
| 10071 | */ |
| 10072 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 10073 | void *event_ptr) |
| 10074 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10075 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10076 | struct sir_p2p_lo_event *evt = event_ptr; |
| 10077 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10078 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10079 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10080 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10081 | |
| 10082 | if (hdd_ctx == NULL) { |
| 10083 | hdd_err("Invalid HDD context pointer"); |
| 10084 | return; |
| 10085 | } |
| 10086 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10087 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10088 | if (!adapter) { |
| 10089 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10090 | evt->vdev_id); |
| 10091 | return; |
| 10092 | } |
| 10093 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10094 | vendor_event = |
| 10095 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10096 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10097 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10098 | GFP_KERNEL); |
| 10099 | |
| 10100 | if (!vendor_event) { |
| 10101 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10102 | return; |
| 10103 | } |
| 10104 | |
| 10105 | if (nla_put_u32(vendor_event, |
| 10106 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10107 | evt->reason_code)) { |
| 10108 | hdd_err("nla put failed"); |
| 10109 | kfree_skb(vendor_event); |
| 10110 | return; |
| 10111 | } |
| 10112 | |
| 10113 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10114 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10115 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10116 | } |
| 10117 | |
| 10118 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10119 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10120 | * @hdd_ctx: HDD context |
| 10121 | * |
| 10122 | * This function sends the adaptive dwell time config configuration to the |
| 10123 | * firmware via WMA |
| 10124 | * |
| 10125 | * Return: 0 - success, < 0 - failure |
| 10126 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10127 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10128 | { |
| 10129 | QDF_STATUS status; |
| 10130 | struct adaptive_dwelltime_params dwelltime_params; |
| 10131 | |
| 10132 | dwelltime_params.is_enabled = |
| 10133 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10134 | dwelltime_params.dwelltime_mode = |
| 10135 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10136 | dwelltime_params.lpf_weight = |
| 10137 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10138 | dwelltime_params.passive_mon_intval = |
| 10139 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10140 | dwelltime_params.wifi_act_threshold = |
| 10141 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10142 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10143 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10144 | &dwelltime_params); |
| 10145 | |
| 10146 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10147 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10148 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10149 | return -EAGAIN; |
| 10150 | } |
| 10151 | return 0; |
| 10152 | } |
| 10153 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10154 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10155 | { |
| 10156 | QDF_STATUS status; |
| 10157 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10158 | uint32_t i = 0; |
| 10159 | uint8_t count = 0, numentries = 0; |
| 10160 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10161 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10162 | |
| 10163 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 10164 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 10165 | DISABLE_DBS_CXN_AND_SCAN) || |
| 10166 | (hdd_ctx->config->dual_mac_feature_disable == |
| 10167 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10168 | return -EINVAL; |
| 10169 | |
| 10170 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10171 | dbs_scan_config, &numentries, |
| 10172 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10173 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10174 | |
| 10175 | hdd_info("numentries %hu", numentries); |
| 10176 | if (!numentries) { |
| 10177 | hdd_info("Donot send scan_selection_config"); |
| 10178 | return 0; |
| 10179 | } |
| 10180 | |
| 10181 | /* hdd_set_fw_log_params */ |
| 10182 | dbs_scan_params.num_clients = 0; |
| 10183 | while (count < (numentries - 2)) { |
| 10184 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10185 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10186 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10187 | dbs_scan_config[count + 2]; |
| 10188 | dbs_scan_params.num_clients++; |
| 10189 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10190 | dbs_scan_params.module_id[i], |
| 10191 | dbs_scan_params.num_dbs_scans[i], |
| 10192 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10193 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10194 | i++; |
| 10195 | } |
| 10196 | |
| 10197 | dbs_scan_params.pdev_id = 0; |
| 10198 | |
| 10199 | hdd_debug("clients:%d pdev:%d", |
| 10200 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10201 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10202 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10203 | &dbs_scan_params); |
| 10204 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10205 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10206 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10207 | return -EAGAIN; |
| 10208 | } |
| 10209 | return 0; |
| 10210 | } |
| 10211 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10212 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10213 | /** |
| 10214 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10215 | * @hdd_ctx: HDD context |
| 10216 | * |
| 10217 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10218 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10219 | * |
| 10220 | * Return: 0 on success and errno on failure. |
| 10221 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10222 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10223 | { |
| 10224 | QDF_STATUS status; |
| 10225 | |
| 10226 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 10227 | return 0; |
| 10228 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10229 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10230 | wlan_hdd_auto_shutdown_cb); |
| 10231 | if (status != QDF_STATUS_SUCCESS) |
| 10232 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10233 | status); |
| 10234 | |
| 10235 | return qdf_status_to_os_return(status); |
| 10236 | } |
| 10237 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10238 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10239 | { |
| 10240 | return 0; |
| 10241 | } |
| 10242 | #endif |
| 10243 | |
| 10244 | /** |
| 10245 | * hdd_features_init() - Init features |
| 10246 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10247 | * |
| 10248 | * Initialize features and their feature context after WLAN firmware is up. |
| 10249 | * |
| 10250 | * Return: 0 on success and errno on failure. |
| 10251 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10252 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10253 | { |
| 10254 | tSirTxPowerLimit hddtxlimit; |
| 10255 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10256 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10257 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10258 | mac_handle_t mac_handle; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10259 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10260 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10261 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10262 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10263 | mac_handle = hdd_ctx->mac_handle; |
| 10264 | sme_setdef_dot11mode(mac_handle); |
| 10265 | sme_set_prefer_80MHz_over_160MHz(mac_handle, |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 10266 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10267 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10268 | |
| 10269 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10270 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10271 | else |
| 10272 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10273 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10274 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10275 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10276 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10277 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10278 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10279 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10280 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10281 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 10282 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10283 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10284 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10285 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10286 | |
| 10287 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10288 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10289 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10290 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10291 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10292 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10293 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10294 | if (ret) { |
| 10295 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10296 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10297 | } |
| 10298 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10299 | /** |
| 10300 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10301 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10302 | * device up. |
| 10303 | */ |
| 10304 | if (cds_is_driver_recovering()) { |
| 10305 | if (hdd_ctx->is_pktlog_enabled) |
| 10306 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 10307 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10308 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10309 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10310 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10311 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10312 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10313 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10314 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10315 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10316 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10317 | ret = hdd_register_cb(hdd_ctx); |
| 10318 | if (ret) { |
| 10319 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10320 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10321 | } |
| 10322 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10323 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 10324 | status = sme_enable_disable_chanavoidind_event( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10325 | mac_handle, 0); |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10326 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10327 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10328 | goto deregister_cb; |
| 10329 | } |
| 10330 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10331 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10332 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10333 | band_pref_params.rssi_boost_threshold_5g = |
| 10334 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10335 | band_pref_params.rssi_boost_factor_5g = |
| 10336 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10337 | band_pref_params.max_rssi_boost_5g = |
| 10338 | hdd_ctx->config->max_rssi_boost_5g; |
| 10339 | band_pref_params.rssi_penalize_threshold_5g = |
| 10340 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10341 | band_pref_params.rssi_penalize_factor_5g = |
| 10342 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10343 | band_pref_params.max_rssi_penalize_5g = |
| 10344 | hdd_ctx->config->max_rssi_penalize_5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10345 | sme_set_5g_band_pref(mac_handle, &band_pref_params); |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10346 | } |
| 10347 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10348 | /* register P2P Listen Offload event callback */ |
| 10349 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10350 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10351 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10352 | |
| 10353 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10354 | |
| 10355 | if (ret) |
| 10356 | goto deregister_cb; |
| 10357 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10358 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10359 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10360 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10361 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10362 | return 0; |
| 10363 | |
| 10364 | deregister_cb: |
| 10365 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10366 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10367 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10368 | } |
| 10369 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10370 | /** |
| 10371 | * hdd_features_deinit() - Deinit features |
| 10372 | * @hdd_ctx: HDD context |
| 10373 | * |
| 10374 | * De-Initialize features and their feature context. |
| 10375 | * |
| 10376 | * Return: none. |
| 10377 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10378 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10379 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10380 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10381 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10382 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10383 | } |
| 10384 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10385 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10386 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10387 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10388 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10389 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10390 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10391 | 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] | 10392 | { |
| 10393 | QDF_STATUS status; |
| 10394 | |
| 10395 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10396 | wlan_cfg80211_inform_bss_frame, |
| 10397 | SCAN_CB_TYPE_INFORM_BCN); |
| 10398 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10399 | hdd_err("failed with status code %08d [x%08x]", |
| 10400 | status, status); |
| 10401 | return status; |
| 10402 | } |
| 10403 | |
| 10404 | return QDF_STATUS_SUCCESS; |
| 10405 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10406 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10407 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10408 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10409 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10410 | * |
| 10411 | * Return: none. |
| 10412 | */ |
| 10413 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10414 | { |
| 10415 | QDF_STATUS status; |
| 10416 | |
| 10417 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10418 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10419 | vdev_id); |
| 10420 | /* |
| 10421 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10422 | * so this above callback is not implemented. |
| 10423 | * Hence this is not actual failure. Dont return failure |
| 10424 | */ |
| 10425 | if ((status != QDF_STATUS_SUCCESS) && |
| 10426 | (status != QDF_STATUS_E_INVAL)) { |
| 10427 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10428 | vdev_id, status); |
| 10429 | } |
| 10430 | } |
| 10431 | |
| 10432 | /** |
| 10433 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10434 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10435 | * |
| 10436 | * Return: none. |
| 10437 | */ |
| 10438 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10439 | { |
| 10440 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10441 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10442 | } |
| 10443 | |
| 10444 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10445 | * hdd_configure_cds() - Configure cds modules |
| 10446 | * @hdd_ctx: HDD context |
| 10447 | * @adapter: Primary adapter context |
| 10448 | * |
| 10449 | * Enable Cds modules after WLAN firmware is up. |
| 10450 | * |
| 10451 | * Return: 0 on success and errno on failure. |
| 10452 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10453 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10454 | { |
| 10455 | int ret; |
| 10456 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10457 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10458 | mac_handle_t mac_handle; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10459 | uint32_t num_abg_tx_chains = 0; |
| 10460 | uint32_t num_11b_tx_chains = 0; |
| 10461 | uint32_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10462 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10463 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10464 | mac_handle = hdd_ctx->mac_handle; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10465 | if (hdd_ctx->config->is_force_1x1) |
| 10466 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10467 | 1, PDEV_CMD); |
| 10468 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10469 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10470 | hdd_chip_pwr_save_fail_detected_cb); |
| 10471 | |
| 10472 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10473 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10474 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10475 | set_value, PDEV_CMD); |
| 10476 | } |
| 10477 | |
| 10478 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10479 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10480 | sme_cli_set_command(0, |
| 10481 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10482 | set_value, PDEV_CMD); |
| 10483 | } |
| 10484 | |
| 10485 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10486 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10487 | sme_cli_set_command(0, |
| 10488 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10489 | set_value, PDEV_CMD); |
| 10490 | } |
| 10491 | |
| 10492 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10493 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10494 | if (!hdd_ctx->config->enable2x2) { |
| 10495 | if (num_11b_tx_chains > 1) |
| 10496 | num_11b_tx_chains = 1; |
| 10497 | if (num_11ag_tx_chains > 1) |
| 10498 | num_11ag_tx_chains = 1; |
| 10499 | } |
| 10500 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10501 | num_11b_tx_chains); |
| 10502 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10503 | num_11ag_tx_chains); |
| 10504 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10505 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10506 | |
| 10507 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10508 | if (ret) { |
| 10509 | hdd_err("Failed to pre-configure cds"); |
| 10510 | goto out; |
| 10511 | } |
| 10512 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10513 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10514 | * IPA module before configuring them to FW. Sequence required as crash |
| 10515 | * observed otherwise. |
| 10516 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10517 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10518 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10519 | hdd_err("Failed to setup pipes"); |
| 10520 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10521 | } |
| 10522 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10523 | /* |
| 10524 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10525 | * else |
| 10526 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10527 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10528 | |
| 10529 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10530 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10531 | goto out; |
| 10532 | } |
| 10533 | |
| 10534 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10535 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10536 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10537 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10538 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10539 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10540 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10541 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10542 | goto cds_disable; |
| 10543 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10544 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10545 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10546 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10547 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10548 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10549 | if (hdd_ctx->ol_enable) |
| 10550 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10551 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10552 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10553 | 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] | 10554 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 10555 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10556 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10557 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10558 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10559 | goto cds_disable; |
| 10560 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10561 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10562 | wlan_hdd_send_mode_change_event); |
| 10563 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10564 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10565 | goto cds_disable; |
| 10566 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10567 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10568 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10569 | hdd_debug("enhance green ap is not enabled"); |
| 10570 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10571 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10572 | hdd_debug("Failed to set wow pulse"); |
| 10573 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10574 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10575 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10576 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10577 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10578 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10579 | |
| 10580 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10581 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10582 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10583 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10584 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10585 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10586 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10587 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10588 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10589 | out: |
| 10590 | return -EINVAL; |
| 10591 | } |
| 10592 | |
| 10593 | /** |
| 10594 | * hdd_deconfigure_cds() -De-Configure cds |
| 10595 | * @hdd_ctx: HDD context |
| 10596 | * |
| 10597 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10598 | * |
| 10599 | * Return: 0 on success and errno on failure. |
| 10600 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10601 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10602 | { |
| 10603 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10604 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10605 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10606 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10607 | |
| 10608 | /* De-init features */ |
| 10609 | hdd_features_deinit(hdd_ctx); |
| 10610 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10611 | /* De-register the SME callbacks */ |
| 10612 | hdd_deregister_cb(hdd_ctx); |
| 10613 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10614 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10615 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10616 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10617 | } |
| 10618 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10619 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10620 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10621 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10622 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10623 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10624 | } |
| 10625 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10626 | 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] | 10627 | hdd_err("Failed to disconnect pipes"); |
| 10628 | ret = -EINVAL; |
| 10629 | } |
| 10630 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10631 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10632 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10633 | } |
| 10634 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10635 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10636 | static void hdd_deregister_policy_manager_callback( |
| 10637 | struct wlan_objmgr_psoc *psoc) |
| 10638 | { |
| 10639 | if (QDF_STATUS_SUCCESS != |
| 10640 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10641 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10642 | } |
| 10643 | } |
| 10644 | #else |
| 10645 | static void hdd_deregister_policy_manager_callback( |
| 10646 | struct wlan_objmgr_psoc *psoc) |
| 10647 | { |
| 10648 | } |
| 10649 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10650 | |
| 10651 | /** |
| 10652 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10653 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10654 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10655 | * |
| 10656 | * This function maintains the driver state machine it will be invoked from |
| 10657 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10658 | * shall perform the stopping/closing of the modules. |
| 10659 | * |
| 10660 | * Return: 0 for success; non-zero for failure |
| 10661 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10662 | 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] | 10663 | { |
| 10664 | void *hif_ctx; |
| 10665 | qdf_device_t qdf_ctx; |
| 10666 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10667 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10668 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10669 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10670 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10671 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10672 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10673 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10674 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10675 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10676 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10677 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10678 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10679 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10680 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10681 | if (!qdf_ctx) { |
| 10682 | hdd_err("QDF device context NULL"); |
| 10683 | return -EINVAL; |
| 10684 | } |
| 10685 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10686 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10687 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10688 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10689 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10690 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10691 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10692 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10693 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10694 | |
| 10695 | cds_print_external_threads(); |
| 10696 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10697 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10698 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10699 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10700 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10701 | hdd_prevent_suspend_timeout( |
| 10702 | hdd_ctx->config->iface_change_wait_time, |
| 10703 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10704 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10705 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10706 | return 0; |
| 10707 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10708 | } |
| 10709 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10710 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10711 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10712 | /* free user wowl patterns */ |
| 10713 | hdd_free_user_wowl_ptrns(); |
| 10714 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10715 | switch (hdd_ctx->driver_status) { |
| 10716 | case DRIVER_MODULES_UNINITIALIZED: |
| 10717 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10718 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10719 | case DRIVER_MODULES_CLOSED: |
| 10720 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10721 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10722 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10723 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10724 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10725 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10726 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10727 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10728 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10729 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10730 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10731 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10732 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10733 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10734 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10735 | |
| 10736 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10737 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10738 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10739 | break; |
| 10740 | default: |
| 10741 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10742 | hdd_ctx->driver_status); |
| 10743 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10744 | ret = -EINVAL; |
| 10745 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10746 | } |
| 10747 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10748 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10749 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10750 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10751 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10752 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10753 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10754 | qdf_status); |
| 10755 | ret = -EINVAL; |
| 10756 | QDF_ASSERT(0); |
| 10757 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10758 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10759 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10760 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10761 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10762 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10763 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10764 | ret = -EINVAL; |
| 10765 | QDF_ASSERT(0); |
| 10766 | } |
| 10767 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10768 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10769 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10770 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10771 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10772 | QDF_ASSERT(0); |
| 10773 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10774 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10775 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10776 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10777 | if (ret) { |
| 10778 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10779 | QDF_ASSERT(0); |
| 10780 | } |
| 10781 | |
| 10782 | /* |
| 10783 | * Reset total mac phy during module stop such that during |
| 10784 | * next module start same psoc is used to populate new service |
| 10785 | * ready data |
| 10786 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10787 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10788 | if (tgt_hdl) |
| 10789 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10790 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10791 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10792 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10793 | if (!hif_ctx) { |
| 10794 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10795 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10796 | } |
| 10797 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10798 | if (hdd_ctx->target_hw_name) { |
| 10799 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10800 | hdd_ctx->target_hw_name = NULL; |
| 10801 | } |
| 10802 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10803 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10804 | |
| 10805 | ol_cds_free(); |
| 10806 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10807 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10808 | ret = pld_power_off(qdf_ctx->dev); |
| 10809 | if (ret) |
| 10810 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10811 | ret); |
| 10812 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10813 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10814 | /* many adapter resources are not freed by design in SSR case */ |
| 10815 | if (!is_recovery_stop) |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 10816 | hdd_check_for_leaks(hdd_ctx); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10817 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10818 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10819 | /* Once the firmware sequence is completed reset this flag */ |
| 10820 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10821 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10822 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10823 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10824 | done: |
| 10825 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10826 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10827 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10828 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10829 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10830 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10831 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10832 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10833 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10834 | } |
| 10835 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10836 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10837 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10838 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10839 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10840 | * @buf: buffer pointer |
| 10841 | * @size: size of buffer to be filled |
| 10842 | * |
| 10843 | * This function is used to dump state information of hdd layer |
| 10844 | * |
| 10845 | * Return: None |
| 10846 | */ |
| 10847 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10848 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10849 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10850 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10851 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10852 | uint16_t len = 0; |
| 10853 | char *buf = *buf_ptr; |
| 10854 | |
| 10855 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10856 | if (!hdd_ctx) { |
| 10857 | hdd_err("Failed to get hdd context "); |
| 10858 | return; |
| 10859 | } |
| 10860 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10861 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10862 | |
| 10863 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10864 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10865 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10866 | "\n is_scheduler_suspended %d", |
| 10867 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10868 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10869 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10870 | if (adapter->dev) |
| 10871 | len += scnprintf(buf + len, *size - len, |
| 10872 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10873 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10874 | "\n device_mode: %d", adapter->device_mode); |
| 10875 | switch (adapter->device_mode) { |
| 10876 | case QDF_STA_MODE: |
| 10877 | case QDF_P2P_CLIENT_MODE: |
| 10878 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10879 | len += scnprintf(buf + len, *size - len, |
| 10880 | "\n connState: %d", |
| 10881 | hdd_sta_ctx->conn_info.connState); |
| 10882 | break; |
| 10883 | |
| 10884 | default: |
| 10885 | break; |
| 10886 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10887 | } |
| 10888 | |
| 10889 | *size -= len; |
| 10890 | *buf_ptr += len; |
| 10891 | } |
| 10892 | |
| 10893 | /** |
| 10894 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10895 | * to print hdd state information |
| 10896 | * |
| 10897 | * Return: None |
| 10898 | */ |
| 10899 | static void hdd_register_debug_callback(void) |
| 10900 | { |
| 10901 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10902 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10903 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 10904 | static void hdd_register_debug_callback(void) |
| 10905 | { |
| 10906 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10907 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10908 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10909 | /* |
| 10910 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10911 | * |
| 10912 | * This function is used to create bug report lock |
| 10913 | * |
| 10914 | * Return: None |
| 10915 | */ |
| 10916 | static void wlan_init_bug_report_lock(void) |
| 10917 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 10918 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10919 | |
| 10920 | p_cds_context = cds_get_global_context(); |
| 10921 | if (!p_cds_context) { |
| 10922 | hdd_err("cds context is NULL"); |
| 10923 | return; |
| 10924 | } |
| 10925 | |
| 10926 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10927 | } |
| 10928 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10929 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10930 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10931 | { |
| 10932 | |
| 10933 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10934 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10935 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10936 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10937 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10938 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10939 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10940 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10941 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10942 | if (!config->enable_dp_trace) { |
| 10943 | hdd_err("dp trace is disabled from ini"); |
| 10944 | return; |
| 10945 | } |
| 10946 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10947 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10948 | &num_entries, sizeof(config_params)); |
| 10949 | |
| 10950 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10951 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10952 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10953 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10954 | else if (bw_compute_interval > 1000) { |
| 10955 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10956 | thresh_time_limit = 1; |
| 10957 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10958 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10959 | |
| 10960 | switch (num_entries) { |
| 10961 | case 4: |
| 10962 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10963 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10964 | case 3: |
| 10965 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10966 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10967 | case 2: |
| 10968 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10969 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10970 | case 1: |
| 10971 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10972 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10973 | default: |
Rajeev Kumar | 3887f9b | 2018-01-10 11:24:01 -0800 | [diff] [blame] | 10974 | 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] | 10975 | live_mode, thresh, thresh_time_limit, |
| 10976 | verbosity, proto_bitmap); |
| 10977 | }; |
| 10978 | |
| 10979 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10980 | verbosity, proto_bitmap); |
| 10981 | |
| 10982 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10983 | #endif |
| 10984 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10985 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10986 | * hdd_wlan_startup() - HDD init function |
| 10987 | * @dev: Pointer to the underlying device |
| 10988 | * |
| 10989 | * This is the driver startup code executed once a WLAN device has been detected |
| 10990 | * |
| 10991 | * Return: 0 for success, < 0 for failure |
| 10992 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10993 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10994 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 10995 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10996 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 10997 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 10998 | bool rtnl_held; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10999 | mac_handle_t mac_handle; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11000 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11001 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11002 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11003 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11004 | |
| 11005 | if (IS_ERR(hdd_ctx)) |
| 11006 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11007 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 11008 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 11009 | DEFAULT_PSOC_ID); |
| 11010 | if (ret) { |
| 11011 | hdd_err("Psoc creation fails!"); |
| 11012 | QDF_BUG(0); |
| 11013 | goto err_hdd_free_context; |
| 11014 | } |
| 11015 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11016 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11017 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11018 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11019 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11020 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11021 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11022 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11023 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11024 | hdd_driver_memdump_init(); |
| 11025 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11026 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11027 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11028 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11029 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11030 | } |
| 11031 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11032 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11033 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11034 | mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11035 | hdd_ctx->mac_handle = mac_handle; |
| 11036 | if (!mac_handle) { |
| 11037 | hdd_err("Mac Handle is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11038 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11039 | } |
| 11040 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 11041 | ret = hdd_wiphy_init(hdd_ctx); |
| 11042 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11043 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11044 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11045 | } |
| 11046 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11047 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11048 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 11049 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11050 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11051 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11052 | if (ret) { |
| 11053 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 11054 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11055 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11056 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11057 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 11058 | if (ret) { |
| 11059 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 11060 | goto err_unregister_netdev; |
| 11061 | } |
| 11062 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11063 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11064 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11065 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11066 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11067 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11068 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11069 | } |
| 11070 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11071 | hdd_release_rtnl_lock(); |
| 11072 | rtnl_held = false; |
| 11073 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11074 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11075 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11076 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11077 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11078 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11079 | hdd_skip_acs_scan_timer_handler, |
| 11080 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11081 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11082 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11083 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11084 | #endif |
| 11085 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 11086 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11087 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 11088 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11089 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11090 | if (hdd_ctx->rps) |
| 11091 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 11092 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11093 | ret = hdd_register_notifiers(hdd_ctx); |
| 11094 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11095 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11096 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11097 | status = wlansap_global_init(); |
| 11098 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11099 | hdd_unregister_notifiers(hdd_ctx); |
| 11100 | goto err_close_adapters; |
| 11101 | } |
| 11102 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11103 | if (hdd_ctx->config->fIsImpsEnabled) |
| 11104 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 11105 | else |
| 11106 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11107 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11108 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 11109 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 11110 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11111 | hdd_prevent_suspend_timeout( |
| 11112 | hdd_ctx->config->iface_change_wait_time, |
| 11113 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 11114 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11115 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11116 | goto success; |
| 11117 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11118 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11119 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11120 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11121 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11122 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11123 | if (rtnl_held) |
| 11124 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11125 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11126 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11127 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11128 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11129 | err_wiphy_unregister: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11130 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11131 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11132 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11133 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11134 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11135 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11136 | err_memdump_deinit: |
| 11137 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11138 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11139 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11140 | hdd_exit_netlink_services(hdd_ctx); |
| 11141 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 11142 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 11143 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11144 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11145 | if (cds_is_fw_down()) |
| 11146 | hdd_err("Not setting the complete event as fw is down"); |
| 11147 | else |
| 11148 | hdd_start_complete(ret); |
| 11149 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11150 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 11151 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 11152 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11153 | |
| 11154 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11155 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11156 | return 0; |
| 11157 | } |
| 11158 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11159 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11160 | * hdd_wlan_update_target_info() - update target type info |
| 11161 | * @hdd_ctx: HDD context |
| 11162 | * @context: hif context |
| 11163 | * |
| 11164 | * Update target info received from firmware in hdd context |
| 11165 | * Return:None |
| 11166 | */ |
| 11167 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11168 | 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] | 11169 | { |
| 11170 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11171 | |
| 11172 | if (!tgt_info) { |
| 11173 | hdd_err("Target info is Null"); |
| 11174 | return; |
| 11175 | } |
| 11176 | |
| 11177 | hdd_ctx->target_type = tgt_info->target_type; |
| 11178 | } |
| 11179 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11180 | 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] | 11181 | { |
| 11182 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11183 | int status; |
| 11184 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11185 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11186 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11187 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11188 | |
| 11189 | if (!rsp) { |
| 11190 | hdd_err("data is null"); |
| 11191 | return; |
| 11192 | } |
| 11193 | |
| 11194 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11195 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11196 | return; |
| 11197 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11198 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11199 | if (!request) { |
| 11200 | hdd_err("obselete request"); |
| 11201 | return; |
| 11202 | } |
| 11203 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11204 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11205 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11206 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11207 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11208 | return; |
| 11209 | } |
| 11210 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11211 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11212 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11213 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11214 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11215 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11216 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11217 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 11218 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 11219 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 11220 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11221 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11222 | 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] | 11223 | adapter->dad |= rsp->dad_detected; |
| 11224 | adapter->con_status = rsp->connect_status; |
| 11225 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11226 | /* Flag true indicates connectivity check stats present. */ |
| 11227 | if (rsp->connect_stats_present) { |
| 11228 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11229 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 11230 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11231 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11232 | rsp->icmpv4_rsp_recvd; |
| 11233 | } |
| 11234 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11235 | osif_request_complete(request); |
| 11236 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11237 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11238 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11239 | } |
| 11240 | |
| 11241 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11242 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11243 | * @hdd_ctx: HDD context |
| 11244 | * |
| 11245 | * Register the HDD callbacks to CDS/SME. |
| 11246 | * |
| 11247 | * Return: 0 for success or Error code for failure |
| 11248 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11249 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11250 | { |
| 11251 | QDF_STATUS status; |
| 11252 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11253 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11254 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11255 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11256 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11257 | mac_handle = hdd_ctx->mac_handle; |
| 11258 | sme_register11d_scan_done_callback(mac_handle, hdd_11d_scan_done); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11259 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11260 | sme_register_oem_data_rsp_callback(mac_handle, |
| 11261 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11262 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11263 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11264 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11265 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
| 11266 | sme_nan_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11267 | wlan_hdd_cfg80211_nan_callback); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11268 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11269 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11270 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11271 | sme_ext_scan_register_callback(mac_handle, |
| 11272 | wlan_hdd_cfg80211_extscan_callback); |
| 11273 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11274 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11275 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11276 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 11277 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11278 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11279 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11280 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11281 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11282 | sme_rso_cmd_status_cb(mac_handle, wlan_hdd_rso_cmd_status_cb); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 11283 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11284 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11285 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11286 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11287 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11288 | hdd_lost_link_info_cb); |
| 11289 | /* print error and not block the startup process */ |
| 11290 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11291 | hdd_err("set lost link info callback failed"); |
| 11292 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11293 | ret = hdd_register_data_stall_detect_cb(); |
| 11294 | if (ret) { |
| 11295 | hdd_err("Register data stall detect detect callback failed."); |
| 11296 | return ret; |
| 11297 | } |
| 11298 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11299 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11300 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11301 | sme_register_set_connection_info_cb(mac_handle, |
| 11302 | hdd_set_connection_in_progress, |
| 11303 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11304 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11305 | status = sme_congestion_register_callback(mac_handle, |
| 11306 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11307 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11308 | hdd_err("set congestion callback failed"); |
| 11309 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11310 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11311 | hdd_bt_activity_cb); |
| 11312 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11313 | hdd_err("set bt activity info callback failed"); |
| 11314 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11315 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11316 | hdd_tx_queue_cb); |
| 11317 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11318 | hdd_err("Register tx queue callback failed"); |
| 11319 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11320 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11321 | |
| 11322 | return ret; |
| 11323 | } |
| 11324 | |
| 11325 | /** |
| 11326 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11327 | * @hdd_ctx: HDD context |
| 11328 | * |
| 11329 | * De-Register the HDD callbacks to CDS/SME. |
| 11330 | * |
| 11331 | * Return: void |
| 11332 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11333 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11334 | { |
| 11335 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11336 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11337 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11338 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11339 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11340 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11341 | mac_handle = hdd_ctx->mac_handle; |
| 11342 | sme_deregister_tx_queue_cb(mac_handle); |
| 11343 | status = sme_deregister_for_dcc_stats_event(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11344 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11345 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11346 | status); |
| 11347 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11348 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 11349 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11350 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11351 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11352 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11353 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11354 | sme_nan_deregister_callback(mac_handle); |
| 11355 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11356 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11357 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11358 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11359 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11360 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11361 | if (ret) |
| 11362 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11363 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11364 | sme_deregister_oem_data_rsp_callback(mac_handle); |
| 11365 | sme_deregister11d_scan_done_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11366 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11367 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11368 | } |
| 11369 | |
| 11370 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11371 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11372 | * @adapter: Pointer to the HDD |
| 11373 | * @enable: bool value |
| 11374 | * |
| 11375 | * This to take counter measure to handle deauth req from HDD |
| 11376 | * |
| 11377 | * Return: None |
| 11378 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11379 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11380 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11381 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11382 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11383 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11384 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11385 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11386 | /* Ignore request to deauth bcmc station */ |
| 11387 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11388 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11389 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11390 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11391 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11392 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11393 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11394 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11395 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11396 | } |
| 11397 | |
| 11398 | /** |
| 11399 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11400 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11401 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11402 | * |
| 11403 | * This to take counter measure to handle deauth req from HDD |
| 11404 | * |
| 11405 | * Return: None |
| 11406 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11407 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11408 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11409 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11410 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11411 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11412 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11413 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11414 | return; |
| 11415 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11416 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11417 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11418 | } |
| 11419 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11420 | /** |
| 11421 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11422 | * @hdd_ctx: HDD Context |
| 11423 | * |
| 11424 | * API to find if there is any STA or P2P-Client is connected |
| 11425 | * |
| 11426 | * Return: true if connected; false otherwise |
| 11427 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11428 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11429 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11430 | return sme_is_sta_p2p_client_connected(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11431 | } |
| 11432 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11433 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11434 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11435 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11436 | struct hdd_adapter *adapter = NULL; |
| 11437 | struct csr_roam_profile *roam_profile; |
| 11438 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11439 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11440 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11441 | hdd_debug("No active sta session"); |
| 11442 | return; |
| 11443 | } |
| 11444 | |
| 11445 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11446 | roam_profile = hdd_roam_profile(adapter); |
| 11447 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11448 | |
| 11449 | if (cur_adapter->session_id != adapter->session_id && |
| 11450 | adapter->device_mode == QDF_STA_MODE && |
| 11451 | hdd_conn_is_connected(sta_ctx)) { |
| 11452 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11453 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11454 | adapter->session_id, |
| 11455 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11456 | } |
| 11457 | } |
| 11458 | } |
| 11459 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11460 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11461 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11462 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11463 | struct hdd_adapter *adapter = NULL; |
| 11464 | struct csr_roam_profile *roam_profile; |
| 11465 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11466 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11467 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11468 | hdd_debug("No active sta session"); |
| 11469 | return; |
| 11470 | } |
| 11471 | |
| 11472 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11473 | roam_profile = hdd_roam_profile(adapter); |
| 11474 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11475 | |
| 11476 | if (cur_adapter->session_id != adapter->session_id && |
| 11477 | adapter->device_mode == QDF_STA_MODE && |
| 11478 | hdd_conn_is_connected(sta_ctx)) { |
| 11479 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11480 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11481 | adapter->session_id, |
| 11482 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11483 | } |
| 11484 | } |
| 11485 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11486 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11487 | /** |
| 11488 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11489 | * @skb: sk buffer pointer |
| 11490 | * |
| 11491 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11492 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11493 | * |
| 11494 | * Return: None |
| 11495 | */ |
| 11496 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11497 | { |
| 11498 | #ifdef CNSS_GENL |
| 11499 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11500 | #else |
| 11501 | nl_srv_bcast(skb); |
| 11502 | #endif |
| 11503 | } |
| 11504 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11505 | 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] | 11506 | { |
| 11507 | struct sk_buff *skb; |
| 11508 | struct nlmsghdr *nlh; |
| 11509 | tAniMsgHdr *ani_hdr; |
| 11510 | void *nl_data = NULL; |
| 11511 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11512 | struct radio_index_tlv *radio_info; |
| 11513 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11514 | |
| 11515 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11516 | flags = GFP_ATOMIC; |
| 11517 | |
| 11518 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11519 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11520 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11521 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11522 | |
| 11523 | nlh = (struct nlmsghdr *)skb->data; |
| 11524 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11525 | nlh->nlmsg_flags = 0; |
| 11526 | nlh->nlmsg_seq = 0; |
| 11527 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11528 | |
| 11529 | ani_hdr = NLMSG_DATA(nlh); |
| 11530 | ani_hdr->type = type; |
| 11531 | |
| 11532 | switch (type) { |
| 11533 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11534 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11535 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11536 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11537 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11538 | ani_hdr->length = 0; |
| 11539 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11540 | break; |
| 11541 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11542 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11543 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11544 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11545 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11546 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11547 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11548 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11549 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11550 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11551 | ani_hdr->length = len; |
| 11552 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11553 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11554 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11555 | break; |
| 11556 | |
| 11557 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11558 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11559 | type); |
| 11560 | kfree_skb(skb); |
| 11561 | return; |
| 11562 | } |
| 11563 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11564 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11565 | * Add radio index at the end of the svc event in TLV format |
| 11566 | * to maintain the backward compatibility with userspace |
| 11567 | * applications. |
| 11568 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11569 | |
| 11570 | tlv_len = 0; |
| 11571 | |
| 11572 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11573 | < WLAN_NL_MAX_PAYLOAD) { |
| 11574 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11575 | sizeof(*ani_hdr) + len); |
| 11576 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11577 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11578 | radio_info->radio = radio; |
| 11579 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11580 | hdd_debug("Added radio index tlv - radio index %d", |
| 11581 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11582 | } |
| 11583 | |
| 11584 | nlh->nlmsg_len += tlv_len; |
| 11585 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11586 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11587 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11588 | } |
| 11589 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11590 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11591 | void wlan_hdd_auto_shutdown_cb(void) |
| 11592 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11593 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11594 | |
| 11595 | if (!hdd_ctx) |
| 11596 | return; |
| 11597 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11598 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11599 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11600 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11601 | } |
| 11602 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11603 | 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] | 11604 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11605 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11606 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11607 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11608 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11609 | mac_handle = hdd_ctx->mac_handle; |
| 11610 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11611 | return; |
| 11612 | |
| 11613 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11614 | return; |
| 11615 | |
| 11616 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11617 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11618 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11619 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11620 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11621 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11622 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11623 | return; |
| 11624 | } |
| 11625 | |
| 11626 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11627 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11628 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11629 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11630 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11631 | conn_info.connState == |
| 11632 | eConnectionState_Associated) { |
| 11633 | sta_connected = true; |
| 11634 | break; |
| 11635 | } |
| 11636 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11637 | |
| 11638 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11639 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11640 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11641 | ap_connected = true; |
| 11642 | break; |
| 11643 | } |
| 11644 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11645 | } |
| 11646 | } |
| 11647 | |
| 11648 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11649 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11650 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11651 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11652 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11653 | if (sme_set_auto_shutdown_timer(mac_handle, |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11654 | hdd_ctx->config->WlanAutoShutdown) |
| 11655 | != QDF_STATUS_SUCCESS) |
| 11656 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11657 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11658 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11659 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11660 | } |
| 11661 | #endif |
| 11662 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11663 | struct hdd_adapter * |
| 11664 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11665 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11666 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11667 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11668 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11669 | |
| 11670 | con_sap_adapter = NULL; |
| 11671 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11672 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11673 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11674 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11675 | adapter != this_sap_adapter) { |
| 11676 | if (check_start_bss) { |
| 11677 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11678 | &adapter->event_flags)) { |
| 11679 | con_sap_adapter = adapter; |
| 11680 | break; |
| 11681 | } |
| 11682 | } else { |
| 11683 | con_sap_adapter = adapter; |
| 11684 | break; |
| 11685 | } |
| 11686 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11687 | } |
| 11688 | |
| 11689 | return con_sap_adapter; |
| 11690 | } |
| 11691 | |
| 11692 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11693 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11694 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11695 | return adapter->device_mode == QDF_STA_MODE || |
| 11696 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11697 | } |
| 11698 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11699 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11700 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11701 | return adapter->device_mode == QDF_SAP_MODE || |
| 11702 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11703 | } |
| 11704 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11705 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11706 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11707 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11708 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11709 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11710 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11711 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11712 | conn_info.connState == eConnectionState_Associated) { |
| 11713 | return true; |
| 11714 | } |
| 11715 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11716 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11717 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11718 | return true; |
| 11719 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11720 | } |
| 11721 | |
| 11722 | return false; |
| 11723 | } |
| 11724 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11725 | 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] | 11726 | { |
| 11727 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11728 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11729 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11730 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11731 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11732 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11733 | return is_running; |
| 11734 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11735 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11736 | 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] | 11737 | { |
| 11738 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11739 | hdd_ctx->bus_bw_timer_running = true; |
| 11740 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11741 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11742 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11743 | } |
| 11744 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11745 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11746 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11747 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11748 | |
| 11749 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11750 | hdd_debug("Bandwidth compute timer already started"); |
| 11751 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11752 | } |
| 11753 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11754 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11755 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11756 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11757 | } |
| 11758 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11759 | 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] | 11760 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11761 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11762 | |
| 11763 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11764 | hdd_debug("Bandwidth compute timer already started"); |
| 11765 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11766 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11767 | |
| 11768 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11769 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11770 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11771 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11772 | } |
| 11773 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11774 | 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] | 11775 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11776 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11777 | |
| 11778 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11779 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11780 | hdd_ctx->bus_bw_timer_running = false; |
| 11781 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11782 | |
| 11783 | hdd_reset_tcp_delack(hdd_ctx); |
| 11784 | } |
| 11785 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11786 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11787 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11788 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11789 | |
| 11790 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11791 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11792 | return; |
| 11793 | } |
| 11794 | |
| 11795 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11796 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11797 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11798 | } |
| 11799 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11800 | 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] | 11801 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11802 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11803 | |
| 11804 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11805 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11806 | return; |
| 11807 | } |
| 11808 | |
| 11809 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11810 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11811 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11812 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11813 | } |
| 11814 | #endif |
| 11815 | |
| 11816 | /** |
| 11817 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11818 | * and sta's operating channel. |
| 11819 | * @sta_adapter: Describe the first argument to foobar. |
| 11820 | * @ap_adapter: Describe the second argument to foobar. |
| 11821 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11822 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11823 | * set this flag to true else false. |
| 11824 | * |
| 11825 | * This function checks the sap's operating channel and sta's operating channel. |
| 11826 | * if both are same then it will return false else it will restart the sap in |
| 11827 | * sta's channel and return true. |
| 11828 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11829 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11830 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11831 | QDF_STATUS |
| 11832 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11833 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11834 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11835 | tScanResultHandle *scan_cache, |
| 11836 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11837 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11838 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11839 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11840 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11841 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11842 | *concurrent_chnl_same = true; |
| 11843 | |
| 11844 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11845 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11846 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11847 | scan_cache, |
| 11848 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11849 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11850 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11851 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11852 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11853 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11854 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11855 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11856 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11857 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11858 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11859 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11860 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11861 | } |
| 11862 | } |
| 11863 | } else { |
| 11864 | /* |
| 11865 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11866 | * failed so we have to stop the SAP to avoid any channel |
| 11867 | * discrepancy between SAP's channel and STA's channel. |
| 11868 | * Return the status as failure so caller function could know |
| 11869 | * that scan look up is failed. |
| 11870 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11871 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11872 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11873 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11874 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11875 | } |
| 11876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11877 | /** |
| 11878 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11879 | * @ap_adapter: SAP adapter |
| 11880 | * |
| 11881 | * This function will process the stopping of sap adapter. |
| 11882 | * |
| 11883 | * Return: None |
| 11884 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11885 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11886 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11887 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11888 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11889 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11890 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11891 | |
| 11892 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11893 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11894 | return; |
| 11895 | } |
| 11896 | |
| 11897 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11898 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11899 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11900 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11901 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11902 | mutex_lock(&hdd_ctx->sap_lock); |
| 11903 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11904 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11905 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11906 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11907 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11908 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11909 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11910 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11911 | qdf_stop_bss_event, |
| 11912 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11913 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11914 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11915 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11916 | return; |
| 11917 | } |
| 11918 | } |
| 11919 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11920 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11921 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11922 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11923 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11924 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11925 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11926 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11927 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11928 | } |
| 11929 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11930 | } |
| 11931 | |
| 11932 | /** |
| 11933 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11934 | * @ap_adapter: SAP adapter |
| 11935 | * |
| 11936 | * This function will process the starting of sap adapter. |
| 11937 | * |
| 11938 | * Return: None |
| 11939 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11940 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11941 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11942 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11943 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11944 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11945 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 11946 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11947 | |
| 11948 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11949 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11950 | return; |
| 11951 | } |
| 11952 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11953 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11954 | hdd_err("SoftAp role has not been enabled"); |
| 11955 | return; |
| 11956 | } |
| 11957 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11958 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11959 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11960 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11961 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11962 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11963 | mutex_lock(&hdd_ctx->sap_lock); |
| 11964 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11965 | goto end; |
| 11966 | |
| 11967 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11968 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11969 | goto end; |
| 11970 | } |
| 11971 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11972 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11973 | 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] | 11974 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11975 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11976 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11977 | goto end; |
| 11978 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11979 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11980 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11981 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11982 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11983 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11984 | goto end; |
| 11985 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11986 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 11987 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11988 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11989 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11990 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 11991 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11992 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11993 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11994 | true); |
| 11995 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 11996 | mutex_unlock(&hdd_ctx->sap_lock); |
| 11997 | |
| 11998 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11999 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12000 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12001 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12002 | /* SAP context and beacon cleanup will happen during driver unload |
| 12003 | * in hdd_stop_adapter |
| 12004 | */ |
| 12005 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12006 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12007 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12008 | |
| 12009 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12010 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 12011 | * mac scan config |
| 12012 | * @status: Status of set antenna mode |
| 12013 | * |
| 12014 | * Callback on setting the dual mac configuration |
| 12015 | * |
| 12016 | * Return: None |
| 12017 | */ |
| 12018 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 12019 | enum set_antenna_mode_status status) |
| 12020 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12021 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12022 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12023 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12024 | |
| 12025 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12026 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 12027 | return; |
| 12028 | |
| 12029 | /* Signal the completion of set dual mac config */ |
| 12030 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 12031 | } |
| 12032 | |
| 12033 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12034 | * hdd_get_fw_version() - Get FW version |
| 12035 | * @hdd_ctx: pointer to HDD context. |
| 12036 | * @major_spid: FW version - major spid. |
| 12037 | * @minor_spid: FW version - minor spid |
| 12038 | * @ssid: FW version - ssid |
| 12039 | * @crmid: FW version - crmid |
| 12040 | * |
| 12041 | * This function is called to get the firmware build version stored |
| 12042 | * as part of the HDD context |
| 12043 | * |
| 12044 | * Return: None |
| 12045 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12046 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12047 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12048 | uint32_t *siid, uint32_t *crmid) |
| 12049 | { |
| 12050 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12051 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12052 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12053 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12054 | } |
| 12055 | |
| 12056 | #ifdef QCA_CONFIG_SMP |
| 12057 | /** |
| 12058 | * wlan_hdd_get_cpu() - get cpu_index |
| 12059 | * |
| 12060 | * Return: cpu_index |
| 12061 | */ |
| 12062 | int wlan_hdd_get_cpu(void) |
| 12063 | { |
| 12064 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12065 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12066 | put_cpu(); |
| 12067 | return cpu_index; |
| 12068 | } |
| 12069 | #endif |
| 12070 | |
| 12071 | /** |
| 12072 | * hdd_get_fwpath() - get framework path |
| 12073 | * |
| 12074 | * This function is used to get the string written by |
| 12075 | * userspace to start the wlan driver |
| 12076 | * |
| 12077 | * Return: string |
| 12078 | */ |
| 12079 | const char *hdd_get_fwpath(void) |
| 12080 | { |
| 12081 | return fwpath.string; |
| 12082 | } |
| 12083 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12084 | static int hdd_qdf_print_init(void) |
| 12085 | { |
| 12086 | int qdf_print_idx; |
| 12087 | QDF_STATUS status; |
| 12088 | |
| 12089 | status = qdf_print_setup(); |
| 12090 | if (status != QDF_STATUS_SUCCESS) { |
| 12091 | pr_err("qdf_print_setup failed\n"); |
| 12092 | return -EINVAL; |
| 12093 | } |
| 12094 | |
| 12095 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 12096 | |
| 12097 | if (qdf_print_idx < 0) { |
| 12098 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 12099 | qdf_print_idx); |
| 12100 | return -EINVAL; |
| 12101 | } |
| 12102 | |
| 12103 | qdf_set_pidx(qdf_print_idx); |
| 12104 | |
| 12105 | return 0; |
| 12106 | } |
| 12107 | |
| 12108 | static void hdd_qdf_print_deinit(void) |
| 12109 | { |
| 12110 | int qdf_print_idx; |
| 12111 | |
| 12112 | qdf_print_idx = qdf_get_pidx(); |
| 12113 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 12114 | } |
| 12115 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12116 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12117 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12118 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12119 | * This function initilizes CDS global context with the help of cds_init. This |
| 12120 | * has to be the first function called after probe to get a valid global |
| 12121 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12122 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12123 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12124 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12125 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12126 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12127 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12128 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12129 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12130 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12131 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12132 | hdd_err("Failed to allocate CDS context"); |
| 12133 | ret = -ENOMEM; |
| 12134 | goto err_out; |
| 12135 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12136 | |
| 12137 | wlan_init_bug_report_lock(); |
| 12138 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12139 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12140 | wlan_logging_sock_init_svc(); |
| 12141 | #endif |
| 12142 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12143 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12144 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12145 | QDF_TIMER_TYPE_SW); |
| 12146 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12147 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12148 | hdd_qdf_print_init(); |
| 12149 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12150 | hdd_register_debug_callback(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12151 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12152 | err_out: |
| 12153 | return ret; |
| 12154 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12155 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12156 | /** |
| 12157 | * hdd_deinit() - Deinitialize Driver |
| 12158 | * |
| 12159 | * This function frees CDS global context with the help of cds_deinit. This |
| 12160 | * has to be the last function call in remove callback to free the global |
| 12161 | * context. |
| 12162 | */ |
| 12163 | void hdd_deinit(void) |
| 12164 | { |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12165 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12166 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 12167 | wlan_destroy_bug_report_lock(); |
| 12168 | cds_deinit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12169 | |
Rajeev Kumar | 2d0f219 | 2017-10-18 19:48:21 -0700 | [diff] [blame] | 12170 | hdd_qdf_print_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12171 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12172 | wlan_logging_sock_deinit_svc(); |
| 12173 | #endif |
| 12174 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12175 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12176 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12177 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12178 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12179 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12180 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12181 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12182 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12183 | struct file *file) |
| 12184 | { |
| 12185 | return 0; |
| 12186 | } |
| 12187 | |
| 12188 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12189 | const char __user *user_buf, |
| 12190 | size_t count, |
| 12191 | loff_t *f_pos) |
| 12192 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12193 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12194 | static const char wlan_off_str[] = "OFF"; |
| 12195 | static const char wlan_on_str[] = "ON"; |
| 12196 | int ret; |
| 12197 | unsigned long rc; |
| 12198 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12199 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12200 | pr_err("Failed to read buffer\n"); |
| 12201 | return -EINVAL; |
| 12202 | } |
| 12203 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12204 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12205 | pr_debug("Wifi turning off from UI\n"); |
| 12206 | goto exit; |
| 12207 | } |
| 12208 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12209 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 12210 | pr_info("Wifi Turning On from UI\n"); |
| 12211 | } |
| 12212 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12213 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12214 | pr_err("Invalid value received from framework"); |
| 12215 | goto exit; |
| 12216 | } |
| 12217 | |
| 12218 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12219 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12220 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12221 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12222 | if (!rc) { |
| 12223 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 12224 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12225 | return ret; |
| 12226 | } |
| 12227 | |
| 12228 | hdd_start_complete(0); |
| 12229 | } |
| 12230 | |
| 12231 | exit: |
| 12232 | return count; |
| 12233 | } |
| 12234 | |
| 12235 | |
| 12236 | const struct file_operations wlan_hdd_state_fops = { |
| 12237 | .owner = THIS_MODULE, |
| 12238 | .open = wlan_hdd_state_ctrl_param_open, |
| 12239 | .write = wlan_hdd_state_ctrl_param_write, |
| 12240 | }; |
| 12241 | |
| 12242 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12243 | { |
| 12244 | unsigned int wlan_hdd_state_major = 0; |
| 12245 | int ret; |
| 12246 | struct device *dev; |
| 12247 | |
| 12248 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12249 | |
| 12250 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12251 | if (ret) { |
| 12252 | pr_err("Failed to register qcwlanstate"); |
| 12253 | goto dev_alloc_err; |
| 12254 | } |
| 12255 | wlan_hdd_state_major = MAJOR(device); |
| 12256 | |
| 12257 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12258 | if (IS_ERR(class)) { |
| 12259 | pr_err("wlan_hdd_state class_create error"); |
| 12260 | goto class_err; |
| 12261 | } |
| 12262 | |
| 12263 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12264 | if (IS_ERR(dev)) { |
| 12265 | pr_err("wlan_hdd_statedevice_create error"); |
| 12266 | goto err_class_destroy; |
| 12267 | } |
| 12268 | |
| 12269 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12270 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12271 | if (ret) { |
| 12272 | pr_err("Failed to add cdev error"); |
| 12273 | goto cdev_add_err; |
| 12274 | } |
| 12275 | |
| 12276 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12277 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12278 | |
| 12279 | return 0; |
| 12280 | |
| 12281 | cdev_add_err: |
| 12282 | device_destroy(class, device); |
| 12283 | err_class_destroy: |
| 12284 | class_destroy(class); |
| 12285 | class_err: |
| 12286 | unregister_chrdev_region(device, dev_num); |
| 12287 | dev_alloc_err: |
| 12288 | return -ENODEV; |
| 12289 | } |
| 12290 | |
| 12291 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12292 | { |
| 12293 | cdev_del(&wlan_hdd_state_cdev); |
| 12294 | device_destroy(class, device); |
| 12295 | class_destroy(class); |
| 12296 | unregister_chrdev_region(device, dev_num); |
| 12297 | |
| 12298 | pr_info("Device node unregistered"); |
| 12299 | } |
| 12300 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12301 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12302 | * component_init - API to init cld component's |
| 12303 | * |
| 12304 | * Return: None |
| 12305 | */ |
| 12306 | static void component_init(void) |
| 12307 | { |
| 12308 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12309 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12310 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12311 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12312 | } |
| 12313 | |
| 12314 | /** |
| 12315 | * component_deinit - API to deinit cld component's |
| 12316 | * |
| 12317 | * Return: None |
| 12318 | */ |
| 12319 | static void component_deinit(void) |
| 12320 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12321 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12322 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12323 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12324 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12325 | } |
| 12326 | |
| 12327 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12328 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12329 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12330 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12331 | } |
| 12332 | |
| 12333 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12334 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12335 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12336 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12337 | } |
| 12338 | |
| 12339 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12340 | * __hdd_module_init - Module init helper |
| 12341 | * |
| 12342 | * Module init helper function used by both module and static driver. |
| 12343 | * |
| 12344 | * Return: 0 for success, errno on failure |
| 12345 | */ |
| 12346 | static int __hdd_module_init(void) |
| 12347 | { |
| 12348 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12349 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12350 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12351 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12352 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12353 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12354 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12355 | pld_init(); |
| 12356 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12357 | ret = hdd_init(); |
| 12358 | if (ret) { |
| 12359 | pr_err("hdd_init failed %x\n", ret); |
| 12360 | goto err_hdd_init; |
| 12361 | } |
| 12362 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12363 | dispatcher_init(); |
| 12364 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12365 | /* Ensure to call post objmgr init */ |
| 12366 | component_init(); |
| 12367 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12368 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12369 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12370 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12371 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12372 | ret = wlan_hdd_register_driver(); |
| 12373 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12374 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12375 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12376 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12377 | } |
| 12378 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12379 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12380 | if (ret) { |
| 12381 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12382 | goto out; |
| 12383 | } |
| 12384 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12385 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12386 | |
| 12387 | return 0; |
| 12388 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12389 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12390 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12391 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12392 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12393 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12394 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12395 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12396 | return ret; |
| 12397 | } |
| 12398 | |
| 12399 | /** |
| 12400 | * __hdd_module_exit - Module exit helper |
| 12401 | * |
| 12402 | * Module exit helper function used by both module and static driver. |
| 12403 | */ |
| 12404 | static void __hdd_module_exit(void) |
| 12405 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12406 | 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] | 12407 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12408 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12409 | QWLAN_VERSIONSTR); |
| 12410 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12411 | if (!hdd_wait_for_recovery_completion()) |
| 12412 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12413 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12414 | if (hdd_ctx) |
| 12415 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12416 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12417 | wlan_hdd_unregister_driver(); |
| 12418 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12419 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12420 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12421 | /* Ensure to call prior to objmgr deinit */ |
| 12422 | component_deinit(); |
| 12423 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12424 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12425 | |
| 12426 | hdd_sysfs_destroy_version_interface(); |
| 12427 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12428 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12429 | pld_deinit(); |
| 12430 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12431 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12432 | } |
| 12433 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12434 | #ifndef MODULE |
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 | * wlan_boot_cb() - Wlan boot callback |
| 12437 | * @kobj: object whose directory we're creating the link in. |
| 12438 | * @attr: attribute the user is interacting with |
| 12439 | * @buff: the buffer containing the user data |
| 12440 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12441 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12442 | * This callback is invoked when the fs is ready to start the |
| 12443 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12444 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12445 | * 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] | 12446 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12447 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12448 | struct kobj_attribute *attr, |
| 12449 | const char *buf, |
| 12450 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12451 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12452 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12453 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12454 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12455 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12456 | } |
| 12457 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12458 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12459 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12460 | return -EIO; |
| 12461 | } |
| 12462 | |
| 12463 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12464 | |
| 12465 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12466 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12467 | |
| 12468 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12469 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12470 | * |
| 12471 | * Return: None |
| 12472 | * |
| 12473 | */ |
| 12474 | static void hdd_sysfs_cleanup(void) |
| 12475 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12476 | /* remove from group */ |
| 12477 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12478 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12479 | wlan_loader->attr_group); |
| 12480 | |
| 12481 | /* unlink the object from parent */ |
| 12482 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12483 | |
| 12484 | /* free the object */ |
| 12485 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12486 | |
| 12487 | kfree(wlan_loader->attr_group); |
| 12488 | kfree(wlan_loader); |
| 12489 | |
| 12490 | wlan_loader = NULL; |
| 12491 | } |
| 12492 | |
| 12493 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12494 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12495 | * ready |
| 12496 | * |
| 12497 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12498 | * when the filesystem is ready. |
| 12499 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12500 | * QDF API cannot be used here since this function is called even before |
| 12501 | * initializing WLAN driver. |
| 12502 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12503 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12504 | */ |
| 12505 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12506 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12507 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12508 | |
| 12509 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12510 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12511 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12512 | |
| 12513 | wlan_loader->boot_wlan_obj = NULL; |
| 12514 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12515 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12516 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12517 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12518 | |
| 12519 | wlan_loader->loaded_state = 0; |
| 12520 | wlan_loader->attr_group->attrs = attrs; |
| 12521 | |
| 12522 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12523 | kernel_kobj); |
| 12524 | if (!wlan_loader->boot_wlan_obj) { |
| 12525 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12526 | goto error_return; |
| 12527 | } |
| 12528 | |
| 12529 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12530 | wlan_loader->attr_group); |
| 12531 | if (ret) { |
| 12532 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12533 | goto error_return; |
| 12534 | } |
| 12535 | |
| 12536 | return 0; |
| 12537 | |
| 12538 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12539 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12540 | |
| 12541 | return ret; |
| 12542 | } |
| 12543 | |
| 12544 | /** |
| 12545 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12546 | * |
| 12547 | * Return: 0 on success or errno on failure |
| 12548 | */ |
| 12549 | static int wlan_deinit_sysfs(void) |
| 12550 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12551 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12552 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12553 | return -EINVAL; |
| 12554 | } |
| 12555 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12556 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12557 | return 0; |
| 12558 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12559 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12560 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12561 | |
| 12562 | #ifdef MODULE |
| 12563 | /** |
| 12564 | * __hdd_module_init - Module init helper |
| 12565 | * |
| 12566 | * Module init helper function used by both module and static driver. |
| 12567 | * |
| 12568 | * Return: 0 for success, errno on failure |
| 12569 | */ |
| 12570 | static int hdd_module_init(void) |
| 12571 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12572 | if (__hdd_module_init()) { |
| 12573 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12574 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12575 | } |
| 12576 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12577 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12578 | } |
| 12579 | #else |
| 12580 | static int __init hdd_module_init(void) |
| 12581 | { |
| 12582 | int ret = -EINVAL; |
| 12583 | |
| 12584 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12585 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12586 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12587 | |
| 12588 | return ret; |
| 12589 | } |
| 12590 | #endif |
| 12591 | |
| 12592 | |
| 12593 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12594 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12595 | * hdd_module_exit() - Exit function |
| 12596 | * |
| 12597 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12598 | * |
| 12599 | * Return: None |
| 12600 | */ |
| 12601 | static void __exit hdd_module_exit(void) |
| 12602 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12603 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12604 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12605 | #else |
| 12606 | static void __exit hdd_module_exit(void) |
| 12607 | { |
| 12608 | __hdd_module_exit(); |
| 12609 | wlan_deinit_sysfs(); |
| 12610 | } |
| 12611 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12612 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12613 | static int fwpath_changed_handler(const char *kmessage, |
| 12614 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12615 | { |
| 12616 | return param_set_copystring(kmessage, kp); |
| 12617 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12618 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12619 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 12620 | static bool is_monitor_mode_supported(void) |
| 12621 | { |
| 12622 | return true; |
| 12623 | } |
| 12624 | #else |
| 12625 | static bool is_monitor_mode_supported(void) |
| 12626 | { |
| 12627 | pr_err("Monitor mode not supported!"); |
| 12628 | return false; |
| 12629 | } |
| 12630 | #endif |
| 12631 | |
| 12632 | #ifdef WLAN_FEATURE_EPPING |
| 12633 | static bool is_epping_mode_supported(void) |
| 12634 | { |
| 12635 | return true; |
| 12636 | } |
| 12637 | #else |
| 12638 | static bool is_epping_mode_supported(void) |
| 12639 | { |
| 12640 | pr_err("Epping mode not supported!"); |
| 12641 | return false; |
| 12642 | } |
| 12643 | #endif |
| 12644 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12645 | /** |
| 12646 | * is_con_mode_valid() check con mode is valid or not |
| 12647 | * @mode: global con mode |
| 12648 | * |
| 12649 | * Return: TRUE on success FALSE on failure |
| 12650 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12651 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12652 | { |
| 12653 | switch (mode) { |
| 12654 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12655 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12656 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12657 | return is_epping_mode_supported(); |
| 12658 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12659 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12660 | return true; |
| 12661 | default: |
| 12662 | return false; |
| 12663 | } |
| 12664 | } |
| 12665 | |
| 12666 | /** |
| 12667 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12668 | * @mode: global con mode |
| 12669 | * |
| 12670 | * Return: adapter mode |
| 12671 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12672 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12673 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12674 | { |
| 12675 | |
| 12676 | switch (mode) { |
| 12677 | case QDF_GLOBAL_MISSION_MODE: |
| 12678 | return QDF_STA_MODE; |
| 12679 | case QDF_GLOBAL_MONITOR_MODE: |
| 12680 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12681 | case QDF_GLOBAL_EPPING_MODE: |
| 12682 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12683 | case QDF_GLOBAL_FTM_MODE: |
| 12684 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12685 | case QDF_GLOBAL_QVIT_MODE: |
| 12686 | return QDF_QVIT_MODE; |
| 12687 | default: |
| 12688 | return QDF_MAX_NO_OF_MODE; |
| 12689 | } |
| 12690 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12691 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12692 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12693 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12694 | { |
| 12695 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12696 | return; |
| 12697 | |
| 12698 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12699 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12700 | hdd_info("Release wakelock for monitor mode!"); |
| 12701 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12702 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 12703 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12704 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12705 | case QDF_GLOBAL_FTM_MODE: |
| 12706 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12707 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12708 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12709 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12710 | break; |
| 12711 | default: |
| 12712 | break; |
| 12713 | } |
| 12714 | } |
| 12715 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12716 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12717 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12718 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12719 | int driver_status; |
| 12720 | |
| 12721 | driver_status = hdd_ctx->driver_status; |
| 12722 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12723 | switch (curr_mode) { |
| 12724 | case QDF_GLOBAL_MISSION_MODE: |
| 12725 | case QDF_GLOBAL_MONITOR_MODE: |
| 12726 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12727 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12728 | hdd_close_all_adapters(hdd_ctx, false); |
| 12729 | break; |
| 12730 | case QDF_GLOBAL_EPPING_MODE: |
| 12731 | epping_disable(); |
| 12732 | epping_close(); |
| 12733 | break; |
| 12734 | default: |
| 12735 | return; |
| 12736 | } |
| 12737 | } |
| 12738 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12739 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12740 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12741 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12742 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12743 | int ret = 0; |
| 12744 | bool rtnl_held; |
| 12745 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12746 | QDF_STATUS status; |
| 12747 | |
| 12748 | if (!qdf_dev) { |
| 12749 | hdd_err("qdf device context is Null return!"); |
| 12750 | return -EINVAL; |
| 12751 | } |
| 12752 | |
| 12753 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12754 | switch (mode) { |
| 12755 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12756 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12757 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12758 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12759 | break; |
| 12760 | case QDF_GLOBAL_FTM_MODE: |
| 12761 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12762 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12763 | NET_NAME_UNKNOWN, rtnl_held); |
| 12764 | if (adapter == NULL) |
| 12765 | ret = -EINVAL; |
| 12766 | break; |
| 12767 | case QDF_GLOBAL_MONITOR_MODE: |
| 12768 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12769 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12770 | NET_NAME_UNKNOWN, rtnl_held); |
| 12771 | if (adapter == NULL) |
| 12772 | ret = -EINVAL; |
| 12773 | break; |
| 12774 | case QDF_GLOBAL_EPPING_MODE: |
| 12775 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12776 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12777 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12778 | ret = -EINVAL; |
| 12779 | break; |
| 12780 | } |
| 12781 | ret = epping_enable(qdf_dev->dev); |
| 12782 | if (ret) { |
| 12783 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12784 | epping_close(); |
| 12785 | } |
| 12786 | break; |
| 12787 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12788 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12789 | ret = -ENOTSUPP; |
| 12790 | break; |
| 12791 | } |
| 12792 | hdd_release_rtnl_lock(); |
| 12793 | rtnl_held = false; |
| 12794 | return ret; |
| 12795 | } |
| 12796 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12797 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12798 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12799 | * @kmessage: con mode name on which driver to be bring up |
| 12800 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12801 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12802 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12803 | * This function is invoked when user updates con mode using sys entry, |
| 12804 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12805 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12806 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12807 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12808 | static int __con_mode_handler(const char *kmessage, |
| 12809 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12810 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12811 | { |
| 12812 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12813 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12814 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12815 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12816 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12817 | hdd_info("con_mode handler: %s", kmessage); |
| 12818 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12819 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12820 | if (ret) |
| 12821 | return ret; |
| 12822 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12823 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12824 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12825 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12826 | if (ret) { |
| 12827 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12828 | goto reset_flags; |
| 12829 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12830 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12831 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12832 | if (!is_con_mode_valid(new_con_mode)) { |
| 12833 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12834 | ret = -EINVAL; |
| 12835 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12836 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12837 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12838 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12839 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12840 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12841 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12842 | ret = 0; |
| 12843 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12844 | } |
| 12845 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12846 | /* ensure adapters are stopped */ |
| 12847 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12848 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12849 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12850 | if (ret) { |
| 12851 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12852 | goto reset_flags; |
| 12853 | } |
| 12854 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 12855 | /* Cleanup present mode before switching to new mode */ |
| 12856 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12857 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12858 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12859 | |
| 12860 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12861 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12862 | if (ret) { |
| 12863 | hdd_err("Failed to register for new mode"); |
| 12864 | goto reset_flags; |
| 12865 | } |
| 12866 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12867 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12868 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12869 | hdd_err("invalid adapter"); |
| 12870 | ret = -EINVAL; |
| 12871 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12872 | } |
| 12873 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12874 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12875 | if (ret) { |
| 12876 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12877 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12878 | } |
| 12879 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12880 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12881 | struct hdd_adapter *adapter = |
| 12882 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 12883 | |
| 12884 | if (!adapter) { |
| 12885 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12886 | goto reset_flags; |
| 12887 | } |
| 12888 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12889 | if (hdd_start_adapter(adapter)) { |
| 12890 | hdd_err("Failed to start %s adapter", kmessage); |
| 12891 | ret = -EINVAL; |
| 12892 | goto reset_flags; |
| 12893 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12894 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12895 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12896 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12897 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12898 | } |
| 12899 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12900 | /* con_mode is a global module parameter */ |
| 12901 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12902 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12903 | ret = 0; |
| 12904 | |
| 12905 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12906 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12907 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12908 | return ret; |
| 12909 | } |
| 12910 | |
| 12911 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12912 | 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] | 12913 | { |
| 12914 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12915 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12916 | |
| 12917 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12918 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12919 | if (ret) |
| 12920 | return ret; |
| 12921 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 12922 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 12923 | hdd_warn("External threads are still active, can not change mode"); |
| 12924 | return -EAGAIN; |
| 12925 | } |
| 12926 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12927 | cds_ssr_protect(__func__); |
| 12928 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12929 | cds_ssr_unprotect(__func__); |
| 12930 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12931 | return ret; |
| 12932 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12933 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12934 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12935 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12936 | { |
| 12937 | int ret; |
| 12938 | |
| 12939 | ret = param_set_int(kmessage, kp); |
| 12940 | |
| 12941 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12942 | pr_err("Only FTM mode supported!"); |
| 12943 | return -ENOTSUPP; |
| 12944 | } |
| 12945 | |
| 12946 | hdd_set_conparam(con_mode_ftm); |
| 12947 | con_mode = con_mode_ftm; |
| 12948 | |
| 12949 | return ret; |
| 12950 | } |
| 12951 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12952 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12953 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12954 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12955 | { |
| 12956 | int ret; |
| 12957 | |
| 12958 | ret = param_set_int(kmessage, kp); |
| 12959 | |
| 12960 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12961 | pr_err("Only Monitor mode supported!"); |
| 12962 | return -ENOTSUPP; |
| 12963 | } |
| 12964 | |
| 12965 | hdd_set_conparam(con_mode_monitor); |
| 12966 | con_mode = con_mode_monitor; |
| 12967 | |
| 12968 | return ret; |
| 12969 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12970 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12971 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12972 | /** |
| 12973 | * hdd_get_conparam() - driver exit point |
| 12974 | * |
| 12975 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12976 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12977 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12978 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12979 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12980 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12981 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12982 | } |
| 12983 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12984 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12985 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 12986 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12987 | } |
| 12988 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 12989 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12990 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 12991 | * @hdd_ctx: HDD context |
| 12992 | * |
| 12993 | * Cleans up the pre cac interface, if it exists |
| 12994 | * |
| 12995 | * Return: None |
| 12996 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12997 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 12998 | { |
| 12999 | uint8_t session_id; |
| 13000 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 13001 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13002 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13003 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->mac_handle, &session_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13004 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13005 | hdd_err("failed to get pre cac vdev id"); |
| 13006 | return; |
| 13007 | } |
| 13008 | |
| 13009 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 13010 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 13011 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13012 | return; |
| 13013 | } |
| 13014 | |
| 13015 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 13016 | wlan_hdd_sap_pre_cac_failure, |
| 13017 | (void *)precac_adapter); |
| 13018 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 13019 | |
| 13020 | } |
| 13021 | |
| 13022 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13023 | * hdd_update_ol_config - API to update ol configuration parameters |
| 13024 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13025 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13026 | * Return: void |
| 13027 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13028 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13029 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13030 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13031 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13032 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13033 | if (!ol_ctx) |
| 13034 | return; |
| 13035 | |
| 13036 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 13037 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 13038 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 13039 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 13040 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13041 | |
| 13042 | ol_init_ini_config(ol_ctx, &cfg); |
| 13043 | } |
| 13044 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13045 | #ifdef FEATURE_RUNTIME_PM |
| 13046 | /** |
| 13047 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 13048 | * @hdd_ctx: hdd context |
| 13049 | * @cfg: pointer to the configuration memory being populated |
| 13050 | * |
| 13051 | * Return: void |
| 13052 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13053 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13054 | struct hif_config_info *cfg) |
| 13055 | { |
| 13056 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 13057 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 13058 | } |
| 13059 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13060 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13061 | struct hif_config_info *cfg) |
| 13062 | { |
| 13063 | } |
| 13064 | #endif |
| 13065 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13066 | /** |
| 13067 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 13068 | * @hdd_ctx: HDD Context |
| 13069 | * |
| 13070 | * Return: void |
| 13071 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13072 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13073 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13074 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13075 | struct hif_config_info cfg; |
| 13076 | |
| 13077 | if (!scn) |
| 13078 | return; |
| 13079 | |
| 13080 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13081 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13082 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 13083 | |
| 13084 | if (hdd_ctx->config->prevent_link_down) |
| 13085 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13086 | } |
| 13087 | |
| 13088 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13089 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 13090 | * datapath |
| 13091 | * @hdd_ctx: HDD Context |
| 13092 | * |
| 13093 | * Return: 0 for success/errno for failure |
| 13094 | */ |
| 13095 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 13096 | { |
| 13097 | struct cdp_config_params params; |
| 13098 | QDF_STATUS status; |
| 13099 | |
| 13100 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 13101 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 13102 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 13103 | params.tx_flow_stop_queue_threshold = |
| 13104 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 13105 | params.tx_flow_start_queue_offset = |
| 13106 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 13107 | #endif |
| 13108 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 13109 | params.napi_enable = hdd_ctx->napi_enable; |
| 13110 | params.tcp_udp_checksumoffload = |
| 13111 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 13112 | |
| 13113 | status = cdp_update_config_parameters( |
| 13114 | cds_get_context(QDF_MODULE_ID_SOC), |
| 13115 | ¶ms); |
| 13116 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13117 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13118 | return status; |
| 13119 | } |
| 13120 | |
| 13121 | return 0; |
| 13122 | } |
| 13123 | |
| 13124 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13125 | * hdd_update_config() - Initialize driver per module ini parameters |
| 13126 | * @hdd_ctx: HDD Context |
| 13127 | * |
| 13128 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13129 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13130 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13131 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13132 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13133 | int ret; |
| 13134 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13135 | hdd_update_ol_config(hdd_ctx); |
| 13136 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13137 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 13138 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 13139 | else |
| 13140 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 13141 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13142 | |
| 13143 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13144 | } |
| 13145 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13146 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 13147 | /** |
| 13148 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 13149 | * @psoc_cfg: pmo psoc Configuration |
| 13150 | * @hdd_ctx: Pointer to hdd context |
| 13151 | * |
| 13152 | * Return: none |
| 13153 | */ |
| 13154 | static inline void hdd_ra_populate_pmo_config( |
| 13155 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13156 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13157 | { |
| 13158 | psoc_cfg->ra_ratelimit_interval = |
| 13159 | hdd_ctx->config->RArateLimitInterval; |
| 13160 | psoc_cfg->ra_ratelimit_enable = |
| 13161 | hdd_ctx->config->IsRArateLimitEnabled; |
| 13162 | } |
| 13163 | #else |
| 13164 | static inline void hdd_ra_populate_pmo_config( |
| 13165 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13166 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13167 | { |
| 13168 | } |
| 13169 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13170 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13171 | /** |
| 13172 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 13173 | * @hdd_ctx: HDD context |
| 13174 | * |
| 13175 | * Return: void |
| 13176 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13177 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13178 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13179 | struct pmo_psoc_cfg psoc_cfg; |
| 13180 | QDF_STATUS status; |
| 13181 | |
| 13182 | /* |
| 13183 | * Value of hdd_ctx->wowEnable can be, |
| 13184 | * 0 - Disable both magic pattern match and pattern byte match. |
| 13185 | * 1 - Enable magic pattern match on all interfaces. |
| 13186 | * 2 - Enable pattern byte match on all interfaces. |
| 13187 | * 3 - Enable both magic patter and pattern byte match on |
| 13188 | * all interfaces. |
| 13189 | */ |
| 13190 | psoc_cfg.magic_ptrn_enable = |
| 13191 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 13192 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 13193 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 13194 | psoc_cfg.apf_enable = hdd_ctx->config->apf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13195 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Nachiket Kukade | f080407 | 2018-02-27 18:20:07 +0530 | [diff] [blame] | 13196 | psoc_cfg.hw_filter_mode_bitmap = hdd_ctx->config->hw_filter_mode_bitmap; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13197 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13198 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13199 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13200 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 13201 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13202 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13203 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13204 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13205 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 13206 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 13207 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13208 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 13209 | psoc_cfg.auto_power_save_fail_mode = |
| 13210 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13211 | |
| 13212 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13213 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 13214 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13215 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13216 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 13217 | if (QDF_IS_STATUS_ERROR(status)) |
| 13218 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 13219 | |
| 13220 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13221 | } |
| 13222 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13223 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13224 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 13225 | struct hdd_config *cfg) |
| 13226 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13227 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 13228 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13229 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 13230 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 13231 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 13232 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 13233 | pno_cfg->channel_prediction_full_scan = |
| 13234 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13235 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 13236 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 13237 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 13238 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13239 | } |
| 13240 | #else |
| 13241 | static inline void |
| 13242 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 13243 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13244 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13245 | } |
| 13246 | #endif |
| 13247 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13248 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 13249 | struct hdd_config *cfg) |
| 13250 | { |
| 13251 | uint8_t i = 0; |
| 13252 | |
| 13253 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 13254 | if (!ie_whitelist->white_list) |
| 13255 | return; |
| 13256 | |
| 13257 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 13258 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 13259 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 13260 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 13261 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 13262 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 13263 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 13264 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 13265 | |
| 13266 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 13267 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 13268 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 13269 | } |
| 13270 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13271 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 13272 | { |
| 13273 | uint8_t i, score; |
| 13274 | |
| 13275 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13276 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13277 | if (score > MAX_INDEX_SCORE) |
| 13278 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13279 | MAX_INDEX_SCORE, i); |
| 13280 | } |
| 13281 | |
| 13282 | return per_index_score; |
| 13283 | } |
| 13284 | |
| 13285 | /** |
| 13286 | * hdd_update_score_config - API to update candidate scoring related params |
| 13287 | * configuration parameters |
| 13288 | * @score_config: score config to update |
| 13289 | * @cfg: config params |
| 13290 | * |
| 13291 | * Return: 0 if success else err |
| 13292 | */ |
| 13293 | static void hdd_update_score_config( |
| 13294 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 13295 | { |
| 13296 | int total_weight; |
| 13297 | |
| 13298 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 13299 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 13300 | score_config->weight_cfg.vht_caps_weightage = |
| 13301 | cfg->vht_caps_weightage; |
| 13302 | score_config->weight_cfg.he_caps_weightage = |
| 13303 | cfg->he_caps_weightage; |
| 13304 | score_config->weight_cfg.chan_width_weightage = |
| 13305 | cfg->chan_width_weightage; |
| 13306 | score_config->weight_cfg.chan_band_weightage = |
| 13307 | cfg->chan_band_weightage; |
| 13308 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 13309 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13310 | cfg->beamforming_cap_weightage; |
| 13311 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 13312 | score_config->weight_cfg.channel_congestion_weightage = |
| 13313 | cfg->channel_congestion_weightage; |
| 13314 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 13315 | |
| 13316 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 13317 | score_config->weight_cfg.ht_caps_weightage + |
| 13318 | score_config->weight_cfg.vht_caps_weightage + |
| 13319 | score_config->weight_cfg.he_caps_weightage + |
| 13320 | score_config->weight_cfg.chan_width_weightage + |
| 13321 | score_config->weight_cfg.chan_band_weightage + |
| 13322 | score_config->weight_cfg.nss_weightage + |
| 13323 | score_config->weight_cfg.beamforming_cap_weightage + |
| 13324 | score_config->weight_cfg.pcl_weightage + |
| 13325 | score_config->weight_cfg.channel_congestion_weightage + |
| 13326 | score_config->weight_cfg.oce_wan_weightage; |
| 13327 | |
| 13328 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 13329 | hdd_err("total weight is greater than %d fallback to default values", |
| 13330 | BEST_CANDIDATE_MAX_WEIGHT); |
| 13331 | |
| 13332 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 13333 | score_config->weight_cfg.ht_caps_weightage = |
| 13334 | HT_CAPABILITY_WEIGHTAGE; |
| 13335 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 13336 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 13337 | score_config->weight_cfg.chan_width_weightage = |
| 13338 | CHAN_WIDTH_WEIGHTAGE; |
| 13339 | score_config->weight_cfg.chan_band_weightage = |
| 13340 | CHAN_BAND_WEIGHTAGE; |
| 13341 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 13342 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13343 | BEAMFORMING_CAP_WEIGHTAGE; |
| 13344 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 13345 | score_config->weight_cfg.channel_congestion_weightage = |
| 13346 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 13347 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 13348 | } |
| 13349 | |
| 13350 | score_config->bandwidth_weight_per_index = |
| 13351 | hdd_limit_max_per_index_score( |
| 13352 | cfg->bandwidth_weight_per_index); |
| 13353 | score_config->nss_weight_per_index = |
| 13354 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 13355 | score_config->band_weight_per_index = |
| 13356 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 13357 | |
| 13358 | score_config->rssi_score.best_rssi_threshold = |
| 13359 | cfg->best_rssi_threshold; |
| 13360 | score_config->rssi_score.good_rssi_threshold = |
| 13361 | cfg->good_rssi_threshold; |
| 13362 | score_config->rssi_score.bad_rssi_threshold = |
| 13363 | cfg->bad_rssi_threshold; |
| 13364 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 13365 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 13366 | score_config->rssi_score.good_rssi_bucket_size = |
| 13367 | cfg->good_rssi_bucket_size; |
| 13368 | score_config->rssi_score.bad_rssi_bucket_size = |
| 13369 | cfg->bad_rssi_bucket_size; |
| 13370 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 13371 | cfg->rssi_pref_5g_rssi_thresh; |
| 13372 | |
| 13373 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 13374 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 13375 | hdd_limit_max_per_index_score( |
| 13376 | cfg->esp_qbss_score_slots3_to_0); |
| 13377 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13378 | hdd_limit_max_per_index_score( |
| 13379 | cfg->esp_qbss_score_slots7_to_4); |
| 13380 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13381 | hdd_limit_max_per_index_score( |
| 13382 | cfg->esp_qbss_score_slots11_to_8); |
| 13383 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13384 | hdd_limit_max_per_index_score( |
| 13385 | cfg->esp_qbss_score_slots15_to_12); |
| 13386 | |
| 13387 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13388 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13389 | hdd_limit_max_per_index_score( |
| 13390 | cfg->oce_wan_score_slots3_to_0); |
| 13391 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13392 | hdd_limit_max_per_index_score( |
| 13393 | cfg->oce_wan_score_slots7_to_4); |
| 13394 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13395 | hdd_limit_max_per_index_score( |
| 13396 | cfg->oce_wan_score_slots11_to_8); |
| 13397 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13398 | hdd_limit_max_per_index_score( |
| 13399 | cfg->oce_wan_score_slots15_to_12); |
| 13400 | |
| 13401 | |
| 13402 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13403 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13404 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13405 | |
| 13406 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13407 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13408 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13409 | score_config->he_cap = 1; |
| 13410 | |
| 13411 | if (score_config->he_cap || |
| 13412 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13413 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13414 | score_config->vht_cap = 1; |
| 13415 | |
| 13416 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13417 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13418 | score_config->ht_cap = 1; |
| 13419 | |
| 13420 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13421 | score_config->vht_24G_cap = 1; |
| 13422 | |
| 13423 | if (cfg->enableTxBF) |
| 13424 | score_config->beamformee_cap = 1; |
| 13425 | |
| 13426 | } |
| 13427 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13428 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13429 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13430 | * @hdd_ctx: HDD context |
| 13431 | * |
| 13432 | * Return: 0 if success else err |
| 13433 | */ |
| 13434 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13435 | { |
| 13436 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13437 | struct hdd_config *cfg = hdd_ctx->config; |
| 13438 | struct dfs_user_config dfs_cfg; |
| 13439 | QDF_STATUS status; |
| 13440 | |
| 13441 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13442 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13443 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13444 | hdd_err("failed dfs psoc configuration"); |
| 13445 | return -EINVAL; |
| 13446 | } |
| 13447 | |
| 13448 | return 0; |
| 13449 | } |
| 13450 | |
| 13451 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13452 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13453 | * @hdd_ctx: HDD context |
| 13454 | * |
| 13455 | * Return: 0 if success else err |
| 13456 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13457 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13458 | { |
| 13459 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13460 | struct scan_user_cfg scan_cfg; |
| 13461 | struct hdd_config *cfg = hdd_ctx->config; |
| 13462 | QDF_STATUS status; |
| 13463 | |
| 13464 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13465 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13466 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13467 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13468 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13469 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13470 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13471 | /* convert to ms */ |
| 13472 | scan_cfg.scan_cache_aging_time = |
| 13473 | cfg->scanAgingTimeout * 1000; |
| 13474 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13475 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13476 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13477 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13478 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13479 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13480 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13481 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13482 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13483 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13484 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13485 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13486 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13487 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13488 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13489 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13490 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13491 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13492 | if (status != QDF_STATUS_SUCCESS) { |
| 13493 | hdd_err("failed pmo psoc configuration"); |
| 13494 | return -EINVAL; |
| 13495 | } |
| 13496 | |
| 13497 | return 0; |
| 13498 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13499 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13500 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13501 | { |
| 13502 | int ret; |
| 13503 | |
| 13504 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13505 | if (ret) |
| 13506 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13507 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13508 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13509 | if (ret) |
| 13510 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13511 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13512 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13513 | if (ret) |
| 13514 | return ret; |
| 13515 | |
| 13516 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13517 | if (ret) |
| 13518 | return ret; |
| 13519 | |
| 13520 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13521 | |
| 13522 | return ret; |
| 13523 | } |
| 13524 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13525 | /** |
| 13526 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13527 | * @mode : cfg80211 DFS mode |
| 13528 | * |
| 13529 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13530 | */ |
| 13531 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13532 | { |
| 13533 | switch (mode) { |
| 13534 | case DFS_MODE_ENABLE: |
| 13535 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13536 | case DFS_MODE_DISABLE: |
| 13537 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13538 | case DFS_MODE_DEPRIORITIZE: |
| 13539 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13540 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13541 | hdd_debug("ACS dfs mode is NONE"); |
| 13542 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13543 | } |
| 13544 | } |
| 13545 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13546 | /** |
| 13547 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13548 | * @hddctx: pointer to hdd context |
| 13549 | * @set_value: enable/disable |
| 13550 | * |
| 13551 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13552 | * Host(even though it is duplicate). When Host send vendor command |
| 13553 | * disable,FW doesn't perform any action. Whenever any change in |
| 13554 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13555 | * |
| 13556 | * return - 0 on success, appropriate error values on failure. |
| 13557 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13558 | int hdd_enable_disable_ca_event(struct hdd_context *hdd_ctx, uint8_t set_value) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13559 | { |
| 13560 | QDF_STATUS status; |
| 13561 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13562 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13563 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13564 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13565 | if (!hdd_ctx->config->goptimize_chan_avoid_event) { |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13566 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13567 | return -EINVAL; |
| 13568 | } |
| 13569 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13570 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 13571 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13572 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13573 | hdd_err("Failed to send chan avoid command to SME"); |
| 13574 | return -EINVAL; |
| 13575 | } |
| 13576 | return 0; |
| 13577 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13578 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13579 | /** |
| 13580 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13581 | * @value: value to set |
| 13582 | * |
| 13583 | * This function will set the passed value to roaming in progress flag. |
| 13584 | * |
| 13585 | * Return: None |
| 13586 | */ |
| 13587 | void hdd_set_roaming_in_progress(bool value) |
| 13588 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13589 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13590 | |
| 13591 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13592 | if (!hdd_ctx) { |
| 13593 | hdd_err("HDD context is NULL"); |
| 13594 | return; |
| 13595 | } |
| 13596 | |
| 13597 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13598 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13599 | } |
| 13600 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13601 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13602 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13603 | if (!hdd_ctx) { |
| 13604 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13605 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13606 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13607 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13608 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 13609 | |
| 13610 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13611 | } |
| 13612 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13613 | /** |
| 13614 | * hdd_is_connection_in_progress() - check if connection is in |
| 13615 | * progress |
| 13616 | * @session_id: session id |
| 13617 | * @reason: scan reject reason |
| 13618 | * |
| 13619 | * Go through each adapter and check if Connection is in progress |
| 13620 | * |
| 13621 | * Return: true if connection is in progress else false |
| 13622 | */ |
| 13623 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13624 | enum scan_reject_states *reason) |
| 13625 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13626 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13627 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13628 | uint8_t sta_id = 0; |
| 13629 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13630 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13631 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13632 | |
| 13633 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13634 | if (!hdd_ctx) { |
| 13635 | hdd_err("HDD context is NULL"); |
| 13636 | return false; |
| 13637 | } |
| 13638 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13639 | mac_handle = hdd_ctx->mac_handle; |
| 13640 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13641 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 13642 | hdd_debug("Adapter with device mode %s(%d) exists", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13643 | hdd_device_mode_to_string(adapter->device_mode), |
| 13644 | adapter->device_mode); |
| 13645 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13646 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13647 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13648 | && (eConnectionState_Connecting == |
| 13649 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13650 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13651 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13652 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13653 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13654 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13655 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13656 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13657 | } |
| 13658 | return true; |
| 13659 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13660 | /* |
| 13661 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13662 | * hdd_is_roaming_in_progress is for LFR3 |
| 13663 | */ |
| 13664 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13665 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13666 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13667 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13668 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13669 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13670 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13671 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13672 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13673 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13674 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13675 | } |
| 13676 | return true; |
| 13677 | } |
| 13678 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13679 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13680 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13681 | hdd_sta_ctx = |
| 13682 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13683 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13684 | hdd_sta_ctx->conn_info.connState) |
| 13685 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13686 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13687 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13688 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13689 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13690 | " is in middle of WPS/EAPOL exchange.", |
| 13691 | MAC_ADDR_ARRAY(sta_mac)); |
| 13692 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13693 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13694 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13695 | } |
| 13696 | return true; |
| 13697 | } |
| 13698 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13699 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13700 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13701 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13702 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13703 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13704 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13705 | continue; |
| 13706 | |
| 13707 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13708 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13709 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13710 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13711 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13712 | MAC_ADDR_ARRAY(sta_mac)); |
| 13713 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13714 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13715 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13716 | } |
| 13717 | return true; |
| 13718 | } |
| 13719 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13720 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13721 | return true; |
| 13722 | } |
| 13723 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13724 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13725 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13726 | return false; |
| 13727 | } |
| 13728 | |
| 13729 | /** |
| 13730 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13731 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13732 | * |
| 13733 | * Return: None |
| 13734 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13735 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13736 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13737 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13738 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13739 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13740 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 13741 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13742 | void *sap_ctx; |
| 13743 | |
| 13744 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13745 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13746 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13747 | |
| 13748 | mutex_lock(&hdd_ctx->sap_lock); |
| 13749 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13750 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13751 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13752 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13753 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13754 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13755 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13756 | qdf_stop_bss_event, |
| 13757 | SME_CMD_TIMEOUT_VALUE); |
| 13758 | |
| 13759 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13760 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13761 | goto end; |
| 13762 | } |
| 13763 | } |
| 13764 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13765 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13766 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13767 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13768 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13769 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13770 | |
| 13771 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13772 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13773 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13774 | eUPDATE_IE_ALL); |
| 13775 | goto end; |
| 13776 | } |
| 13777 | |
| 13778 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13779 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13780 | sap_config, |
| 13781 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13782 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13783 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13784 | eUPDATE_IE_ALL); |
| 13785 | goto end; |
| 13786 | } |
| 13787 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13788 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13789 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13790 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13791 | SME_CMD_TIMEOUT_VALUE); |
| 13792 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13793 | eUPDATE_IE_ALL); |
| 13794 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13795 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13796 | goto end; |
| 13797 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13798 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13799 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13800 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13801 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13802 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13803 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13804 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13805 | ap_adapter->device_mode, |
| 13806 | true); |
| 13807 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13808 | } |
| 13809 | end: |
| 13810 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13811 | } |
| 13812 | |
| 13813 | /** |
| 13814 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13815 | * with non dfs acs |
| 13816 | * |
| 13817 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13818 | * |
| 13819 | * Return: None |
| 13820 | */ |
| 13821 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13822 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13823 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13824 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 13825 | struct cds_context *cds_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13826 | |
| 13827 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13828 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13829 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13830 | return; |
| 13831 | } |
| 13832 | |
| 13833 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13834 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13835 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13836 | return; |
| 13837 | } |
| 13838 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13839 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13840 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13841 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13842 | return; |
| 13843 | } |
| 13844 | |
| 13845 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13846 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13847 | &ap_adapter->event_flags) && |
| 13848 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13849 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13850 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13851 | 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] | 13852 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13853 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13854 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13855 | acs_cfg.acs_mode = true; |
| 13856 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13857 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13858 | } |
| 13859 | } |
| 13860 | |
| 13861 | /** |
| 13862 | * hdd_set_connection_in_progress() - to set the connection in |
| 13863 | * progress flag |
| 13864 | * @value: value to set |
| 13865 | * |
| 13866 | * This function will set the passed value to connection in progress flag. |
| 13867 | * If value is previously being set to true then no need to set it again. |
| 13868 | * |
| 13869 | * Return: true if value is being set correctly and false otherwise. |
| 13870 | */ |
| 13871 | bool hdd_set_connection_in_progress(bool value) |
| 13872 | { |
| 13873 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13874 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13875 | |
| 13876 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13877 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13878 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13879 | return false; |
| 13880 | } |
| 13881 | |
| 13882 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13883 | /* |
| 13884 | * if the value is set to true previously and if someone is |
| 13885 | * trying to make it true again then it could be some race |
| 13886 | * condition being triggered. Avoid this situation by returning |
| 13887 | * false |
| 13888 | */ |
| 13889 | if (hdd_ctx->connection_in_progress && value) |
| 13890 | status = false; |
| 13891 | else |
| 13892 | hdd_ctx->connection_in_progress = value; |
| 13893 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13894 | return status; |
| 13895 | } |
| 13896 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13897 | 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] | 13898 | { |
| 13899 | if (!adapter) { |
| 13900 | hdd_err("Invalid adapter"); |
| 13901 | return -EINVAL; |
| 13902 | } |
| 13903 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13904 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13905 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13906 | set_value, VDEV_CMD); |
| 13907 | return 0; |
| 13908 | |
| 13909 | } |
| 13910 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13911 | 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] | 13912 | { |
| 13913 | if (!adapter) { |
| 13914 | hdd_err("Invalid adapter"); |
| 13915 | return -EINVAL; |
| 13916 | } |
| 13917 | |
| 13918 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13919 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13920 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13921 | set_value, VDEV_CMD); |
| 13922 | return 0; |
| 13923 | } |
| 13924 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13925 | 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] | 13926 | *psoc, uint8_t vdev_id) |
| 13927 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13928 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13929 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13930 | |
| 13931 | /* |
| 13932 | * Currently PSOC is not being used. But this logic will |
| 13933 | * change once we have the converged implementation of |
| 13934 | * HDD context per PSOC in place. This would break if |
| 13935 | * multiple vdev objects reuse the vdev id. |
| 13936 | */ |
| 13937 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13938 | if (!adapter) |
| 13939 | hdd_err("Get adapter by vdev id failed"); |
| 13940 | |
| 13941 | return adapter; |
| 13942 | } |
| 13943 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13944 | 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] | 13945 | int8_t *rssi, int8_t *snr) |
| 13946 | { |
| 13947 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13948 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13949 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13950 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13951 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13952 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 13953 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13954 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13955 | if (QDF_STATUS_SUCCESS != status) { |
| 13956 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13957 | return -EINVAL; |
| 13958 | } |
| 13959 | |
| 13960 | return 0; |
| 13961 | } |
| 13962 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13963 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13964 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13965 | * @adapter - HDD adapter |
| 13966 | * @tos - type of service |
| 13967 | * @status - status of the traffic |
| 13968 | * |
| 13969 | * Return: 0 on success and non zero value on failure |
| 13970 | */ |
| 13971 | |
| 13972 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13973 | bool is_tos_active) |
| 13974 | { |
| 13975 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13976 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13977 | uint32_t max_off_chan_time = 0; |
| 13978 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13979 | int ret; |
| 13980 | |
| 13981 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 13982 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 13983 | |
| 13984 | if (ret < 0) { |
| 13985 | hdd_err("failed to set limit off chan params"); |
| 13986 | return ret; |
| 13987 | } |
| 13988 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13989 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 13990 | |
| 13991 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13992 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13993 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13994 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13995 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 13996 | if (adapter->active_ac) { |
| 13997 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 13998 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13999 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 14000 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14001 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 14002 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14003 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14004 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 14005 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14006 | PM_LATENCY); |
| 14007 | } else { |
| 14008 | /*ignore this command if only BE/BK is active */ |
| 14009 | is_tos_active = false; |
| 14010 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14011 | hdd_ctx->config->conc_system_pref); |
| 14012 | } |
| 14013 | } else { |
| 14014 | /* No active tos */ |
| 14015 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14016 | hdd_ctx->config->conc_system_pref); |
| 14017 | } |
| 14018 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14019 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14020 | adapter->session_id, |
| 14021 | is_tos_active, |
| 14022 | max_off_chan_time, |
| 14023 | hdd_ctx->config->nRestTimeConc, |
| 14024 | true); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14025 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14026 | hdd_err("failed to set limit off chan params"); |
| 14027 | ret = -EINVAL; |
| 14028 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14029 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14030 | return ret; |
| 14031 | } |
| 14032 | |
| 14033 | /** |
| 14034 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14035 | * @adapter - HDD adapter |
| 14036 | * |
| 14037 | * Return: 0 on success and non zero value on failure |
| 14038 | */ |
| 14039 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14040 | { |
| 14041 | struct hdd_context *hdd_ctx; |
| 14042 | int ret; |
| 14043 | QDF_STATUS status; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14044 | |
| 14045 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14046 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14047 | if (ret < 0) |
| 14048 | return ret; |
| 14049 | |
| 14050 | /* set the system preferece to default */ |
| 14051 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14052 | hdd_ctx->config->conc_system_pref); |
| 14053 | |
| 14054 | /* clear the bitmap */ |
| 14055 | adapter->active_ac = 0; |
| 14056 | |
| 14057 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14058 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14059 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14060 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14061 | adapter->session_id, |
| 14062 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14063 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14064 | hdd_err("failed to reset limit off chan params"); |
| 14065 | ret = -EINVAL; |
| 14066 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14067 | |
| 14068 | return ret; |
| 14069 | } |
| 14070 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14071 | /** |
| 14072 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14073 | * @drv_op: Enum indicating driver op |
| 14074 | * |
| 14075 | * Return: none |
| 14076 | */ |
| 14077 | void hdd_start_driver_ops_timer(int drv_op) |
| 14078 | { |
| 14079 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14080 | switch (drv_op) { |
| 14081 | case eHDD_DRV_OP_PROBE: |
| 14082 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14083 | break; |
| 14084 | case eHDD_DRV_OP_REMOVE: |
| 14085 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 14086 | break; |
| 14087 | case eHDD_DRV_OP_SHUTDOWN: |
| 14088 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 14089 | break; |
| 14090 | case eHDD_DRV_OP_REINIT: |
| 14091 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 14092 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 14093 | case eHDD_DRV_OP_IFF_UP: |
| 14094 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 14095 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14096 | } |
| 14097 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14098 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14099 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 14100 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14101 | } |
| 14102 | |
| 14103 | /** |
| 14104 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 14105 | * |
| 14106 | * Return: none |
| 14107 | */ |
| 14108 | void hdd_stop_driver_ops_timer(void) |
| 14109 | { |
| 14110 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 14111 | } |
| 14112 | |
| 14113 | /** |
| 14114 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 14115 | * inactivity timer |
| 14116 | * |
| 14117 | * Return: None |
| 14118 | */ |
| 14119 | void hdd_drv_ops_inactivity_handler(void) |
| 14120 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 14121 | hdd_err("WLAN_BUG_RCA %s: %d Sec timer expired while in .%s", |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14122 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 14123 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14124 | if (hdd_drv_ops_task) { |
| 14125 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 14126 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 14127 | } else { |
| 14128 | hdd_err("hdd_drv_ops_task is null"); |
| 14129 | } |
| 14130 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14131 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 14132 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 14133 | sizeof("shutdown"))) |
| 14134 | QDF_BUG(0); |
| 14135 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 14136 | if (cds_is_fw_down()) { |
| 14137 | hdd_err("FW is down"); |
| 14138 | return; |
| 14139 | } |
| 14140 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14141 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 14142 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14143 | else |
| 14144 | QDF_BUG(0); |
| 14145 | } |
| 14146 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14147 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 14148 | { |
| 14149 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14150 | |
| 14151 | if (!hdd_ctx) |
| 14152 | return; |
| 14153 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 14154 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14155 | } |
| 14156 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14157 | /** |
| 14158 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 14159 | * @struct hdd_context *hdd_ctx |
| 14160 | * @struct hdd_adapter *padapter |
| 14161 | * @bool enble |
| 14162 | * |
| 14163 | * Return: none |
| 14164 | */ |
| 14165 | void hdd_set_rx_mode_rps(bool enable) |
| 14166 | { |
| 14167 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14168 | struct hdd_context *hdd_ctx; |
| 14169 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14170 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14171 | if (!cds_cfg) |
| 14172 | return; |
| 14173 | |
| 14174 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14175 | if (!hdd_ctx) |
| 14176 | return; |
| 14177 | |
| 14178 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 14179 | if (!adapter) |
| 14180 | return; |
| 14181 | |
| 14182 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14183 | if (enable && !cds_cfg->rps_enabled) |
| 14184 | hdd_send_rps_ind(adapter); |
| 14185 | else if (!enable && cds_cfg->rps_enabled) |
| 14186 | hdd_send_rps_disable_ind(adapter); |
| 14187 | } |
| 14188 | } |
| 14189 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 14190 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 14191 | { |
| 14192 | struct hdd_adapter *adapter = NULL; |
| 14193 | |
| 14194 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 14195 | if ((adapter->device_mode == QDF_STA_MODE || |
| 14196 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 14197 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 14198 | &adapter->event_flags)){ |
| 14199 | return true; |
| 14200 | } |
| 14201 | } |
| 14202 | |
| 14203 | return false; |
| 14204 | } |
| 14205 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14206 | /* Register the module init/exit functions */ |
| 14207 | module_init(hdd_module_init); |
| 14208 | module_exit(hdd_module_exit); |
| 14209 | |
| 14210 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14211 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14212 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14213 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14214 | static const struct kernel_param_ops con_mode_ops = { |
| 14215 | .set = con_mode_handler, |
| 14216 | .get = param_get_int, |
| 14217 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14218 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14219 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14220 | .set = con_mode_handler_ftm, |
| 14221 | .get = param_get_int, |
| 14222 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14223 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14224 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14225 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14226 | .set = con_mode_handler_monitor, |
| 14227 | .get = param_get_int, |
| 14228 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14229 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14230 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14231 | static const struct kernel_param_ops fwpath_ops = { |
| 14232 | .set = fwpath_changed_handler, |
| 14233 | .get = param_get_string, |
| 14234 | }; |
| 14235 | |
| 14236 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14237 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14238 | |
| 14239 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 14240 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14241 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14242 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14243 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 14244 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14245 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14246 | |
| 14247 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 14248 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14249 | |
| 14250 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14251 | |
| 14252 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14253 | |
| 14254 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |