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> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame^] | 40 | #include <wlan_roam_debug.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 41 | #include <wlan_hdd_wowl.h> |
| 42 | #include <wlan_hdd_misc.h> |
| 43 | #include <wlan_hdd_wext.h> |
| 44 | #include "wlan_hdd_trace.h" |
| 45 | #include "wlan_hdd_ioctl.h" |
| 46 | #include "wlan_hdd_ftm.h" |
| 47 | #include "wlan_hdd_power.h" |
| 48 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 49 | #include "wlan_hdd_scan.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 50 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 51 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 52 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 53 | #endif |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 54 | #include "qdf_str.h" |
| 55 | #include "qdf_trace.h" |
| 56 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 57 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 58 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 59 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 60 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 61 | |
| 62 | #include <net/addrconf.h> |
| 63 | #include <linux/wireless.h> |
| 64 | #include <net/cfg80211.h> |
| 65 | #include <linux/inetdevice.h> |
| 66 | #include <net/addrconf.h> |
| 67 | #include "wlan_hdd_cfg80211.h" |
| 68 | #include "wlan_hdd_ext_scan.h" |
| 69 | #include "wlan_hdd_p2p.h" |
| 70 | #include <linux/rtnetlink.h> |
| 71 | #include "sap_api.h" |
| 72 | #include <linux/semaphore.h> |
| 73 | #include <linux/ctype.h> |
| 74 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 75 | #include <linux/reboot.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 76 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 77 | #include <soc/qcom/subsystem_restart.h> |
| 78 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 79 | #include <wlan_hdd_hostapd.h> |
| 80 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 81 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 82 | #include "cfg_api.h" |
| 83 | #include "qwlan_version.h" |
| 84 | #include "wma_types.h" |
| 85 | #include "wlan_hdd_tdls.h" |
| 86 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 87 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 89 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 90 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 91 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 92 | #include "wlan_hdd_nan.h" |
| 93 | #include "wlan_hdd_debugfs.h" |
| 94 | #include "wlan_hdd_driver_ops.h" |
| 95 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 96 | #include "wlan_hdd_data_stall_detection.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 97 | |
| 98 | #include <wlan_hdd_ipa.h> |
| 99 | #include "hif.h" |
| 100 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 101 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 102 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 103 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 104 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 105 | #include "wlan_hdd_lpass.h" |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 106 | #include "nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 107 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 108 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 109 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 110 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 111 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 112 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 113 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 114 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 115 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 116 | #include "os_if_wifi_pos.h" |
| 117 | #include "wifi_pos_api.h" |
| 118 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 119 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 120 | #include "os_if_nan.h" |
| 121 | #include "nan_public_structs.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 122 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 123 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 124 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 125 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 126 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 127 | #include <cdp_txrx_cmn_struct.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 128 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 129 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 130 | #include "wlan_disa_obj_mgmt_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 131 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 132 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 133 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 134 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 135 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 136 | #include "qc_sap_ioctl.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 137 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 138 | #ifdef CNSS_GENL |
| 139 | #include <net/cnss_nl.h> |
| 140 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 141 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 142 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 143 | #include <wlan_hdd_spectralscan.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 144 | #ifdef MODULE |
| 145 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 146 | #else |
| 147 | #define WLAN_MODULE_NAME "wlan" |
| 148 | #endif |
| 149 | |
| 150 | #ifdef TIMER_MANAGER |
| 151 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 152 | #else |
| 153 | #define TIMER_MANAGER_STR "" |
| 154 | #endif |
| 155 | |
| 156 | #ifdef MEMORY_DEBUG |
| 157 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 158 | #else |
| 159 | #define MEMORY_DEBUG_STR "" |
| 160 | #endif |
| 161 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 162 | #ifdef PANIC_ON_BUG |
| 163 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 164 | #else |
| 165 | #define PANIC_ON_BUG_STR "" |
| 166 | #endif |
| 167 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 168 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 169 | int wlan_start_ret_val; |
| 170 | static DECLARE_COMPLETION(wlan_start_comp); |
| 171 | static unsigned int dev_num = 1; |
| 172 | static struct cdev wlan_hdd_state_cdev; |
| 173 | static struct class *class; |
| 174 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 175 | #ifndef MODULE |
| 176 | static struct gwlan_loader *wlan_loader; |
| 177 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 178 | struct kobj_attribute *attr, |
| 179 | const char *buf, size_t count); |
| 180 | struct gwlan_loader { |
| 181 | bool loaded_state; |
| 182 | struct kobject *boot_wlan_obj; |
| 183 | struct attribute_group *attr_group; |
| 184 | }; |
| 185 | |
| 186 | static struct kobj_attribute wlan_boot_attribute = |
| 187 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 188 | |
| 189 | static struct attribute *attrs[] = { |
| 190 | &wlan_boot_attribute.attr, |
| 191 | NULL, |
| 192 | }; |
| 193 | |
| 194 | #define MODULE_INITIALIZED 1 |
| 195 | #endif |
| 196 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 197 | #define HDD_OPS_INACTIVITY_TIMEOUT (120000) |
| 198 | #define MAX_OPS_NAME_STRING_SIZE 20 |
Rajeev Kumar | 6d0b2ea | 2017-12-26 17:55:33 -0800 | [diff] [blame] | 199 | #define RATE_LIMIT_ERROR_LOG (256) |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 200 | |
| 201 | static qdf_timer_t hdd_drv_ops_inactivity_timer; |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 202 | static struct task_struct *hdd_drv_ops_task; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 203 | static char drv_ops_string[MAX_OPS_NAME_STRING_SIZE]; |
| 204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 205 | /* the Android framework expects this param even though we don't use it */ |
| 206 | #define BUF_LEN 20 |
| 207 | static char fwpath_buffer[BUF_LEN]; |
| 208 | static struct kparam_string fwpath = { |
| 209 | .string = fwpath_buffer, |
| 210 | .maxlen = BUF_LEN, |
| 211 | }; |
| 212 | |
| 213 | static char *country_code; |
| 214 | static int enable_11d = -1; |
| 215 | static int enable_dfs_chan_scan = -1; |
| 216 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 217 | /* |
| 218 | * spinlock for synchronizing asynchronous request/response |
| 219 | * (full description of use in wlan_hdd_main.h) |
| 220 | */ |
| 221 | DEFINE_SPINLOCK(hdd_context_lock); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 222 | DEFINE_MUTEX(hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 223 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 224 | #define WLAN_NLINK_CESIUM 30 |
| 225 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 226 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 227 | |
| 228 | #define WOW_MAX_FILTER_LISTS 1 |
| 229 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 230 | #define WOW_MIN_PATTERN_SIZE 6 |
| 231 | #define WOW_MAX_PATTERN_SIZE 64 |
| 232 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 233 | /* max peer can be tdls peers + self peer + bss peer */ |
| 234 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
| 235 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 236 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 237 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 238 | .flags = WIPHY_WOWLAN_ANY | |
| 239 | WIPHY_WOWLAN_MAGIC_PKT | |
| 240 | WIPHY_WOWLAN_DISCONNECT | |
| 241 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 242 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 243 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 244 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 245 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 246 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 247 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 248 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 249 | }; |
| 250 | #endif |
| 251 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 252 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 253 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 254 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 255 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 256 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 257 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 258 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 259 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 260 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 261 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 262 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 263 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 264 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 265 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 266 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 267 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 268 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 269 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 270 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 271 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 272 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 273 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 274 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 286 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 287 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 288 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 289 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 290 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 291 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 292 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 293 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 294 | }; |
| 295 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 296 | int limit_off_chan_tbl[HDD_MAX_AC][HDD_MAX_OFF_CHAN_ENTRIES] = { |
| 297 | { HDD_AC_BK_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BK }, |
| 298 | { HDD_AC_BE_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_BE }, |
| 299 | { HDD_AC_VI_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VI }, |
| 300 | { HDD_AC_VO_BIT, HDD_MAX_OFF_CHAN_TIME_FOR_VO }, |
| 301 | }; |
| 302 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 303 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 304 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 305 | |
| 306 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 307 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 308 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 309 | #endif |
| 310 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 311 | void hdd_start_complete(int ret) |
| 312 | { |
| 313 | wlan_start_ret_val = ret; |
| 314 | |
| 315 | complete(&wlan_start_comp); |
| 316 | } |
| 317 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 318 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 319 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 320 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 321 | * |
| 322 | * Return: none |
| 323 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 324 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 325 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 326 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 327 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 328 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 329 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 330 | } |
| 331 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 332 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 333 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 334 | enum netif_action_type action) |
| 335 | { |
| 336 | if (!adapter->tx_flow_timer_initialized) |
| 337 | return; |
| 338 | |
| 339 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 340 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 341 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 342 | QDF_STATUS status = |
| 343 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 344 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 345 | |
| 346 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 347 | hdd_err("Failed to start tx_flow_control_timer"); |
| 348 | else |
| 349 | adapter-> |
| 350 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 351 | |
| 352 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 353 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 354 | } |
| 355 | } |
| 356 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 357 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 358 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 359 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 360 | * @vdev_id: vdev_id |
| 361 | * @action: action type |
| 362 | * @reason: reason type |
| 363 | * |
| 364 | * Return: none |
| 365 | */ |
| 366 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 367 | enum netif_action_type action, enum netif_reason_type reason) |
| 368 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 369 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 370 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 371 | |
| 372 | if (!hdd_ctx) { |
| 373 | hdd_err("hdd ctx is NULL"); |
| 374 | return; |
| 375 | } |
| 376 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 377 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 378 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 382 | * Store WLAN driver version and timestamp info in global variables such that |
| 383 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 384 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 385 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 386 | #ifdef BUILD_TAG |
| 387 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR "; " BUILD_TAG; |
| 388 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 389 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 390 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 391 | |
| 392 | /** |
| 393 | * hdd_device_mode_to_string() - return string conversion of device mode |
| 394 | * @device_mode: device mode |
| 395 | * |
| 396 | * This utility function helps log string conversion of device mode. |
| 397 | * |
| 398 | * Return: string conversion of device mode, if match found; |
| 399 | * "Unknown" otherwise. |
| 400 | */ |
| 401 | const char *hdd_device_mode_to_string(uint8_t device_mode) |
| 402 | { |
| 403 | switch (device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 404 | CASE_RETURN_STRING(QDF_STA_MODE); |
| 405 | CASE_RETURN_STRING(QDF_SAP_MODE); |
| 406 | CASE_RETURN_STRING(QDF_P2P_CLIENT_MODE); |
| 407 | CASE_RETURN_STRING(QDF_P2P_GO_MODE); |
| 408 | CASE_RETURN_STRING(QDF_FTM_MODE); |
| 409 | CASE_RETURN_STRING(QDF_IBSS_MODE); |
| 410 | CASE_RETURN_STRING(QDF_P2P_DEVICE_MODE); |
| 411 | CASE_RETURN_STRING(QDF_OCB_MODE); |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 412 | CASE_RETURN_STRING(QDF_NDI_MODE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 413 | default: |
| 414 | return "Unknown"; |
| 415 | } |
| 416 | } |
| 417 | |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 418 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 419 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 420 | * @hdd_ctx: HDD context |
| 421 | * @chan_list: buf hold returned chan list |
| 422 | * @chan_num: input buf size and output returned chan num |
| 423 | * |
| 424 | * This function helps get current available chan list from regulatory |
| 425 | * module. It excludes the "disabled" and "invalid" channels. |
| 426 | * |
| 427 | * Return: 0 for success. |
| 428 | */ |
| 429 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 430 | uint8_t *chan_list, |
| 431 | uint32_t *chan_num) |
| 432 | { |
| 433 | int i = 0, j = 0; |
| 434 | struct regulatory_channel *cur_chan_list; |
| 435 | struct wlan_objmgr_pdev *pdev; |
| 436 | |
| 437 | if (!hdd_ctx || !hdd_ctx->hdd_pdev || !chan_list || !chan_num) |
| 438 | return -EINVAL; |
| 439 | |
| 440 | pdev = hdd_ctx->hdd_pdev; |
| 441 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 442 | sizeof(struct regulatory_channel)); |
| 443 | if (!cur_chan_list) |
| 444 | return -ENOMEM; |
| 445 | |
| 446 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 447 | QDF_STATUS_SUCCESS) { |
| 448 | qdf_mem_free(cur_chan_list); |
| 449 | return -EINVAL; |
| 450 | } |
| 451 | |
| 452 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 453 | uint32_t ch = cur_chan_list[i].chan_num; |
| 454 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 455 | ch); |
| 456 | |
| 457 | if (state != CHANNEL_STATE_DISABLE && |
| 458 | state != CHANNEL_STATE_INVALID && |
| 459 | j < *chan_num) { |
| 460 | chan_list[j] = (uint8_t)ch; |
| 461 | j++; |
| 462 | } |
| 463 | } |
| 464 | *chan_num = j; |
| 465 | qdf_mem_free(cur_chan_list); |
| 466 | return 0; |
| 467 | } |
| 468 | |
| 469 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 470 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 471 | * @adapter: HDD adapter |
| 472 | * @chan_number: Channel number |
| 473 | * @chan_bw: Bandwidth |
| 474 | * |
| 475 | * Checks if the given bandwidth is valid for the given channel number. |
| 476 | * |
| 477 | * Return: 0 for success, non-zero for failure |
| 478 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 479 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 480 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 481 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 482 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 483 | uint8_t chan[NUM_CHANNELS]; |
| 484 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 485 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 486 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 487 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 488 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 489 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 490 | if (!mac_handle) { |
| 491 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 492 | return -EINVAL; |
| 493 | } |
| 494 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 495 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 496 | &len); |
| 497 | if (ret) { |
| 498 | hdd_err("error %d in getting valid channel list", ret); |
| 499 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | for (i = 0; i < len; i++) { |
| 503 | if (chan[i] == chan_number) { |
| 504 | found = true; |
| 505 | break; |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | if (found == false) { |
| 510 | hdd_err("Channel not in driver's valid channel list"); |
| 511 | return -EOPNOTSUPP; |
| 512 | } |
| 513 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 514 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 515 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 516 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 517 | return -EINVAL; |
| 518 | } |
| 519 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 520 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 521 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 522 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 523 | return -EINVAL; |
| 524 | } |
| 525 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 526 | (chan_bw != CH_WIDTH_MAX)) { |
| 527 | hdd_err("Only BW20 possible on channel 14"); |
| 528 | return -EINVAL; |
| 529 | } |
| 530 | } |
| 531 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 532 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 533 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 534 | (chan_bw != CH_WIDTH_MAX)) { |
| 535 | hdd_err("Only BW20 possible on channel 165"); |
| 536 | return -EINVAL; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | return 0; |
| 541 | } |
| 542 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 543 | /** |
| 544 | * hdd_wait_for_recovery_completion() - Wait for cds recovery completion |
| 545 | * |
| 546 | * Block the unloading of the driver (or) interface up until the |
| 547 | * cds recovery is completed |
| 548 | * |
| 549 | * Return: true for recovery completion else false |
| 550 | */ |
| 551 | static bool hdd_wait_for_recovery_completion(void) |
| 552 | { |
| 553 | int retry = 0; |
| 554 | |
| 555 | /* Wait for recovery to complete */ |
| 556 | while (cds_is_driver_recovering()) { |
| 557 | if (retry == HDD_MOD_EXIT_SSR_MAX_RETRIES/2) |
| 558 | hdd_err("Recovery in progress; wait here!!!"); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 559 | |
| 560 | if (g_is_system_reboot_triggered) { |
| 561 | hdd_info("System Reboot happening ignore unload!!"); |
| 562 | return false; |
| 563 | } |
| 564 | |
Arunk Khandavalli | e1b3a38 | 2017-09-26 12:01:26 +0530 | [diff] [blame] | 565 | msleep(1000); |
| 566 | if (retry++ == HDD_MOD_EXIT_SSR_MAX_RETRIES) { |
| 567 | hdd_err("SSR never completed, error"); |
| 568 | /* |
| 569 | * Trigger the bug_on in the internal builds, in the |
| 570 | * customer builds self-recovery will be enabled |
| 571 | * in those cases just return error. |
| 572 | */ |
| 573 | if (cds_is_self_recovery_enabled()) |
| 574 | return false; |
| 575 | QDF_BUG(0); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | hdd_info("Recovery completed successfully!"); |
| 580 | return true; |
| 581 | } |
| 582 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 583 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 584 | static int __hdd_netdev_notifier_call(struct notifier_block *nb, |
| 585 | unsigned long state, void *data) |
| 586 | { |
| 587 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 588 | struct netdev_notifier_info *dev_notif_info = data; |
| 589 | struct net_device *dev = dev_notif_info->dev; |
| 590 | #else |
| 591 | struct net_device *dev = data; |
| 592 | #endif |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 593 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 594 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 595 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 596 | hdd_enter_dev(dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 598 | /* Make sure that this callback corresponds to our device. */ |
| 599 | if ((strncmp(dev->name, "wlan", 4)) && (strncmp(dev->name, "p2p", 3))) |
| 600 | return NOTIFY_DONE; |
| 601 | |
Samuel Ahn | c9c48ca | 2016-09-19 15:46:36 +0530 | [diff] [blame] | 602 | if ((adapter->magic != WLAN_HDD_ADAPTER_MAGIC) || |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 603 | (adapter->dev != dev)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 604 | hdd_err("device adapter is not matching!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 605 | return NOTIFY_DONE; |
| 606 | } |
| 607 | |
| 608 | if (!dev->ieee80211_ptr) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 609 | hdd_err("ieee80211_ptr is NULL!!!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 610 | return NOTIFY_DONE; |
| 611 | } |
| 612 | |
| 613 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 614 | if (NULL == hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 615 | hdd_err("HDD Context Null Pointer"); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 616 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 617 | return NOTIFY_DONE; |
| 618 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 619 | |
| 620 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 621 | hdd_err("%s: Driver module is closed", __func__); |
| 622 | return NOTIFY_DONE; |
| 623 | } |
| 624 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 625 | if (cds_is_driver_recovering() || cds_is_driver_in_bad_state()) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 626 | return NOTIFY_DONE; |
| 627 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 628 | hdd_debug("%s New Net Device State = %lu", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 629 | dev->name, state); |
| 630 | |
| 631 | switch (state) { |
| 632 | case NETDEV_REGISTER: |
| 633 | break; |
| 634 | |
| 635 | case NETDEV_UNREGISTER: |
| 636 | break; |
| 637 | |
| 638 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 639 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 640 | break; |
| 641 | |
| 642 | case NETDEV_DOWN: |
| 643 | break; |
| 644 | |
| 645 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 646 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 647 | complete(&adapter->linkup_event_var); |
| 648 | break; |
| 649 | |
| 650 | case NETDEV_GOING_DOWN: |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 651 | if (ucfg_scan_get_vdev_status(adapter->hdd_vdev) != |
| 652 | SCAN_NOT_IN_PROGRESS) { |
Abhishek Singh | 69ccb51 | 2017-04-25 11:58:16 +0530 | [diff] [blame] | 653 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 654 | adapter->session_id, INVALID_SCAN_ID, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 655 | } |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 656 | cds_flush_work(&adapter->scan_block_work); |
| 657 | /* Need to clean up blocked scan request */ |
| 658 | wlan_hdd_cfg80211_scan_block_cb(&adapter->scan_block_work); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 659 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 660 | /* |
| 661 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 662 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 663 | * flag after which driver does not send the cfg80211_scan_done. |
| 664 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 665 | */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 666 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 667 | break; |
| 668 | |
| 669 | default: |
| 670 | break; |
| 671 | } |
| 672 | |
| 673 | return NOTIFY_DONE; |
| 674 | } |
| 675 | |
| 676 | /** |
| 677 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 678 | * @nb: pointer to notifier block |
| 679 | * @state: state |
| 680 | * @ndev: ndev pointer |
| 681 | * |
| 682 | * Return: 0 on success, error number otherwise. |
| 683 | */ |
| 684 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 685 | unsigned long state, |
| 686 | void *ndev) |
| 687 | { |
| 688 | int ret; |
| 689 | |
| 690 | cds_ssr_protect(__func__); |
| 691 | ret = __hdd_netdev_notifier_call(nb, state, ndev); |
| 692 | cds_ssr_unprotect(__func__); |
| 693 | |
| 694 | return ret; |
| 695 | } |
| 696 | |
| 697 | struct notifier_block hdd_netdev_notifier = { |
| 698 | .notifier_call = hdd_netdev_notifier_call, |
| 699 | }; |
| 700 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 701 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 702 | unsigned long msg_type, void *_unused) |
| 703 | { |
| 704 | switch (msg_type) { |
| 705 | case SYS_DOWN: |
| 706 | case SYS_HALT: |
| 707 | case SYS_POWER_OFF: |
| 708 | g_is_system_reboot_triggered = true; |
| 709 | hdd_info("reboot, reason: %ld", msg_type); |
| 710 | break; |
| 711 | default: |
| 712 | break; |
| 713 | } |
| 714 | |
| 715 | return NOTIFY_OK; |
| 716 | } |
| 717 | |
| 718 | struct notifier_block system_reboot_notifier = { |
| 719 | .notifier_call = system_reboot_notifier_call, |
| 720 | }; |
| 721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 722 | /* variable to hold the insmod parameters */ |
| 723 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 724 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 725 | static int con_mode_ftm; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 726 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 727 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 728 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 729 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 730 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 731 | /** |
| 732 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 733 | * @ch_width: NL channel width |
| 734 | * |
| 735 | * Converts the NL channel width to the driver's internal representation |
| 736 | * |
| 737 | * Return: Converted channel width. In case of non matching NL channel width, |
| 738 | * CH_WIDTH_MAX will be returned. |
| 739 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 740 | 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] | 741 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 742 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 743 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 744 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 745 | switch (ch_width) { |
| 746 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 747 | case NL80211_CHAN_WIDTH_20: |
| 748 | return CH_WIDTH_20MHZ; |
| 749 | case NL80211_CHAN_WIDTH_40: |
| 750 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 751 | case NL80211_CHAN_WIDTH_80: |
| 752 | return CH_WIDTH_80MHZ; |
| 753 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 754 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 755 | return CH_WIDTH_80P80MHZ; |
| 756 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 757 | return CH_WIDTH_160MHZ; |
| 758 | else |
| 759 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 760 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 761 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 762 | return CH_WIDTH_160MHZ; |
| 763 | else |
| 764 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 765 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 766 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 767 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 768 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 769 | default: |
| 770 | hdd_err("Invalid channel width %d, setting to default", |
| 771 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 772 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 773 | } |
| 774 | } |
| 775 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 776 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 777 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 778 | { |
| 779 | uint8_t opclass = 0; |
| 780 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 781 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 782 | return opclass; |
| 783 | } |
| 784 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 785 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 786 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 787 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 788 | * @bitmask: Bitmask of log levels to be enabled |
| 789 | * |
| 790 | * Called immediately after the cfg.ini is read in order to configure |
| 791 | * the desired trace levels. |
| 792 | * |
| 793 | * Return: None |
| 794 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 795 | 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] | 796 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 797 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 798 | int qdf_print_idx = -1; |
| 799 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 800 | /* |
| 801 | * if the bitmask is the default value, then a bitmask was not |
| 802 | * specified in cfg.ini, so leave the logging level alone (it |
| 803 | * will remain at the "compiled in" default value) |
| 804 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 805 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 806 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 807 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 808 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 810 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 811 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 812 | QDF_TRACE_LEVEL_NONE, 0); |
| 813 | |
| 814 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 815 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 816 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 817 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 818 | while (0 != bitmask) { |
| 819 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 820 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 821 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 822 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 823 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 824 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 825 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | level++; |
| 827 | bitmask >>= 1; |
| 828 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 829 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | } |
| 831 | |
| 832 | /** |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 833 | * wlan_hdd_validate_context_in_loading() - check the HDD context in loading |
| 834 | * @hdd_ctx: HDD context pointer |
| 835 | * |
| 836 | * Return: 0 if the context is valid. Error code otherwise |
| 837 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 838 | int wlan_hdd_validate_context_in_loading(struct hdd_context *hdd_ctx) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 839 | { |
| 840 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
| 841 | hdd_info("%pS HDD context is Null", (void *)_RET_IP_); |
| 842 | return -ENODEV; |
| 843 | } |
| 844 | |
| 845 | if (cds_is_driver_recovering()) { |
| 846 | hdd_info("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
| 847 | (void *)_RET_IP_, cds_get_driver_state()); |
| 848 | return -EAGAIN; |
| 849 | } |
| 850 | |
| 851 | if (hdd_ctx->start_modules_in_progress || |
| 852 | hdd_ctx->stop_modules_in_progress) { |
| 853 | hdd_info("%pS Start/Stop Modules in progress. Ignore!!!", |
| 854 | (void *)_RET_IP_); |
| 855 | return -EAGAIN; |
| 856 | } |
| 857 | |
| 858 | return 0; |
| 859 | } |
| 860 | |
| 861 | |
| 862 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 863 | * wlan_hdd_validate_context() - check the HDD context |
| 864 | * @hdd_ctx: HDD context pointer |
| 865 | * |
| 866 | * Return: 0 if the context is valid. Error code otherwise |
| 867 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 868 | int wlan_hdd_validate_context(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 869 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | if (NULL == hdd_ctx || NULL == hdd_ctx->config) { |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 871 | hdd_err("%pS HDD context is Null", (void *)_RET_IP_); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 872 | return -ENODEV; |
| 873 | } |
| 874 | |
Prashanth Bhatta | 9e14305 | 2015-12-04 11:56:47 -0800 | [diff] [blame] | 875 | if (cds_is_driver_recovering()) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 876 | hdd_debug("%pS Recovery in Progress. State: 0x%x Ignore!!!", |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 877 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 878 | return -EAGAIN; |
| 879 | } |
| 880 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 881 | if (cds_is_load_or_unload_in_progress()) { |
| 882 | hdd_debug("%pS Load or unload in progress, state: 0x%x, ignore!", |
| 883 | (void *)_RET_IP_, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 884 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 885 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 886 | |
| 887 | if (hdd_ctx->start_modules_in_progress || |
| 888 | hdd_ctx->stop_modules_in_progress) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 889 | hdd_debug("%pS Start/Stop Modules in progress. Ignore!!!", |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 890 | (void *)_RET_IP_); |
| 891 | return -EAGAIN; |
| 892 | } |
| 893 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 894 | if (cds_is_driver_in_bad_state()) { |
| 895 | hdd_debug("%pS driver in bad State: 0x%x Ignore!!!", |
| 896 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 897 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 898 | } |
| 899 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 900 | if (cds_is_fw_down()) { |
| 901 | hdd_debug("%pS FW is down: 0x%x Ignore!!!", |
| 902 | (void *)_RET_IP_, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 903 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 904 | } |
| 905 | |
Liangwei Dong | 858feb1 | 2018-05-21 01:52:46 -0400 | [diff] [blame] | 906 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 907 | hdd_debug("con_mode_handler is in progress Ignore!!!"); |
| 908 | return -EAGAIN; |
| 909 | } |
| 910 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 911 | return 0; |
| 912 | } |
| 913 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 914 | int hdd_validate_adapter(struct hdd_adapter *adapter) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 915 | { |
| 916 | if (!adapter) { |
| 917 | hdd_err("adapter is null"); |
| 918 | return -EINVAL; |
| 919 | } |
| 920 | |
| 921 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Mahesh Kumar Kalikot Veetil | 4442754 | 2018-06-08 12:29:36 -0700 | [diff] [blame] | 922 | hdd_err("bad adapter magic"); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 923 | return -EINVAL; |
| 924 | } |
| 925 | |
| 926 | if (!adapter->dev) { |
| 927 | hdd_err("adapter net_device is null"); |
| 928 | return -EINVAL; |
| 929 | } |
| 930 | |
| 931 | if (!(adapter->dev->flags & IFF_UP)) { |
| 932 | hdd_info("adapter net_device is not up"); |
| 933 | return -EAGAIN; |
| 934 | } |
| 935 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 936 | if (wlan_hdd_validate_session_id(adapter->session_id)) { |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 937 | hdd_info("adapter session is not open"); |
| 938 | return -EAGAIN; |
| 939 | } |
| 940 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 941 | if (adapter->session_id >= MAX_NUMBER_OF_ADAPTERS) { |
| 942 | hdd_err("bad adapter session Id: %u", adapter->session_id); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 943 | return -EINVAL; |
| 944 | } |
| 945 | |
| 946 | return 0; |
| 947 | } |
| 948 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 949 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 950 | * wlan_hdd_validate_modules_state() - Check modules status |
| 951 | * @hdd_ctx: HDD context pointer |
| 952 | * |
| 953 | * Check's the driver module's state and returns true if the |
| 954 | * modules are enabled returns false if modules are closed. |
| 955 | * |
| 956 | * Return: True if modules are enabled or false. |
| 957 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 958 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 959 | { |
| 960 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 961 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
| 962 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 963 | hdd_info("Modules not enabled, Present status: %d", |
| 964 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 965 | return false; |
| 966 | } |
| 967 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 968 | return true; |
| 969 | } |
| 970 | |
| 971 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | * 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] | 973 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 974 | * |
| 975 | * This function sets the IBSS power save config parameters to WMA |
| 976 | * which will send it to firmware if FW supports IBSS power save |
| 977 | * before vdev start. |
| 978 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 979 | * 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] | 980 | * on failure. |
| 981 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 982 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 983 | { |
| 984 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 985 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | |
| 987 | if (hdd_ctx == NULL) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 988 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 989 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 990 | } |
| 991 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 992 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 993 | WMA_VDEV_IBSS_SET_ATIM_WINDOW_SIZE, |
| 994 | hdd_ctx->config->ibssATIMWinSize, |
| 995 | VDEV_CMD); |
| 996 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 997 | hdd_err("atim window set failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 998 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 999 | } |
| 1000 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1001 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | WMA_VDEV_IBSS_SET_POWER_SAVE_ALLOWED, |
| 1003 | hdd_ctx->config->isIbssPowerSaveAllowed, |
| 1004 | VDEV_CMD); |
| 1005 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1006 | hdd_err("power save allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1007 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1008 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | } |
| 1010 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1011 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1012 | WMA_VDEV_IBSS_SET_POWER_COLLAPSE_ALLOWED, |
| 1013 | hdd_ctx->config-> |
| 1014 | isIbssPowerCollapseAllowed, VDEV_CMD); |
| 1015 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1016 | hdd_err("power collapse allow failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1017 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1018 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1019 | } |
| 1020 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1021 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1022 | WMA_VDEV_IBSS_SET_AWAKE_ON_TX_RX, |
| 1023 | hdd_ctx->config->isIbssAwakeOnTxRx, |
| 1024 | VDEV_CMD); |
| 1025 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1026 | hdd_err("set awake on tx/rx failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1027 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1028 | } |
| 1029 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1030 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1031 | WMA_VDEV_IBSS_SET_INACTIVITY_TIME, |
| 1032 | hdd_ctx->config->ibssInactivityCount, |
| 1033 | VDEV_CMD); |
| 1034 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1035 | hdd_err("set inactivity time failed %d", ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1036 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1037 | } |
| 1038 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1039 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1040 | WMA_VDEV_IBSS_SET_TXSP_END_INACTIVITY_TIME, |
| 1041 | hdd_ctx->config->ibssTxSpEndInactivityTime, |
| 1042 | VDEV_CMD); |
| 1043 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1044 | hdd_err("set txsp end failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1045 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1046 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1047 | } |
| 1048 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1049 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1050 | WMA_VDEV_IBSS_PS_SET_WARMUP_TIME_SECS, |
| 1051 | hdd_ctx->config->ibssPsWarmupTime, |
| 1052 | VDEV_CMD); |
| 1053 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1054 | hdd_err("set ps warmup failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1055 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1056 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1057 | } |
| 1058 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 1059 | ret = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1060 | WMA_VDEV_IBSS_PS_SET_1RX_CHAIN_IN_ATIM_WINDOW, |
| 1061 | hdd_ctx->config->ibssPs1RxChainInAtimEnable, |
| 1062 | VDEV_CMD); |
| 1063 | if (0 != ret) { |
Rajeev Kumar | eeeb6f2 | 2018-07-12 11:10:27 -0700 | [diff] [blame] | 1064 | hdd_err("set 1rx chain atim failed %d", |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1065 | ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1066 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1067 | } |
| 1068 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1069 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1070 | } |
| 1071 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1072 | #ifdef FEATURE_RUNTIME_PM |
| 1073 | /** |
| 1074 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1075 | * @hdd_ctx: HDD context |
| 1076 | * |
| 1077 | * Return: None |
| 1078 | */ |
| 1079 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1080 | { |
| 1081 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1082 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1083 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1084 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1085 | |
| 1086 | wlan_scan_runtime_pm_init(hdd_ctx->hdd_pdev); |
| 1087 | } |
| 1088 | |
| 1089 | /** |
| 1090 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1091 | * @hdd_ctx: HDD Context |
| 1092 | * |
| 1093 | * Return: None |
| 1094 | */ |
| 1095 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1096 | { |
| 1097 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1098 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1099 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1100 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1101 | |
| 1102 | wlan_scan_runtime_pm_deinit(hdd_ctx->hdd_pdev); |
| 1103 | } |
| 1104 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1105 | #else /* FEATURE_RUNTIME_PM */ |
| 1106 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1107 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1108 | #endif /* FEATURE_RUNTIME_PM */ |
| 1109 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1110 | #define INTF_MACADDR_MASK 0x7 |
| 1111 | |
| 1112 | /** |
| 1113 | * hdd_update_macaddr() - update mac address |
| 1114 | * @config: hdd configuration |
| 1115 | * @hw_macaddr: mac address |
| 1116 | * |
| 1117 | * Mac address for multiple virtual interface is found as following |
| 1118 | * i) The mac address of the first interface is just the actual hw mac address. |
| 1119 | * ii) MSM 3 or 4 bits of byte5 of the actual mac address are used to |
| 1120 | * define the mac address for the remaining interfaces and locally |
| 1121 | * admistered bit is set. INTF_MACADDR_MASK is based on the number of |
| 1122 | * supported virtual interfaces, right now this is 0x07 (meaning 8 |
| 1123 | * interface). |
| 1124 | * Byte[3] of second interface will be hw_macaddr[3](bit5..7) + 1, |
| 1125 | * for third interface it will be hw_macaddr[3](bit5..7) + 2, etc. |
| 1126 | * |
| 1127 | * Return: None |
| 1128 | */ |
| 1129 | void hdd_update_macaddr(struct hdd_config *config, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1130 | struct qdf_mac_addr hw_macaddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1131 | { |
| 1132 | int8_t i; |
| 1133 | uint8_t macaddr_b3, tmp_br3; |
| 1134 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1135 | qdf_mem_copy(config->intfMacAddr[0].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1136 | QDF_MAC_ADDR_SIZE); |
| 1137 | for (i = 1; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1138 | qdf_mem_copy(config->intfMacAddr[i].bytes, hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1139 | QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1140 | macaddr_b3 = config->intfMacAddr[i].bytes[3]; |
| 1141 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1142 | INTF_MACADDR_MASK; |
| 1143 | macaddr_b3 += tmp_br3; |
| 1144 | |
| 1145 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1146 | * mac address range before collision |
| 1147 | */ |
| 1148 | macaddr_b3 ^= (1 << 7); |
| 1149 | |
| 1150 | /* Set locally administered bit */ |
| 1151 | config->intfMacAddr[i].bytes[0] |= 0x02; |
| 1152 | config->intfMacAddr[i].bytes[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1153 | hdd_debug("config->intfMacAddr[%d]: " |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1154 | MAC_ADDRESS_STR, i, |
| 1155 | MAC_ADDR_ARRAY(config->intfMacAddr[i].bytes)); |
| 1156 | } |
| 1157 | } |
| 1158 | |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1159 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1160 | { |
| 1161 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 1162 | struct tdls_start_params tdls_cfg; |
| 1163 | struct tdls_user_config *config = &tdls_cfg.config; |
| 1164 | struct hdd_config *cfg = hdd_ctx->config; |
| 1165 | QDF_STATUS status; |
| 1166 | |
| 1167 | config->tdls_tx_states_period = cfg->fTDLSTxStatsPeriod; |
| 1168 | config->tdls_tx_pkt_threshold = cfg->fTDLSTxPacketThreshold; |
| 1169 | config->tdls_rx_pkt_threshold = cfg->fTDLSRxFrameThreshold; |
| 1170 | config->tdls_max_discovery_attempt = cfg->fTDLSMaxDiscoveryAttempt; |
| 1171 | config->tdls_idle_timeout = cfg->tdls_idle_timeout; |
| 1172 | config->tdls_idle_pkt_threshold = cfg->fTDLSIdlePacketThreshold; |
| 1173 | config->tdls_rssi_trigger_threshold = cfg->fTDLSRSSITriggerThreshold; |
| 1174 | config->tdls_rssi_teardown_threshold = cfg->fTDLSRSSITeardownThreshold; |
| 1175 | config->tdls_rssi_delta = cfg->fTDLSRSSIDelta; |
| 1176 | config->tdls_uapsd_mask = cfg->fTDLSUapsdMask; |
| 1177 | config->tdls_uapsd_inactivity_time = cfg->fTDLSPuapsdInactivityTimer; |
| 1178 | config->tdls_uapsd_pti_window = cfg->fTDLSPuapsdPTIWindow; |
| 1179 | config->tdls_uapsd_ptr_timeout = cfg->fTDLSPuapsdPTRTimeout; |
| 1180 | config->tdls_pre_off_chan_num = cfg->fTDLSPrefOffChanNum; |
| 1181 | config->tdls_pre_off_chan_bw = cfg->fTDLSPrefOffChanBandwidth; |
| 1182 | config->tdls_peer_kickout_threshold = cfg->tdls_peer_kickout_threshold; |
| 1183 | config->delayed_trig_framint = cfg->DelayedTriggerFrmInt; |
| 1184 | config->tdls_feature_flags = ((cfg->fEnableTDLSOffChannel ? |
| 1185 | 1 << TDLS_FEATURE_OFF_CHANNEL : 0) | |
| 1186 | (cfg->fEnableTDLSWmmMode ? 1 << TDLS_FEATURE_WMM : 0) | |
| 1187 | (cfg->fEnableTDLSBufferSta ? 1 << TDLS_FEATURE_BUFFER_STA : 0) | |
| 1188 | (cfg->fEnableTDLSSleepSta ? 1 << TDLS_FEATURE_SLEEP_STA : 0) | |
| 1189 | (cfg->enable_tdls_scan ? 1 << TDLS_FEATURE_SCAN : 0) | |
| 1190 | (cfg->fEnableTDLSSupport ? 1 << TDLS_FEATURE_ENABLE : 0) | |
| 1191 | (cfg->fEnableTDLSImplicitTrigger ? |
| 1192 | 1 << TDLS_FEAUTRE_IMPLICIT_TRIGGER : 0) | |
| 1193 | (cfg->fTDLSExternalControl ? |
| 1194 | 1 << TDLS_FEATURE_EXTERNAL_CONTROL : 0)); |
| 1195 | config->tdls_vdev_nss_2g = CFG_TDLS_NSS(cfg->vdev_type_nss_2g); |
| 1196 | config->tdls_vdev_nss_5g = CFG_TDLS_NSS(cfg->vdev_type_nss_5g); |
| 1197 | |
| 1198 | tdls_cfg.tdls_send_mgmt_req = eWNI_SME_TDLS_SEND_MGMT_REQ; |
| 1199 | tdls_cfg.tdls_add_sta_req = eWNI_SME_TDLS_ADD_STA_REQ; |
| 1200 | tdls_cfg.tdls_del_sta_req = eWNI_SME_TDLS_DEL_STA_REQ; |
| 1201 | tdls_cfg.tdls_update_peer_state = WMA_UPDATE_TDLS_PEER_STATE; |
| 1202 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1203 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1204 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1205 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1206 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1207 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1208 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1209 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1210 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1211 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1212 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1213 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1214 | |
| 1215 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1216 | if (status != QDF_STATUS_SUCCESS) { |
| 1217 | hdd_err("failed pmo psoc configuration"); |
| 1218 | return -EINVAL; |
| 1219 | } |
| 1220 | |
| 1221 | hdd_ctx->tdls_umac_comp_active = true; |
| 1222 | /* enable napier specific tdls data path */ |
| 1223 | hdd_ctx->tdls_nap_active = true; |
| 1224 | |
| 1225 | return 0; |
| 1226 | } |
| 1227 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1228 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | struct wma_tgt_services *cfg) |
| 1230 | { |
| 1231 | struct hdd_config *config = hdd_ctx->config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1232 | |
| 1233 | /* Set up UAPSD */ |
| 1234 | config->apUapsdEnabled &= cfg->uapsd; |
| 1235 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1236 | /* 11AX mode support */ |
| 1237 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1238 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1239 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1240 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1241 | /* 11AC mode support */ |
| 1242 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1243 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1244 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1245 | |
| 1246 | /* ARP offload: override user setting if invalid */ |
| 1247 | config->fhostArpOffload &= cfg->arp_offload; |
| 1248 | |
| 1249 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1250 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1251 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | if (cfg->pno_offload) |
| 1253 | config->PnoOffload = true; |
| 1254 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | #ifdef FEATURE_WLAN_TDLS |
| 1256 | config->fEnableTDLSSupport &= cfg->en_tdls; |
Manjeet Singh | fdd2ac7 | 2016-09-02 18:11:43 +0530 | [diff] [blame] | 1257 | config->fEnableTDLSOffChannel = config->fEnableTDLSOffChannel && |
| 1258 | cfg->en_tdls_offchan; |
| 1259 | config->fEnableTDLSBufferSta = config->fEnableTDLSBufferSta && |
| 1260 | cfg->en_tdls_uapsd_buf_sta; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1261 | if (config->fTDLSUapsdMask && cfg->en_tdls_uapsd_sleep_sta) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1262 | config->fEnableTDLSSleepSta = true; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1263 | else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1264 | config->fEnableTDLSSleepSta = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1265 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1266 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1267 | config->isRoamOffloadEnabled &= cfg->en_roam_offload; |
| 1268 | #endif |
Will Huang | 496b36c | 2017-07-11 16:38:50 +0800 | [diff] [blame] | 1269 | config->sap_get_peer_info &= cfg->get_peer_info_enabled; |
Varun Reddy Yeturu | 62c3265 | 2017-10-26 15:32:35 -0700 | [diff] [blame] | 1270 | config->MAWCEnabled &= cfg->is_fw_mawc_capable; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1271 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1272 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1273 | |
| 1274 | } |
| 1275 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1276 | /** |
| 1277 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1278 | * @hdd_ctx: HDD context |
| 1279 | * |
| 1280 | * Sets the Nss per vdev type based on INI |
| 1281 | * |
| 1282 | * Return: None |
| 1283 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1284 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1285 | { |
| 1286 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1287 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1288 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1289 | |
Naveen Rawat | 10b1c15 | 2017-01-18 11:16:06 -0800 | [diff] [blame] | 1290 | if (cfg_ini->enable2x2 && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1291 | max_supp_nss = 2; |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 1292 | hdd_debug("max nss %d vdev_type_nss_2g %x vdev_type_nss_5g %x", |
| 1293 | max_supp_nss, cfg_ini->vdev_type_nss_2g, |
| 1294 | cfg_ini->vdev_type_nss_5g); |
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 | mac_handle = hdd_ctx->mac_handle; |
| 1297 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1298 | cfg_ini->vdev_type_nss_2g, BAND_2G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1299 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1300 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
| 1301 | cfg_ini->vdev_type_nss_5g, BAND_5G); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1302 | } |
| 1303 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1304 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1305 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1306 | * @hdd_ctx: HDD context |
| 1307 | * |
| 1308 | * Updates wiphy vhtcap fields |
| 1309 | * |
| 1310 | * Return: None |
| 1311 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1312 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1313 | { |
| 1314 | struct ieee80211_supported_band *band_5g = |
| 1315 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
| 1316 | uint32_t val; |
| 1317 | |
| 1318 | if (!band_5g) { |
| 1319 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1320 | return; |
| 1321 | } |
| 1322 | |
| 1323 | val = hdd_ctx->config->txBFCsnValue; |
| 1324 | band_5g->vht_cap.cap |= (val << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
| 1325 | |
| 1326 | val = NUM_OF_SOUNDING_DIMENSIONS; |
| 1327 | band_5g->vht_cap.cap |= |
| 1328 | (val << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
| 1329 | |
| 1330 | hdd_info("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
| 1331 | band_5g->vht_cap.cap, hdd_ctx->config->txBFCsnValue, val); |
| 1332 | } |
| 1333 | |
| 1334 | /** |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1335 | * hdd_update_hw_dbs_capable() - sets the dbs capability of the device |
| 1336 | * @hdd_ctx: HDD context |
| 1337 | * |
| 1338 | * Sets the DBS capability as per INI and firmware capability |
| 1339 | * |
| 1340 | * Return: None |
| 1341 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1342 | static void hdd_update_hw_dbs_capable(struct hdd_context *hdd_ctx) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1343 | { |
| 1344 | struct hdd_config *cfg_ini = hdd_ctx->config; |
| 1345 | uint8_t hw_dbs_capable = 0; |
| 1346 | |
Tushnim Bhattacharyya | 49ed8ab | 2017-05-26 18:20:10 -0700 | [diff] [blame] | 1347 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc) && |
| 1348 | ((cfg_ini->dual_mac_feature_disable == |
| 1349 | ENABLE_DBS_CXN_AND_SCAN) || |
| 1350 | (cfg_ini->dual_mac_feature_disable == |
| 1351 | ENABLE_DBS_CXN_AND_ENABLE_SCAN_WITH_ASYNC_SCAN_OFF))) |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1352 | hw_dbs_capable = 1; |
| 1353 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1354 | sme_update_hw_dbs_capable(hdd_ctx->mac_handle, hw_dbs_capable); |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1355 | } |
| 1356 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1357 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1358 | struct wma_tgt_ht_cap *cfg) |
| 1359 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1360 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | uint32_t value, val32; |
| 1362 | uint16_t val16; |
| 1363 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1364 | tSirMacHTCapabilityInfo *phtCapInfo; |
| 1365 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
| 1366 | uint8_t enable_tx_stbc; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1367 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1368 | |
| 1369 | /* check and update RX STBC */ |
| 1370 | if (pconfig->enableRxSTBC && !cfg->ht_rx_stbc) |
| 1371 | pconfig->enableRxSTBC = cfg->ht_rx_stbc; |
| 1372 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1373 | mac_handle = hdd_ctx->mac_handle; |
| 1374 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1375 | /* get the MPDU density */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1376 | status = sme_cfg_get_int(mac_handle, WNI_CFG_MPDU_DENSITY, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1377 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1378 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1379 | hdd_err("could not get MPDU DENSITY"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1380 | value = 0; |
| 1381 | } |
| 1382 | |
| 1383 | /* |
| 1384 | * MPDU density: |
| 1385 | * override user's setting if value is larger |
| 1386 | * than the one supported by target |
| 1387 | */ |
| 1388 | if (value > cfg->mpdu_density) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1389 | status = sme_cfg_set_int(mac_handle, WNI_CFG_MPDU_DENSITY, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1390 | cfg->mpdu_density); |
| 1391 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1392 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1393 | hdd_err("could not set MPDU DENSITY to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1394 | } |
| 1395 | |
| 1396 | /* get the HT capability info */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1397 | 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] | 1398 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1399 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | return; |
| 1401 | } |
| 1402 | val16 = (uint16_t) val32; |
| 1403 | phtCapInfo = (tSirMacHTCapabilityInfo *) &val16; |
| 1404 | |
| 1405 | /* Set the LDPC capability */ |
| 1406 | phtCapInfo->advCodingCap = cfg->ht_rx_ldpc; |
| 1407 | |
| 1408 | if (pconfig->ShortGI20MhzEnable && !cfg->ht_sgi_20) |
| 1409 | pconfig->ShortGI20MhzEnable = cfg->ht_sgi_20; |
| 1410 | |
| 1411 | if (pconfig->ShortGI40MhzEnable && !cfg->ht_sgi_40) |
| 1412 | pconfig->ShortGI40MhzEnable = cfg->ht_sgi_40; |
| 1413 | |
| 1414 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1415 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1416 | |
| 1417 | enable_tx_stbc = pconfig->enableTxSTBC; |
| 1418 | |
| 1419 | if (pconfig->enable2x2 && (cfg->num_rf_chains == 2)) { |
| 1420 | pconfig->enable2x2 = 1; |
| 1421 | } else { |
| 1422 | pconfig->enable2x2 = 0; |
| 1423 | enable_tx_stbc = 0; |
| 1424 | |
| 1425 | /* 1x1 */ |
| 1426 | /* Update Rx Highest Long GI data Rate */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1427 | if (sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1428 | WNI_CFG_VHT_RX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1429 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1430 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1431 | 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] | 1432 | } |
| 1433 | |
| 1434 | /* Update Tx Highest Long GI data Rate */ |
| 1435 | if (sme_cfg_set_int |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1436 | (mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1437 | WNI_CFG_VHT_TX_HIGHEST_SUPPORTED_DATA_RATE, |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1438 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1439 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1440 | hdd_err("VHT_TX_HIGHEST_SUPP_RATE_1_1 to CCM fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1441 | } |
| 1442 | } |
| 1443 | if (!(cfg->ht_tx_stbc && pconfig->enable2x2)) |
| 1444 | enable_tx_stbc = 0; |
| 1445 | phtCapInfo->txSTBC = enable_tx_stbc; |
| 1446 | |
| 1447 | val32 = val16; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1448 | 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] | 1449 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1450 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
| 1452 | value = SIZE_OF_SUPPORTED_MCS_SET; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1453 | 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] | 1454 | &value) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1455 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1456 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1457 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1458 | if (pconfig->enable2x2) { |
| 1459 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1460 | mcs_set[value] = |
| 1461 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1462 | |
| 1463 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1464 | sme_cfg_set_str(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | WNI_CFG_SUPPORTED_MCS_SET, |
| 1466 | mcs_set, |
| 1467 | SIZE_OF_SUPPORTED_MCS_SET); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1468 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1469 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1470 | } |
| 1471 | } |
| 1472 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1473 | } |
| 1474 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1475 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1476 | struct wma_tgt_vht_cap *cfg) |
| 1477 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1478 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1479 | uint32_t value = 0; |
| 1480 | struct hdd_config *pconfig = hdd_ctx->config; |
| 1481 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1482 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1483 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1484 | uint32_t temp = 0; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1485 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1486 | uint32_t hw_rx_ldpc_enabled; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1487 | struct wma_caps_per_phy caps_per_phy; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1488 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1489 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1490 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1491 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1492 | return; |
| 1493 | } |
| 1494 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1495 | mac_handle = hdd_ctx->mac_handle; |
| 1496 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | /* Get the current MPDU length */ |
| 1498 | status = |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1499 | sme_cfg_get_int(mac_handle, WNI_CFG_VHT_MAX_MPDU_LENGTH, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1500 | &value); |
| 1501 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1502 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1503 | hdd_err("could not get MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1504 | value = 0; |
| 1505 | } |
| 1506 | |
| 1507 | /* |
| 1508 | * VHT max MPDU length: |
| 1509 | * override if user configured value is too high |
| 1510 | * that the target cannot support |
| 1511 | */ |
| 1512 | if (value > cfg->vht_max_mpdu) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1513 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1514 | WNI_CFG_VHT_MAX_MPDU_LENGTH, |
| 1515 | cfg->vht_max_mpdu); |
| 1516 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1517 | if (status == QDF_STATUS_E_FAILURE) |
| 1518 | hdd_err("could not set VHT MAX MPDU LENGTH"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1519 | } |
| 1520 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1521 | 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] | 1522 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1523 | |
| 1524 | if (pconfig->enable2x2) |
| 1525 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1526 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1527 | 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] | 1528 | QDF_STATUS_E_FAILURE) { |
| 1529 | hdd_err("Could not pass VHT_BASIC_MCS_SET to CCM"); |
| 1530 | } |
| 1531 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1532 | 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] | 1533 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtRxMCS; |
| 1534 | if (pconfig->enable2x2) |
| 1535 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtRxMCS2x2 << 2); |
| 1536 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1537 | 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] | 1538 | QDF_STATUS_E_FAILURE) { |
| 1539 | hdd_err("Could not pass WNI_CFG_VHT_RX_MCS_MAP to CCM"); |
| 1540 | } |
| 1541 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1542 | 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] | 1543 | temp = (temp & VHT_MCS_1x1) | pconfig->vhtTxMCS; |
| 1544 | if (pconfig->enable2x2) |
| 1545 | temp = (temp & VHT_MCS_2x2) | (pconfig->vhtTxMCS2x2 << 2); |
| 1546 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1547 | hdd_debug("vhtRxMCS2x2 - %x temp - %u enable2x2 %d", |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1548 | pconfig->vhtRxMCS2x2, temp, pconfig->enable2x2); |
| 1549 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1550 | 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] | 1551 | QDF_STATUS_E_FAILURE) { |
| 1552 | hdd_err("Could not pass WNI_CFG_VHT_TX_MCS_MAP to CCM"); |
| 1553 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1554 | /* Get the current RX LDPC setting */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1555 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_LDPC_CODING_CAP, |
| 1556 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1557 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1558 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1559 | hdd_err("could not get VHT LDPC CODING CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1560 | value = 0; |
| 1561 | } |
| 1562 | |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1563 | /* Set HW RX LDPC capability */ |
| 1564 | hw_rx_ldpc_enabled = !!cfg->vht_rx_ldpc; |
| 1565 | if (hw_rx_ldpc_enabled != value) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1566 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1567 | WNI_CFG_VHT_LDPC_CODING_CAP, |
jiad | 4a7a33c | 2017-08-08 15:32:24 +0800 | [diff] [blame] | 1568 | hw_rx_ldpc_enabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1569 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1570 | if (status == QDF_STATUS_E_FAILURE) |
| 1571 | hdd_err("could not set VHT LDPC CODING CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1572 | } |
| 1573 | |
| 1574 | /* Get current GI 80 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1575 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1576 | &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1577 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1578 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1579 | hdd_err("could not get SHORT GI 80MHZ"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1580 | value = 0; |
| 1581 | } |
| 1582 | |
| 1583 | /* set the Guard interval 80MHz */ |
| 1584 | if (value && !cfg->vht_short_gi_80) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1585 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1586 | WNI_CFG_VHT_SHORT_GI_80MHZ, |
| 1587 | cfg->vht_short_gi_80); |
| 1588 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1589 | if (status == QDF_STATUS_E_FAILURE) |
| 1590 | hdd_err("could not set SHORT GI 80MHZ to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1591 | } |
| 1592 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1593 | /* Get VHT TX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1594 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_TXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1595 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1596 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1597 | hdd_err("could not get VHT TX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1598 | value = 0; |
| 1599 | } |
| 1600 | |
| 1601 | /* VHT TX STBC cap */ |
| 1602 | if (value && !cfg->vht_tx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1603 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1604 | cfg->vht_tx_stbc); |
| 1605 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1606 | if (status == QDF_STATUS_E_FAILURE) |
| 1607 | hdd_err("could not set the VHT TX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1608 | } |
| 1609 | |
| 1610 | /* Get VHT RX STBC cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1611 | status = sme_cfg_get_int(mac_handle, WNI_CFG_VHT_RXSTBC, &value); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1612 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1613 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1614 | hdd_err("could not get VHT RX STBC"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1615 | value = 0; |
| 1616 | } |
| 1617 | |
| 1618 | /* VHT RX STBC cap */ |
| 1619 | if (value && !cfg->vht_rx_stbc) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1620 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_RXSTBC, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1621 | cfg->vht_rx_stbc); |
| 1622 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1623 | if (status == QDF_STATUS_E_FAILURE) |
| 1624 | hdd_err("could not set the VHT RX STBC to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1625 | } |
| 1626 | |
| 1627 | /* Get VHT SU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1628 | 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] | 1629 | &value); |
| 1630 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1631 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1632 | hdd_err("could not get VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1633 | value = 0; |
| 1634 | } |
| 1635 | |
| 1636 | /* set VHT SU Beamformer cap */ |
| 1637 | if (value && !cfg->vht_su_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1638 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1639 | WNI_CFG_VHT_SU_BEAMFORMER_CAP, |
| 1640 | cfg->vht_su_bformer); |
| 1641 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1642 | if (status == QDF_STATUS_E_FAILURE) |
| 1643 | hdd_err("could not set VHT SU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1644 | } |
| 1645 | |
| 1646 | /* check and update SU BEAMFORMEE capabality */ |
| 1647 | if (pconfig->enableTxBF && !cfg->vht_su_bformee) |
| 1648 | pconfig->enableTxBF = cfg->vht_su_bformee; |
| 1649 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1650 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1651 | WNI_CFG_VHT_SU_BEAMFORMEE_CAP, |
| 1652 | pconfig->enableTxBF); |
| 1653 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1654 | if (status == QDF_STATUS_E_FAILURE) |
| 1655 | hdd_err("could not set VHT SU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1656 | |
| 1657 | /* Get VHT MU Beamformer cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1658 | 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] | 1659 | &value); |
| 1660 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1661 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1662 | hdd_err("could not get VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1663 | value = 0; |
| 1664 | } |
| 1665 | |
| 1666 | /* set VHT MU Beamformer cap */ |
| 1667 | if (value && !cfg->vht_mu_bformer) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1668 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1669 | WNI_CFG_VHT_MU_BEAMFORMER_CAP, |
| 1670 | cfg->vht_mu_bformer); |
| 1671 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1672 | if (status == QDF_STATUS_E_FAILURE) |
| 1673 | hdd_err("could not set the VHT MU BEAMFORMER CAP to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1674 | } |
| 1675 | |
| 1676 | /* Get VHT MU Beamformee cap */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1677 | 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] | 1678 | &value); |
| 1679 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1680 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1681 | hdd_err("could not get VHT MU BEAMFORMEE CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1682 | value = 0; |
| 1683 | } |
| 1684 | |
| 1685 | /* set VHT MU Beamformee cap */ |
| 1686 | if (value && !cfg->vht_mu_bformee) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1687 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1688 | WNI_CFG_VHT_MU_BEAMFORMEE_CAP, |
| 1689 | cfg->vht_mu_bformee); |
| 1690 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1691 | if (status == QDF_STATUS_E_FAILURE) |
| 1692 | hdd_err("could not set VHT MU BEAMFORMER CAP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1693 | } |
| 1694 | |
| 1695 | /* Get VHT MAX AMPDU Len exp */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1696 | 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] | 1697 | &value); |
| 1698 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1699 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1700 | hdd_err("could not get VHT AMPDU LEN"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1701 | value = 0; |
| 1702 | } |
| 1703 | |
| 1704 | /* |
| 1705 | * VHT max AMPDU len exp: |
| 1706 | * override if user configured value is too high |
| 1707 | * that the target cannot support. |
| 1708 | * Even though Rome publish ampdu_len=7, it can |
| 1709 | * only support 4 because of some h/w bug. |
| 1710 | */ |
| 1711 | |
| 1712 | if (value > cfg->vht_max_ampdu_len_exp) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1713 | status = sme_cfg_set_int(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1714 | WNI_CFG_VHT_AMPDU_LEN_EXPONENT, |
| 1715 | cfg->vht_max_ampdu_len_exp); |
| 1716 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1717 | if (status == QDF_STATUS_E_FAILURE) |
| 1718 | hdd_err("could not set the VHT AMPDU LEN EXP"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1719 | } |
| 1720 | |
| 1721 | /* Get VHT TXOP PS CAP */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1722 | 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] | 1723 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1724 | if (status != QDF_STATUS_SUCCESS) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1725 | hdd_err("could not get VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1726 | value = 0; |
| 1727 | } |
| 1728 | |
| 1729 | /* set VHT TXOP PS cap */ |
| 1730 | if (value && !cfg->vht_txop_ps) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1731 | status = sme_cfg_set_int(mac_handle, WNI_CFG_VHT_TXOP_PS, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1732 | cfg->vht_txop_ps); |
| 1733 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1734 | if (status == QDF_STATUS_E_FAILURE) |
| 1735 | hdd_err("could not set the VHT TXOP PS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1736 | } |
| 1737 | |
| 1738 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1739 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1740 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1741 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1742 | else |
| 1743 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1744 | |
| 1745 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1746 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1747 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1748 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1749 | VHT_CAP_160_AND_80P80_SUPP); |
| 1750 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1751 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1752 | band_5g->vht_cap.cap |= |
| 1753 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1754 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1755 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1756 | status = sme_cfg_set_int(mac_handle, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1757 | WNI_CFG_VHT_SUPPORTED_CHAN_WIDTH_SET, |
| 1758 | VHT_CAP_160_SUPP); |
| 1759 | if (status == QDF_STATUS_E_FAILURE) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1760 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1761 | band_5g->vht_cap.cap |= |
| 1762 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1763 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1764 | } |
| 1765 | pconfig->vhtChannelWidth = QDF_MIN(pconfig->vhtChannelWidth, |
| 1766 | ch_width); |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1767 | /* Get the current GI 160 value */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1768 | status = sme_cfg_get_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1769 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1770 | &value); |
| 1771 | if (status != QDF_STATUS_SUCCESS) { |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1772 | hdd_err("could not get GI 80 & 160"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1773 | value = 0; |
| 1774 | } |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1775 | /* set the Guard interval 160MHz */ |
| 1776 | if (value && !cfg->vht_short_gi_160) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1777 | status = sme_cfg_set_int(mac_handle, |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1778 | WNI_CFG_VHT_SHORT_GI_160_AND_80_PLUS_80MHZ, |
| 1779 | cfg->vht_short_gi_160); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1780 | |
| 1781 | if (status == QDF_STATUS_E_FAILURE) |
Ashish Kumar Dhanotiya | 7ebf569 | 2017-04-12 20:04:47 +0530 | [diff] [blame] | 1782 | hdd_err("failed to set SHORT GI 160MHZ"); |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1783 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1784 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1785 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1786 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1787 | hdd_debug("VHT RxLDPC capability is set"); |
| 1788 | } else { |
| 1789 | /* |
| 1790 | * Get the RX LDPC capability for the NON DBS |
| 1791 | * hardware mode for 5G band |
| 1792 | */ |
| 1793 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1794 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1795 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1796 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1797 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1798 | hdd_debug("VHT RX LDPC capability is set"); |
| 1799 | } |
| 1800 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1801 | |
| 1802 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1803 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1804 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1805 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1806 | |
| 1807 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1808 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1809 | |
| 1810 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1811 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1812 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1813 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1814 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1815 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1816 | |
| 1817 | band_5g->vht_cap.cap |= |
| 1818 | (cfg->vht_max_ampdu_len_exp << |
| 1819 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1820 | |
| 1821 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1822 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1823 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1824 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1825 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1826 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1827 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1828 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1829 | |
| 1830 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1831 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1832 | |
| 1833 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1834 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1835 | /** |
| 1836 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1837 | * @hdd_ctx: Pointer to the HDD context |
| 1838 | * |
| 1839 | * Auto-generate mac address using device serial number. |
| 1840 | * Keep the first 3 bytes of OUI as before and replace |
| 1841 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1842 | * |
| 1843 | * Return: 0 for success |
| 1844 | * Non zero failure code for errors |
| 1845 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1846 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1847 | { |
| 1848 | unsigned int serialno = 0; |
| 1849 | struct qdf_mac_addr mac_addr = { |
| 1850 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1851 | }; |
| 1852 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1853 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1854 | if (serialno == 0) |
| 1855 | return -EINVAL; |
| 1856 | |
| 1857 | serialno &= 0x00ffffff; |
| 1858 | |
| 1859 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1860 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1861 | mac_addr.bytes[5] = serialno & 0xff; |
| 1862 | |
| 1863 | hdd_update_macaddr(hdd_ctx->config, mac_addr); |
| 1864 | return 0; |
| 1865 | } |
| 1866 | |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 1867 | #ifdef FEATURE_WLAN_APF |
| 1868 | /** |
| 1869 | * hdd_update_apf_support() - Update APF supported flag in hdd context |
| 1870 | * @hdd_ctx: Pointer to hdd_ctx |
| 1871 | * @cfg: target configuration |
| 1872 | * |
| 1873 | * Update the APF support flag in HDD Context using INI and target config. |
| 1874 | * |
| 1875 | * Return: None |
| 1876 | */ |
| 1877 | static void hdd_update_apf_support(struct hdd_context *hdd_ctx, |
| 1878 | struct wma_tgt_cfg *cfg) |
| 1879 | { |
| 1880 | hdd_ctx->apf_supported = (cfg->apf_enabled && |
| 1881 | hdd_ctx->config->apf_packet_filter_enable); |
| 1882 | } |
| 1883 | #else |
| 1884 | static void hdd_update_apf_support(struct hdd_context *hdd_ctx, |
| 1885 | struct wma_tgt_cfg *cfg) |
| 1886 | { |
| 1887 | } |
| 1888 | #endif |
| 1889 | |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1890 | /** |
| 1891 | * hdd_update_ra_rate_limit() - Update RA rate limit from target |
| 1892 | * configuration to cfg_ini in HDD |
| 1893 | * @hdd_ctx: Pointer to hdd_ctx |
| 1894 | * @cfg: target configuration |
| 1895 | * |
| 1896 | * Return: None |
| 1897 | */ |
| 1898 | #ifdef FEATURE_WLAN_RA_FILTERING |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1899 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1900 | struct wma_tgt_cfg *cfg) |
| 1901 | { |
| 1902 | hdd_ctx->config->IsRArateLimitEnabled = cfg->is_ra_rate_limit_enabled; |
| 1903 | } |
| 1904 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1905 | static void hdd_update_ra_rate_limit(struct hdd_context *hdd_ctx, |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 1906 | struct wma_tgt_cfg *cfg) |
| 1907 | { |
| 1908 | } |
| 1909 | #endif |
| 1910 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1911 | 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] | 1912 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1913 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1914 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1915 | uint8_t temp_band_cap; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1916 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1917 | uint8_t antenna_mode; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1918 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1919 | mac_handle_t mac_handle; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1920 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1921 | if (!hdd_ctx) { |
| 1922 | hdd_err("HDD context is NULL"); |
| 1923 | return; |
| 1924 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1925 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1926 | if (ret) { |
| 1927 | hdd_err("Failed to create pdev; errno:%d", ret); |
| 1928 | QDF_BUG(0); |
Sandeep Puligilla | 1cf6ebe | 2017-04-04 14:40:27 -0700 | [diff] [blame] | 1929 | } else { |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1930 | hdd_debug("New pdev has been created with pdev_id = %u", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1931 | hdd_ctx->hdd_pdev->pdev_objmgr.wlan_pdev_id); |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 1932 | if (dispatcher_pdev_open(hdd_ctx->hdd_pdev)) { |
| 1933 | hdd_err("dispatcher pdev open failed"); |
| 1934 | QDF_BUG(0); |
| 1935 | } |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1936 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1937 | |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1938 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1939 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 1940 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->hdd_pdev); |
| 1941 | |
| 1942 | wlan_pdev_set_dp_handle(hdd_ctx->hdd_pdev, |
| 1943 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1944 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1945 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1946 | |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 1947 | ret = hdd_green_ap_update_config(hdd_ctx); |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 1948 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1949 | ucfg_ipa_set_dp_handle(hdd_ctx->hdd_psoc, |
| 1950 | cds_get_context(QDF_MODULE_ID_SOC)); |
| 1951 | ucfg_ipa_set_txrx_handle(hdd_ctx->hdd_psoc, |
| 1952 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1953 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->hdd_pdev, |
| 1954 | hdd_softap_hard_start_xmit); |
| 1955 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->hdd_pdev, |
| 1956 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1957 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1958 | if (cds_cfg) { |
| 1959 | if (hdd_ctx->config->enable_sub_20_channel_width != |
| 1960 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
| 1961 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1962 | cds_cfg->sub_20_channel_width = |
| 1963 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1964 | } else { |
| 1965 | cds_cfg->sub_20_channel_width = |
| 1966 | hdd_ctx->config->enable_sub_20_channel_width; |
| 1967 | } |
| 1968 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1969 | |
| 1970 | /* first store the INI band capability */ |
| 1971 | temp_band_cap = hdd_ctx->config->nBandCapability; |
| 1972 | |
| 1973 | hdd_ctx->config->nBandCapability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1974 | hdd_ctx->is_fils_roaming_supported = |
| 1975 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1976 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1977 | hdd_ctx->config->is_11k_offload_supported = |
| 1978 | cfg->services.is_11k_offload_supported; |
| 1979 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1980 | /* |
| 1981 | * now overwrite the target band capability with INI |
| 1982 | * setting if INI setting is a subset |
| 1983 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1984 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1985 | if ((hdd_ctx->config->nBandCapability == BAND_ALL) && |
| 1986 | (temp_band_cap != BAND_ALL)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1987 | hdd_ctx->config->nBandCapability = temp_band_cap; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1988 | else if ((hdd_ctx->config->nBandCapability != BAND_ALL) && |
| 1989 | (temp_band_cap != BAND_ALL) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1990 | (hdd_ctx->config->nBandCapability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1991 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1992 | } |
| 1993 | |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1994 | hdd_ctx->curr_band = hdd_ctx->config->nBandCapability; |
| 1995 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1996 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1997 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1998 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1999 | } |
| 2000 | |
| 2001 | /* This can be extended to other configurations like ht, vht cap... */ |
| 2002 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 2003 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2004 | hdd_update_macaddr(hdd_ctx->config, cfg->hw_macaddr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2005 | hdd_ctx->update_mac_addr_to_fw = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2006 | } else { |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 2007 | static struct qdf_mac_addr default_mac_addr = { |
| 2008 | {0x00, 0x0A, 0xF5, 0x89, 0x89, 0xFF} |
| 2009 | }; |
| 2010 | if (qdf_is_macaddr_equal(&hdd_ctx->config->intfMacAddr[0], |
| 2011 | &default_mac_addr)) { |
| 2012 | if (hdd_generate_macaddr_auto(hdd_ctx) != 0) |
| 2013 | hdd_err("Fail to auto-generate MAC, using MAC from ini file " |
| 2014 | MAC_ADDRESS_STR, |
| 2015 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2016 | intfMacAddr[0].bytes)); |
| 2017 | } else { |
| 2018 | hdd_err("Invalid MAC passed from target, using MAC from ini file " |
| 2019 | MAC_ADDRESS_STR, |
| 2020 | MAC_ADDR_ARRAY(hdd_ctx->config-> |
| 2021 | intfMacAddr[0].bytes)); |
| 2022 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 2023 | hdd_ctx->update_mac_addr_to_fw = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2024 | } |
| 2025 | |
| 2026 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 2027 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2028 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2029 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 2030 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 2031 | sizeof(cfg->hw_bd_info)); |
| 2032 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2033 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 2034 | |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 2035 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 2036 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2037 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 2038 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 2039 | |
| 2040 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 2041 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2042 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 2043 | if (cfg->services.en_11ax) { |
| 2044 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 2045 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 2046 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 2047 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 2048 | |
| 2049 | hdd_update_vdev_nss(hdd_ctx); |
| 2050 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 2051 | hdd_update_hw_dbs_capable(hdd_ctx); |
| 2052 | |
Krishna Kumaar Natarajan | 1ae4911 | 2015-11-24 21:43:22 -0800 | [diff] [blame] | 2053 | hdd_ctx->config->fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 2054 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2055 | hdd_debug("fine_time_meas_cap: 0x%x", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2056 | hdd_ctx->config->fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2057 | |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 2058 | antenna_mode = (hdd_ctx->config->enable2x2 == 0x01) ? |
| 2059 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 2060 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2061 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2062 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 2063 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 2064 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Anurag Chouhan | 04dbf6d | 2016-09-08 15:32:52 +0530 | [diff] [blame] | 2065 | hdd_update_ra_rate_limit(hdd_ctx, cfg); |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 2066 | |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2067 | if ((hdd_ctx->config->txBFCsnValue > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2068 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
| 2069 | !cfg->tx_bfee_8ss_enabled) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2070 | hdd_ctx->config->txBFCsnValue = |
| 2071 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF; |
| 2072 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2073 | mac_handle = hdd_ctx->mac_handle; |
| 2074 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2075 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED, |
| 2076 | hdd_ctx->config->txBFCsnValue); |
| 2077 | if (QDF_IS_STATUS_ERROR(status)) |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2078 | hdd_err("fw update WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED to CFG fails"); |
| 2079 | |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 2080 | hdd_update_apf_support(hdd_ctx, cfg); |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2081 | |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 2082 | hdd_debug("Target APF %d Host APF %d 8ss fw support %d txBFCsnValue %d", |
| 2083 | cfg->apf_enabled, hdd_ctx->config->apf_packet_filter_enable, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2084 | cfg->tx_bfee_8ss_enabled, hdd_ctx->config->txBFCsnValue); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2085 | |
| 2086 | /* |
| 2087 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2088 | */ |
| 2089 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2090 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2091 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2092 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2093 | /* |
| 2094 | * This needs to be done after HDD pdev is created and stored since |
| 2095 | * it will access the HDD pdev object lock. |
| 2096 | */ |
| 2097 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2098 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2099 | /* Configure NAN datapath features */ |
| 2100 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2101 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2102 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2103 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2104 | status = sme_cfg_set_int(mac_handle, WNI_CFG_OBSS_DETECTION_OFFLOAD, |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2105 | cfg->obss_detection_offloaded); |
| 2106 | if (QDF_IS_STATUS_ERROR(status)) |
| 2107 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2108 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2109 | status = sme_cfg_set_int(mac_handle, |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2110 | WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD, |
| 2111 | cfg->obss_color_collision_offloaded); |
| 2112 | if (QDF_IS_STATUS_ERROR(status)) |
| 2113 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2114 | } |
| 2115 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2116 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2117 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2118 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2119 | struct hdd_ap_ctx *ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2120 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2121 | if (!hdd_ctx) { |
| 2122 | hdd_info("Couldn't get hdd_ctx"); |
| 2123 | return true; |
| 2124 | } |
| 2125 | |
| 2126 | if (hdd_ctx->config->disableDFSChSwitch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2127 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2128 | hdd_ctx, hdd_ctx->config->disableDFSChSwitch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2129 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2130 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2131 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2132 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2133 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2134 | |
| 2135 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2136 | QDF_P2P_GO_MODE == adapter->device_mode) && |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2137 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2138 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2139 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2140 | true; |
| 2141 | hdd_info("tx blocked for session: %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 2142 | adapter->session_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2143 | if (adapter->txrx_vdev) |
| 2144 | cdp_fc_vdev_flush( |
| 2145 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2146 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2147 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2148 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2149 | |
| 2150 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2151 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2152 | |
| 2153 | /** |
| 2154 | * hdd_is_valid_mac_address() - validate MAC address |
| 2155 | * @pMacAddr: Pointer to the input MAC address |
| 2156 | * |
| 2157 | * This function validates whether the given MAC address is valid or not |
| 2158 | * Expected MAC address is of the format XX:XX:XX:XX:XX:XX |
| 2159 | * where X is the hexa decimal digit character and separated by ':' |
| 2160 | * This algorithm works even if MAC address is not separated by ':' |
| 2161 | * |
| 2162 | * This code checks given input string mac contains exactly 12 hexadecimal |
| 2163 | * digits and a separator colon : appears in the input string only after |
| 2164 | * an even number of hex digits. |
| 2165 | * |
| 2166 | * Return: 1 for valid and 0 for invalid |
| 2167 | */ |
| 2168 | bool hdd_is_valid_mac_address(const uint8_t *pMacAddr) |
| 2169 | { |
| 2170 | int xdigit = 0; |
| 2171 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2172 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2173 | while (*pMacAddr) { |
| 2174 | if (isxdigit(*pMacAddr)) { |
| 2175 | xdigit++; |
| 2176 | } else if (':' == *pMacAddr) { |
| 2177 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2178 | break; |
| 2179 | |
| 2180 | ++separator; |
| 2181 | } else { |
| 2182 | /* Invalid MAC found */ |
| 2183 | return 0; |
| 2184 | } |
| 2185 | ++pMacAddr; |
| 2186 | } |
| 2187 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2188 | } |
| 2189 | |
| 2190 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2191 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2192 | * @dev: Handle to struct net_device to be updated. |
| 2193 | * |
| 2194 | * Return: None |
| 2195 | */ |
| 2196 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2197 | { |
| 2198 | dev->header_ops = NULL; |
| 2199 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2200 | dev->hard_header_len = ETH_HLEN; |
| 2201 | dev->mtu = ETH_DATA_LEN; |
| 2202 | dev->addr_len = ETH_ALEN; |
| 2203 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2204 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2205 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2206 | |
| 2207 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2208 | } |
| 2209 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2210 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2211 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2212 | * __hdd__mon_open() - HDD Open function |
| 2213 | * @dev: Pointer to net_device structure |
| 2214 | * |
| 2215 | * This is called in response to ifconfig up |
| 2216 | * |
| 2217 | * Return: 0 for success; non-zero for failure |
| 2218 | */ |
| 2219 | static int __hdd_mon_open(struct net_device *dev) |
| 2220 | { |
| 2221 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2222 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2223 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2224 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2225 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2226 | |
| 2227 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2228 | if (ret) |
| 2229 | return ret; |
| 2230 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2231 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2232 | |
| 2233 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2234 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2235 | if (ret) { |
| 2236 | hdd_err("Failed to start WLAN modules return"); |
| 2237 | return ret; |
| 2238 | } |
| 2239 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2240 | |
| 2241 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2242 | ret = hdd_start_adapter(adapter); |
| 2243 | if (ret) { |
| 2244 | hdd_err("Failed to start adapter :%d", |
| 2245 | adapter->device_mode); |
| 2246 | return ret; |
| 2247 | } |
| 2248 | hdd_err("hdd_start_adapters() successful !"); |
| 2249 | } |
| 2250 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2251 | } |
| 2252 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2253 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2254 | |
| 2255 | if (!ret) |
| 2256 | ret = hdd_enable_monitor_mode(dev); |
| 2257 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2258 | return ret; |
| 2259 | } |
| 2260 | |
| 2261 | /** |
| 2262 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2263 | * @dev: Pointer to net_device structure |
| 2264 | * |
| 2265 | * This is called in response to ifconfig up |
| 2266 | * |
| 2267 | * Return: 0 for success; non-zero for failure |
| 2268 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 2269 | static int hdd_mon_open(struct net_device *dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2270 | { |
| 2271 | int ret; |
| 2272 | |
| 2273 | cds_ssr_protect(__func__); |
| 2274 | ret = __hdd_mon_open(dev); |
| 2275 | cds_ssr_unprotect(__func__); |
| 2276 | |
| 2277 | return ret; |
| 2278 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2279 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2280 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2281 | static QDF_STATUS |
| 2282 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2283 | { |
| 2284 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2285 | QDF_STATUS status; |
| 2286 | uint32_t channel_select_logic_conc; |
| 2287 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2288 | |
| 2289 | if (!hdd_ctx) { |
| 2290 | hdd_err("HDD context is NULL"); |
| 2291 | return QDF_STATUS_E_FAILURE; |
| 2292 | } |
| 2293 | |
| 2294 | |
| 2295 | if (!policy_mgr_is_hw_dbs_capable(hdd_ctx->hdd_psoc)) |
| 2296 | return QDF_STATUS_SUCCESS; |
| 2297 | |
| 2298 | cfg.scan_config = 0; |
| 2299 | cfg.fw_mode_config = 0; |
| 2300 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
| 2301 | |
| 2302 | channel_select_logic_conc = hdd_ctx->config-> |
| 2303 | channel_select_logic_conc; |
| 2304 | |
| 2305 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 2306 | DISABLE_DBS_CXN_AND_SCAN) { |
| 2307 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
| 2308 | hdd_ctx->hdd_psoc, &cfg.scan_config, |
| 2309 | &cfg.fw_mode_config, |
| 2310 | hdd_ctx->config->dual_mac_feature_disable, |
| 2311 | channel_select_logic_conc); |
| 2312 | |
| 2313 | if (status != QDF_STATUS_SUCCESS) { |
| 2314 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2315 | status); |
| 2316 | return status; |
| 2317 | } |
| 2318 | } |
| 2319 | |
| 2320 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2321 | cfg.scan_config, cfg.fw_mode_config); |
| 2322 | |
| 2323 | status = sme_soc_set_dual_mac_config(cfg); |
| 2324 | if (status != QDF_STATUS_SUCCESS) { |
| 2325 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2326 | return status; |
| 2327 | } |
| 2328 | |
| 2329 | return QDF_STATUS_SUCCESS; |
| 2330 | } |
| 2331 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2332 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2333 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2334 | * @adapter: pointer to HDD adapter |
| 2335 | * |
| 2336 | * This function is called to start the device specific adapter for |
| 2337 | * the mode passed in the adapter's device_mode. |
| 2338 | * |
| 2339 | * Return: 0 for success; non-zero for failure |
| 2340 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2341 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2342 | { |
| 2343 | |
| 2344 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2345 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2346 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2347 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2348 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2349 | |
| 2350 | switch (device_mode) { |
| 2351 | case QDF_P2P_CLIENT_MODE: |
| 2352 | case QDF_P2P_DEVICE_MODE: |
| 2353 | case QDF_OCB_MODE: |
| 2354 | case QDF_STA_MODE: |
| 2355 | case QDF_MONITOR_MODE: |
| 2356 | ret = hdd_start_station_adapter(adapter); |
| 2357 | if (ret) |
| 2358 | goto err_start_adapter; |
| 2359 | break; |
| 2360 | case QDF_P2P_GO_MODE: |
| 2361 | case QDF_SAP_MODE: |
| 2362 | ret = hdd_start_ap_adapter(adapter); |
| 2363 | if (ret) |
| 2364 | goto err_start_adapter; |
| 2365 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2366 | case QDF_IBSS_MODE: |
| 2367 | /* |
| 2368 | * For IBSS interface is initialized as part of |
| 2369 | * hdd_init_station_mode() |
| 2370 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2371 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2372 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2373 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2374 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2375 | default: |
| 2376 | hdd_err("Invalid session type %d", device_mode); |
| 2377 | QDF_ASSERT(0); |
| 2378 | goto err_start_adapter; |
| 2379 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2380 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2381 | if (hdd_set_fw_params(adapter)) |
| 2382 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2383 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2384 | if (adapter->session_id != HDD_SESSION_ID_INVALID) { |
| 2385 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2386 | if (ret < 0) { |
| 2387 | hdd_err("Failed to register frames - ret %d", ret); |
| 2388 | goto err_start_adapter; |
| 2389 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2390 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2391 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2392 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2393 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2394 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2395 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2396 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2397 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2398 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2399 | err_start_adapter: |
| 2400 | return -EINVAL; |
| 2401 | } |
| 2402 | |
| 2403 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2404 | * hdd_enable_power_management() - API to Enable Power Management |
| 2405 | * |
| 2406 | * API invokes Bus Interface Layer power management functionality |
| 2407 | * |
| 2408 | * Return: None |
| 2409 | */ |
| 2410 | static void hdd_enable_power_management(void) |
| 2411 | { |
| 2412 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2413 | |
| 2414 | if (!hif_ctx) { |
| 2415 | hdd_err("Bus Interface Context is Invalid"); |
| 2416 | return; |
| 2417 | } |
| 2418 | |
| 2419 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2420 | } |
| 2421 | |
| 2422 | /** |
| 2423 | * hdd_disable_power_management() - API to disable Power Management |
| 2424 | * |
| 2425 | * API disable Bus Interface Layer Power management functionality |
| 2426 | * |
| 2427 | * Return: None |
| 2428 | */ |
| 2429 | static void hdd_disable_power_management(void) |
| 2430 | { |
| 2431 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2432 | |
| 2433 | if (!hif_ctx) { |
| 2434 | hdd_err("Bus Interface Context is Invalid"); |
| 2435 | return; |
| 2436 | } |
| 2437 | |
| 2438 | hif_disable_power_management(hif_ctx); |
| 2439 | } |
| 2440 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2441 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2442 | { |
| 2443 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2444 | size_t target_hw_name_len; |
| 2445 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2446 | uint8_t *buf; |
| 2447 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2448 | |
| 2449 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2450 | if (!hif_sc) { |
| 2451 | hdd_err("HIF context is NULL"); |
| 2452 | return; |
| 2453 | } |
| 2454 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2455 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2456 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2457 | &target_hw_name); |
| 2458 | |
| 2459 | if (hdd_ctx->target_hw_name) |
| 2460 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2461 | |
| 2462 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2463 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2464 | if (hdd_ctx->target_hw_name) |
| 2465 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2466 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2467 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2468 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2469 | if (buf) { |
| 2470 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2471 | hdd_info("%s", buf); |
| 2472 | qdf_mem_free(buf); |
| 2473 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2474 | } |
| 2475 | |
| 2476 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2477 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2478 | * @hdd_ctx: Pointer to hdd context |
| 2479 | * |
| 2480 | * Return: none |
| 2481 | */ |
| 2482 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2483 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2484 | { |
| 2485 | uint8_t num_entries = 0; |
| 2486 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM]; |
| 2487 | uint8_t *tx_sched_wrr_ac; |
| 2488 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2489 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2490 | |
| 2491 | if (NULL == hdd_ctx) |
| 2492 | return; |
| 2493 | |
| 2494 | if (NULL == hdd_ctx->config) { |
| 2495 | /* Do nothing if hdd_ctx is invalid */ |
| 2496 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2497 | return; |
| 2498 | } |
| 2499 | |
| 2500 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2501 | |
| 2502 | if (!cds_ctx) { |
| 2503 | hdd_err("Invalid CDS Context"); |
| 2504 | return; |
| 2505 | } |
| 2506 | |
| 2507 | for (i = 0; i < OL_TX_NUM_WMM_AC; i++) { |
| 2508 | switch (i) { |
| 2509 | case OL_TX_WMM_AC_BE: |
| 2510 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_be; |
| 2511 | break; |
| 2512 | case OL_TX_WMM_AC_BK: |
| 2513 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_bk; |
| 2514 | break; |
| 2515 | case OL_TX_WMM_AC_VI: |
| 2516 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vi; |
| 2517 | break; |
| 2518 | case OL_TX_WMM_AC_VO: |
| 2519 | tx_sched_wrr_ac = hdd_ctx->config->tx_sched_wrr_vo; |
| 2520 | break; |
| 2521 | default: |
| 2522 | tx_sched_wrr_ac = NULL; |
| 2523 | break; |
| 2524 | } |
| 2525 | |
| 2526 | hdd_string_to_u8_array(tx_sched_wrr_ac, |
| 2527 | tx_sched_wrr_param, |
| 2528 | &num_entries, |
| 2529 | sizeof(tx_sched_wrr_param)); |
| 2530 | |
| 2531 | if (num_entries == TX_SCHED_WRR_PARAMS_NUM) { |
| 2532 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2533 | tx_sched_wrr_param[0]; |
| 2534 | cds_ctx->ac_specs[i].credit_threshold = |
| 2535 | tx_sched_wrr_param[1]; |
| 2536 | cds_ctx->ac_specs[i].send_limit = |
| 2537 | tx_sched_wrr_param[2]; |
| 2538 | cds_ctx->ac_specs[i].credit_reserve = |
| 2539 | tx_sched_wrr_param[3]; |
| 2540 | cds_ctx->ac_specs[i].discard_weight = |
| 2541 | tx_sched_wrr_param[4]; |
| 2542 | } |
| 2543 | |
| 2544 | num_entries = 0; |
| 2545 | } |
| 2546 | } |
| 2547 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2548 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2549 | const size_t version_len, uint8_t *version) |
| 2550 | { |
| 2551 | uint32_t size; |
| 2552 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2553 | |
| 2554 | if (!hdd_ctx) { |
| 2555 | hdd_err("Invalid context, HDD context is null"); |
| 2556 | return 0; |
| 2557 | } |
| 2558 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2559 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2560 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2561 | return 0; |
| 2562 | } |
| 2563 | |
| 2564 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2565 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2566 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2567 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2568 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2569 | |
| 2570 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2571 | "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] | 2572 | QWLAN_VERSIONSTR, |
| 2573 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2574 | hdd_ctx->target_hw_name, |
| 2575 | hdd_ctx->hw_bd_info.bdf_version, |
| 2576 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2577 | hdd_ctx->hw_bd_info.customer_id, |
| 2578 | hdd_ctx->hw_bd_info.project_id, |
| 2579 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2580 | |
| 2581 | return size; |
| 2582 | } |
| 2583 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2584 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2585 | struct sap_config *sap_config) |
| 2586 | { |
| 2587 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2588 | int ret; |
| 2589 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2590 | |
| 2591 | if (!sap_config) { |
| 2592 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2593 | hdd_err("Target does not support 11ax"); |
| 2594 | return -EIO; |
| 2595 | } |
| 2596 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2597 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2598 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2599 | sap_config->SapHw_mode, sap_config->channel); |
| 2600 | return -EIO; |
| 2601 | } |
| 2602 | |
| 2603 | if (set_value != 0xff) { |
| 2604 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2605 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2606 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2607 | |
| 2608 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2609 | } else { |
| 2610 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->session_id, |
| 2611 | QCA_WLAN_HE_LTF_AUTO); |
| 2612 | } |
| 2613 | |
| 2614 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2615 | set_value, rix, preamble, nss); |
| 2616 | |
| 2617 | ret = wma_cli_set_command(adapter->session_id, |
| 2618 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2619 | set_value, VDEV_CMD); |
| 2620 | |
| 2621 | return ret; |
| 2622 | } |
| 2623 | |
| 2624 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2625 | { |
| 2626 | int set_value; |
| 2627 | |
| 2628 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2629 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2630 | else |
| 2631 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2632 | |
| 2633 | return set_value; |
| 2634 | } |
| 2635 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2636 | #ifdef IPA_OFFLOAD |
| 2637 | /** |
| 2638 | * hdd_update_ipa_component_config() - update ipa config |
| 2639 | * @hdd_ctx: Pointer to hdd context |
| 2640 | * |
| 2641 | * Return: none |
| 2642 | */ |
| 2643 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2644 | { |
| 2645 | struct hdd_config *cfg = hdd_ctx->config; |
| 2646 | struct wlan_ipa_config ipa_cfg; |
| 2647 | |
| 2648 | ipa_cfg.ipa_config = cfg->IpaConfig; |
| 2649 | ipa_cfg.desc_size = cfg->IpaDescSize; |
| 2650 | ipa_cfg.txbuf_count = cfg->IpaUcTxBufCount; |
| 2651 | ipa_cfg.bus_bw_high = cfg->busBandwidthHighThreshold; |
| 2652 | ipa_cfg.bus_bw_medium = cfg->busBandwidthMediumThreshold; |
| 2653 | ipa_cfg.bus_bw_low = cfg->busBandwidthLowThreshold; |
| 2654 | ipa_cfg.ipa_bw_high = cfg->IpaHighBandwidthMbps; |
| 2655 | ipa_cfg.ipa_bw_medium = cfg->IpaMediumBandwidthMbps; |
| 2656 | ipa_cfg.ipa_bw_low = cfg->IpaLowBandwidthMbps; |
| 2657 | |
| 2658 | ucfg_ipa_update_config(&ipa_cfg); |
| 2659 | } |
| 2660 | #else |
| 2661 | static void hdd_update_ipa_component_config(struct hdd_context *hdd_ctx) |
| 2662 | { |
| 2663 | } |
| 2664 | #endif |
| 2665 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2666 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2667 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2668 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2669 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2670 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2671 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2672 | |
| 2673 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2674 | if (!adapter) { |
| 2675 | hdd_err("Adapter is NULL"); |
| 2676 | return PM_MAX_NUM_OF_MODE; |
| 2677 | } |
| 2678 | |
| 2679 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2680 | adapter->device_mode); |
| 2681 | } |
| 2682 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2683 | static void hdd_register_policy_manager_callback( |
| 2684 | struct wlan_objmgr_psoc *psoc) |
| 2685 | { |
| 2686 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2687 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2688 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2689 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2690 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2691 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2692 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2693 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2694 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2695 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2696 | if (QDF_STATUS_SUCCESS != |
| 2697 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2698 | hdd_err("HDD callback registration with policy manager failed"); |
| 2699 | } |
| 2700 | } |
| 2701 | #else |
| 2702 | static void hdd_register_policy_manager_callback( |
| 2703 | struct wlan_objmgr_psoc *psoc) |
| 2704 | { |
| 2705 | } |
| 2706 | #endif |
| 2707 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2708 | static void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2709 | { |
| 2710 | struct nan_callbacks cb_obj = {0}; |
| 2711 | |
| 2712 | cb_obj.ndi_open = hdd_ndi_open; |
| 2713 | cb_obj.ndi_close = hdd_ndi_close; |
| 2714 | cb_obj.ndi_start = hdd_ndi_start; |
| 2715 | cb_obj.ndi_delete = hdd_ndi_delete; |
| 2716 | cb_obj.drv_ndi_create_rsp_handler = hdd_ndi_drv_ndi_create_rsp_handler; |
| 2717 | cb_obj.drv_ndi_delete_rsp_handler = hdd_ndi_drv_ndi_delete_rsp_handler; |
| 2718 | |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2719 | cb_obj.new_peer_ind = hdd_ndp_new_peer_handler; |
| 2720 | cb_obj.get_peer_idx = hdd_ndp_get_peer_idx; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2721 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2722 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2723 | os_if_nan_register_hdd_callbacks(hdd_ctx->hdd_psoc, &cb_obj); |
| 2724 | } |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2725 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2726 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2727 | /** |
| 2728 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2729 | * @hdd_ctx: the global HDD context |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2730 | * |
| 2731 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2732 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2733 | * |
| 2734 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2735 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2736 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2737 | * fixed. |
| 2738 | * |
| 2739 | * Return: None |
| 2740 | */ |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2741 | static void hdd_check_for_leaks(struct hdd_context *hdd_ctx) |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2742 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2743 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2744 | |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2745 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 2946296 | 2018-06-18 14:02:00 -0700 | [diff] [blame] | 2746 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->hdd_psoc); |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2747 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2748 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2749 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2750 | } |
| 2751 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2752 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2753 | #else |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2754 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx) { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2755 | |
| 2756 | #define hdd_debug_domain_set(domain) |
| 2757 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2758 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2759 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2760 | * hdd_update_country_code - Update country code |
| 2761 | * @hdd_ctx: HDD context |
| 2762 | * |
| 2763 | * Update country code based on module parameter country_code |
| 2764 | * |
| 2765 | * Return: 0 on success and errno on failure |
| 2766 | */ |
| 2767 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2768 | { |
| 2769 | if (!country_code) |
| 2770 | return 0; |
| 2771 | |
| 2772 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2773 | } |
| 2774 | |
| 2775 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2776 | * hdd_wlan_start_modules() - Single driver state machine for starting modules |
| 2777 | * @hdd_ctx: HDD context |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2778 | * @reinit: flag to indicate from SSR or normal path |
| 2779 | * |
| 2780 | * This function maintains the driver state machine it will be invoked from |
| 2781 | * startup, reinit and change interface. Depending on the driver state shall |
| 2782 | * perform the opening of the modules. |
| 2783 | * |
| 2784 | * Return: 0 for success; non-zero for failure |
| 2785 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2786 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2787 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2788 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2789 | qdf_device_t qdf_dev; |
| 2790 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2791 | bool unint = false; |
| 2792 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2793 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2794 | |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2795 | hdd_debug("state:%d reinit:%d", hdd_ctx->driver_status, reinit); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2796 | |
| 2797 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2798 | if (!qdf_dev) { |
| 2799 | hdd_err("QDF Device Context is Invalid return"); |
| 2800 | return -EINVAL; |
| 2801 | } |
| 2802 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 2803 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2804 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2805 | mutex_lock(&hdd_ctx->iface_change_lock); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2806 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
| 2807 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 2808 | hdd_info("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2809 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2810 | return 0; |
| 2811 | } |
| 2812 | |
Dustin Brown | 1fe30a8 | 2017-10-03 16:13:36 -0700 | [diff] [blame] | 2813 | hdd_ctx->start_modules_in_progress = true; |
| 2814 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | switch (hdd_ctx->driver_status) { |
| 2816 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2817 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2818 | unint = true; |
| 2819 | /* Fall through dont add break here */ |
| 2820 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2821 | hdd_info("Wlan transitioning (CLOSED -> OPENED)"); |
| 2822 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2823 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2824 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2825 | if (!reinit && !unint) { |
| 2826 | ret = pld_power_on(qdf_dev->dev); |
| 2827 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2828 | hdd_err("Failed to Powerup the device; errno: %d", |
| 2829 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2830 | goto release_lock; |
| 2831 | } |
| 2832 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2833 | |
| 2834 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2835 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2836 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2837 | qdf_dev->bus_type, |
| 2838 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2839 | HIF_ENABLE_TYPE_PROBE); |
| 2840 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2841 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2842 | goto power_down; |
| 2843 | } |
| 2844 | |
| 2845 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2846 | if (!hif_ctx) { |
| 2847 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2848 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2849 | goto power_down; |
| 2850 | } |
| 2851 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2852 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2853 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2854 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2855 | status); |
| 2856 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2857 | goto hif_close; |
| 2858 | } |
| 2859 | |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2860 | hdd_update_ipa_component_config(hdd_ctx); |
| 2861 | |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2862 | ret = hdd_update_config(hdd_ctx); |
| 2863 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2864 | hdd_err("Failed to update configuration; errno: %d", |
| 2865 | ret); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2866 | goto cds_free; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 2867 | } |
| 2868 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2869 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2870 | |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 2871 | status = cds_open(hdd_ctx->hdd_psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2872 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2873 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2874 | ret = qdf_status_to_os_return(status); |
| 2875 | goto deinit_config; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2876 | } |
| 2877 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2878 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2879 | cds_set_rx_thread_cpu_mask( |
| 2880 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2881 | |
| 2882 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2883 | ret = hdd_update_components_config(hdd_ctx); |
| 2884 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2885 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2886 | ret); |
| 2887 | goto close; |
| 2888 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2889 | status = cds_dp_open(hdd_ctx->hdd_psoc); |
| 2890 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2891 | hdd_err("Failed to Open cds post open; status: %d", |
| 2892 | status); |
| 2893 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2894 | goto close; |
| 2895 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2896 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2897 | /* |
| 2898 | * NAN compoenet requires certian operations like, open adapter, |
| 2899 | * close adapter, etc. to be initiated by HDD, for those |
| 2900 | * register HDD callbacks with UMAC's NAN componenet. |
| 2901 | */ |
| 2902 | hdd_nan_register_callbacks(hdd_ctx); |
| 2903 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2904 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2905 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2906 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2907 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2908 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2909 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2910 | goto cds_txrx_free; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2911 | } |
| 2912 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2913 | hdd_register_policy_manager_callback( |
| 2914 | hdd_ctx->hdd_psoc); |
| 2915 | |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 2916 | hdd_sysfs_create_version_interface(hdd_ctx->hdd_psoc); |
| 2917 | |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2918 | hdd_update_hw_sw_info(hdd_ctx); |
Himanshu Agarwal | 0b9bbc3 | 2017-02-23 16:23:05 +0530 | [diff] [blame] | 2919 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2920 | hdd_info("Wlan transitioned (now OPENED)"); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2921 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2922 | if (unint) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2923 | hdd_debug("In phase-1 initialization don't enable modules"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2924 | break; |
| 2925 | } |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 2926 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2927 | /* Fall through dont add break here */ |
| 2928 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2929 | hdd_info("Wlan transitioning (OPENED -> ENABLED)"); |
| 2930 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2931 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2932 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2933 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2934 | break; |
| 2935 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2936 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2937 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2938 | if (ret) { |
| 2939 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2940 | goto post_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2941 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2942 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2943 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2944 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2945 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2946 | hdd_info("Wlan transitioned (now ENABLED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2947 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2948 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2949 | default: |
| 2950 | hdd_err("WLAN start invoked in wrong state! :%d\n", |
| 2951 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2952 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2953 | goto release_lock; |
| 2954 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2955 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 2956 | hdd_ctx->start_modules_in_progress = false; |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2957 | if (DRIVER_MODULES_ENABLED == hdd_ctx->driver_status) { |
| 2958 | ret = hdd_update_country_code(hdd_ctx); |
| 2959 | if (ret) |
| 2960 | hdd_err("Failed to update command line country code!"); |
| 2961 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2962 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2963 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2964 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2965 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2966 | return 0; |
| 2967 | |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2968 | post_disable: |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2969 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2970 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2971 | cds_txrx_free: |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2972 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 2973 | |
| 2974 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 2975 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 2976 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
| 2977 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 2978 | } |
| 2979 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2980 | cds_dp_close(hdd_ctx->hdd_psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2981 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2982 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2983 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2984 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 2985 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 2986 | cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2987 | |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2988 | deinit_config: |
| 2989 | cds_deinit_ini_config(); |
| 2990 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2991 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2992 | ol_cds_free(); |
| 2993 | |
| 2994 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 2995 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2996 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2997 | power_down: |
| 2998 | if (!reinit && !unint) |
| 2999 | pld_power_off(qdf_dev->dev); |
| 3000 | release_lock: |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 3001 | hdd_ctx->start_modules_in_progress = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3002 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3003 | if (hdd_ctx->target_hw_name) { |
| 3004 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3005 | hdd_ctx->target_hw_name = NULL; |
| 3006 | } |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3007 | /* many adapter resources are not freed by design in SSR case */ |
| 3008 | if (!reinit) |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 3009 | hdd_check_for_leaks(hdd_ctx); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3010 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3011 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3012 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3013 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3014 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3015 | } |
| 3016 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3017 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3018 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3019 | { |
| 3020 | int ret = os_if_wifi_pos_register_nl(); |
| 3021 | |
| 3022 | if (ret) |
| 3023 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3024 | |
| 3025 | return ret; |
| 3026 | } |
| 3027 | |
| 3028 | static int hdd_deactivate_wifi_pos(void) |
| 3029 | { |
| 3030 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3031 | |
| 3032 | if (ret) |
| 3033 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3034 | |
| 3035 | return ret; |
| 3036 | } |
| 3037 | |
| 3038 | /** |
| 3039 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3040 | * @hdd_ctx: hdd context |
| 3041 | * |
| 3042 | * Return: status of operation |
| 3043 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3044 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3045 | { |
| 3046 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3047 | struct hdd_config *cfg = hdd_ctx->config; |
| 3048 | |
| 3049 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3050 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3051 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3052 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3053 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3054 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
| 3055 | wifi_pos_set_dwell_time_min(psoc, cfg->nNeighborScanMinChanTime); |
| 3056 | wifi_pos_set_dwell_time_max(psoc, cfg->nNeighborScanMaxChanTime); |
| 3057 | } |
| 3058 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3059 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3060 | { |
| 3061 | return oem_activate_service(hdd_ctx); |
| 3062 | } |
| 3063 | |
| 3064 | static int hdd_deactivate_wifi_pos(void) |
| 3065 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3066 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3067 | } |
| 3068 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3069 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3070 | { |
| 3071 | } |
| 3072 | #endif |
| 3073 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3074 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3075 | * __hdd_open() - HDD Open function |
| 3076 | * @dev: Pointer to net_device structure |
| 3077 | * |
| 3078 | * This is called in response to ifconfig up |
| 3079 | * |
| 3080 | * Return: 0 for success; non-zero for failure |
| 3081 | */ |
| 3082 | static int __hdd_open(struct net_device *dev) |
| 3083 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3084 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3085 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3086 | int ret; |
| 3087 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3088 | hdd_enter_dev(dev); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3089 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3090 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3091 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3092 | /* Nothing to be done if device is unloading */ |
| 3093 | if (cds_is_driver_unloading()) { |
| 3094 | hdd_err("Driver is unloading can not open the hdd"); |
| 3095 | return -EBUSY; |
| 3096 | } |
| 3097 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3098 | if (cds_is_driver_recovering()) { |
| 3099 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3100 | return -EBUSY; |
| 3101 | } |
| 3102 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3103 | if (qdf_atomic_read(&hdd_ctx->con_mode_flag)) { |
| 3104 | hdd_err("con_mode_handler is in progress; Please try again."); |
| 3105 | return -EBUSY; |
| 3106 | } |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3107 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 3108 | mutex_lock(&hdd_init_deinit_lock); |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3109 | hdd_start_driver_ops_timer(eHDD_DRV_OP_IFF_UP); |
| 3110 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3111 | /* |
| 3112 | * This scenario can be hit in cases where in the wlan driver after |
| 3113 | * registering the netdevices and there is a failure in driver |
| 3114 | * initialization. So return error gracefully because the netdevices |
| 3115 | * will be de-registered as part of the load failure. |
| 3116 | */ |
| 3117 | |
| 3118 | if (!cds_is_driver_loaded()) { |
| 3119 | hdd_err("Failed to start the wlan driver!!"); |
| 3120 | ret = -EIO; |
| 3121 | goto err_hdd_hdd_init_deinit_lock; |
| 3122 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3124 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 3125 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3126 | if (ret) { |
| 3127 | hdd_err("Failed to start WLAN modules return"); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3128 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3129 | } |
| 3130 | |
| 3131 | |
| 3132 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3133 | ret = hdd_start_adapter(adapter); |
| 3134 | if (ret) { |
| 3135 | hdd_err("Failed to start adapter :%d", |
| 3136 | adapter->device_mode); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3137 | goto err_hdd_hdd_init_deinit_lock; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3138 | } |
| 3139 | } |
| 3140 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3141 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3142 | 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] | 3143 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3144 | /* Enable TX queues only when we are connected */ |
| 3145 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3146 | WLAN_START_ALL_NETIF_QUEUE, |
| 3147 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3148 | } |
| 3149 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3150 | /* Enable carrier and transmit queues for NDI */ |
| 3151 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3152 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3153 | wlan_hdd_netif_queue_control(adapter, |
| 3154 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3155 | WLAN_CONTROL_PATH); |
| 3156 | } |
| 3157 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3158 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
| 3159 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3160 | err_hdd_hdd_init_deinit_lock: |
Hanumanth Reddy Pothula | 006f383 | 2017-10-12 15:52:43 +0530 | [diff] [blame] | 3161 | hdd_stop_driver_ops_timer(); |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3162 | mutex_unlock(&hdd_init_deinit_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3163 | return ret; |
| 3164 | } |
| 3165 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3166 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3167 | /** |
| 3168 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
| 3169 | * @dev: Pointer to net_device structure |
| 3170 | * |
| 3171 | * This is called in response to ifconfig up |
| 3172 | * |
| 3173 | * Return: 0 for success; non-zero for failure |
| 3174 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3175 | static int hdd_open(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3176 | { |
| 3177 | int ret; |
| 3178 | |
| 3179 | cds_ssr_protect(__func__); |
| 3180 | ret = __hdd_open(dev); |
| 3181 | cds_ssr_unprotect(__func__); |
| 3182 | |
| 3183 | return ret; |
| 3184 | } |
| 3185 | |
| 3186 | /** |
| 3187 | * __hdd_stop() - HDD stop function |
| 3188 | * @dev: Pointer to net_device structure |
| 3189 | * |
| 3190 | * This is called in response to ifconfig down |
| 3191 | * |
| 3192 | * Return: 0 for success; non-zero for failure |
| 3193 | */ |
| 3194 | static int __hdd_stop(struct net_device *dev) |
| 3195 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3196 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3197 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3198 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3199 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3201 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 3203 | MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3204 | adapter->session_id, adapter->device_mode)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3205 | |
| 3206 | ret = wlan_hdd_validate_context(hdd_ctx); |
Hanumantha Reddy Pothula | 2db50ed | 2015-11-23 10:48:33 +0530 | [diff] [blame] | 3207 | if (0 != ret) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3208 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3209 | |
| 3210 | /* Nothing to be done if the interface is not opened */ |
| 3211 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3212 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3213 | return -ENODEV; |
| 3214 | } |
| 3215 | |
| 3216 | /* Make sure the interface is marked as closed */ |
| 3217 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3218 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3219 | mac_handle = hdd_ctx->mac_handle; |
| 3220 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3221 | hdd_debug("Disabling Auto Power save timer"); |
| 3222 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3223 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3224 | adapter->session_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3225 | |
| 3226 | /* |
| 3227 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3228 | * be called on that interface |
| 3229 | */ |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 3230 | hdd_info("Disabling queues, adapter device mode: %s(%d)", |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3231 | hdd_device_mode_to_string(adapter->device_mode), |
| 3232 | adapter->device_mode); |
| 3233 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3234 | wlan_hdd_netif_queue_control(adapter, |
| 3235 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3236 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3237 | |
| 3238 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3239 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3240 | * bursty in nature and depends on the need to transfer. The service |
| 3241 | * layer may down the interface after the usage and up again when |
| 3242 | * required. In some sense, the NDI is expected to be available |
| 3243 | * (like SAP) iface until NDI delete request is issued by the service |
| 3244 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3245 | * interface (NDI). |
| 3246 | */ |
| 3247 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3248 | return 0; |
| 3249 | |
| 3250 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3251 | * The interface is marked as down for outside world (aka kernel) |
| 3252 | * But the driver is pretty much alive inside. The driver needs to |
| 3253 | * tear down the existing connection on the netdev (session) |
| 3254 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3255 | * for this interface. The call also needs to wait until the above |
| 3256 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3257 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3258 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3259 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3260 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | |
| 3262 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3263 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3264 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3265 | |
| 3266 | /* |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3267 | * Upon wifi turn off, DUT has to flush the scan results so if |
| 3268 | * this is the last cli iface, flush the scan database. |
| 3269 | */ |
| 3270 | if (!hdd_is_cli_iface_up(hdd_ctx)) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3271 | sme_scan_flush_result(mac_handle); |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 3272 | |
| 3273 | /* |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3274 | * Find if any iface is up. If any iface is up then can't put device to |
| 3275 | * sleep/power save mode |
| 3276 | */ |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 3277 | if (hdd_check_for_opened_interfaces(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3278 | hdd_debug("Closing all modules from the hdd_stop"); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 3279 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 3280 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 3281 | hdd_prevent_suspend_timeout( |
| 3282 | hdd_ctx->config->iface_change_wait_time, |
| 3283 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3284 | } |
| 3285 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3286 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3287 | return 0; |
| 3288 | } |
| 3289 | |
| 3290 | /** |
| 3291 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3292 | * @dev: pointer to net_device structure |
| 3293 | * |
| 3294 | * This is called in response to ifconfig down |
| 3295 | * |
| 3296 | * Return: 0 for success and error number for failure |
| 3297 | */ |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 3298 | static int hdd_stop(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3299 | { |
| 3300 | int ret; |
| 3301 | |
| 3302 | cds_ssr_protect(__func__); |
| 3303 | ret = __hdd_stop(dev); |
| 3304 | cds_ssr_unprotect(__func__); |
| 3305 | |
| 3306 | return ret; |
| 3307 | } |
| 3308 | |
| 3309 | /** |
| 3310 | * __hdd_uninit() - HDD uninit function |
| 3311 | * @dev: Pointer to net_device structure |
| 3312 | * |
| 3313 | * This is called during the netdev unregister to uninitialize all data |
| 3314 | * associated with the device |
| 3315 | * |
| 3316 | * Return: None |
| 3317 | */ |
| 3318 | static void __hdd_uninit(struct net_device *dev) |
| 3319 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3320 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3321 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3323 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3324 | |
| 3325 | do { |
| 3326 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3327 | hdd_err("Invalid magic"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3328 | break; |
| 3329 | } |
| 3330 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3331 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3332 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3333 | hdd_err("NULL hdd_ctx"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3334 | break; |
| 3335 | } |
| 3336 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3337 | if (dev != adapter->dev) |
| 3338 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3340 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | |
| 3342 | /* after uninit our adapter structure will no longer be valid */ |
| 3343 | adapter->dev = NULL; |
| 3344 | adapter->magic = 0; |
| 3345 | } while (0); |
| 3346 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3347 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3348 | } |
| 3349 | |
| 3350 | /** |
| 3351 | * hdd_uninit() - Wrapper function to protect __hdd_uninit from SSR |
| 3352 | * @dev: pointer to net_device structure |
| 3353 | * |
| 3354 | * This is called during the netdev unregister to uninitialize all data |
| 3355 | * associated with the device |
| 3356 | * |
| 3357 | * Return: none |
| 3358 | */ |
| 3359 | static void hdd_uninit(struct net_device *dev) |
| 3360 | { |
| 3361 | cds_ssr_protect(__func__); |
| 3362 | __hdd_uninit(dev); |
| 3363 | cds_ssr_unprotect(__func__); |
| 3364 | } |
| 3365 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3366 | static int hdd_open_cesium_nl_sock(void) |
| 3367 | { |
| 3368 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3369 | struct netlink_kernel_cfg cfg = { |
| 3370 | .groups = WLAN_NLINK_MCAST_GRP_ID, |
| 3371 | .input = NULL |
| 3372 | }; |
| 3373 | #endif |
| 3374 | int ret = 0; |
| 3375 | |
| 3376 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) |
| 3377 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3378 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0)) |
| 3379 | THIS_MODULE, |
| 3380 | #endif |
| 3381 | &cfg); |
| 3382 | #else |
| 3383 | cesium_nl_srv_sock = netlink_kernel_create(&init_net, WLAN_NLINK_CESIUM, |
| 3384 | WLAN_NLINK_MCAST_GRP_ID, |
| 3385 | NULL, NULL, THIS_MODULE); |
| 3386 | #endif |
| 3387 | |
| 3388 | if (cesium_nl_srv_sock == NULL) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3389 | hdd_err("NLINK: cesium netlink_kernel_create failed"); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3390 | ret = -ECONNREFUSED; |
| 3391 | } |
| 3392 | |
| 3393 | return ret; |
| 3394 | } |
| 3395 | |
| 3396 | static void hdd_close_cesium_nl_sock(void) |
| 3397 | { |
| 3398 | if (NULL != cesium_nl_srv_sock) { |
| 3399 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3400 | cesium_nl_srv_sock = NULL; |
| 3401 | } |
| 3402 | } |
| 3403 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3404 | /** |
| 3405 | * __hdd_set_mac_address() - set the user specified mac address |
| 3406 | * @dev: Pointer to the net device. |
| 3407 | * @addr: Pointer to the sockaddr. |
| 3408 | * |
| 3409 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3410 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3411 | * |
| 3412 | * Return: 0 for success, non zero for failure |
| 3413 | */ |
| 3414 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3415 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3416 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3417 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3418 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3419 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3420 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3421 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3422 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3423 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3424 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3425 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3426 | if (netif_running(dev)) { |
| 3427 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3428 | return -EBUSY; |
| 3429 | } |
| 3430 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3431 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3432 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3433 | if (0 != ret) |
| 3434 | return ret; |
| 3435 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3436 | 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] | 3437 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3438 | if (adapter_temp) { |
| 3439 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3440 | return 0; |
| 3441 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3442 | adapter_temp->dev->name, |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3443 | MAC_ADDR_ARRAY(mac_addr.bytes)); |
| 3444 | return -EINVAL; |
| 3445 | } |
| 3446 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3447 | if (qdf_is_macaddr_zero(&mac_addr)) { |
| 3448 | hdd_err("MAC is all zero"); |
| 3449 | return -EINVAL; |
| 3450 | } |
| 3451 | |
| 3452 | if (qdf_is_macaddr_broadcast(&mac_addr)) { |
| 3453 | hdd_err("MAC is Broadcast"); |
| 3454 | return -EINVAL; |
| 3455 | } |
| 3456 | |
| 3457 | if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) { |
| 3458 | hdd_err("MAC is Multicast"); |
| 3459 | return -EINVAL; |
| 3460 | } |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3461 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
| 3462 | MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3463 | |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3464 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3465 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3466 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3467 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3468 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3469 | } |
| 3470 | |
| 3471 | /** |
| 3472 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
| 3473 | * function from SSR |
| 3474 | * @dev: pointer to net_device structure |
| 3475 | * @addr: Pointer to the sockaddr |
| 3476 | * |
| 3477 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3478 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | * |
| 3480 | * Return: 0 for success. |
| 3481 | */ |
| 3482 | static int hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3483 | { |
| 3484 | int ret; |
| 3485 | |
| 3486 | cds_ssr_protect(__func__); |
| 3487 | ret = __hdd_set_mac_address(dev, addr); |
| 3488 | cds_ssr_unprotect(__func__); |
| 3489 | |
| 3490 | return ret; |
| 3491 | } |
| 3492 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3493 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3494 | { |
| 3495 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3496 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3497 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3498 | if (0 == ((hdd_ctx->config->intfAddrMask) & (1 << i))) |
| 3499 | break; |
| 3500 | } |
| 3501 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3502 | if (QDF_MAX_CONCURRENCY_PERSONA == i) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3503 | return NULL; |
| 3504 | |
| 3505 | hdd_ctx->config->intfAddrMask |= (1 << i); |
| 3506 | return &hdd_ctx->config->intfMacAddr[i].bytes[0]; |
| 3507 | } |
| 3508 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3509 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3510 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3511 | { |
| 3512 | int i; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3513 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3514 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3515 | if (!memcmp(releaseAddr, |
| 3516 | &hdd_ctx->config->intfMacAddr[i].bytes[0], |
| 3517 | 6)) { |
| 3518 | hdd_ctx->config->intfAddrMask &= ~(1 << i); |
| 3519 | break; |
| 3520 | } |
| 3521 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | } |
| 3523 | |
| 3524 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
| 3525 | /** |
| 3526 | * __hdd_set_multicast_list() - set the multicast address list |
| 3527 | * @dev: Pointer to the WLAN device. |
| 3528 | * @skb: Pointer to OS packet (sk_buff). |
| 3529 | * |
| 3530 | * This funciton sets the multicast address list. |
| 3531 | * |
| 3532 | * Return: None |
| 3533 | */ |
| 3534 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3535 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3536 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3537 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3538 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3539 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3540 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
| 3541 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 3542 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3543 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3544 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3545 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3546 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3547 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3548 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3549 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3550 | goto out; |
| 3551 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3552 | errno = hdd_validate_adapter(adapter); |
| 3553 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3554 | goto out; |
| 3555 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3556 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3557 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3558 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3559 | } |
| 3560 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3561 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
| 3562 | if (!mc_list_request) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3563 | hdd_err("Cannot allocate mc_list_request"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3564 | goto out; |
| 3565 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3566 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3567 | /* Delete already configured multicast address list */ |
| 3568 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3569 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3570 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3571 | pmo_mc_list_change_notify); |
| 3572 | } |
| 3573 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3574 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3575 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3576 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3577 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3578 | } else { |
| 3579 | mc_count = netdev_mc_count(dev); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3580 | if (mc_count > pmo_ucfg_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3581 | 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] | 3582 | pmo_ucfg_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3583 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3584 | pmo_mc_list_change_notify); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3585 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3586 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3587 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3588 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Sachin Ahuja | a69c72a | 2016-09-03 15:59:33 +0530 | [diff] [blame] | 3589 | i, MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3590 | if (i == mc_count) |
| 3591 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3592 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3593 | 0, ETH_ALEN); |
| 3594 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3595 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3596 | hdd_debug("mlist[%d] = %pM", i, |
| 3597 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3598 | i++; |
| 3599 | } |
| 3600 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3601 | |
| 3602 | mc_list_request->psoc = psoc; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3603 | mc_list_request->vdev_id = adapter->session_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3604 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3605 | |
| 3606 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3607 | if (errno) { |
| 3608 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
| 3609 | adapter->session_id, errno); |
| 3610 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3611 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3612 | |
| 3613 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3614 | |
| 3615 | free_req: |
| 3616 | qdf_mem_free(mc_list_request); |
| 3617 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3618 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3619 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3620 | } |
| 3621 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3622 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3623 | /** |
| 3624 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
| 3625 | * @dev: pointer to net_device |
| 3626 | * |
| 3627 | * Return: none |
| 3628 | */ |
| 3629 | static void hdd_set_multicast_list(struct net_device *dev) |
| 3630 | { |
| 3631 | cds_ssr_protect(__func__); |
| 3632 | __hdd_set_multicast_list(dev); |
| 3633 | cds_ssr_unprotect(__func__); |
| 3634 | } |
| 3635 | #endif |
| 3636 | |
| 3637 | /** |
| 3638 | * hdd_select_queue() - used by Linux OS to decide which queue to use first |
| 3639 | * @dev: Pointer to the WLAN device. |
| 3640 | * @skb: Pointer to OS packet (sk_buff). |
| 3641 | * |
| 3642 | * This function is registered with the Linux OS for network |
| 3643 | * core to decide which queue to use first. |
| 3644 | * |
| 3645 | * Return: ac, Queue Index/access category corresponding to UP in IP header |
| 3646 | */ |
| 3647 | static uint16_t hdd_select_queue(struct net_device *dev, struct sk_buff *skb |
| 3648 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) |
| 3649 | , void *accel_priv |
| 3650 | #endif |
| 3651 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) |
| 3652 | , select_queue_fallback_t fallback |
| 3653 | #endif |
| 3654 | ) |
| 3655 | { |
| 3656 | return hdd_wmm_select_queue(dev, skb); |
| 3657 | } |
| 3658 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3659 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3660 | .ndo_open = hdd_open, |
| 3661 | .ndo_stop = hdd_stop, |
| 3662 | .ndo_uninit = hdd_uninit, |
| 3663 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3664 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3665 | .ndo_get_stats = hdd_get_stats, |
| 3666 | .ndo_do_ioctl = hdd_ioctl, |
| 3667 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3668 | .ndo_select_queue = hdd_select_queue, |
| 3669 | #ifdef WLAN_FEATURE_PACKET_FILTERING |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3670 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3671 | #endif |
| 3672 | }; |
| 3673 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3674 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3675 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3676 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3677 | .ndo_open = hdd_mon_open, |
| 3678 | .ndo_stop = hdd_stop, |
| 3679 | .ndo_get_stats = hdd_get_stats, |
| 3680 | }; |
| 3681 | |
| 3682 | /** |
| 3683 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3684 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3685 | * Return: None |
| 3686 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3687 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3689 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3690 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3691 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3692 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3693 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3694 | #else |
| 3695 | void hdd_set_station_ops(struct net_device *dev) |
| 3696 | { |
| 3697 | dev->netdev_ops = &wlan_drv_ops; |
| 3698 | } |
| 3699 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3700 | |
| 3701 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3702 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3703 | * @hdd_ctx: global hdd context |
| 3704 | * @macAddr: mac address to assign to the interface |
| 3705 | * @name: User-visible name of the interface |
| 3706 | * |
| 3707 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3708 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3709 | * |
| 3710 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3711 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3712 | 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] | 3713 | tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3714 | unsigned char name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3715 | const char *name) |
| 3716 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3717 | struct net_device *dev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3718 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3719 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3720 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3721 | /* |
| 3722 | * cfg80211 initialization and registration.... |
| 3723 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3724 | dev = alloc_netdev_mq(sizeof(struct hdd_adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3725 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
| 3726 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3727 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3728 | (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam() ? |
| 3729 | hdd_mon_mode_ether_setup : ether_setup), |
| 3730 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3731 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3732 | if (dev != NULL) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3733 | |
| 3734 | /* Save the pointer to the net_device in the HDD adapter */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3735 | adapter = (struct hdd_adapter *) netdev_priv(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3736 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3737 | qdf_mem_zero(adapter, sizeof(struct hdd_adapter)); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 3738 | sta_ctx = &adapter->session.station; |
Hanumanth Reddy Pothula | 18553ae | 2017-04-28 15:03:10 +0530 | [diff] [blame] | 3739 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 3740 | sizeof(sta_ctx->conn_info.staId), |
| 3741 | HDD_WLAN_INVALID_STA_ID); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3742 | adapter->dev = dev; |
Jeff Johnson | dba0db6 | 2017-08-30 11:12:39 -0700 | [diff] [blame] | 3743 | adapter->hdd_ctx = hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3744 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3745 | adapter->session_id = HDD_SESSION_ID_INVALID; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3746 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3747 | qdf_status = qdf_event_create( |
| 3748 | &adapter->qdf_session_open_event); |
| 3749 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3750 | hdd_err("Session open QDF event init failed!"); |
| 3751 | free_netdev(adapter->dev); |
| 3752 | return NULL; |
| 3753 | } |
| 3754 | |
| 3755 | qdf_status = qdf_event_create( |
| 3756 | &adapter->qdf_session_close_event); |
| 3757 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 3758 | hdd_err("Session close QDF event init failed!"); |
| 3759 | free_netdev(adapter->dev); |
| 3760 | return NULL; |
| 3761 | } |
| 3762 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3763 | init_completion(&adapter->disconnect_comp_var); |
Abhishek Singh | 533c9da | 2017-05-04 10:23:34 +0530 | [diff] [blame] | 3764 | init_completion(&adapter->roaming_comp_var); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3765 | init_completion(&adapter->linkup_event_var); |
| 3766 | init_completion(&adapter->cancel_rem_on_chan_var); |
| 3767 | init_completion(&adapter->rem_on_chan_ready_event); |
| 3768 | init_completion(&adapter->sta_authorized_event); |
| 3769 | init_completion(&adapter->offchannel_tx_event); |
| 3770 | init_completion(&adapter->tx_action_cnf_event); |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3771 | init_completion(&adapter->ibss_peer_info_comp); |
Sreelakshmi Konamki | 88a2a41 | 2017-04-14 15:11:55 +0530 | [diff] [blame] | 3772 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3773 | |
| 3774 | adapter->offloads_configured = false; |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 3775 | adapter->is_link_up_service_needed = false; |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 3776 | adapter->disconnection_in_progress = false; |
Yeshwanth Sriram Guntuka | 4fe30bd | 2018-06-13 11:41:42 +0530 | [diff] [blame] | 3777 | adapter->send_mode_change = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3778 | /* Init the net_device structure */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3779 | strlcpy(dev->name, name, IFNAMSIZ); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3780 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3781 | qdf_mem_copy(dev->dev_addr, (void *)macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3782 | sizeof(tSirMacAddr)); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3783 | qdf_mem_copy(adapter->mac_addr.bytes, macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3784 | sizeof(tSirMacAddr)); |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3785 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3786 | |
| 3787 | if (hdd_ctx->config->enable_ip_tcp_udp_checksum_offload) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3788 | dev->features |= |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3789 | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3790 | dev->features |= NETIF_F_RXCSUM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3791 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3792 | hdd_set_tso_flags(hdd_ctx, dev); |
Dhanashri Atre | 83d373d | 2015-07-28 16:45:59 -0700 | [diff] [blame] | 3793 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3794 | hdd_set_station_ops(adapter->dev); |
| 3795 | |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3796 | hdd_dev_setup_destructor(dev); |
| 3797 | dev->ieee80211_ptr = &adapter->wdev; |
| 3798 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3799 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3800 | adapter->wdev.netdev = dev; |
| 3801 | /* set dev's parent to underlying device */ |
| 3802 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3803 | hdd_wmm_init(adapter); |
| 3804 | spin_lock_init(&adapter->pause_map_lock); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 3805 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3806 | } |
| 3807 | |
| 3808 | return adapter; |
| 3809 | } |
| 3810 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3811 | 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] | 3812 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3813 | struct net_device *dev = adapter->dev; |
| 3814 | int ret; |
| 3815 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3816 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3817 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3818 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3819 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3820 | |
| 3821 | ret = dev_alloc_name(dev, dev->name); |
| 3822 | if (ret < 0) { |
| 3823 | hdd_err( |
| 3824 | "unable to get dev name: %s, err = 0x%x", |
| 3825 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3826 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3827 | } |
| 3828 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3829 | |
| 3830 | ret = register_netdevice(dev); |
| 3831 | if (ret) { |
| 3832 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3833 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3834 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3835 | } |
| 3836 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3837 | ret = register_netdev(dev); |
| 3838 | if (ret) { |
| 3839 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3840 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3841 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3842 | } |
| 3843 | } |
| 3844 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3845 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3846 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3847 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3848 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3849 | } |
| 3850 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3851 | QDF_STATUS hdd_sme_open_session_callback(uint8_t session_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3852 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3853 | struct hdd_adapter *adapter; |
| 3854 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3855 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3856 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3857 | if (!hdd_ctx) { |
| 3858 | hdd_err("Invalid HDD_CTX"); |
| 3859 | return QDF_STATUS_E_FAILURE; |
| 3860 | } |
| 3861 | |
| 3862 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 3863 | if (NULL == adapter) { |
Naveen Rawat | 23a3b91 | 2018-05-30 17:45:52 -0700 | [diff] [blame] | 3864 | hdd_err("NULL adapter for %d", session_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3865 | return QDF_STATUS_E_INVAL; |
| 3866 | } |
| 3867 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3868 | qdf_event_set(&adapter->qdf_session_open_event); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3869 | hdd_debug("session %d opened", adapter->session_id); |
| 3870 | |
| 3871 | return QDF_STATUS_SUCCESS; |
| 3872 | } |
| 3873 | |
| 3874 | QDF_STATUS hdd_sme_close_session_callback(uint8_t session_id) |
| 3875 | { |
| 3876 | struct hdd_adapter *adapter; |
| 3877 | struct hdd_context *hdd_ctx; |
| 3878 | |
| 3879 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3880 | if (!hdd_ctx) { |
| 3881 | hdd_err("Invalid HDD_CTX"); |
| 3882 | return QDF_STATUS_E_FAILURE; |
| 3883 | } |
| 3884 | |
| 3885 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3886 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3887 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3888 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3889 | } |
| 3890 | |
| 3891 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3892 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3893 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3894 | } |
| 3895 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3896 | /* |
| 3897 | * For NAN Data interface, the close session results in the final |
| 3898 | * indication to the userspace |
| 3899 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 3900 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3901 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3902 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3903 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3904 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3905 | /* |
| 3906 | * We can be blocked while waiting for scheduled work to be |
| 3907 | * flushed, and the adapter structure can potentially be freed, in |
| 3908 | * which case the magic will have been reset. So make sure the |
| 3909 | * magic is still good, and hence the adapter structure is still |
| 3910 | * valid, before signaling completion |
| 3911 | */ |
| 3912 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3913 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3915 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3916 | } |
| 3917 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3918 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3919 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3920 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3921 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3922 | status = pmo_vdev_ready(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3923 | if (QDF_IS_STATUS_ERROR(status)) |
| 3924 | return qdf_status_to_os_return(status); |
| 3925 | |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3926 | status = ucfg_reg_11d_vdev_created_update(adapter->hdd_vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 3927 | if (QDF_IS_STATUS_ERROR(status)) |
| 3928 | return qdf_status_to_os_return(status); |
| 3929 | |
| 3930 | if (wma_capability_enhanced_mcast_filter()) |
| 3931 | status = pmo_ucfg_enhanced_mc_filter_enable(adapter->hdd_vdev); |
| 3932 | else |
| 3933 | status = pmo_ucfg_enhanced_mc_filter_disable(adapter->hdd_vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3934 | |
| 3935 | return qdf_status_to_os_return(status); |
| 3936 | } |
| 3937 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3938 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3939 | { |
| 3940 | QDF_STATUS status; |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3941 | int errno = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3942 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3943 | uint8_t vdev_id; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3944 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 3945 | vdev_id = adapter->session_id; |
| 3946 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3947 | |
| 3948 | /* vdev created sanity check */ |
| 3949 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 3950 | hdd_err("vdev for Id %d does not exist", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3951 | return -EINVAL; |
| 3952 | } |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 3953 | status = ucfg_reg_11d_vdev_delete_update(adapter->hdd_vdev); |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 3954 | ucfg_scan_set_vdev_del_in_progress(adapter->hdd_vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3955 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3956 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3957 | qdf_event_reset(&adapter->qdf_session_close_event); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3958 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3959 | status = sme_close_session(hdd_ctx->mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3960 | if (QDF_IS_STATUS_ERROR(status)) { |
| 3961 | hdd_err("failed to close sme session: %d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3962 | errno = qdf_status_to_os_return(status); |
| 3963 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3964 | } |
| 3965 | |
| 3966 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3967 | status = qdf_wait_for_event_completion( |
| 3968 | &adapter->qdf_session_close_event, |
| 3969 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 3970 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3971 | if (adapter->device_mode == QDF_NDI_MODE) |
| 3972 | hdd_ndp_session_end_handler(adapter); |
| 3973 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3974 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 3975 | if (QDF_STATUS_E_TIMEOUT != status) { |
| 3976 | hdd_err("timed out waiting for close sme session: %u", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3977 | errno = -ETIMEDOUT; |
| 3978 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3979 | } else if (adapter->qdf_session_close_event.force_set) { |
| 3980 | hdd_err("Session close evt focefully set, SSR/PDR has occurred"); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3981 | errno = -EINVAL; |
| 3982 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3983 | } else { |
| 3984 | hdd_err("Failed to close sme session (%u)", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3985 | errno = -EINVAL; |
| 3986 | goto release_vdev; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3987 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 3988 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3989 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 3990 | release_vdev: |
Krunal Soni | 8a06d83 | 2018-06-20 16:41:17 -0700 | [diff] [blame] | 3991 | ucfg_scan_clear_vdev_del_in_progress(adapter->hdd_vdev); |
Frank Liu | c66d4bf | 2018-01-26 16:18:18 +0800 | [diff] [blame] | 3992 | /* |
| 3993 | * In SSR or driver unloading case, directly exit may cause objects |
| 3994 | * leak, if sme_close_session failed. Free objects anyway. |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3995 | */ |
Kabilan Kannan | b867c31 | 2018-02-15 17:43:21 -0800 | [diff] [blame] | 3996 | if (errno && !cds_is_driver_recovering() && !cds_is_driver_unloading()) |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 3997 | return errno; |
| 3998 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 3999 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4000 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4001 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4002 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4003 | return errno; |
| 4004 | } |
| 4005 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4006 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4007 | |
| 4008 | return 0; |
| 4009 | } |
| 4010 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4011 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4012 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4013 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4014 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4015 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4016 | uint32_t type; |
| 4017 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4018 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4019 | |
| 4020 | /* determine vdev (sub)type */ |
| 4021 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4022 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4023 | hdd_err("failed to get vdev type: %d", status); |
| 4024 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4025 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4026 | session_param->sme_session_id = adapter->session_id; |
| 4027 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4028 | session_param->type_of_persona = type; |
| 4029 | session_param->subtype_of_persona = sub_type; |
| 4030 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4031 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4032 | session_param->callback = callback; |
| 4033 | session_param->callback_ctx = callback_ctx; |
| 4034 | |
| 4035 | return 0; |
| 4036 | } |
| 4037 | |
| 4038 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4039 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4040 | { |
| 4041 | QDF_STATUS status; |
| 4042 | int errno; |
| 4043 | struct hdd_context *hdd_ctx; |
| 4044 | struct sme_session_params sme_session_params = {0}; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4045 | |
| 4046 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4047 | |
| 4048 | /* do vdev create via objmgr */ |
| 4049 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4050 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->hdd_pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4051 | if (errno) { |
| 4052 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4053 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4054 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4055 | |
| 4056 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4057 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4058 | if (QDF_STATUS_SUCCESS != status) { |
| 4059 | hdd_err("failed to reinit session open event"); |
| 4060 | return -EINVAL; |
| 4061 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4062 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4063 | callback, ctx); |
| 4064 | if (errno) { |
| 4065 | hdd_err("failed to populating SME params"); |
| 4066 | goto objmgr_vdev_destroy_procedure; |
| 4067 | } |
| 4068 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4069 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4070 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4071 | hdd_err("failed to open sme session: %d", status); |
| 4072 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4073 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4074 | } |
| 4075 | |
| 4076 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4077 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
| 4078 | WLAN_WAIT_TIME_SESSIONOPENCLOSE); |
| 4079 | if (QDF_STATUS_SUCCESS != status) { |
| 4080 | if (adapter->qdf_session_open_event.force_set) { |
| 4081 | /* |
| 4082 | * SSR/PDR has caused shutdown, which has forcefully |
| 4083 | * set the event. Return without the closing session. |
| 4084 | */ |
| 4085 | adapter->session_id = HDD_SESSION_ID_INVALID; |
| 4086 | hdd_err("Session open event forcefully set"); |
| 4087 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4088 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4089 | |
| 4090 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4091 | hdd_err("Session failed to open within timeout period"); |
| 4092 | else |
| 4093 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4094 | status); |
| 4095 | errno = -ETIMEDOUT; |
| 4096 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4097 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4098 | } |
| 4099 | |
| 4100 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4101 | errno = hdd_vdev_ready(adapter); |
| 4102 | if (errno) { |
| 4103 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4104 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4105 | } |
| 4106 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4107 | if (adapter->device_mode == QDF_STA_MODE) { |
| 4108 | hdd_debug("setting RTT mac randomization param: %d", |
| 4109 | hdd_ctx->config->enable_rtt_mac_randomization); |
| 4110 | errno = sme_cli_set_command(adapter->session_id, |
| 4111 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
| 4112 | hdd_ctx->config->enable_rtt_mac_randomization, |
| 4113 | VDEV_CMD); |
| 4114 | if (0 != errno) |
| 4115 | hdd_err("RTT mac randomization param set failed %d", |
| 4116 | errno); |
| 4117 | } |
| 4118 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4119 | if (adapter->device_mode == QDF_STA_MODE || |
| 4120 | adapter->device_mode == QDF_P2P_CLIENT_MODE) |
| 4121 | wlan_vdev_set_max_peer_count(adapter->hdd_vdev, |
| 4122 | HDD_MAX_VDEV_PEER_COUNT); |
| 4123 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4124 | hdd_info("vdev %d created successfully", adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4125 | |
| 4126 | return 0; |
| 4127 | |
| 4128 | /* |
| 4129 | * Due to legacy constraints, we need to destroy in the same order as |
| 4130 | * create. So, split error handling into 2 cases to accommodate. |
| 4131 | */ |
| 4132 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4133 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4134 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4135 | |
| 4136 | return errno; |
| 4137 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4138 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4139 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4140 | |
| 4141 | return errno; |
| 4142 | } |
| 4143 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4144 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4145 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4146 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4147 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4148 | QDF_STATUS status; |
| 4149 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4150 | mac_handle_t mac_handle; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4151 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4152 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4153 | mac_handle = hdd_ctx->mac_handle; |
| 4154 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
| 4155 | sme_set_pdev_ht_vht_ies(mac_handle, hdd_ctx->config->enable2x2); |
| 4156 | sme_set_vdev_ies_per_band(mac_handle, adapter->session_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4157 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4158 | hdd_roam_profile_init(adapter); |
| 4159 | hdd_register_wext(adapter->dev); |
| 4160 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4161 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4162 | |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4163 | qdf_mem_set(sta_ctx->conn_info.staId, |
| 4164 | sizeof(sta_ctx->conn_info.staId), HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4165 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4166 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4167 | status = sme_config_fast_roaming(mac_handle, adapter->session_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4168 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4169 | /* Set the default operation channel */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4170 | sta_ctx->conn_info.operationChannel = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4171 | hdd_ctx->config->OperatingChannel; |
| 4172 | |
| 4173 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 4174 | sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4175 | |
| 4176 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4177 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4178 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4179 | status, status); |
| 4180 | goto error_init_txrx; |
| 4181 | } |
| 4182 | |
| 4183 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4184 | |
| 4185 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4186 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4187 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4188 | status, status); |
| 4189 | goto error_wmm_init; |
| 4190 | } |
| 4191 | |
| 4192 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4193 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4194 | ret_val = sme_cli_set_command(adapter->session_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4195 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4196 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4197 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4198 | if (ret_val) |
| 4199 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4200 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4201 | /* |
| 4202 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4203 | * during that time, then as part of SSR init, do not enable |
| 4204 | * the LRO again. Keep the LRO state same as before SSR. |
| 4205 | */ |
| 4206 | if (!(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4207 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4208 | |
| 4209 | /* rcpi info initialization */ |
| 4210 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4211 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4212 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4213 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4214 | error_wmm_init: |
| 4215 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4216 | hdd_deinit_tx_rx(adapter); |
| 4217 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4218 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4219 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4220 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4221 | return status; |
| 4222 | } |
| 4223 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4224 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4225 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4226 | * @hdd_ctx: global hdd context |
| 4227 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4228 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4229 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4230 | * |
| 4231 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4232 | * |
| 4233 | * Return: None. |
| 4234 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4235 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4236 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4237 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4238 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4239 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4240 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4241 | if (adapter->dev) { |
| 4242 | if (rtnl_held) |
| 4243 | adapter->dev->wireless_handlers = NULL; |
| 4244 | else { |
| 4245 | rtnl_lock(); |
| 4246 | adapter->dev->wireless_handlers = NULL; |
| 4247 | rtnl_unlock(); |
| 4248 | } |
| 4249 | } |
| 4250 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4251 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4252 | hdd_deinit_tx_rx(adapter); |
| 4253 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4254 | } |
| 4255 | |
| 4256 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4257 | hdd_wmm_adapter_close(adapter); |
| 4258 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4259 | } |
| 4260 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4261 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4262 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4263 | } |
| 4264 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4265 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4266 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4267 | bool rtnl_held) |
| 4268 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4269 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4270 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4271 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4272 | case QDF_STA_MODE: |
| 4273 | case QDF_P2P_CLIENT_MODE: |
| 4274 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4275 | case QDF_IBSS_MODE: |
| 4276 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4277 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4278 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4279 | break; |
| 4280 | } |
| 4281 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4282 | case QDF_SAP_MODE: |
| 4283 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4284 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4285 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4286 | break; |
| 4287 | } |
| 4288 | |
| 4289 | default: |
| 4290 | break; |
| 4291 | } |
| 4292 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4293 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4294 | } |
| 4295 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4296 | 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] | 4297 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4298 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4299 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4300 | |
| 4301 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4302 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4303 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4304 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4305 | return; |
| 4306 | } |
| 4307 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4308 | hdd_nud_deinit_tracking(adapter); |
| 4309 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4310 | hdd_apf_context_destroy(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4311 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4312 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4313 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4314 | /* |
| 4315 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4316 | * the driver is almost closed and cannot handle either control |
| 4317 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4318 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4319 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4320 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4321 | * the interface is closed and restricts any operations on that |
| 4322 | */ |
| 4323 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4324 | |
| 4325 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4326 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4327 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4328 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4329 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4330 | /* |
| 4331 | * Note that the adapter is no longer valid at this point |
| 4332 | * since the memory has been reclaimed |
| 4333 | */ |
| 4334 | } |
| 4335 | } |
| 4336 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4337 | 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] | 4338 | tSirMacAddr macAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4339 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4340 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4341 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4342 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4343 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 4344 | macAddr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4345 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4346 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4347 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4348 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4349 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4350 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4351 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4352 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4353 | /** |
| 4354 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4355 | * @hdd_ctx: HDD Context |
| 4356 | * @adapter: HDD Adapter |
| 4357 | * |
| 4358 | * This function set the FW Debug log level based on the INI. |
| 4359 | * |
| 4360 | * Return: None |
| 4361 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4362 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4363 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4364 | { |
| 4365 | uint8_t count = 0, numentries = 0, |
| 4366 | moduleloglevel[FW_MODULE_LOG_LEVEL_STRING_LENGTH]; |
| 4367 | uint32_t value = 0; |
| 4368 | int ret; |
| 4369 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4370 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4371 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4372 | 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] | 4373 | return; |
| 4374 | } |
| 4375 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4376 | /* Enable FW logs based on INI configuration */ |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4377 | hdd_ctx->fw_log_settings.dl_type = |
| 4378 | hdd_ctx->config->enableFwLogType; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4379 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4380 | WMI_DBGLOG_TYPE, |
| 4381 | hdd_ctx->config->enableFwLogType, |
| 4382 | DBG_CMD); |
| 4383 | if (ret != 0) |
| 4384 | hdd_err("Failed to enable FW log type ret %d", |
| 4385 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4386 | |
| 4387 | hdd_ctx->fw_log_settings.dl_loglevel = |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4388 | hdd_ctx->config->enableFwLogLevel; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4389 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4390 | WMI_DBGLOG_LOG_LEVEL, |
| 4391 | hdd_ctx->config->enableFwLogLevel, |
| 4392 | DBG_CMD); |
| 4393 | if (ret != 0) |
| 4394 | hdd_err("Failed to enable FW log level ret %d", |
| 4395 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4396 | |
| 4397 | hdd_string_to_u8_array( |
| 4398 | hdd_ctx->config->enableFwModuleLogLevel, |
| 4399 | moduleloglevel, |
| 4400 | &numentries, |
| 4401 | FW_MODULE_LOG_LEVEL_STRING_LENGTH); |
| 4402 | |
| 4403 | while (count < numentries) { |
| 4404 | /* |
| 4405 | * FW module log level input string looks like |
| 4406 | * below: |
| 4407 | * gFwDebugModuleLoglevel=<FW Module ID>, |
| 4408 | * <Log Level>,... |
| 4409 | * For example: |
| 4410 | * gFwDebugModuleLoglevel= |
| 4411 | * 1,0,2,1,3,2,4,3,5,4,6,5,7,6 |
| 4412 | * Above input string means : |
| 4413 | * For FW module ID 1 enable log level 0 |
| 4414 | * For FW module ID 2 enable log level 1 |
| 4415 | * For FW module ID 3 enable log level 2 |
| 4416 | * For FW module ID 4 enable log level 3 |
| 4417 | * For FW module ID 5 enable log level 4 |
| 4418 | * For FW module ID 6 enable log level 5 |
| 4419 | * For FW module ID 7 enable log level 6 |
| 4420 | */ |
| 4421 | |
Nishank Aggarwal | e239d96 | 2017-03-03 12:26:02 +0530 | [diff] [blame] | 4422 | if ((moduleloglevel[count] > WLAN_MODULE_ID_MAX) |
| 4423 | || (moduleloglevel[count + 1] > DBGLOG_LVL_MAX)) { |
| 4424 | hdd_err("Module id %d and dbglog level %d input length is more than max", |
| 4425 | moduleloglevel[count], |
| 4426 | moduleloglevel[count + 1]); |
| 4427 | return; |
| 4428 | } |
| 4429 | |
| 4430 | value = moduleloglevel[count] << 16; |
| 4431 | value |= moduleloglevel[count + 1]; |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4432 | ret = sme_cli_set_command(adapter->session_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4433 | WMI_DBGLOG_MOD_LOG_LEVEL, |
| 4434 | value, DBG_CMD); |
| 4435 | if (ret != 0) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4436 | hdd_err("Failed to enable FW module log level %d ret %d", |
| 4437 | value, ret); |
| 4438 | |
| 4439 | count += 2; |
| 4440 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4441 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4442 | } |
| 4443 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4444 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4445 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4446 | { |
| 4447 | } |
| 4448 | |
| 4449 | #endif |
| 4450 | |
| 4451 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4452 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4453 | * @adapter: HDD adapter |
| 4454 | * |
| 4455 | * Return: 0 on success or errno on failure |
| 4456 | */ |
| 4457 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4458 | { |
| 4459 | int ret_val; |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4460 | QDF_STATUS status; |
| 4461 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4462 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4463 | |
| 4464 | hdd_debug("enable2x2: %d, lte_coex: %d, ChainMask1x1: tx: %d rx: %d", |
| 4465 | hdd_ctx->config->enable2x2, hdd_ctx->lte_coex_ant_share, |
| 4466 | hdd_ctx->config->txchainmask1x1, |
| 4467 | hdd_ctx->config->rxchainmask1x1); |
| 4468 | hdd_debug("disable_DBS: %d, tx_chain_mask_2g: %d, rx_chain_mask_2g: %d", |
| 4469 | hdd_ctx->config->dual_mac_feature_disable, |
| 4470 | hdd_ctx->config->tx_chain_mask_2g, |
| 4471 | hdd_ctx->config->rx_chain_mask_2g); |
| 4472 | hdd_debug("tx_chain_mask_5g: %d, rx_chain_mask_5g: %d", |
| 4473 | hdd_ctx->config->tx_chain_mask_5g, |
| 4474 | hdd_ctx->config->rx_chain_mask_5g); |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4475 | hdd_debug("enable_bt_chain_separation %d", |
| 4476 | hdd_ctx->config->enable_bt_chain_separation); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4477 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4478 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4479 | HW_MODE_DBS_NONE, |
| 4480 | CDS_BAND_ALL); |
| 4481 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4482 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4483 | return qdf_status_to_os_return(status); |
| 4484 | } |
| 4485 | |
| 4486 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4487 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4488 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4489 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
| 4490 | hdd_info("firmware not capable. skip chain mask programming"); |
| 4491 | return 0; |
| 4492 | } |
| 4493 | |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4494 | if (hdd_ctx->config->enable2x2 && |
| 4495 | !hdd_ctx->config->enable_bt_chain_separation) { |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4496 | hdd_info("2x2 enabled. skip chain mask programming"); |
| 4497 | return 0; |
| 4498 | } |
| 4499 | |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4500 | if (hdd_ctx->config->dual_mac_feature_disable != |
| 4501 | DISABLE_DBS_CXN_AND_SCAN) { |
| 4502 | hdd_info("DBS enabled(%d). skip chain mask programming", |
| 4503 | hdd_ctx->config->dual_mac_feature_disable); |
| 4504 | return 0; |
| 4505 | } |
| 4506 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4507 | if (hdd_ctx->lte_coex_ant_share) { |
| 4508 | hdd_info("lte ant sharing enabled. skip chainmask programming"); |
| 4509 | return 0; |
| 4510 | } |
| 4511 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4512 | if (hdd_ctx->config->txchainmask1x1) { |
| 4513 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4514 | WMI_PDEV_PARAM_TX_CHAIN_MASK, |
| 4515 | hdd_ctx->config->txchainmask1x1, |
| 4516 | PDEV_CMD); |
| 4517 | if (ret_val) |
| 4518 | goto error; |
| 4519 | } |
| 4520 | |
| 4521 | if (hdd_ctx->config->rxchainmask1x1) { |
| 4522 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4523 | WMI_PDEV_PARAM_RX_CHAIN_MASK, |
| 4524 | hdd_ctx->config->rxchainmask1x1, |
| 4525 | PDEV_CMD); |
| 4526 | if (ret_val) |
| 4527 | goto error; |
| 4528 | } |
| 4529 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4530 | if (hdd_ctx->config->txchainmask1x1 || |
| 4531 | hdd_ctx->config->rxchainmask1x1) { |
| 4532 | hdd_info("band agnostic tx/rx chain mask set. skip per band chain mask"); |
| 4533 | return 0; |
| 4534 | } |
| 4535 | |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4536 | if (hdd_ctx->config->tx_chain_mask_2g) { |
| 4537 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4538 | WMI_PDEV_PARAM_TX_CHAIN_MASK_2G, |
| 4539 | hdd_ctx->config->tx_chain_mask_2g, PDEV_CMD); |
| 4540 | if (0 != ret_val) |
| 4541 | goto error; |
| 4542 | } |
| 4543 | |
| 4544 | if (hdd_ctx->config->rx_chain_mask_2g) { |
| 4545 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4546 | WMI_PDEV_PARAM_RX_CHAIN_MASK_2G, |
| 4547 | hdd_ctx->config->rx_chain_mask_2g, PDEV_CMD); |
| 4548 | if (0 != ret_val) |
| 4549 | goto error; |
| 4550 | } |
| 4551 | |
| 4552 | if (hdd_ctx->config->tx_chain_mask_5g) { |
| 4553 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4554 | WMI_PDEV_PARAM_TX_CHAIN_MASK_5G, |
| 4555 | hdd_ctx->config->tx_chain_mask_5g, PDEV_CMD); |
| 4556 | if (0 != ret_val) |
| 4557 | goto error; |
| 4558 | } |
| 4559 | |
| 4560 | if (hdd_ctx->config->rx_chain_mask_5g) { |
| 4561 | ret_val = sme_cli_set_command(adapter->session_id, |
| 4562 | WMI_PDEV_PARAM_RX_CHAIN_MASK_5G, |
| 4563 | hdd_ctx->config->rx_chain_mask_5g, PDEV_CMD); |
| 4564 | if (0 != ret_val) |
| 4565 | goto error; |
| 4566 | } |
| 4567 | |
| 4568 | return 0; |
| 4569 | |
| 4570 | error: |
| 4571 | hdd_err("WMI PDEV set param failed %d", ret_val); |
| 4572 | return -EINVAL; |
| 4573 | } |
| 4574 | |
| 4575 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4576 | * hdd_set_fw_params() - Set parameters to firmware |
| 4577 | * @adapter: HDD adapter |
| 4578 | * |
| 4579 | * This function Sets various parameters to fw once the |
| 4580 | * adapter is started. |
| 4581 | * |
| 4582 | * Return: 0 on success or errno on failure |
| 4583 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4584 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4585 | { |
| 4586 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4587 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4588 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4589 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4590 | |
| 4591 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4592 | if (!hdd_ctx) |
| 4593 | return -EINVAL; |
| 4594 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4595 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4596 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4597 | return 0; |
| 4598 | } |
| 4599 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4600 | ret = sme_cli_set_command(adapter->session_id, |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4601 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4602 | hdd_ctx->config->enable_lprx, PDEV_CMD); |
| 4603 | if (ret) { |
| 4604 | hdd_err("Failed to set LPRx"); |
| 4605 | goto error; |
| 4606 | } |
| 4607 | |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4608 | |
| 4609 | ret = sme_cli_set_command( |
| 4610 | adapter->session_id, |
| 4611 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
| 4612 | hdd_ctx->config->enable_dtim_selection_diversity, |
| 4613 | PDEV_CMD); |
| 4614 | if (ret) { |
| 4615 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4616 | goto error; |
| 4617 | } |
| 4618 | |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4619 | ret = sme_cli_set_command( |
| 4620 | adapter->session_id, |
| 4621 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4622 | hdd_ctx->config->enable_tx_sch_delay, |
| 4623 | PDEV_CMD); |
| 4624 | if (ret) { |
| 4625 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4626 | goto error; |
| 4627 | } |
| 4628 | |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4629 | ret = sme_cli_set_command( |
| 4630 | adapter->session_id, |
| 4631 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4632 | hdd_ctx->config->enable_secondary_rate, |
| 4633 | PDEV_CMD); |
| 4634 | if (ret) { |
| 4635 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4636 | goto error; |
| 4637 | } |
| 4638 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4639 | if (adapter->device_mode == QDF_STA_MODE) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4640 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4641 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4642 | hdd_ctx->config->upper_brssi_thresh); |
| 4643 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4644 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4645 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4646 | hdd_ctx->config->lower_brssi_thresh); |
| 4647 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4648 | sme_set_smps_cfg(adapter->session_id, |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4649 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4650 | hdd_ctx->config->enable_dtim_1chrx); |
| 4651 | } |
| 4652 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4653 | if (hdd_ctx->config->enable2x2) { |
| 4654 | hdd_debug("configuring 2x2 mode fw params"); |
| 4655 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4656 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4657 | WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE, |
| 4658 | hdd_ctx->config->enable_cck_tx_fir_override, |
| 4659 | PDEV_CMD); |
| 4660 | if (ret) { |
| 4661 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4662 | ret); |
| 4663 | goto error; |
| 4664 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4665 | |
| 4666 | if (hdd_configure_chain_mask(adapter)) |
| 4667 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4668 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4669 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4670 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4671 | hdd_debug("configuring 1x1 mode fw params"); |
| 4672 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4673 | /* |
| 4674 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4675 | * we are passing two value |
| 4676 | * as param_id << 29 | param_value. |
| 4677 | * Below param_value = 0(disable) |
| 4678 | */ |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4679 | ret = sme_cli_set_command(adapter->session_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4680 | WMI_STA_SMPS_PARAM_CMDID, |
| 4681 | HDD_DTIM_1CHAIN_RX_ID << |
| 4682 | HDD_SMPS_PARAM_VALUE_S, |
| 4683 | VDEV_CMD); |
| 4684 | if (ret) { |
| 4685 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4686 | goto error; |
| 4687 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4688 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4689 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4690 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4691 | |
| 4692 | if (hdd_configure_chain_mask(adapter)) |
| 4693 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4694 | } |
| 4695 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4696 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4697 | WMI_PDEV_PARAM_HYST_EN, |
| 4698 | hdd_ctx->config->enableMemDeepSleep, |
| 4699 | PDEV_CMD); |
| 4700 | if (ret) { |
| 4701 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4702 | goto error; |
| 4703 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4704 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4705 | ret = sme_cli_set_command(adapter->session_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4706 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
| 4707 | hdd_ctx->config->rts_profile, |
| 4708 | VDEV_CMD); |
| 4709 | if (ret) { |
| 4710 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4711 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4712 | } |
| 4713 | |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4714 | hdd_debug("SET AMSDU num %d", hdd_ctx->config->max_amsdu_num); |
| 4715 | |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 4716 | ret = wma_cli_set_command(adapter->session_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4717 | GEN_VDEV_PARAM_AMSDU, |
| 4718 | hdd_ctx->config->max_amsdu_num, |
| 4719 | GEN_CMD); |
| 4720 | if (ret != 0) { |
| 4721 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4722 | goto error; |
| 4723 | } |
| 4724 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4725 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4726 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4727 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4728 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4729 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4730 | error: |
| 4731 | return -EINVAL; |
| 4732 | } |
| 4733 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4734 | /** |
| 4735 | * hdd_open_adapter() - open and setup the hdd adatper |
| 4736 | * @hdd_ctx: global hdd context |
| 4737 | * @session_type: type of the interface to be created |
| 4738 | * @iface_name: User-visible name of the interface |
| 4739 | * @macAddr: MAC address to assign to the interface |
| 4740 | * @name_assign_type: the name of assign type of the netdev |
| 4741 | * @rtnl_held: the rtnl lock hold flag |
| 4742 | * |
| 4743 | * This function open and setup the hdd adpater according to the device |
| 4744 | * type request, assign the name, the mac address assigned, and then prepared |
| 4745 | * the hdd related parameters, queue, lock and ready to start. |
| 4746 | * |
| 4747 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 4748 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4749 | 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] | 4750 | const char *iface_name, tSirMacAddr macAddr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4751 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 4752 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4753 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4754 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4755 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4756 | |
| 4757 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 4758 | /* |
| 4759 | * Max limit reached on the number of vdevs configured by the |
| 4760 | * host. Return error |
| 4761 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4762 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 4763 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4764 | return NULL; |
| 4765 | } |
| 4766 | |
| 4767 | if (macAddr == NULL) { |
| 4768 | /* Not received valid macAddr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4769 | 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] | 4770 | return NULL; |
| 4771 | } |
| 4772 | status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4773 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4774 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 4775 | " already exists", |
| 4776 | MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4777 | return NULL; |
| 4778 | } |
| 4779 | |
| 4780 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4781 | case QDF_STA_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4782 | /* Reset locally administered bit if the device mode is STA */ |
| 4783 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(macAddr); |
Arunk Khandavalli | 794fdfc | 2017-09-13 18:00:40 +0530 | [diff] [blame] | 4784 | hdd_info("locally administered bit reset in sta mode: " |
| 4785 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4786 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4787 | case QDF_P2P_CLIENT_MODE: |
| 4788 | case QDF_P2P_DEVICE_MODE: |
| 4789 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 4790 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4791 | case QDF_MONITOR_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4792 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4793 | name_assign_type, |
| 4794 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4795 | |
| 4796 | if (NULL == adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4797 | hdd_err("failed to allocate adapter for session %d", |
| 4798 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4799 | return NULL; |
| 4800 | } |
| 4801 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4802 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4803 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4804 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4805 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4806 | else if (QDF_MONITOR_MODE == session_type) |
| 4807 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4808 | else |
| 4809 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4810 | |
| 4811 | adapter->device_mode = session_type; |
| 4812 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4813 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4814 | /* |
| 4815 | * Workqueue which gets scheduled in IPv4 notification |
| 4816 | * callback |
| 4817 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4818 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4819 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4820 | |
| 4821 | #ifdef WLAN_NS_OFFLOAD |
| 4822 | /* |
| 4823 | * Workqueue which gets scheduled in IPv6 |
| 4824 | * notification callback. |
| 4825 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4826 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4827 | hdd_ipv6_notifier_work_queue); |
| 4828 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4829 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4830 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4831 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4832 | |
| 4833 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4834 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4835 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4836 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4837 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4838 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4839 | hdd_nud_init_tracking(adapter); |
| 4840 | |
| 4841 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 4842 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 4843 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4844 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4845 | case QDF_P2P_GO_MODE: |
| 4846 | case QDF_SAP_MODE: |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4847 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, macAddr, |
| 4848 | name_assign_type, |
| 4849 | (uint8_t *) iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4850 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4851 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4852 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4853 | return NULL; |
| 4854 | } |
| 4855 | |
| 4856 | adapter->wdev.iftype = |
| 4857 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4858 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4859 | NL80211_IFTYPE_P2P_GO; |
| 4860 | adapter->device_mode = session_type; |
| 4861 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 4862 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4863 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4864 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4865 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4866 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4867 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4868 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4869 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4870 | |
| 4871 | /* |
| 4872 | * Workqueue which gets scheduled in IPv4 notification |
| 4873 | * callback |
| 4874 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4875 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4876 | hdd_ipv4_notifier_work_queue); |
| 4877 | |
| 4878 | #ifdef WLAN_NS_OFFLOAD |
| 4879 | /* |
| 4880 | * Workqueue which gets scheduled in IPv6 |
| 4881 | * notification callback. |
| 4882 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 4883 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 4884 | hdd_ipv6_notifier_work_queue); |
| 4885 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4886 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4887 | case QDF_FTM_MODE: |
| 4888 | adapter = hdd_alloc_station_adapter(hdd_ctx, macAddr, |
| 4889 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 4890 | iface_name); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4891 | if (NULL == adapter) { |
| 4892 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 4893 | return NULL; |
| 4894 | } |
| 4895 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 4896 | adapter->device_mode = session_type; |
| 4897 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4898 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 4899 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4900 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4901 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 4902 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4903 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 4904 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 4905 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 4906 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4907 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4908 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 4909 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4910 | return NULL; |
| 4911 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4912 | |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4913 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 4914 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 4915 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 4916 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4917 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4918 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4919 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4920 | } |
| 4921 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4922 | if (QDF_STATUS_SUCCESS != status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4923 | if (NULL != adapter) { |
| 4924 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 4925 | adapter = NULL; |
| 4926 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4927 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4928 | return NULL; |
| 4929 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4930 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4931 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4932 | if (QDF_STATUS_SUCCESS == status) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 4933 | policy_mgr_set_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4934 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4935 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4936 | /* Adapter successfully added. Increment the vdev count */ |
| 4937 | hdd_ctx->current_intf_count++; |
| 4938 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4939 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4940 | hdd_ctx->current_intf_count); |
| 4941 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 4942 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4943 | } |
| 4944 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4945 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4946 | hdd_err("Interface %s wow debug_fs init failed", |
| 4947 | netdev_name(adapter->dev)); |
| 4948 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 4949 | hdd_register_hl_netdev_fc_timer(adapter, |
| 4950 | hdd_tx_resume_timer_expired_handler); |
| 4951 | |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 4952 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 4953 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4954 | |
| 4955 | return adapter; |
| 4956 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4957 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 4958 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Hanumanth Reddy Pothula | 00a39e7 | 2016-11-09 21:32:16 +0530 | [diff] [blame] | 4959 | free_netdev(adapter->dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4960 | |
| 4961 | return NULL; |
| 4962 | } |
| 4963 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 4964 | #ifdef MSM_PLATFORM |
| 4965 | static inline |
| 4966 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4967 | { |
| 4968 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 4969 | } |
| 4970 | #else |
| 4971 | static inline |
| 4972 | void hdd_cancel_bus_bw_work(struct hdd_context *hdd_ctx) |
| 4973 | { |
| 4974 | } |
| 4975 | #endif |
| 4976 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4977 | 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] | 4978 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4979 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4980 | /* |
| 4981 | * Here we are stopping global bus_bw timer & work per adapter. |
| 4982 | * |
| 4983 | * The reason is to fix one race condition between |
| 4984 | * bus bandwidth work and cleaning up an adapter. |
| 4985 | * Under some conditions, it is possible for the bus bandwidth |
| 4986 | * work to access a particularly destroyed adapter, leading to |
| 4987 | * use-after-free. |
| 4988 | */ |
| 4989 | hdd_debug("wait for bus bw work to flush"); |
| 4990 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 4991 | hdd_bus_bw_cancel_work(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4992 | |
Min Liu | ef92ef5 | 2018-06-25 18:08:54 +0800 | [diff] [blame] | 4993 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 4994 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 4995 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4996 | /* cleanup adapter */ |
| 4997 | policy_mgr_clear_concurrency_mode(hdd_ctx->hdd_psoc, |
| 4998 | adapter->device_mode); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4999 | hdd_remove_adapter(hdd_ctx, adapter); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5000 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5001 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5002 | /* conditionally restart the bw timer */ |
| 5003 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5004 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5005 | /* Adapter removed. Decrement vdev count */ |
| 5006 | if (hdd_ctx->current_intf_count != 0) |
| 5007 | hdd_ctx->current_intf_count--; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 5008 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5009 | /* Fw will take care incase of concurrency */ |
| 5010 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5011 | } |
| 5012 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5013 | /** |
| 5014 | * hdd_close_all_adapters - Close all open adapters |
| 5015 | * @hdd_ctx: Hdd context |
| 5016 | * rtnl_held: True if RTNL lock held |
| 5017 | * |
| 5018 | * Close all open adapters. |
| 5019 | * |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5020 | * Return: QDF status code |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5021 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5022 | 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] | 5023 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5024 | struct hdd_adapter *adapter; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5025 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5026 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5027 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5028 | |
| 5029 | do { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5030 | status = hdd_remove_front_adapter(hdd_ctx, &adapter); |
| 5031 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5032 | wlan_hdd_release_intf_addr(hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5033 | adapter->mac_addr.bytes); |
| 5034 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5035 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5036 | /* Adapter removed. Decrement vdev count */ |
| 5037 | if (hdd_ctx->current_intf_count != 0) |
| 5038 | hdd_ctx->current_intf_count--; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5039 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5040 | } while (QDF_IS_STATUS_SUCCESS(status)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5041 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5042 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5043 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5044 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5045 | } |
| 5046 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5047 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5048 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5049 | struct qdf_mac_addr *bssid = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5050 | tSirUpdateIE updateIE; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5051 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5052 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5053 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5054 | case QDF_STA_MODE: |
| 5055 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5056 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5057 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5058 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5059 | bssid = &sta_ctx->conn_info.bssId; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5060 | break; |
| 5061 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5062 | case QDF_SAP_MODE: |
| 5063 | case QDF_P2P_GO_MODE: |
| 5064 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5065 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5066 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5067 | break; |
| 5068 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5069 | case QDF_FTM_MODE: |
| 5070 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5071 | default: |
| 5072 | /* |
| 5073 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5074 | * for these kind of devices |
| 5075 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5076 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5077 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5078 | return; |
| 5079 | } |
| 5080 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5081 | qdf_copy_macaddr(&updateIE.bssid, bssid); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5082 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | updateIE.ieBufferlength = 0; |
| 5084 | updateIE.pAdditionIEBuffer = NULL; |
| 5085 | updateIE.append = true; |
| 5086 | updateIE.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5087 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5088 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5089 | &updateIE, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5090 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5091 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5092 | } |
| 5093 | } |
| 5094 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5095 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5096 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5097 | { |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5098 | return hdd_stop_adapter_ext(hdd_ctx, adapter, 0); |
| 5099 | } |
| 5100 | |
| 5101 | QDF_STATUS hdd_stop_adapter_ext(struct hdd_context *hdd_ctx, |
| 5102 | struct hdd_adapter *adapter, |
| 5103 | enum hdd_adapter_stop_flag_t flag) |
| 5104 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5105 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5106 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5107 | union iwreq_data wrqu; |
| 5108 | tSirUpdateIE updateIE; |
| 5109 | unsigned long rc; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 5110 | tsap_config_t *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5111 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5112 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5113 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5114 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5115 | if (adapter->session_id != HDD_SESSION_ID_INVALID) |
| 5116 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5117 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5118 | hdd_nud_ignore_tracking(adapter, true); |
| 5119 | hdd_nud_reset_tracking(adapter); |
| 5120 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5121 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5122 | wlan_hdd_netif_queue_control(adapter, |
| 5123 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5124 | WLAN_CONTROL_PATH); |
Tushnim Bhattacharyya | 9bd058f | 2017-12-27 14:01:31 -0800 | [diff] [blame] | 5125 | /* |
| 5126 | * if this is the last active connection check & stop the |
| 5127 | * opportunistic timer first |
| 5128 | */ |
| 5129 | if (((policy_mgr_get_connection_count(hdd_ctx->hdd_psoc) == 1) && |
| 5130 | (policy_mgr_mode_specific_connection_count(hdd_ctx->hdd_psoc, |
| 5131 | policy_mgr_convert_device_mode_to_qdf_type( |
| 5132 | adapter->device_mode), NULL) == 1)) || |
| 5133 | !policy_mgr_get_connection_count(hdd_ctx->hdd_psoc)) |
| 5134 | policy_mgr_check_and_stop_opportunistic_timer( |
| 5135 | hdd_ctx->hdd_psoc, adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5136 | |
| 5137 | mac_handle = hdd_ctx->mac_handle; |
| 5138 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5139 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5140 | case QDF_STA_MODE: |
| 5141 | case QDF_P2P_CLIENT_MODE: |
| 5142 | case QDF_IBSS_MODE: |
| 5143 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5144 | case QDF_NDI_MODE: |
| 5145 | if ((QDF_NDI_MODE == adapter->device_mode) || |
| 5146 | hdd_conn_is_connected( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5147 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)) || |
| 5148 | hdd_is_connecting( |
| 5149 | WLAN_HDD_GET_STATION_CTX_PTR(adapter))) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5150 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5151 | roam_profile = hdd_roam_profile(adapter); |
| 5152 | /* For NDI do not use roam_profile */ |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5153 | if (QDF_NDI_MODE == adapter->device_mode) |
| 5154 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5155 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5156 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5157 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5158 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5159 | eCSR_BSS_TYPE_START_IBSS) |
| 5160 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5161 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5162 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5163 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 5164 | else if (QDF_STA_MODE == adapter->device_mode) { |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5165 | qdf_ret_status = |
| 5166 | wlan_hdd_try_disconnect(adapter); |
Jingxiang Ge | cc7e1f4 | 2017-11-14 16:21:27 +0800 | [diff] [blame] | 5167 | hdd_debug("Send disconnected event to userspace"); |
| 5168 | wlan_hdd_cfg80211_indicate_disconnect( |
| 5169 | adapter->dev, true, |
| 5170 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | 109e79d | 2018-02-27 15:10:04 -0800 | [diff] [blame] | 5171 | } else |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5172 | qdf_ret_status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5173 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5174 | adapter->session_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5175 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5176 | /* success implies disconnect command got |
| 5177 | * queued up successfully |
| 5178 | */ |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5179 | if (qdf_ret_status == QDF_STATUS_SUCCESS && |
| 5180 | QDF_STA_MODE != adapter->device_mode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5181 | rc = wait_for_completion_timeout( |
| 5182 | &adapter->disconnect_comp_var, |
| 5183 | msecs_to_jiffies |
| 5184 | (WLAN_WAIT_TIME_DISCONNECT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5185 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5186 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5187 | } |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5188 | if (qdf_ret_status != QDF_STATUS_SUCCESS) |
| 5189 | hdd_warn("failed to post disconnect"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5190 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5191 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5192 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5193 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5194 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5195 | } |
Wu Gao | aceec6c | 2017-08-30 16:08:21 +0800 | [diff] [blame] | 5196 | wlan_hdd_scan_abort(adapter); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5197 | |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5198 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5199 | hdd_clear_fils_connection_info(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5200 | |
| 5201 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5202 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5203 | #endif |
| 5204 | |
| 5205 | hdd_deregister_tx_flow_control(adapter); |
| 5206 | |
| 5207 | #ifdef WLAN_NS_OFFLOAD |
| 5208 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5209 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5210 | #endif |
| 5211 | #endif |
| 5212 | |
Hanumanth Reddy Pothula | 0586014 | 2017-07-26 18:45:27 +0530 | [diff] [blame] | 5213 | if (adapter->device_mode == QDF_STA_MODE) |
| 5214 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5215 | adapter->dev); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5216 | |
| 5217 | if (wlan_hdd_try_disconnect(adapter)) { |
| 5218 | hdd_err("Error: Can't disconnect adapter"); |
| 5219 | return QDF_STATUS_E_FAILURE; |
Krunal Soni | 985b813 | 2017-02-10 18:49:08 -0800 | [diff] [blame] | 5220 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5221 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5222 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5223 | break; |
| 5224 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5225 | case QDF_MONITOR_MODE: |
| 5226 | wlan_hdd_scan_abort(adapter); |
| 5227 | hdd_deregister_tx_flow_control(adapter); |
| 5228 | hdd_vdev_destroy(adapter); |
| 5229 | break; |
| 5230 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5231 | case QDF_SAP_MODE: |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5232 | wlan_hdd_scan_abort(adapter); |
Govind Singh | 1dab23b | 2017-08-12 13:31:00 +0530 | [diff] [blame] | 5233 | /* Flush IPA exception path packets */ |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5234 | sap_config = &adapter->session.ap.sap_config; |
| 5235 | if (sap_config) |
| 5236 | wlansap_reset_sap_config_add_ie(sap_config, |
| 5237 | eUPDATE_IE_ALL); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 5238 | ucfg_ipa_flush(hdd_ctx->hdd_pdev); |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5239 | if (!(flag & HDD_IN_CAC_WORK_TH_CONTEXT)) |
| 5240 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5241 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5242 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5243 | case QDF_P2P_GO_MODE: |
Kiran Kumar Lokere | 85cb36b | 2017-09-14 15:19:14 -0700 | [diff] [blame] | 5244 | if (QDF_SAP_MODE == adapter->device_mode) { |
| 5245 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5246 | cds_flush_delayed_work( |
| 5247 | &adapter->acs_pending_work); |
| 5248 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5249 | } |
| 5250 | } |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5251 | cds_flush_work(&adapter->sap_stop_bss_work); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5252 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5253 | /* Any softap specific cleanup here... */ |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5254 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5255 | wlan_hdd_undo_acs(adapter); |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5256 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5257 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5258 | |
| 5259 | hdd_deregister_tx_flow_control(adapter); |
| 5260 | |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5261 | hdd_destroy_acs_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5262 | mutex_lock(&hdd_ctx->sap_lock); |
| 5263 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5264 | QDF_STATUS status; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5265 | QDF_STATUS qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5266 | |
| 5267 | /* Stop Bss. */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5268 | status = wlansap_stop_bss( |
| 5269 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5270 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5271 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5272 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5273 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5274 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5275 | qdf_stop_bss_event); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5276 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5277 | qdf_wait_for_event_completion( |
| 5278 | &hostapd_state->qdf_stop_bss_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 5279 | SME_CMD_TIMEOUT_VALUE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5280 | |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5281 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5282 | hdd_err("failure waiting for wlansap_stop_bss %d", |
| 5283 | qdf_status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5284 | } |
| 5285 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5286 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5287 | } |
| 5288 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5289 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 5290 | adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5291 | adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5292 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5293 | adapter->device_mode, |
| 5294 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5295 | |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 5296 | qdf_copy_macaddr(&updateIE.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5297 | &adapter->mac_addr); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5298 | updateIE.smeSessionId = adapter->session_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5299 | updateIE.ieBufferlength = 0; |
| 5300 | updateIE.pAdditionIEBuffer = NULL; |
| 5301 | updateIE.append = false; |
| 5302 | updateIE.notify = false; |
| 5303 | /* Probe bcn reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5304 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5305 | &updateIE, eUPDATE_IE_PROBE_BCN) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5306 | == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5307 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5308 | } |
| 5309 | /* Assoc resp reset */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5310 | if (sme_update_add_ie(mac_handle, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | &updateIE, |
| 5312 | eUPDATE_IE_ASSOC_RESP) == |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5313 | QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5314 | hdd_err("Could not pass on ASSOC_RSP data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5315 | } |
| 5316 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5317 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5318 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5319 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5320 | qdf_mem_free(adapter->session.ap.beacon); |
| 5321 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5322 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5323 | /* |
| 5324 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5325 | */ |
| 5326 | if (policy_mgr_is_dnsc_set(adapter->hdd_vdev)) |
| 5327 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
| 5328 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5329 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5330 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5331 | #endif |
| 5332 | |
| 5333 | #ifdef WLAN_NS_OFFLOAD |
| 5334 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5335 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5336 | #endif |
| 5337 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5338 | |
| 5339 | hdd_vdev_destroy(adapter); |
| 5340 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5341 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5342 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5343 | case QDF_OCB_MODE: |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5344 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 5345 | (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX), |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 5346 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.staId[0]); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5347 | hdd_deregister_tx_flow_control(adapter); |
| 5348 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5349 | break; |
| 5350 | default: |
| 5351 | break; |
| 5352 | } |
| 5353 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 5354 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5355 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5356 | if (adapter->scan_info.default_scan_ies) { |
| 5357 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5358 | adapter->scan_info.default_scan_ies = NULL; |
| 5359 | } |
| 5360 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5361 | hdd_exit(); |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5362 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5363 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5364 | } |
| 5365 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5366 | /** |
| 5367 | * hdd_deinit_all_adapters - deinit all adapters |
| 5368 | * @hdd_ctx: HDD context |
| 5369 | * @rtnl_held: True if RTNL lock held |
| 5370 | * |
| 5371 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5372 | 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] | 5373 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5374 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5375 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5376 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5377 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5378 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5379 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5380 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5381 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5382 | } |
| 5383 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5384 | QDF_STATUS hdd_stop_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; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5387 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5388 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5389 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5390 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5391 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5392 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5393 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5394 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5395 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5396 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5397 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | } |
| 5399 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5400 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5401 | struct hdd_adapter *adapter) |
| 5402 | { |
| 5403 | switch (adapter->device_mode) { |
| 5404 | case QDF_STA_MODE: |
| 5405 | case QDF_P2P_CLIENT_MODE: |
| 5406 | case QDF_IBSS_MODE: |
| 5407 | case QDF_P2P_DEVICE_MODE: |
| 5408 | case QDF_NDI_MODE: |
| 5409 | wlan_hdd_scan_abort(adapter); |
| 5410 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5411 | if (adapter->device_mode == QDF_STA_MODE) |
| 5412 | wlan_cfg80211_sched_scan_stop(hdd_ctx->hdd_pdev, |
| 5413 | adapter->dev); |
| 5414 | break; |
| 5415 | case QDF_P2P_GO_MODE: |
| 5416 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5417 | break; |
| 5418 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5419 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5420 | wlan_hdd_undo_acs(adapter); |
| 5421 | break; |
| 5422 | default: |
| 5423 | break; |
| 5424 | } |
| 5425 | } |
| 5426 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5427 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5428 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5429 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5430 | struct hdd_station_ctx *sta_ctx; |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5431 | struct qdf_mac_addr peerMacAddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5432 | int sta_id; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5433 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5434 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5436 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5437 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5438 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5439 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
| 5440 | hdd_device_mode_to_string(adapter->device_mode), |
| 5441 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5442 | |
| 5443 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5444 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5445 | /* Stop tdls timers */ |
Kabilan Kannan | 00d2041 | 2017-06-04 14:20:32 -0700 | [diff] [blame] | 5446 | hdd_notify_tdls_reset_adapter(adapter->hdd_vdev); |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5447 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5448 | } |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5449 | |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5450 | if (hdd_ctx->config->sap_internal_restart && |
| 5451 | adapter->device_mode == QDF_SAP_MODE) { |
| 5452 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5453 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5454 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5455 | if (test_bit(SOFTAP_BSS_STARTED, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5456 | &adapter->event_flags)) |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5457 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5458 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
| 5459 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5460 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5461 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5462 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5463 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5464 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5465 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5466 | |
| 5467 | hdd_deinit_tx_rx(adapter); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5468 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 5469 | adapter->device_mode, adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5470 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5471 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5472 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5473 | hdd_wmm_adapter_close(adapter); |
| 5474 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5475 | } |
| 5476 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5477 | if (adapter->device_mode == QDF_STA_MODE) |
| 5478 | hdd_clear_fils_connection_info(adapter); |
| 5479 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5480 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 5481 | /* |
| 5482 | * If adapter is SAP, set session ID to invalid |
| 5483 | * since SAP session will be cleanup during SSR. |
| 5484 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5485 | wlansap_set_invalid_session( |
| 5486 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5487 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5488 | wlansap_cleanup_cac_timer( |
| 5489 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5490 | } |
| 5491 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5492 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5493 | if (adapter->device_mode == QDF_STA_MODE || |
| 5494 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5495 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5496 | qdf_copy_macaddr(&peerMacAddr, |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5497 | &sta_ctx->conn_info.bssId); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5498 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5499 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5500 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5501 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5502 | if (adapter->sta_info[sta_id].in_use) { |
| 5503 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5504 | sta_id); |
| 5505 | hdd_softap_deregister_sta(adapter, |
| 5506 | sta_id); |
| 5507 | adapter->sta_info[sta_id].in_use = 0; |
| 5508 | } |
| 5509 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5510 | } |
| 5511 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5512 | hdd_nud_reset_tracking(adapter); |
| 5513 | hdd_nud_ignore_tracking(adapter, true); |
| 5514 | hdd_set_disconnect_status(adapter, false); |
| 5515 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5516 | hdd_softap_deinit_tx_rx(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5517 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5518 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5519 | /* Destroy vdev which will be recreated during reinit. */ |
| 5520 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5521 | } |
| 5522 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5523 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5524 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5525 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5526 | } |
| 5527 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5528 | bool hdd_check_for_opened_interfaces(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5529 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5530 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5531 | bool close_modules = true; |
| 5532 | |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5533 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 5534 | hdd_info("FTM mode, don't close the module"); |
| 5535 | return false; |
| 5536 | } |
| 5537 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5538 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5539 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
| 5540 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5541 | hdd_debug("Still other ifaces are up cannot close modules"); |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5542 | close_modules = false; |
| 5543 | break; |
| 5544 | } |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5545 | } |
| 5546 | |
| 5547 | return close_modules; |
| 5548 | } |
| 5549 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5550 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5551 | { |
| 5552 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5553 | return true; |
| 5554 | else |
| 5555 | return false; |
| 5556 | } |
| 5557 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5558 | #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) \ |
bings | bdcd4a2 | 2017-06-20 09:27:00 +0800 | [diff] [blame] | 5559 | && !defined(WITH_BACKPORTS) && !defined(IEEE80211_PRIVACY) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5560 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5561 | struct ieee80211_channel *channel, |
| 5562 | const u8 *bssid, const u8 *ssid, |
| 5563 | size_t ssid_len) |
| 5564 | { |
| 5565 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5566 | ssid, ssid_len, |
| 5567 | WLAN_CAPABILITY_ESS, |
| 5568 | WLAN_CAPABILITY_ESS); |
| 5569 | } |
| 5570 | #else |
| 5571 | struct cfg80211_bss *hdd_cfg80211_get_bss(struct wiphy *wiphy, |
| 5572 | struct ieee80211_channel *channel, |
| 5573 | const u8 *bssid, const u8 *ssid, |
| 5574 | size_t ssid_len) |
| 5575 | { |
| 5576 | return cfg80211_get_bss(wiphy, channel, bssid, |
| 5577 | ssid, ssid_len, |
| 5578 | IEEE80211_BSS_TYPE_ESS, |
| 5579 | IEEE80211_PRIVACY_ANY); |
| 5580 | } |
| 5581 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5582 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5583 | #if defined CFG80211_CONNECT_BSS || \ |
| 5584 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5585 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5586 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5587 | /** |
| 5588 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5589 | * @timeout_reason: reason for connect timeout |
| 5590 | * |
| 5591 | * This function is used to convert host timeout |
| 5592 | * reason enum to kernel specific enum. |
| 5593 | * |
| 5594 | * Return: nl timeout enum |
| 5595 | */ |
| 5596 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5597 | tSirResultCodes timeout_reason) |
| 5598 | { |
| 5599 | switch (timeout_reason) { |
| 5600 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5601 | return NL80211_TIMEOUT_SCAN; |
| 5602 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5603 | return NL80211_TIMEOUT_AUTH; |
| 5604 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5605 | return NL80211_TIMEOUT_ASSOC; |
| 5606 | default: |
| 5607 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5608 | } |
| 5609 | } |
| 5610 | |
| 5611 | /** |
| 5612 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 5613 | * @dev: network device |
| 5614 | * @bssid: bssid to which we want to associate |
| 5615 | * @timeout_reason: reason for connect timeout |
| 5616 | * |
| 5617 | * This API is used to send connection timeout reason to supplicant |
| 5618 | * |
| 5619 | * Return: void |
| 5620 | */ |
| 5621 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5622 | const u8 *bssid, |
| 5623 | tSirResultCodes timeout_reason) |
| 5624 | { |
| 5625 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5626 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5627 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5628 | |
| 5629 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 5630 | nl_timeout_reason); |
| 5631 | } |
| 5632 | |
| 5633 | /** |
| 5634 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 5635 | * @dev: network device |
| 5636 | * @bssid: bssid to which we want to associate |
| 5637 | * @req_ie: Request Information Element |
| 5638 | * @req_ie_len: len of the req IE |
| 5639 | * @resp_ie: Response IE |
| 5640 | * @resp_ie_len: len of ht response IE |
| 5641 | * @status: status |
| 5642 | * @gfp: Kernel Flag |
| 5643 | * @timeout_reason: reason for connect timeout |
| 5644 | * |
| 5645 | * Return: void |
| 5646 | */ |
| 5647 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5648 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5649 | size_t req_ie_len, const u8 *resp_ie, |
| 5650 | size_t resp_ie_len, int status, gfp_t gfp, |
| 5651 | tSirResultCodes timeout_reason) |
| 5652 | { |
| 5653 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5654 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5655 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 5656 | |
| 5657 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5658 | resp_ie, resp_ie_len, status, gfp, |
| 5659 | nl_timeout_reason); |
| 5660 | } |
| 5661 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5662 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5663 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5664 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 5665 | const u8 *bssid, |
| 5666 | tSirResultCodes timeout_reason) |
| 5667 | { |
| 5668 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 5669 | } |
| 5670 | #endif |
| 5671 | |
| 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, |
| 5676 | tSirResultCodes timeout_reason) |
| 5677 | { |
| 5678 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 5679 | resp_ie, resp_ie_len, status, gfp); |
| 5680 | } |
| 5681 | #endif |
| 5682 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5683 | /** |
| 5684 | * hdd_connect_bss() - API to send connection status to supplicant |
| 5685 | * @dev: network device |
| 5686 | * @bssid: bssid to which we want to associate |
| 5687 | * @req_ie: Request Information Element |
| 5688 | * @req_ie_len: len of the req IE |
| 5689 | * @resp_ie: Response IE |
| 5690 | * @resp_ie_len: len of ht response IE |
| 5691 | * @status: status |
| 5692 | * @gfp: Kernel Flag |
| 5693 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5694 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5695 | * |
| 5696 | * The API is a wrapper to send connection status to supplicant |
| 5697 | * |
| 5698 | * Return: Void |
| 5699 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5700 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 5701 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5702 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5703 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5704 | size_t req_ie_len, const u8 *resp_ie, |
| 5705 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5706 | bool connect_timeout, |
| 5707 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5708 | { |
| 5709 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5710 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5711 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5712 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5713 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5714 | } |
| 5715 | #else |
| 5716 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 5717 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 5718 | size_t req_ie_len, const u8 *resp_ie, |
| 5719 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5720 | bool connect_timeout, |
| 5721 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5722 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5723 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 5724 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5725 | } |
| 5726 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5727 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5728 | #if defined(WLAN_FEATURE_FILS_SK) |
| 5729 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 5730 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 5731 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 5732 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5733 | /** |
| 5734 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 5735 | * @fils_params: connect response to supplicant |
| 5736 | * @fils_kek: FILS kek |
| 5737 | * @fils_kek_len: FILS kek length |
| 5738 | * @pmk: FILS PMK |
| 5739 | * @pmk_len: FILS PMK length |
| 5740 | * @pmkid: PMKID |
| 5741 | * @fils_seq_num: FILS Seq number |
| 5742 | * |
| 5743 | * Return: None |
| 5744 | */ |
| 5745 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5746 | *fils_params, const uint8_t *fils_kek, |
| 5747 | size_t fils_kek_len, const uint8_t *pmk, |
| 5748 | size_t pmk_len, const uint8_t *pmkid, |
| 5749 | uint16_t fils_seq_num) |
| 5750 | { |
| 5751 | /* Increament seq number to be used for next FILS */ |
| 5752 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 5753 | fils_params->update_erp_next_seq_num = true; |
| 5754 | fils_params->fils_kek = fils_kek; |
| 5755 | fils_params->fils_kek_len = fils_kek_len; |
| 5756 | fils_params->pmk = pmk; |
| 5757 | fils_params->pmk_len = pmk_len; |
| 5758 | fils_params->pmkid = pmkid; |
| 5759 | } |
| 5760 | #else |
| 5761 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 5762 | *fils_params, const uint8_t |
| 5763 | *fils_kek, size_t fils_kek_len, |
| 5764 | const uint8_t *pmk, size_t pmk_len, |
| 5765 | const uint8_t *pmkid, |
| 5766 | uint16_t fils_seq_num) |
| 5767 | { } |
| 5768 | #endif |
| 5769 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5770 | void hdd_update_hlp_info(struct net_device *dev, |
| 5771 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5772 | { |
| 5773 | struct sk_buff *skb; |
| 5774 | uint16_t skb_len; |
| 5775 | struct llc_snap_hdr_t *llc_hdr; |
| 5776 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5777 | uint8_t *hlp_data; |
| 5778 | uint16_t hlp_data_len; |
| 5779 | struct fils_join_rsp_params *roam_fils_params |
| 5780 | = roam_info->fils_join_rsp; |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5781 | struct hdd_adapter *padapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5782 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5783 | if (!roam_fils_params) { |
| 5784 | hdd_err("FILS Roam Param NULL"); |
| 5785 | return; |
| 5786 | } |
| 5787 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 5788 | if (!roam_fils_params->hlp_data_len) { |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5789 | hdd_err("FILS HLP Data NULL, len %d", |
| 5790 | roam_fils_params->hlp_data_len); |
| 5791 | return; |
| 5792 | } |
| 5793 | |
| 5794 | hlp_data = roam_fils_params->hlp_data; |
| 5795 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 5796 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5797 | /* Calculate skb length */ |
| 5798 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 5799 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
| 5800 | if (skb == NULL) { |
| 5801 | hdd_err("HLP packet nbuf alloc fails"); |
| 5802 | return; |
| 5803 | } |
| 5804 | |
| 5805 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 5806 | QDF_MAC_ADDR_SIZE); |
| 5807 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 5808 | QDF_MAC_ADDR_SIZE); |
| 5809 | |
| 5810 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 5811 | if (IS_SNAP(llc_hdr)) { |
| 5812 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5813 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 5814 | } |
| 5815 | |
| 5816 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 5817 | |
| 5818 | /* |
| 5819 | * This HLP packet is formed from HLP info encapsulated |
| 5820 | * in assoc response frame which is AEAD encrypted. |
| 5821 | * Hence, this checksum validation can be set unnecessary. |
| 5822 | * i.e. network layer need not worry about checksum. |
| 5823 | */ |
| 5824 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 5825 | |
| 5826 | status = hdd_rx_packet_cbk(padapter, skb); |
| 5827 | if (QDF_IS_STATUS_ERROR(status)) { |
| 5828 | hdd_err("Sending HLP packet fails"); |
| 5829 | return; |
| 5830 | } |
| 5831 | hdd_debug("send HLP packet to netif successfully"); |
| 5832 | } |
| 5833 | |
| 5834 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5835 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 5836 | * @dev: network device |
| 5837 | * @bssid: bssid to which we want to associate |
| 5838 | * @bss: cfg80211 bss info |
| 5839 | * @roam_info: information about connected bss |
| 5840 | * @req_ie: Request Information Element |
| 5841 | * @req_ie_len: len of the req IE |
| 5842 | * @resp_ie: Response IE |
| 5843 | * @resp_ie_len: len of ht response IE |
| 5844 | * @status: status |
| 5845 | * @gfp: allocation flags |
| 5846 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5847 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5848 | * |
| 5849 | * This API is used as wrapper to send FILS key/sequence number |
| 5850 | * params etc. to supplicant in case of FILS connection |
| 5851 | * |
| 5852 | * Return: None |
| 5853 | */ |
| 5854 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5855 | struct cfg80211_bss *bss, |
| 5856 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5857 | const u8 *req_ie, size_t req_ie_len, |
| 5858 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5859 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5860 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5861 | { |
| 5862 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5863 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 5864 | struct fils_join_rsp_params *roam_fils_params = |
| 5865 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5866 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5867 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 5868 | |
| 5869 | if (!roam_fils_params) { |
| 5870 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 5871 | } else { |
| 5872 | fils_params.status = status; |
| 5873 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 5874 | fils_params.timeout_reason = |
| 5875 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5876 | fils_params.req_ie = req_ie; |
| 5877 | fils_params.req_ie_len = req_ie_len; |
| 5878 | fils_params.resp_ie = resp_ie; |
| 5879 | fils_params.resp_ie_len = resp_ie_len; |
| 5880 | fils_params.bss = bss; |
| 5881 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 5882 | roam_fils_params->kek_len, |
| 5883 | roam_fils_params->fils_pmk, |
| 5884 | roam_fils_params->fils_pmk_len, |
| 5885 | roam_fils_params->fils_pmkid, |
| 5886 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 5887 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5888 | } |
| 5889 | hdd_debug("FILS indicate connect status %d seq no %d", |
| 5890 | fils_params.status, |
| 5891 | fils_params.fils_erp_next_seq_num); |
| 5892 | |
| 5893 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 5894 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5895 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5896 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5897 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5898 | /* Clear all the FILS key info */ |
| 5899 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 5900 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 5901 | if (roam_fils_params) |
| 5902 | qdf_mem_free(roam_fils_params); |
| 5903 | roam_info->fils_join_rsp = NULL; |
| 5904 | } |
| 5905 | #else |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5906 | static inline void |
| 5907 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5908 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 5909 | const u8 *req_ie, size_t req_ie_len, |
| 5910 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 5911 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5912 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 5913 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5914 | #endif |
| 5915 | #endif |
| 5916 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5917 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 5918 | (defined(CFG80211_CONNECT_DONE) || \ |
| 5919 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5920 | /** |
| 5921 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 5922 | * supplicant. |
| 5923 | * @dev: network device |
| 5924 | * @bssid: bssid to which we want to associate |
| 5925 | * @bss: cfg80211 bss info |
| 5926 | * @roam_info: information about connected bss |
| 5927 | * @req_ie: Request Information Element |
| 5928 | * @req_ie_len: len of the req IE |
| 5929 | * @resp_ie: Response IE |
| 5930 | * @resp_ie_len: len of ht response IE |
| 5931 | * @status: status |
| 5932 | * @gfp: allocation flags |
| 5933 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 5934 | * @timeout_reason: reason for connect timeout |
| 5935 | * |
| 5936 | * The API is a wrapper to send connection status to supplicant |
| 5937 | * |
| 5938 | * Return: 0 if success else failure |
| 5939 | */ |
| 5940 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 5941 | const u8 *bssid, |
| 5942 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5943 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5944 | size_t req_ie_len, const u8 *resp_ie, |
| 5945 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5946 | bool connect_timeout, |
| 5947 | tSirResultCodes timeout_reason) |
| 5948 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5949 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5950 | if (!roam_info || !roam_info->is_fils_connection) |
| 5951 | return -EINVAL; |
| 5952 | |
| 5953 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 5954 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 5955 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5956 | return 0; |
| 5957 | } |
| 5958 | #else |
| 5959 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 5960 | const u8 *bssid, |
| 5961 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5962 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 5963 | size_t req_ie_len, const u8 *resp_ie, |
| 5964 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 5965 | bool connect_timeout, |
| 5966 | tSirResultCodes timeout_reason) |
| 5967 | { |
| 5968 | return -EINVAL; |
| 5969 | } |
| 5970 | #endif |
| 5971 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5972 | /** |
| 5973 | * hdd_connect_result() - API to send connection status to supplicant |
| 5974 | * @dev: network device |
| 5975 | * @bssid: bssid to which we want to associate |
| 5976 | * @roam_info: information about connected bss |
| 5977 | * @req_ie: Request Information Element |
| 5978 | * @req_ie_len: len of the req IE |
| 5979 | * @resp_ie: Response IE |
| 5980 | * @resp_ie_len: len of ht response IE |
| 5981 | * @status: status |
| 5982 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5983 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5984 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5985 | * |
| 5986 | * The API is a wrapper to send connection status to supplicant |
| 5987 | * and allow runtime suspend |
| 5988 | * |
| 5989 | * Return: Void |
| 5990 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5991 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 5992 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5993 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 5994 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5995 | bool connect_timeout, |
| 5996 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5997 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5998 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 5999 | struct cfg80211_bss *bss = NULL; |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6000 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6001 | |
| 6002 | if (WLAN_STATUS_SUCCESS == status) { |
| 6003 | struct ieee80211_channel *chan; |
| 6004 | int freq; |
| 6005 | int chan_no = roam_info->pBssDesc->channelId; |
| 6006 | |
| 6007 | if (chan_no <= 14) |
| 6008 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6009 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6010 | else |
| 6011 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6012 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6013 | |
| 6014 | chan = ieee80211_get_channel(padapter->wdev.wiphy, freq); |
| 6015 | bss = hdd_cfg80211_get_bss(padapter->wdev.wiphy, chan, bssid, |
| 6016 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6017 | roam_info->u.pConnectedProfile->SSID.length); |
| 6018 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6019 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6020 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6021 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6022 | resp_ie_len, status, gfp, connect_timeout, |
| 6023 | timeout_reason) != 0) { |
| 6024 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6025 | req_ie_len, resp_ie, resp_ie_len, |
| 6026 | status, gfp, connect_timeout, timeout_reason); |
| 6027 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6028 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6029 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6030 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6031 | } |
| 6032 | #else |
| 6033 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6034 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6035 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6036 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6037 | bool connect_timeout, |
| 6038 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6039 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6040 | struct hdd_adapter *padapter = (struct hdd_adapter *) netdev_priv(dev); |
Jingxiang Ge | 929c793 | 2018-01-24 14:01:12 +0800 | [diff] [blame] | 6041 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(padapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6042 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6043 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6044 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6045 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6046 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6047 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6048 | } |
| 6049 | #endif |
| 6050 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6051 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6052 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6053 | uint32_t bandwidth) |
| 6054 | { |
| 6055 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6056 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6057 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6058 | QDF_STATUS status; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6059 | struct qdf_mac_addr bssid; |
| 6060 | struct csr_roam_profile roam_profile; |
| 6061 | struct ch_params ch_params; |
| 6062 | |
| 6063 | if (QDF_GLOBAL_MONITOR_MODE != hdd_get_conparam()) { |
| 6064 | hdd_err("Not supported, device is not in monitor mode"); |
| 6065 | return -EINVAL; |
| 6066 | } |
| 6067 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6068 | /* Validate Channel */ |
| 6069 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6070 | hdd_err("Channel %d Not supported", chan); |
| 6071 | return -EINVAL; |
| 6072 | } |
| 6073 | |
| 6074 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6075 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6076 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6077 | return -EINVAL; |
| 6078 | } |
| 6079 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6080 | (bandwidth != CH_WIDTH_MAX)) { |
| 6081 | hdd_err("Only BW20 possible on channel 14"); |
| 6082 | return -EINVAL; |
| 6083 | } |
| 6084 | } |
| 6085 | |
| 6086 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6087 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6088 | (bandwidth != CH_WIDTH_MAX)) { |
| 6089 | hdd_err("Only BW20 possible on channel 165"); |
| 6090 | return -EINVAL; |
| 6091 | } |
| 6092 | } |
| 6093 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6094 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6095 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6096 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6097 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6098 | roam_profile.phyMode = ch_info->phy_mode; |
| 6099 | roam_profile.ch_params.ch_width = bandwidth; |
| 6100 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
| 6101 | |
| 6102 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6103 | QDF_MAC_ADDR_SIZE); |
| 6104 | |
| 6105 | ch_params.ch_width = bandwidth; |
| 6106 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, chan, 0, &ch_params); |
| 6107 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6108 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6109 | return -EINVAL; |
| 6110 | } |
| 6111 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6112 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6113 | hdd_err("Failed to change hw mode"); |
| 6114 | return -EINVAL; |
| 6115 | } |
| 6116 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6117 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6118 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6119 | &roam_profile); |
| 6120 | if (status) { |
| 6121 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6122 | status); |
| 6123 | } |
| 6124 | |
| 6125 | adapter->mon_chan = chan; |
| 6126 | adapter->mon_bandwidth = bandwidth; |
| 6127 | return qdf_status_to_os_return(status); |
| 6128 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6129 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6130 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6131 | #ifdef MSM_PLATFORM |
| 6132 | /** |
| 6133 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6134 | * @adapter: pointer to adapter |
| 6135 | * |
| 6136 | * This function calls cfg80211 API to stop P2P GO |
| 6137 | * |
| 6138 | * Return: None |
| 6139 | */ |
| 6140 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6141 | { |
| 6142 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6143 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6144 | } |
| 6145 | |
| 6146 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6147 | { |
| 6148 | } |
| 6149 | #else |
| 6150 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6151 | { |
| 6152 | } |
| 6153 | |
| 6154 | /** |
| 6155 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6156 | * @adapter: pointer to adapter |
| 6157 | * |
| 6158 | * This function calls cfg80211 API to delete STA |
| 6159 | * |
| 6160 | * Return: None |
| 6161 | */ |
| 6162 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6163 | { |
| 6164 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6165 | |
| 6166 | hdd_debug("[SSR] send restart supplicant"); |
| 6167 | /* event supplicant to restart */ |
| 6168 | cfg80211_del_sta(adapter->dev, |
| 6169 | (const u8 *)&bcast_mac.bytes[0], |
| 6170 | GFP_KERNEL); |
| 6171 | } |
| 6172 | #endif |
| 6173 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6174 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6175 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6176 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6177 | eConnectionState connState; |
| 6178 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6179 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6180 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6181 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6182 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6183 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6184 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6185 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
| 6186 | hdd_device_mode_to_string(adapter->device_mode), |
| 6187 | adapter->device_mode); |
| 6188 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6189 | hdd_wmm_init(adapter); |
| 6190 | |
| 6191 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6192 | case QDF_STA_MODE: |
| 6193 | case QDF_P2P_CLIENT_MODE: |
| 6194 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6195 | |
| 6196 | connState = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6197 | ->conn_info.connState; |
| 6198 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6199 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6200 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6201 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6202 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6203 | /* Indicate disconnect event to supplicant |
| 6204 | * if associated previously |
| 6205 | */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6206 | if (eConnectionState_Associated == connState || |
Yue Ma | cd96144 | 2015-10-20 16:15:31 -0700 | [diff] [blame] | 6207 | eConnectionState_IbssConnected == connState || |
| 6208 | eConnectionState_NotConnected == connState || |
| 6209 | eConnectionState_IbssDisconnected == connState || |
| 6210 | eConnectionState_Disconnecting == connState) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6211 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6212 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6213 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6214 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6215 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6216 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6217 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6218 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6219 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6220 | |
| 6221 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6222 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6223 | adapter->dev, false, |
| 6224 | WLAN_REASON_UNSPECIFIED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6225 | } else if (eConnectionState_Connecting == connState) { |
| 6226 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6227 | * Indicate connect failure to supplicant if we |
| 6228 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6229 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6230 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6231 | NULL, 0, NULL, 0, |
| 6232 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6233 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6234 | } |
| 6235 | |
| 6236 | hdd_register_tx_flow_control(adapter, |
| 6237 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6238 | hdd_tx_resume_cb, |
| 6239 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6240 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6241 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6242 | break; |
| 6243 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6244 | case QDF_SAP_MODE: |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6245 | if (hdd_ctx->config->sap_internal_restart) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6246 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6247 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6248 | break; |
| 6249 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6250 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6251 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6252 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6253 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6254 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6255 | hdd_set_mon_rx_cb(adapter->dev); |
| 6256 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6257 | adapter->mon_bandwidth); |
| 6258 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6259 | default: |
| 6260 | break; |
| 6261 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6262 | /* |
| 6263 | * Action frame registered in one adapter which will |
| 6264 | * applicable to all interfaces |
| 6265 | */ |
| 6266 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6267 | } |
| 6268 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6269 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6270 | if (!hdd_is_interface_up(adapter)) |
| 6271 | continue; |
| 6272 | |
| 6273 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6274 | hdd_stop_p2p_go(adapter); |
| 6275 | } |
| 6276 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6277 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6278 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6279 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6280 | } |
| 6281 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6282 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6283 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6284 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6285 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6286 | qdf_list_node_t *node; |
| 6287 | |
| 6288 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6289 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6290 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6291 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6292 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6293 | |
| 6294 | if (QDF_IS_STATUS_ERROR(status)) |
| 6295 | return status; |
| 6296 | |
| 6297 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6298 | |
| 6299 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6300 | } |
| 6301 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6302 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6303 | struct hdd_adapter *current_adapter, |
| 6304 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6305 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6306 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6307 | qdf_list_node_t *node; |
| 6308 | |
| 6309 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6310 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6311 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6312 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6313 | ¤t_adapter->node, |
| 6314 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6315 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6316 | |
| 6317 | if (QDF_IS_STATUS_ERROR(status)) |
| 6318 | return status; |
| 6319 | |
| 6320 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 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_remove_adapter(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 | ffb2154 | 2016-02-17 14:33:03 +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_remove_node(&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 | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6337 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6338 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6339 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6340 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6341 | qdf_list_node_t *node; |
| 6342 | |
| 6343 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6344 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6345 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6346 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6347 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6348 | |
| 6349 | if (QDF_IS_STATUS_ERROR(status)) |
| 6350 | return status; |
| 6351 | |
| 6352 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6353 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6354 | return status; |
| 6355 | } |
| 6356 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6357 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6358 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6359 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6360 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6361 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6362 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6363 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6364 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6365 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6366 | return status; |
| 6367 | } |
| 6368 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6369 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6370 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6371 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6372 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6373 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6374 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6375 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6376 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6377 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6378 | return status; |
| 6379 | } |
| 6380 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6381 | 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] | 6382 | tSirMacAddr macAddr) |
| 6383 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6384 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6385 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6386 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6387 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
| 6388 | macAddr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6389 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6390 | } |
| 6391 | |
| 6392 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6393 | } |
| 6394 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6395 | 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] | 6396 | uint32_t vdev_id) |
| 6397 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6398 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6399 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6400 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6401 | if (adapter->session_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6402 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6403 | } |
| 6404 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6405 | return NULL; |
| 6406 | } |
| 6407 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6408 | /** |
| 6409 | * hdd_get_adapter_by_sme_session_id() - Return adapter with |
| 6410 | * the sessionid |
| 6411 | * @hdd_ctx: hdd context. |
| 6412 | * @sme_session_id: sme session is for the adapter to get. |
| 6413 | * |
| 6414 | * This function is used to get the adapter with provided session id |
| 6415 | * |
| 6416 | * Return: adapter pointer if found |
| 6417 | * |
| 6418 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 6419 | struct hdd_adapter * |
| 6420 | hdd_get_adapter_by_sme_session_id(struct hdd_context *hdd_ctx, |
| 6421 | uint32_t sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6422 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6423 | struct hdd_adapter *adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6424 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6425 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6426 | if (adapter->session_id == sme_session_id) |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6427 | return adapter; |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6428 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6429 | |
Abhishek Singh | 7996eb7 | 2015-12-30 17:24:02 +0530 | [diff] [blame] | 6430 | return NULL; |
| 6431 | } |
| 6432 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6433 | 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] | 6434 | const char *iface_name) |
| 6435 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6436 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6437 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6438 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6439 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6440 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6441 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6442 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6443 | return NULL; |
| 6444 | } |
| 6445 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6446 | /** |
| 6447 | * hdd_get_adapter() - to get adapter matching the mode |
| 6448 | * @hdd_ctx: hdd context |
| 6449 | * @mode: adapter mode |
| 6450 | * |
| 6451 | * This routine will return the pointer to adapter matching |
| 6452 | * with the passed mode. |
| 6453 | * |
| 6454 | * Return: pointer to adapter or null |
| 6455 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6456 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6457 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6458 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6459 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6460 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6461 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6462 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6463 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6464 | } |
| 6465 | |
| 6466 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6467 | } |
| 6468 | |
Jeff Johnson | 36a0abf | 2018-05-20 11:24:25 -0700 | [diff] [blame] | 6469 | enum QDF_OPMODE hdd_get_device_mode(uint32_t session_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6470 | { |
| 6471 | struct hdd_context *hdd_ctx; |
| 6472 | struct hdd_adapter *adapter; |
| 6473 | |
| 6474 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6475 | if (!hdd_ctx) { |
| 6476 | hdd_err("Invalid HDD context"); |
| 6477 | return QDF_MAX_NO_OF_MODE; |
| 6478 | } |
| 6479 | |
| 6480 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, session_id); |
| 6481 | if (!adapter) { |
| 6482 | hdd_err("Invalid HDD adapter"); |
| 6483 | return QDF_MAX_NO_OF_MODE; |
| 6484 | } |
| 6485 | |
| 6486 | return adapter->device_mode; |
| 6487 | } |
| 6488 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6489 | /** |
| 6490 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6491 | * @hdd_ctx: Pointer to the HDD context. |
| 6492 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6493 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6494 | * QDF_STA_MODE, |
| 6495 | * QDF_P2P_CLIENT_MODE, |
| 6496 | * QDF_SAP_MODE, |
| 6497 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6498 | * |
| 6499 | * This API returns the operating channel of the requested device mode |
| 6500 | * |
| 6501 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6502 | * not connected. |
| 6503 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6504 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6505 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6506 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6507 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6508 | uint8_t operatingChannel = 0; |
| 6509 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6510 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6511 | if (mode == adapter->device_mode) { |
| 6512 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6513 | case QDF_STA_MODE: |
| 6514 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6515 | if (hdd_conn_is_connected |
| 6516 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6517 | (adapter))) { |
| 6518 | operatingChannel = |
| 6519 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6520 | (adapter))->conn_info. |
| 6521 | operationChannel; |
| 6522 | } |
| 6523 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6524 | case QDF_SAP_MODE: |
| 6525 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6526 | /* softap connection info */ |
| 6527 | if (test_bit |
| 6528 | (SOFTAP_BSS_STARTED, |
| 6529 | &adapter->event_flags)) |
| 6530 | operatingChannel = |
| 6531 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6532 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6533 | break; |
| 6534 | default: |
| 6535 | break; |
| 6536 | } |
| 6537 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6538 | /* Found the device of interest. break the loop */ |
| 6539 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6540 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6541 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6542 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6543 | return operatingChannel; |
| 6544 | } |
| 6545 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6546 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6547 | hdd_ctx) |
| 6548 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6549 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6550 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6551 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6552 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6553 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6554 | if (adapter->device_mode == QDF_STA_MODE || |
| 6555 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6556 | adapter->device_mode == QDF_IBSS_MODE || |
| 6557 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6558 | adapter->device_mode == QDF_SAP_MODE || |
| 6559 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6560 | hdd_unregister_wext(adapter->dev); |
| 6561 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6562 | } |
| 6563 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6564 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6565 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6566 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6567 | } |
| 6568 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6569 | 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] | 6570 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6571 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6572 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6573 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6574 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6575 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6576 | if (adapter->device_mode == QDF_STA_MODE || |
| 6577 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6578 | adapter->device_mode == QDF_IBSS_MODE || |
| 6579 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6580 | adapter->device_mode == QDF_SAP_MODE || |
| 6581 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 6582 | wlan_abort_scan(hdd_ctx->hdd_pdev, INVAL_PDEV_ID, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 6583 | adapter->session_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 6584 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6585 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6586 | } |
| 6587 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6588 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6589 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6590 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6591 | } |
| 6592 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6593 | /** |
| 6594 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 6595 | * adapters |
| 6596 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 6597 | * |
| 6598 | * return: QDF_STATUS_SUCCESS |
| 6599 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6600 | 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] | 6601 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6602 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6603 | int err; |
| 6604 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6605 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6606 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6607 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6608 | if (adapter->device_mode == QDF_STA_MODE || |
| 6609 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6610 | adapter->device_mode == QDF_IBSS_MODE || |
| 6611 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 6612 | adapter->device_mode == QDF_SAP_MODE || |
| 6613 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6614 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 6615 | if (err) |
| 6616 | hdd_err("Unable to stop scheduled scan"); |
| 6617 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6618 | } |
| 6619 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6620 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6621 | |
| 6622 | return QDF_STATUS_SUCCESS; |
| 6623 | } |
| 6624 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6625 | #ifdef WLAN_NS_OFFLOAD |
| 6626 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6627 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6628 | * @hdd_ctx: Pointer to hdd context |
| 6629 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6630 | * Unregister for IPv6 address change notifications. |
| 6631 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6632 | * Return: None |
| 6633 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6634 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6635 | { |
| 6636 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | } |
| 6638 | |
| 6639 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6640 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6641 | * @hdd_ctx: Pointer to hdd context |
| 6642 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6643 | * Register for IPv6 address change notifications. |
| 6644 | * |
| 6645 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6647 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6648 | { |
| 6649 | int ret; |
| 6650 | |
| 6651 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 6652 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6653 | if (ret) { |
| 6654 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 6655 | goto out; |
| 6656 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6657 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6658 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6659 | out: |
| 6660 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6661 | } |
| 6662 | #else |
| 6663 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6664 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6665 | * @hdd_ctx: Pointer to hdd context |
| 6666 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6667 | * Unregister for IPv6 address change notifications. |
| 6668 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6669 | * Return: None |
| 6670 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6671 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6672 | { |
| 6673 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6674 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6675 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6676 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6677 | * @hdd_ctx: Pointer to hdd context |
| 6678 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6679 | * Register for IPv6 address change notifications. |
| 6680 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6681 | * Return: None |
| 6682 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6683 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6684 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6685 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6686 | } |
| 6687 | #endif |
| 6688 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6689 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 6690 | { |
| 6691 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 6692 | adapter->disconnection_in_progress = status; |
| 6693 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 6694 | hdd_debug("setting disconnection status: %d", status); |
| 6695 | } |
| 6696 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6697 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6698 | * hdd_register_notifiers - Register netdev notifiers. |
| 6699 | * @hdd_ctx: HDD context |
| 6700 | * |
| 6701 | * Register netdev notifiers like IPv4 and IPv6. |
| 6702 | * |
| 6703 | * Return: 0 on success and errno on failure |
| 6704 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6705 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6706 | { |
| 6707 | int ret; |
| 6708 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6709 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 6710 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6711 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6712 | |
| 6713 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 6714 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 6715 | if (ret) { |
| 6716 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 6717 | goto unregister_ip6_notifier; |
| 6718 | } |
| 6719 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6720 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 6721 | if (ret) { |
| 6722 | hdd_err("Failed to register netevent notifier: %d", |
| 6723 | ret); |
| 6724 | goto unregister_inetaddr_notifier; |
| 6725 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6726 | return 0; |
| 6727 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6728 | unregister_inetaddr_notifier: |
| 6729 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6730 | unregister_ip6_notifier: |
| 6731 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6732 | out: |
| 6733 | return ret; |
| 6734 | |
| 6735 | } |
| 6736 | |
| 6737 | /** |
| 6738 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 6739 | * @hdd_ctx: HDD context |
| 6740 | * |
| 6741 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 6742 | * |
| 6743 | * Return: None. |
| 6744 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6745 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6746 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6747 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6748 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 6749 | |
| 6750 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 6751 | } |
| 6752 | |
| 6753 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6754 | * hdd_exit_netlink_services - Exit netlink services |
| 6755 | * @hdd_ctx: HDD context |
| 6756 | * |
| 6757 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6758 | * nl service. |
| 6759 | * |
| 6760 | * Return: None. |
| 6761 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6762 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6763 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6764 | spectral_scan_deactivate_service(); |
| 6765 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6766 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6767 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6768 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6769 | |
| 6770 | nl_srv_exit(); |
| 6771 | } |
| 6772 | |
| 6773 | /** |
| 6774 | * hdd_init_netlink_services- Init netlink services |
| 6775 | * @hdd_ctx: HDD context |
| 6776 | * |
| 6777 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 6778 | * nl service. |
| 6779 | * |
| 6780 | * Return: 0 on success and errno on failure. |
| 6781 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6782 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6783 | { |
| 6784 | int ret; |
| 6785 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6786 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6787 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6788 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6789 | goto out; |
| 6790 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 6791 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6792 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 6793 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6794 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6795 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6796 | goto err_nl_srv; |
| 6797 | } |
| 6798 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6799 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6800 | |
| 6801 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 6802 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6803 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6804 | |
| 6805 | ret = cnss_diag_activate_service(); |
| 6806 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 6807 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6808 | goto err_close_cesium; |
| 6809 | } |
| 6810 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6811 | spectral_scan_activate_service(); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 6812 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6813 | return 0; |
| 6814 | |
| 6815 | err_close_cesium: |
| 6816 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6817 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 6818 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6819 | err_nl_srv: |
| 6820 | nl_srv_exit(); |
| 6821 | out: |
| 6822 | return ret; |
| 6823 | } |
| 6824 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6825 | /** |
| 6826 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 6827 | * @hdd_ctx: HDD context. |
| 6828 | * |
| 6829 | * Destroy RX wakelock. |
| 6830 | * |
| 6831 | * Return: None. |
| 6832 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6833 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6834 | { |
| 6835 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 6836 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 6837 | |
| 6838 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6839 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 6840 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6841 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6842 | * Create RX wakelock. |
| 6843 | * |
| 6844 | * Return: None. |
| 6845 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6846 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6847 | { |
| 6848 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 6849 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6850 | |
| 6851 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6852 | * hdd_context_deinit() - Deinitialize HDD context |
| 6853 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6854 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6855 | * Deinitialize HDD context along with all the feature specific contexts but |
| 6856 | * do not free hdd context itself. Caller of this API is supposed to free |
| 6857 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6858 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6859 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6860 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6861 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6862 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 6863 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 6864 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6865 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6866 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6867 | hdd_sap_context_destroy(hdd_ctx); |
| 6868 | |
| 6869 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 6870 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6871 | hdd_scan_context_destroy(hdd_ctx); |
| 6872 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6873 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 6874 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6875 | return 0; |
| 6876 | } |
| 6877 | |
| 6878 | /** |
| 6879 | * hdd_context_destroy() - Destroy HDD context |
| 6880 | * @hdd_ctx: HDD context to be destroyed. |
| 6881 | * |
| 6882 | * Free config and HDD context as well as destroy all the resources. |
| 6883 | * |
| 6884 | * Return: None |
| 6885 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6886 | static void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6887 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 6888 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 6889 | |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 6890 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 6891 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 6892 | hdd_context_deinit(hdd_ctx); |
| 6893 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 6894 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6895 | hdd_ctx->config = NULL; |
| 6896 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 6897 | cfg_release(); |
| 6898 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 6899 | wiphy_free(hdd_ctx->wiphy); |
| 6900 | } |
| 6901 | |
| 6902 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6903 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 6904 | * |
| 6905 | * This function is used to destroy bug report lock |
| 6906 | * |
| 6907 | * Return: None |
| 6908 | */ |
| 6909 | static void wlan_destroy_bug_report_lock(void) |
| 6910 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 6911 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 6912 | |
| 6913 | p_cds_context = cds_get_global_context(); |
| 6914 | if (!p_cds_context) { |
| 6915 | hdd_err("cds context is NULL"); |
| 6916 | return; |
| 6917 | } |
| 6918 | |
| 6919 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 6920 | } |
| 6921 | |
| 6922 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6923 | * hdd_wlan_exit() - HDD WLAN exit function |
| 6924 | * @hdd_ctx: Pointer to the HDD Context |
| 6925 | * |
| 6926 | * This is the driver exit point (invoked during rmmod) |
| 6927 | * |
| 6928 | * Return: None |
| 6929 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6930 | static void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6931 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6932 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6933 | int driver_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6934 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6935 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6936 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6937 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6938 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 6939 | hdd_bus_bandwidth_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6940 | |
| 6941 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6942 | if (QDF_TIMER_STATE_RUNNING == |
| 6943 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 6944 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6945 | } |
| 6946 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6947 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 6948 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 6949 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6950 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 6951 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 6952 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 6953 | hdd_ctx->last_acs_channel_list = NULL; |
| 6954 | hdd_ctx->num_of_channels = 0; |
| 6955 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6956 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6957 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6958 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 6959 | driver_status = hdd_ctx->driver_status; |
| 6960 | mutex_unlock(&hdd_ctx->iface_change_lock); |
| 6961 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6962 | /* |
| 6963 | * Powersave Offload Case |
| 6964 | * Disable Idle Power Save Mode |
| 6965 | */ |
| 6966 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 6967 | /* clear the scan queue in all the scenarios */ |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 6968 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6969 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6970 | if (driver_status != DRIVER_MODULES_CLOSED) { |
| 6971 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 6972 | /* |
| 6973 | * Cancel any outstanding scan requests. We are about to close |
| 6974 | * all of our adapters, but an adapter structure is what SME |
| 6975 | * passes back to our callback function. Hence if there |
| 6976 | * are any outstanding scan requests then there is a |
| 6977 | * race condition between when the adapter is closed and |
| 6978 | * when the callback is invoked. We try to resolve that |
| 6979 | * race condition here by canceling any outstanding scans |
| 6980 | * before we close the adapters. |
| 6981 | * Note that the scans may be cancelled in an asynchronous |
| 6982 | * manner, so ideally there needs to be some kind of |
| 6983 | * synchronization. Rather than introduce a new |
| 6984 | * synchronization here, we will utilize the fact that we are |
| 6985 | * about to Request Full Power, and since that is synchronized, |
| 6986 | * the expectation is that by the time Request Full Power has |
| 6987 | * completed, all scans will be cancelled |
| 6988 | */ |
| 6989 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 6990 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 6991 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 6992 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6993 | } |
| 6994 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 6995 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 6996 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 6997 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 6998 | qdf_dp_trace_deinit(); |
| 6999 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7000 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7001 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7002 | hdd_driver_memdump_deinit(); |
| 7003 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7004 | qdf_nbuf_deinit_replenish_timer(); |
| 7005 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7006 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7007 | hdd_info("Release wakelock for monitor mode!"); |
| 7008 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7009 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7010 | } |
| 7011 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7012 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
| 7013 | qdf_spinlock_destroy(&hdd_ctx->sta_update_info_lock); |
| 7014 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
| 7015 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7016 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7017 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7018 | hdd_close_all_adapters(hdd_ctx, false); |
| 7019 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7020 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7021 | /* |
| 7022 | * If there is re_init failure wiphy would have already de-registered |
| 7023 | * check the wiphy status before un-registering again |
| 7024 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7025 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7026 | wiphy_unregister(wiphy); |
| 7027 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7028 | hdd_lpass_notify_stop(hdd_ctx); |
| 7029 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7030 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7031 | hdd_exit_netlink_services(hdd_ctx); |
| 7032 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7033 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7034 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7035 | #endif |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7036 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 7037 | driver_status = hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7038 | if (driver_status) |
| 7039 | hdd_err("Psoc delete failed"); |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 7040 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7041 | hdd_context_destroy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7042 | } |
| 7043 | |
| 7044 | void __hdd_wlan_exit(void) |
| 7045 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7046 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7047 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7048 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7049 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7050 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7051 | if (!hdd_ctx) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7052 | hdd_err("Invalid HDD Context"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7053 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7054 | return; |
| 7055 | } |
| 7056 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7057 | /* Do all the cleanup before deregistering the driver */ |
| 7058 | hdd_wlan_exit(hdd_ctx); |
Mohit Khanna | ebf8a86 | 2016-04-28 17:53:59 -0700 | [diff] [blame] | 7059 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7060 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7061 | } |
| 7062 | |
| 7063 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7064 | /** |
| 7065 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7066 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7067 | * |
| 7068 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7069 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7070 | * scan information. |
| 7071 | * |
| 7072 | * Return: void |
| 7073 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7074 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7075 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7076 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7077 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7078 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7079 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7080 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7081 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7082 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7083 | hdd_ctx->last_acs_channel_list = NULL; |
| 7084 | hdd_ctx->num_of_channels = 0; |
| 7085 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7086 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7087 | mac_handle = hdd_ctx->mac_handle; |
| 7088 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7089 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7090 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7091 | } |
| 7092 | #endif |
| 7093 | |
| 7094 | #ifdef QCA_HT_2040_COEX |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7095 | int hdd_wlan_set_ht2040_mode(struct hdd_adapter *adapter, uint16_t sta_id, |
| 7096 | struct qdf_mac_addr sta_mac, int channel_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7097 | { |
| 7098 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7099 | QDF_STATUS qdf_status; |
Jeff Johnson | e7672e7 | 2017-10-21 15:10:04 -0700 | [diff] [blame] | 7100 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7101 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7102 | |
| 7103 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 7104 | |
| 7105 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7106 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7107 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7108 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7109 | mac_handle = hdd_ctx->mac_handle; |
| 7110 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7111 | return -EINVAL; |
| 7112 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7113 | qdf_status = sme_notify_ht2040_mode(mac_handle, sta_id, sta_mac, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7114 | adapter->session_id, channel_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7115 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7116 | hdd_err("Fail to send notification with ht2040 mode"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7117 | return -EINVAL; |
| 7118 | } |
| 7119 | |
| 7120 | return 0; |
| 7121 | } |
| 7122 | #endif |
| 7123 | |
| 7124 | /** |
| 7125 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7126 | * @state: state |
| 7127 | * |
| 7128 | * This function notifies FW with modem power status |
| 7129 | * |
| 7130 | * Return: 0 if successful, error number otherwise |
| 7131 | */ |
| 7132 | int hdd_wlan_notify_modem_power_state(int state) |
| 7133 | { |
| 7134 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7135 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7136 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7137 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7138 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7139 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7140 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7141 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7142 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7143 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7144 | mac_handle = hdd_ctx->mac_handle; |
| 7145 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7146 | return -EINVAL; |
| 7147 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7148 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7149 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7150 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7151 | state); |
| 7152 | return -EINVAL; |
| 7153 | } |
| 7154 | return 0; |
| 7155 | } |
| 7156 | |
| 7157 | /** |
| 7158 | * |
| 7159 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7160 | * @adapter - Pointer to the HDD |
| 7161 | * |
| 7162 | * Return: None |
| 7163 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7164 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7165 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7166 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7167 | |
| 7168 | /* |
| 7169 | * Send ready indication to the HDD. This will kick off the MAC |
| 7170 | * into a 'running' state and should kick off an initial scan. |
| 7171 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7172 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7173 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7174 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7175 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7176 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7177 | } |
| 7178 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7179 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7180 | } |
| 7181 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7182 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7183 | { |
| 7184 | struct hdd_adapter *adapter; |
| 7185 | |
| 7186 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7187 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7188 | return adapter; |
| 7189 | } |
| 7190 | |
| 7191 | return NULL; |
| 7192 | } |
| 7193 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7194 | /* wake lock APIs for HDD */ |
| 7195 | void hdd_prevent_suspend(uint32_t reason) |
| 7196 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7197 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7198 | } |
| 7199 | |
| 7200 | void hdd_allow_suspend(uint32_t reason) |
| 7201 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7202 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7203 | } |
| 7204 | |
| 7205 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7206 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7207 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7208 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7209 | } |
| 7210 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7211 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7212 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7213 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7214 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7215 | hdd_ctx->reg.alpha2, |
| 7216 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7217 | } |
| 7218 | |
| 7219 | /** |
| 7220 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7221 | * @hdd_ctx: Pointer to the hdd context |
| 7222 | * |
| 7223 | * HDD function to know if hardware supports 5GHz |
| 7224 | * |
| 7225 | * Return: true if hardware supports 5GHz |
| 7226 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7227 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7228 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7229 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7230 | return true; |
| 7231 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7232 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7233 | return true; |
| 7234 | else |
| 7235 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7236 | } |
| 7237 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7238 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7239 | { |
| 7240 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7241 | int ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7242 | |
| 7243 | wiphy = hdd_ctx->wiphy; |
| 7244 | |
| 7245 | /* |
| 7246 | * The channel information in |
| 7247 | * wiphy needs to be initialized before wiphy registration |
| 7248 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7249 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7250 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7251 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7252 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7253 | } |
| 7254 | |
| 7255 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7256 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7257 | #else |
| 7258 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7259 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7260 | WIPHY_WOWLAN_DISCONNECT | |
| 7261 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7262 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7263 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7264 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7265 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7266 | |
| 7267 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7268 | WOW_MAX_FILTERS_PER_LIST); |
| 7269 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7270 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7271 | #endif |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7272 | if (hdd_ctx->obss_scan_offload) { |
| 7273 | hdd_debug("wmi_service_obss_scan supported"); |
| 7274 | } else if (hdd_ctx->config->nChannelBondingMode24GHz) { |
| 7275 | hdd_debug("enable wpa_supp obss_scan"); |
| 7276 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7277 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7278 | |
| 7279 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7280 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7281 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7282 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7283 | return ret_val; |
| 7284 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7285 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7286 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7287 | * has support for processing user cell_base hints when wiphy is |
| 7288 | * self managed or check the backport flag for the same. |
| 7289 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7290 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7291 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7292 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7293 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7294 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7295 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7296 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7297 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7298 | } |
| 7299 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7300 | #ifdef MSM_PLATFORM |
| 7301 | /** |
| 7302 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7303 | * @hdd_ctx - handle to hdd context |
| 7304 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7305 | * |
| 7306 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7307 | * Stats show up in wlan driver logs. |
| 7308 | * |
| 7309 | * Returns: None |
| 7310 | */ |
| 7311 | static inline |
| 7312 | void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7313 | bool data_in_interval) |
| 7314 | { |
| 7315 | static u32 counter; |
| 7316 | static bool data_in_time_period; |
| 7317 | ol_txrx_pdev_handle pdev; |
| 7318 | |
| 7319 | if (hdd_ctx->config->periodic_stats_disp_time == 0) |
| 7320 | return; |
| 7321 | |
| 7322 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7323 | if (!pdev) { |
| 7324 | hdd_err("pdev is NULL"); |
| 7325 | return; |
| 7326 | } |
| 7327 | |
| 7328 | counter++; |
| 7329 | if (data_in_interval) |
| 7330 | data_in_time_period = data_in_interval; |
| 7331 | |
| 7332 | if (counter * hdd_ctx->config->busBandwidthComputeInterval >= |
| 7333 | hdd_ctx->config->periodic_stats_disp_time * 1000) { |
| 7334 | if (data_in_time_period) { |
| 7335 | cdp_display_stats(cds_get_context(QDF_MODULE_ID_SOC), |
| 7336 | CDP_TXRX_PATH_STATS, |
| 7337 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7338 | wlan_hdd_display_netif_queue_history |
| 7339 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7340 | qdf_dp_trace_dump_stats(); |
| 7341 | } |
| 7342 | counter = 0; |
| 7343 | data_in_time_period = false; |
| 7344 | } |
| 7345 | } |
| 7346 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7347 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7348 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7349 | * @hdd_ctx: pointer to struct hdd_context |
| 7350 | * |
| 7351 | * Return: none |
| 7352 | */ |
| 7353 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7354 | { |
| 7355 | struct hdd_adapter *adapter; |
| 7356 | |
| 7357 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7358 | hdd_send_rps_disable_ind(adapter); |
| 7359 | } |
| 7360 | |
| 7361 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7362 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7363 | * @hdd_ctx - handle to hdd context |
| 7364 | * @tx_packets - transmit packet count |
| 7365 | * @rx_packets - receive packet count |
| 7366 | * |
| 7367 | * The function controls the bus bandwidth and dynamic control of |
| 7368 | * tcp delayed ack configuration |
| 7369 | * |
| 7370 | * Returns: None |
| 7371 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7372 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7373 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7374 | const uint64_t tx_packets, |
| 7375 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7376 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7377 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7378 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7379 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7380 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7381 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7382 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7383 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7384 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7385 | uint16_t index = 0; |
| 7386 | bool vote_level_change = false; |
| 7387 | bool rx_level_change = false; |
| 7388 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7389 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7390 | bool dptrace_high_tput_req; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7391 | if (total_pkts > hdd_ctx->config->busBandwidthHighThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7392 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7393 | else if (total_pkts > hdd_ctx->config->busBandwidthMediumThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7394 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7395 | else if (total_pkts > hdd_ctx->config->busBandwidthLowThreshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7396 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7397 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7398 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7399 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7400 | dptrace_high_tput_req = |
| 7401 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7403 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7404 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7405 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7406 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7407 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7408 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7409 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7410 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7411 | if (hdd_ctx->hbw_requested) { |
| 7412 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7413 | hdd_ctx->hbw_requested = false; |
| 7414 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7415 | if (hdd_ctx->dynamic_rps) |
| 7416 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7417 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7418 | if (!hdd_ctx->hbw_requested) { |
| 7419 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7420 | hdd_ctx->hbw_requested = true; |
| 7421 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7422 | if (hdd_ctx->dynamic_rps) |
| 7423 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7424 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7425 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7426 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7427 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7428 | tx_packets, |
| 7429 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7430 | |
| 7431 | if (rx_packets < hdd_ctx->config->busBandwidthLowThreshold) |
| 7432 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7433 | else |
| 7434 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7435 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7436 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7437 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7438 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7439 | /* |
| 7440 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7441 | * perf core is also required for udp. |
| 7442 | */ |
| 7443 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7444 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7445 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7446 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7447 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7448 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7449 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7450 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7451 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7452 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7453 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7454 | |
| 7455 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7456 | /* |
| 7457 | * Takes care to set Rx_thread affinity for below case |
| 7458 | * 1)LRO/GRO not supported ROME case |
| 7459 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7460 | * 3)For UDP cases |
| 7461 | */ |
| 7462 | if (avg_no_rx_offload_pkts > |
| 7463 | hdd_ctx->config->busBandwidthHighThreshold) |
| 7464 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7465 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7466 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7467 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7468 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7469 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7470 | rxthread_high_tput_req); |
| 7471 | |
| 7472 | /* fine-tuning parameters for RX Flows */ |
| 7473 | if (avg_rx > hdd_ctx->config->tcpDelackThresholdHigh) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7474 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7475 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7476 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7477 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7478 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7479 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7480 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7481 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7482 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7483 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7484 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7485 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7486 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7487 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7488 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7489 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7490 | /* Send throughput indication only if it is enabled. |
| 7491 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7492 | * to default delayed ack. Note that this will disable the |
| 7493 | * dynamic delayed ack mechanism across the system |
| 7494 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7495 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7496 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7497 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7498 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7499 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7500 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7501 | rx_tp_data.level = next_rx_level; |
| 7502 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7503 | WLAN_SVC_WLAN_TP_IND, &rx_tp_data, |
| 7504 | sizeof(rx_tp_data)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7505 | } |
| 7506 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7507 | /* fine-tuning parameters for TX Flows */ |
| 7508 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7509 | hdd_ctx->prev_tx = tx_packets; |
| 7510 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7511 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7512 | else |
| 7513 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7514 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7515 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7516 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7517 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7518 | next_tx_level, temp_tx); |
| 7519 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7520 | tx_level_change = true; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 7521 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 7522 | WLAN_SVC_WLAN_TP_TX_IND, |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7523 | &next_tx_level, |
| 7524 | sizeof(next_tx_level)); |
| 7525 | } |
| 7526 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7527 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7528 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7529 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7530 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7531 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7532 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7533 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7534 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7535 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7536 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7537 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7538 | |
| 7539 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7540 | } |
| 7541 | |
| 7542 | #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] | 7543 | static void hdd_bus_bw_work_handler(struct work_struct *work) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7544 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7545 | struct hdd_context *hdd_ctx = container_of(work, struct hdd_context, |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7546 | bus_bw_work); |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7547 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7548 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7549 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7550 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7551 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7552 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7553 | bool connected = false; |
| 7554 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7555 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7556 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7557 | return; |
| 7558 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7559 | if (hdd_ctx->is_wiphy_suspended) |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7560 | goto restart_timer; |
| 7561 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7562 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7563 | /* |
| 7564 | * Validate magic so we don't end up accessing |
| 7565 | * an invalid adapter. |
| 7566 | */ |
| 7567 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7568 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7569 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7570 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7571 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7572 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.connState |
| 7573 | != eConnectionState_Associated) { |
| 7574 | |
| 7575 | continue; |
| 7576 | } |
| 7577 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7578 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7579 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7580 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7581 | |
| 7582 | continue; |
| 7583 | } |
| 7584 | |
| 7585 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7586 | adapter->prev_tx_packets); |
| 7587 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7588 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7589 | |
| 7590 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7591 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7592 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7593 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7594 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7595 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7596 | adapter->session_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7597 | &fwd_tx_packets, &fwd_rx_packets); |
| 7598 | if (ret == A_OK) { |
| 7599 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 7600 | fwd_tx_packets, |
| 7601 | adapter->prev_fwd_tx_packets); |
| 7602 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 7603 | fwd_tx_packets, |
| 7604 | adapter->prev_fwd_rx_packets); |
| 7605 | } |
| 7606 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7607 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7608 | if (adapter->device_mode == QDF_SAP_MODE) |
| 7609 | con_sap_adapter = adapter; |
| 7610 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7611 | total_rx += adapter->stats.rx_packets; |
| 7612 | total_tx += adapter->stats.tx_packets; |
| 7613 | |
| 7614 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 7615 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 7616 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7617 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 7618 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7619 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 7620 | connected = true; |
| 7621 | } |
| 7622 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7623 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7624 | hdd_err("bus bandwidth timer running in disconnected state"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7625 | return; |
| 7626 | } |
| 7627 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7628 | /* add intra bss forwarded tx and rx packets */ |
| 7629 | tx_packets += fwd_tx_packets_diff; |
| 7630 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7631 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7632 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->hdd_pdev)) { |
| 7633 | ucfg_ipa_uc_stat_query(hdd_ctx->hdd_pdev, &ipa_tx_packets, |
| 7634 | &ipa_rx_packets); |
| 7635 | tx_packets += (uint64_t)ipa_tx_packets; |
| 7636 | rx_packets += (uint64_t)ipa_rx_packets; |
| 7637 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7638 | if (con_sap_adapter) { |
| 7639 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 7640 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 7641 | } |
| 7642 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 7643 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, tx_packets, rx_packets); |
| 7644 | ucfg_ipa_uc_stat_request(hdd_ctx->hdd_pdev, 2); |
| 7645 | } |
| 7646 | |
| 7647 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7648 | |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7649 | restart_timer: |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7650 | /* ensure periodic timer should still be running before restarting it */ |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7651 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 2ed6036 | 2017-01-18 12:25:50 -0800 | [diff] [blame] | 7652 | if (hdd_ctx->bus_bw_timer_running) |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 7653 | qdf_timer_mod(&hdd_ctx->bus_bw_timer, |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7654 | hdd_ctx->config->busBandwidthComputeInterval); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7655 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7656 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7657 | |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7658 | /** |
| 7659 | * __hdd_bus_bw_cbk() - Bus bandwidth data structure callback. |
| 7660 | * @arg: Argument of timer function |
| 7661 | * |
| 7662 | * Schedule a workqueue in this function where all the processing is done. |
| 7663 | * |
| 7664 | * Return: None. |
| 7665 | */ |
| 7666 | static void __hdd_bus_bw_cbk(void *arg) |
| 7667 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7668 | struct hdd_context *hdd_ctx = (struct hdd_context *) arg; |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7669 | |
| 7670 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 7671 | return; |
| 7672 | |
| 7673 | schedule_work(&hdd_ctx->bus_bw_work); |
| 7674 | } |
| 7675 | |
| 7676 | /** |
| 7677 | * hdd_bus_bw_cbk() - Wrapper for bus bw callback for SSR protection. |
| 7678 | * @arg: Argument of timer function |
| 7679 | * |
| 7680 | * Return: None. |
| 7681 | */ |
| 7682 | static void hdd_bus_bw_cbk(void *arg) |
| 7683 | { |
| 7684 | cds_ssr_protect(__func__); |
| 7685 | __hdd_bus_bw_cbk(arg); |
| 7686 | cds_ssr_unprotect(__func__); |
| 7687 | } |
| 7688 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7689 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7690 | { |
| 7691 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7692 | INIT_WORK(&hdd_ctx->bus_bw_work, |
| 7693 | hdd_bus_bw_work_handler); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7694 | hdd_ctx->bus_bw_timer_running = false; |
| 7695 | qdf_spinlock_create(&hdd_ctx->bus_bw_timer_lock); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7696 | qdf_timer_init(NULL, |
| 7697 | &hdd_ctx->bus_bw_timer, |
| 7698 | hdd_bus_bw_cbk, (void *)hdd_ctx, |
| 7699 | QDF_TIMER_TYPE_SW); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7700 | |
| 7701 | return 0; |
| 7702 | } |
| 7703 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7704 | void hdd_bus_bandwidth_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7705 | { |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7706 | if (hdd_ctx->bus_bw_timer_running) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7707 | hdd_reset_tcp_delack(hdd_ctx); |
| 7708 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7709 | hdd_debug("wait for bus bw work to flush"); |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 7710 | hdd_cancel_bus_bw_work(hdd_ctx); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 7711 | qdf_timer_free(&hdd_ctx->bus_bw_timer); |
Dustin Brown | fce08d1 | 2017-01-17 16:29:38 -0800 | [diff] [blame] | 7712 | hdd_ctx->bus_bw_timer_running = false; |
| 7713 | qdf_spinlock_destroy(&hdd_ctx->bus_bw_timer_lock); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7714 | } |
Lin Bai | c5c0688 | 2017-09-21 13:58:43 +0800 | [diff] [blame] | 7715 | |
| 7716 | void hdd_bus_bw_cancel_work(struct hdd_context *hdd_ctx) |
| 7717 | { |
| 7718 | if (hdd_ctx) |
| 7719 | cancel_work_sync(&hdd_ctx->bus_bw_work); |
| 7720 | } |
jiad | cdaf9bd | 2017-10-26 12:20:21 +0800 | [diff] [blame] | 7721 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7722 | #endif |
| 7723 | |
| 7724 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7725 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 7726 | * @hdd_ctx: hdd context |
| 7727 | * |
| 7728 | * Return: 0 for success or error code |
| 7729 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7730 | 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] | 7731 | { |
| 7732 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 7733 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
| 7734 | if (hdd_ctx->hdd_txrx_hist == NULL) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7735 | hdd_err("Failed malloc for hdd_txrx_hist"); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7736 | return -ENOMEM; |
| 7737 | } |
| 7738 | return 0; |
| 7739 | } |
| 7740 | |
| 7741 | /** |
| 7742 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 7743 | * @hdd_ctx: hdd context |
| 7744 | * |
| 7745 | * Return: none |
| 7746 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7747 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7748 | { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7749 | if (!hdd_ctx || hdd_ctx->hdd_txrx_hist == NULL) |
| 7750 | return; |
| 7751 | |
| 7752 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 7753 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7754 | } |
| 7755 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7756 | static uint8_t *convert_level_to_string(uint32_t level) |
| 7757 | { |
| 7758 | switch (level) { |
| 7759 | /* initialize the wlan sub system */ |
| 7760 | case WLAN_SVC_TP_NONE: |
| 7761 | return "NONE"; |
| 7762 | case WLAN_SVC_TP_LOW: |
| 7763 | return "LOW"; |
| 7764 | case WLAN_SVC_TP_MEDIUM: |
| 7765 | return "MED"; |
| 7766 | case WLAN_SVC_TP_HIGH: |
| 7767 | return "HIGH"; |
| 7768 | default: |
| 7769 | return "INVAL"; |
| 7770 | } |
| 7771 | } |
| 7772 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7773 | |
| 7774 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7775 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 7776 | * @hdd_ctx: hdd context |
| 7777 | * |
| 7778 | * Return: none |
| 7779 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7780 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7781 | { |
| 7782 | int i; |
| 7783 | |
| 7784 | #ifdef MSM_PLATFORM |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7785 | hdd_debug("BW compute Interval: %dms", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7786 | hdd_ctx->config->busBandwidthComputeInterval); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7787 | 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] | 7788 | hdd_ctx->config->busBandwidthHighThreshold, |
| 7789 | hdd_ctx->config->busBandwidthMediumThreshold, |
| 7790 | hdd_ctx->config->busBandwidthLowThreshold); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7791 | hdd_debug("Enable TCP DEL ACK: %d", |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7792 | hdd_ctx->en_tcp_delack_no_lro); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7793 | hdd_debug("TCP DEL High TH: %d TCP DEL Low TH: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7794 | hdd_ctx->config->tcpDelackThresholdHigh, |
| 7795 | hdd_ctx->config->tcpDelackThresholdLow); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7796 | 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] | 7797 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7798 | #endif |
| 7799 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7800 | hdd_debug("Total entries: %d Current index: %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7801 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
| 7802 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7803 | 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] | 7804 | |
| 7805 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7806 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7807 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7808 | hdd_debug("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 7809 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 7810 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 7811 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 7812 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7813 | hdd_ctx->hdd_txrx_hist[i]. |
| 7814 | next_vote_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7815 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7816 | hdd_ctx->hdd_txrx_hist[i]. |
| 7817 | next_rx_level), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7818 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7819 | hdd_ctx->hdd_txrx_hist[i]. |
| 7820 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7821 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7822 | } |
| 7823 | |
| 7824 | /** |
| 7825 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 7826 | * @hdd_ctx: hdd context |
| 7827 | * |
| 7828 | * Return: none |
| 7829 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7830 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7831 | { |
| 7832 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 7833 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 7834 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7835 | } |
| 7836 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7837 | /* length of the netif queue log needed per adapter */ |
| 7838 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 7839 | |
| 7840 | /** |
| 7841 | * |
| 7842 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 7843 | * @hdd_ctx: hdd context |
| 7844 | * |
| 7845 | * Return: none |
| 7846 | */ |
| 7847 | static void |
| 7848 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 7849 | { |
| 7850 | int adapter_num = 0; |
| 7851 | int i; |
| 7852 | int bytes_written; |
| 7853 | u32 tbytes; |
| 7854 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7855 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7856 | char *comb_log_str; |
| 7857 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7858 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7859 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7860 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * MAX_NUMBER_OF_ADAPTERS) + 1; |
| 7861 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
| 7862 | if (!comb_log_str) { |
| 7863 | hdd_err("failed to alloc comb_log_str"); |
| 7864 | return; |
| 7865 | } |
| 7866 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7867 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7868 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7869 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7870 | curr_time = qdf_system_ticks(); |
| 7871 | total = curr_time - adapter->start_time; |
| 7872 | delta = curr_time - adapter->last_time; |
| 7873 | |
| 7874 | if (adapter->pause_map) { |
| 7875 | pause = adapter->total_pause_time + delta; |
| 7876 | unpause = adapter->total_unpause_time; |
| 7877 | } else { |
| 7878 | unpause = adapter->total_unpause_time + delta; |
| 7879 | pause = adapter->total_pause_time; |
| 7880 | } |
| 7881 | |
| 7882 | tbytes = 0; |
| 7883 | qdf_mem_set(temp_str, 0, sizeof(temp_str)); |
| 7884 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7885 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 7886 | continue; |
| 7887 | tbytes += |
| 7888 | snprintf( |
| 7889 | &temp_str[tbytes], |
| 7890 | (tbytes >= sizeof(temp_str) ? |
| 7891 | 0 : sizeof(temp_str) - tbytes), |
| 7892 | "%d(%d,%d) ", |
| 7893 | i, |
| 7894 | adapter->queue_oper_stats[i]. |
| 7895 | pause_count, |
| 7896 | adapter->queue_oper_stats[i]. |
| 7897 | unpause_count); |
| 7898 | } |
| 7899 | if (tbytes >= sizeof(temp_str)) |
| 7900 | hdd_warn("log truncated"); |
| 7901 | |
| 7902 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7903 | bytes_written >= comb_log_str_size ? 0 : |
| 7904 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7905 | "[%d %d] (%d) %u/%ums %s|", |
| 7906 | adapter->session_id, adapter->device_mode, |
| 7907 | adapter->pause_map, |
| 7908 | qdf_system_ticks_to_msecs(pause), |
| 7909 | qdf_system_ticks_to_msecs(total), |
| 7910 | temp_str); |
| 7911 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7912 | adapter_num++; |
| 7913 | } |
| 7914 | |
| 7915 | /* using QDF_TRACE to avoid printing function name */ |
| 7916 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 7917 | "STATS |%s", comb_log_str); |
| 7918 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7919 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7920 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 7921 | |
| 7922 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7923 | } |
| 7924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7925 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 7926 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 7927 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7928 | * |
| 7929 | * Return: none |
| 7930 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7931 | void |
| 7932 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 7933 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7934 | { |
| 7935 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7936 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7937 | int i; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7938 | qdf_time_t total, pause, unpause, curr_time, delta; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7939 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7940 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 7941 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 7942 | return; |
| 7943 | } |
| 7944 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7945 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7946 | hdd_debug("Netif queue operation statistics:"); |
| 7947 | hdd_debug("Session_id %d device mode %d", |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 7948 | adapter->session_id, adapter->device_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7949 | hdd_debug("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7950 | curr_time = qdf_system_ticks(); |
| 7951 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7952 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7953 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7954 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7955 | unpause = adapter->total_unpause_time; |
| 7956 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7957 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7958 | pause = adapter->total_pause_time; |
| 7959 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7960 | hdd_debug("Total: %ums Pause: %ums Unpause: %ums", |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 7961 | qdf_system_ticks_to_msecs(total), |
| 7962 | qdf_system_ticks_to_msecs(pause), |
| 7963 | qdf_system_ticks_to_msecs(unpause)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7964 | hdd_debug("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7965 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7966 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 7967 | qdf_time_t pause_delta = 0; |
| 7968 | |
| 7969 | if (adapter->pause_map & (1 << i)) |
| 7970 | pause_delta = delta; |
| 7971 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7972 | /* using hdd_log to avoid printing function name */ |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7973 | hdd_debug("%s: %d: %d: %ums", |
| 7974 | hdd_reason_type_to_string(i), |
| 7975 | adapter->queue_oper_stats[i].pause_count, |
| 7976 | adapter->queue_oper_stats[i].unpause_count, |
| 7977 | qdf_system_ticks_to_msecs( |
| 7978 | adapter->queue_oper_stats[i].total_pause_time + |
| 7979 | pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7980 | } |
| 7981 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7982 | hdd_debug("Netif queue operation history:"); |
| 7983 | hdd_debug("Total entries: %d current index %d", |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 7984 | WLAN_HDD_MAX_HISTORY_ENTRY, adapter->history_index); |
| 7985 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7986 | hdd_debug("index: time: action_type: reason_type: pause_map"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7987 | |
| 7988 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 7989 | /* using hdd_log to avoid printing function name */ |
| 7990 | if (adapter->queue_oper_history[i].time == 0) |
| 7991 | continue; |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7992 | hdd_debug("%d: %u: %s: %s: %x", |
| 7993 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7994 | adapter->queue_oper_history[i].time), |
Dustin Brown | 632af71 | 2018-03-14 15:03:55 -0700 | [diff] [blame] | 7995 | hdd_action_type_to_string( |
| 7996 | adapter->queue_oper_history[i].netif_action), |
| 7997 | hdd_reason_type_to_string( |
| 7998 | adapter->queue_oper_history[i].netif_reason), |
| 7999 | adapter->queue_oper_history[i].pause_map); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8000 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8001 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8002 | } |
| 8003 | |
| 8004 | /** |
| 8005 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8006 | * @hdd_ctx: hdd context |
| 8007 | * |
| 8008 | * Return: none |
| 8009 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8010 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8011 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8012 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8013 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8014 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8015 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8016 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8017 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8018 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8019 | adapter->history_index = 0; |
| 8020 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8021 | adapter->total_pause_time = 0; |
| 8022 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8023 | } |
| 8024 | } |
| 8025 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8026 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8027 | /** |
| 8028 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8029 | * @hdd_ctx: hdd global context |
| 8030 | * |
| 8031 | * Return: none |
| 8032 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8033 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8034 | { |
| 8035 | uint8_t i; |
| 8036 | |
| 8037 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8038 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8039 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8040 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8041 | } |
| 8042 | } |
| 8043 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8044 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8045 | { |
| 8046 | } |
| 8047 | #endif |
| 8048 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8049 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8050 | /** |
| 8051 | * 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] | 8052 | * @phddctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8053 | * @enable: enable or disable this behaviour |
| 8054 | * |
| 8055 | * Return: int |
| 8056 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8057 | 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] | 8058 | { |
| 8059 | struct hdd_config *pcfg_ini = phddctx->config; |
| 8060 | struct wow_pulse_mode wow_pulse_set_info; |
| 8061 | QDF_STATUS status; |
| 8062 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8063 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8064 | |
| 8065 | if (false == phddctx->config->wow_pulse_support) |
| 8066 | return 0; |
| 8067 | |
| 8068 | /* prepare the request to send to SME */ |
| 8069 | if (enable == true) { |
| 8070 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8071 | wow_pulse_set_info.wow_pulse_pin = |
| 8072 | pcfg_ini->wow_pulse_pin; |
| 8073 | wow_pulse_set_info.wow_pulse_interval_low = |
| 8074 | pcfg_ini->wow_pulse_interval_low; |
| 8075 | wow_pulse_set_info.wow_pulse_interval_high = |
| 8076 | pcfg_ini->wow_pulse_interval_high; |
| 8077 | } else { |
| 8078 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8079 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8080 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8081 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8082 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8083 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8084 | wow_pulse_set_info.wow_pulse_enable, |
| 8085 | wow_pulse_set_info.wow_pulse_pin, |
| 8086 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8087 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8088 | |
| 8089 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8090 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8091 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8092 | return -EIO; |
| 8093 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8094 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8095 | return 0; |
| 8096 | } |
| 8097 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8098 | 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] | 8099 | { |
| 8100 | return 0; |
| 8101 | } |
| 8102 | #endif |
| 8103 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8104 | #ifdef WLAN_FEATURE_FASTPATH |
| 8105 | /** |
| 8106 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8107 | * @hdd_cfg: hdd config |
| 8108 | * @context: lower layer context |
| 8109 | * |
| 8110 | * Return: none |
| 8111 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8112 | void hdd_enable_fastpath(struct hdd_config *hdd_cfg, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8113 | void *context) |
| 8114 | { |
| 8115 | if (hdd_cfg->fastpath_enable) |
| 8116 | hif_enable_fastpath(context); |
| 8117 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8118 | #endif |
| 8119 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8120 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8121 | /** |
| 8122 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8123 | * @context: hdd context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8124 | * @level: thermal level |
| 8125 | * |
| 8126 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8127 | * than 0, and restore the original data path when throttle level is 0 |
| 8128 | * |
| 8129 | * Return: none |
| 8130 | */ |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8131 | 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] | 8132 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8133 | struct hdd_context *hdd_ctx = context; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8135 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8136 | if (level > THROTTLE_LEVEL_0) |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8137 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->hdd_pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8138 | else |
| 8139 | /* restore original concurrency mode */ |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8140 | 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] | 8141 | } |
| 8142 | |
| 8143 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8144 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8145 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8146 | * @adapter: AP adapter, which should be checked for NULL |
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 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8149 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8150 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8151 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8152 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8153 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8154 | */ |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8155 | static uint8_t hdd_get_safe_channel_from_pcl_and_acs_range( |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8156 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8157 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8158 | struct sir_pcl_list pcl; |
| 8159 | QDF_STATUS status; |
| 8160 | uint32_t i, j; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8161 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8162 | struct hdd_context *hdd_ctx; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8163 | bool found = false; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 8164 | int ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8165 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8166 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8167 | if (!hdd_ctx) { |
| 8168 | hdd_err("invalid HDD context"); |
| 8169 | return INVALID_CHANNEL_ID; |
| 8170 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8171 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8172 | mac_handle = hdd_ctx->mac_handle; |
| 8173 | if (!mac_handle) { |
| 8174 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8175 | return INVALID_CHANNEL_ID; |
| 8176 | } |
| 8177 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8178 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->hdd_psoc, |
| 8179 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8180 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8181 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8182 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8183 | hdd_err("Get PCL failed"); |
| 8184 | return INVALID_CHANNEL_ID; |
| 8185 | } |
| 8186 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8187 | /* |
| 8188 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8189 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8190 | * try to choose a safe channel from acs range. |
| 8191 | */ |
| 8192 | if (!pcl.pcl_len) |
| 8193 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8194 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8195 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8196 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8197 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8198 | |
| 8199 | /* PCL already takes unsafe channel into account */ |
| 8200 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8201 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8202 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8203 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8204 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8205 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8206 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8207 | return pcl.pcl_list[i]; |
| 8208 | } |
| 8209 | } |
| 8210 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8211 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8212 | |
| 8213 | /* Try for safe channel from all valid channel */ |
| 8214 | pcl.pcl_len = MAX_NUM_CHAN; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 8215 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8216 | &pcl.pcl_len); |
| 8217 | if (ret) { |
| 8218 | hdd_err("error %d in getting valid channel list", ret); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8219 | return INVALID_CHANNEL_ID; |
| 8220 | } |
| 8221 | |
| 8222 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8223 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8224 | found = false; |
| 8225 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
Krunal Soni | 15f0db1 | 2016-10-11 18:53:37 -0700 | [diff] [blame] | 8226 | if (pcl.pcl_list[i] == |
| 8227 | hdd_ctx->unsafe_channel_list[j]) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8228 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8229 | found = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8230 | break; |
| 8231 | } |
| 8232 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8233 | |
| 8234 | if (found) |
| 8235 | continue; |
| 8236 | |
| 8237 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8238 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8239 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8240 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8241 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8242 | return pcl.pcl_list[i]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8243 | } |
| 8244 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8245 | |
| 8246 | return INVALID_CHANNEL_ID; |
| 8247 | } |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8248 | #endif |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8249 | |
| 8250 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8251 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8252 | * @adapter: AP adapter |
| 8253 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8254 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8255 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8256 | * Moves the SAP interface by invoking the function which |
| 8257 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8258 | * |
| 8259 | * Return: None |
| 8260 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8261 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8262 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8263 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8264 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8265 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8266 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8267 | |
| 8268 | if (!adapter) { |
| 8269 | hdd_err("invalid adapter"); |
| 8270 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8271 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8272 | |
| 8273 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8274 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8275 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8276 | if (!mac_handle) { |
| 8277 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8278 | return; |
| 8279 | } |
| 8280 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8281 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8282 | |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8283 | hdd_ap_ctx->sap_config.channel = channel; |
Himanshu Agarwal | f5c5b10 | 2018-05-22 20:13:57 +0530 | [diff] [blame] | 8284 | hdd_ap_ctx->sap_config.ch_params.ch_width = CH_WIDTH_MAX; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8285 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8286 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8287 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8288 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 8289 | wlan_reg_set_channel_params(hdd_ctx->hdd_pdev, |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8290 | hdd_ap_ctx->sap_config.channel, |
| 8291 | hdd_ap_ctx->sap_config.sec_ch, |
| 8292 | &hdd_ap_ctx->sap_config.ch_params); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8293 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8294 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8295 | adapter->session_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8296 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8297 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8298 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8299 | 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] | 8300 | { |
| 8301 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8302 | int status; |
| 8303 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8304 | |
| 8305 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8306 | |
| 8307 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8308 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8309 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8310 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8311 | } |
| 8312 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8313 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8314 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8315 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8316 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8317 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8318 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8319 | hdd_err("failed to start external acs timer"); |
| 8320 | return -ENOSPC; |
| 8321 | } |
| 8322 | /* Update config to application */ |
| 8323 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8324 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8325 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8326 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8327 | } |
| 8328 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8329 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8330 | /** |
| 8331 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8332 | * @hdd_ctx: hdd context pointer |
| 8333 | * |
| 8334 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8335 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8336 | * sap. User space on LTE coex indication restart driver. |
| 8337 | * |
| 8338 | * Return - none |
| 8339 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8340 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8341 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8342 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8343 | uint32_t i; |
| 8344 | bool found = false; |
| 8345 | uint8_t restart_chan; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8346 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8347 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8348 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8349 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8350 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8351 | adapter->device_mode, |
| 8352 | adapter->session.ap.sap_config. |
| 8353 | acs_cfg.acs_mode); |
| 8354 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8355 | } |
| 8356 | |
| 8357 | found = false; |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8358 | /* |
| 8359 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8360 | * is set, no need to move SAP. |
| 8361 | */ |
| 8362 | if (policy_mgr_is_sta_sap_scc(hdd_ctxt->hdd_psoc, |
| 8363 | adapter->session.ap.operating_channel) && |
| 8364 | hdd_ctxt->config->sta_sap_scc_on_lte_coex_chan) |
| 8365 | hdd_debug("SAP is allowed on SCC channel, no need to move SAP"); |
| 8366 | else { |
| 8367 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8368 | if (adapter->session.ap.operating_channel == |
| 8369 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8370 | found = true; |
| 8371 | hdd_debug("operating ch:%d is unsafe", |
| 8372 | adapter->session.ap.operating_channel); |
| 8373 | break; |
| 8374 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8375 | } |
| 8376 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8377 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8378 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8379 | adapter->session.ap.operating_channel); |
| 8380 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8381 | } |
| 8382 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8383 | if (hdd_ctxt->config->vendor_acs_support && |
| 8384 | hdd_ctxt->config->acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8385 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8386 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8387 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8388 | } else |
| 8389 | restart_chan = |
| 8390 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8391 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8392 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8393 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8394 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8395 | /* |
| 8396 | * SAP restart due to unsafe channel. While |
| 8397 | * restarting the SAP, make sure to clear |
| 8398 | * acs_channel, channel to reset to |
| 8399 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8400 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8401 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8402 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8403 | adapter->session.ap.sap_config.channel = |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8404 | AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8405 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8406 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8407 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8408 | hdd_debug("driver to start sap: %d", |
| 8409 | hdd_ctxt->config->sap_internal_restart); |
| 8410 | if (hdd_ctxt->config->sap_internal_restart) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8411 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8412 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8413 | else |
| 8414 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8415 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8416 | } |
| 8417 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8418 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8419 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8420 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8421 | * @hdd_ctx: HDD global context |
| 8422 | * |
| 8423 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8424 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8425 | * down to the lower layers. Then subscribe to subsequent channel |
| 8426 | * avoidance events. |
| 8427 | * |
| 8428 | * Return: None |
| 8429 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8430 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8431 | { |
| 8432 | uint16_t unsafe_channel_count; |
| 8433 | int index; |
| 8434 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8435 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8436 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8437 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8438 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8439 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8440 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8441 | hdd_ctx->unsafe_channel_count); |
| 8442 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8443 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8444 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8445 | |
| 8446 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8447 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8448 | hdd_ctx->unsafe_channel_list[index]); |
| 8449 | |
| 8450 | } |
| 8451 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8452 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8453 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8454 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8455 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8456 | { |
| 8457 | uint8_t restart_chan; |
| 8458 | |
| 8459 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8460 | if (!restart_chan) { |
| 8461 | hdd_alert("fail to restart SAP"); |
| 8462 | return; |
| 8463 | } |
| 8464 | |
| 8465 | /* SAP restart due to unsafe channel. While restarting |
| 8466 | * the SAP, make sure to clear acs_channel, channel to |
| 8467 | * reset to 0. Otherwise these settings will override |
| 8468 | * the ACS while restart. |
| 8469 | */ |
| 8470 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8471 | adapter->session.ap.sap_config.channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8472 | |
| 8473 | hdd_debug("sending coex indication"); |
| 8474 | |
| 8475 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8476 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8477 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8478 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8479 | |
| 8480 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8481 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8482 | { |
| 8483 | uint32_t size; |
| 8484 | uint16_t *unsafe_list; |
| 8485 | uint16_t chan_count; |
| 8486 | |
| 8487 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8488 | return -EINVAL; |
| 8489 | |
| 8490 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8491 | NUM_CHANNELS); |
| 8492 | if (chan_count) { |
| 8493 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8494 | unsafe_list = qdf_mem_malloc(size); |
| 8495 | if (!unsafe_list) { |
| 8496 | hdd_err("No memory for unsafe chan list size%d", |
| 8497 | size); |
| 8498 | return -ENOMEM; |
| 8499 | } |
| 8500 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8501 | } else { |
| 8502 | unsafe_list = NULL; |
| 8503 | } |
| 8504 | |
| 8505 | *local_unsafe_list = unsafe_list; |
| 8506 | *local_unsafe_list_count = chan_count; |
| 8507 | |
| 8508 | return 0; |
| 8509 | } |
| 8510 | |
| 8511 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8512 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8513 | { |
| 8514 | int i, j; |
| 8515 | |
| 8516 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8517 | return true; |
| 8518 | if (local_unsafe_list_count == 0) |
| 8519 | return false; |
| 8520 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8521 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8522 | if (local_unsafe_list[i] == |
| 8523 | hdd_ctx->unsafe_channel_list[j]) |
| 8524 | break; |
| 8525 | if (j >= local_unsafe_list_count) |
| 8526 | break; |
| 8527 | } |
| 8528 | if (i >= local_unsafe_list_count) { |
| 8529 | hdd_info("unsafe chan list same"); |
| 8530 | return false; |
| 8531 | } |
| 8532 | |
| 8533 | return true; |
| 8534 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8535 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8536 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8537 | { |
| 8538 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8539 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8540 | 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] | 8541 | { |
| 8542 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8543 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8544 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8545 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8546 | { |
| 8547 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8548 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8549 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8550 | |
| 8551 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8552 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 8553 | * user space |
| 8554 | * @frame_ind: Management frame data to be informed. |
| 8555 | * |
| 8556 | * This function is used to indicate management frame to |
| 8557 | * user space |
| 8558 | * |
| 8559 | * Return: None |
| 8560 | * |
| 8561 | */ |
| 8562 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 8563 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8564 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8565 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8566 | int i; |
| 8567 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 8568 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 8569 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8570 | return; |
| 8571 | |
| 8572 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
| 8573 | for (i = 0; i < CSR_ROAM_SESSION_MAX; i++) { |
| 8574 | adapter = |
| 8575 | hdd_get_adapter_by_sme_session_id(hdd_ctx, i); |
| 8576 | if (adapter) |
| 8577 | break; |
| 8578 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 8579 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 8580 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 8581 | if ((NULL != adapter) && |
| 8582 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 8583 | __hdd_indicate_mgmt_frame(adapter, |
| 8584 | frame_ind->frame_len, |
| 8585 | frame_ind->frameBuf, |
| 8586 | frame_ind->frameType, |
| 8587 | frame_ind->rxChan, |
| 8588 | frame_ind->rxRssi); |
| 8589 | } |
| 8590 | } |
| 8591 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8592 | } else { |
| 8593 | adapter = hdd_get_adapter_by_sme_session_id(hdd_ctx, |
| 8594 | frame_ind->sessionId); |
| 8595 | } |
| 8596 | |
| 8597 | if ((NULL != adapter) && |
| 8598 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 8599 | __hdd_indicate_mgmt_frame(adapter, |
| 8600 | frame_ind->frame_len, |
| 8601 | frame_ind->frameBuf, |
| 8602 | frame_ind->frameType, |
| 8603 | frame_ind->rxChan, |
| 8604 | frame_ind->rxRssi); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 8605 | } |
| 8606 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8607 | void hdd_acs_response_timeout_handler(void *context) |
| 8608 | { |
| 8609 | struct hdd_external_acs_timer_context *timer_context = |
| 8610 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8611 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8612 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8613 | uint8_t reason; |
| 8614 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8615 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8616 | if (!timer_context) { |
| 8617 | hdd_err("invlaid timer context"); |
| 8618 | return; |
| 8619 | } |
| 8620 | adapter = timer_context->adapter; |
| 8621 | reason = timer_context->reason; |
| 8622 | |
| 8623 | |
| 8624 | if ((!adapter) || |
| 8625 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 8626 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 8627 | return; |
| 8628 | } |
| 8629 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8630 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 8631 | return; |
| 8632 | |
| 8633 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 8634 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8635 | else |
| 8636 | return; |
| 8637 | |
| 8638 | hdd_err("ACS timeout happened for %s reason %d", |
| 8639 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8640 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8641 | switch (reason) { |
| 8642 | /* SAP init case */ |
| 8643 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 8644 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 8645 | false); |
| 8646 | wlan_hdd_cfg80211_start_acs(adapter); |
| 8647 | break; |
| 8648 | /* DFS detected on current channel */ |
| 8649 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 8650 | wlan_sap_update_next_channel( |
| 8651 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8652 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 8653 | adapter->session_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8654 | break; |
| 8655 | /* LTE coex event on current channel */ |
| 8656 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 8657 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 8658 | break; |
| 8659 | default: |
| 8660 | hdd_info("invalid reason for timer invoke"); |
| 8661 | |
| 8662 | } |
| 8663 | } |
| 8664 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8665 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8666 | * hdd_override_ini_config - Override INI config |
| 8667 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8668 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8669 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8670 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8671 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8672 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8673 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8674 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8675 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8676 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
| 8677 | hdd_ctx->config->enableDFSChnlScan = enable_dfs_chan_scan; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8678 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8679 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8680 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8681 | if (0 == enable_11d || 1 == enable_11d) { |
| 8682 | hdd_ctx->config->Is11dSupportEnabled = enable_11d; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8683 | hdd_debug("Module enable_11d set to %d", enable_11d); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8684 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8685 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 8686 | if (!ucfg_ipa_is_present()) { |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 8687 | hdd_ctx->config->IpaConfig = 0; |
Jingxiang Ge | 7a040dc | 2018-02-02 11:07:59 +0800 | [diff] [blame] | 8688 | hdd_debug("IpaConfig override to %d", |
| 8689 | hdd_ctx->config->IpaConfig); |
| 8690 | } |
Yeshwanth Sriram Guntuka | 2ba6fe9 | 2017-10-04 14:40:45 +0530 | [diff] [blame] | 8691 | |
| 8692 | if (!hdd_ctx->config->rssi_assoc_reject_enabled || |
| 8693 | !hdd_ctx->config->enable_bcast_probe_rsp) { |
| 8694 | hdd_debug("OCE disabled, rssi_assoc_reject_enabled: %d enable_bcast_probe_rsp: %d", |
| 8695 | hdd_ctx->config->rssi_assoc_reject_enabled, |
| 8696 | hdd_ctx->config->enable_bcast_probe_rsp); |
| 8697 | hdd_ctx->config->oce_sta_enabled = 0; |
| 8698 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8699 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8700 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8701 | /** |
| 8702 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 8703 | * @hdd_ctx - HDD context |
| 8704 | * |
| 8705 | * Set trace level for each module based on INI config. |
| 8706 | * |
| 8707 | * Return: None |
| 8708 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8709 | 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] | 8710 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8711 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMI, |
| 8712 | hdd_ctx->config->qdf_trace_enable_wdi); |
| 8713 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD, |
| 8714 | hdd_ctx->config->qdf_trace_enable_hdd); |
| 8715 | hdd_qdf_trace_enable(QDF_MODULE_ID_SME, |
| 8716 | hdd_ctx->config->qdf_trace_enable_sme); |
| 8717 | hdd_qdf_trace_enable(QDF_MODULE_ID_PE, |
| 8718 | hdd_ctx->config->qdf_trace_enable_pe); |
| 8719 | hdd_qdf_trace_enable(QDF_MODULE_ID_WMA, |
| 8720 | hdd_ctx->config->qdf_trace_enable_wma); |
| 8721 | hdd_qdf_trace_enable(QDF_MODULE_ID_SYS, |
| 8722 | hdd_ctx->config->qdf_trace_enable_sys); |
| 8723 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF, |
| 8724 | hdd_ctx->config->qdf_trace_enable_qdf); |
| 8725 | hdd_qdf_trace_enable(QDF_MODULE_ID_SAP, |
| 8726 | hdd_ctx->config->qdf_trace_enable_sap); |
| 8727 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SOFTAP, |
| 8728 | hdd_ctx->config->qdf_trace_enable_hdd_sap); |
| 8729 | hdd_qdf_trace_enable(QDF_MODULE_ID_BMI, |
| 8730 | hdd_ctx->config->qdf_trace_enable_bmi); |
| 8731 | hdd_qdf_trace_enable(QDF_MODULE_ID_CFG, |
| 8732 | hdd_ctx->config->qdf_trace_enable_cfg); |
| 8733 | hdd_qdf_trace_enable(QDF_MODULE_ID_EPPING, |
| 8734 | hdd_ctx->config->qdf_trace_enable_epping); |
| 8735 | hdd_qdf_trace_enable(QDF_MODULE_ID_QDF_DEVICE, |
| 8736 | hdd_ctx->config->qdf_trace_enable_qdf_devices); |
| 8737 | hdd_qdf_trace_enable(QDF_MODULE_ID_TXRX, |
Houston Hoffman | fbf0510 | 2017-08-28 11:37:01 -0700 | [diff] [blame] | 8738 | hdd_ctx->config->qdf_trace_enable_txrx); |
| 8739 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, |
| 8740 | hdd_ctx->config->qdf_trace_enable_dp); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 8741 | hdd_qdf_trace_enable(QDF_MODULE_ID_HTC, |
| 8742 | hdd_ctx->config->qdf_trace_enable_htc); |
| 8743 | hdd_qdf_trace_enable(QDF_MODULE_ID_HIF, |
| 8744 | hdd_ctx->config->qdf_trace_enable_hif); |
| 8745 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_SAP_DATA, |
| 8746 | hdd_ctx->config->qdf_trace_enable_hdd_sap_data); |
| 8747 | hdd_qdf_trace_enable(QDF_MODULE_ID_HDD_DATA, |
| 8748 | hdd_ctx->config->qdf_trace_enable_hdd_data); |
Naveen Rawat | 7df3186 | 2017-03-01 17:09:30 -0800 | [diff] [blame] | 8749 | hdd_qdf_trace_enable(QDF_MODULE_ID_WIFIPOS, |
| 8750 | hdd_ctx->config->qdf_trace_enable_wifi_pos); |
Naveen Rawat | f2b0dbd | 2017-03-27 10:00:15 -0700 | [diff] [blame] | 8751 | hdd_qdf_trace_enable(QDF_MODULE_ID_NAN, |
| 8752 | hdd_ctx->config->qdf_trace_enable_nan); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8753 | hdd_qdf_trace_enable(QDF_MODULE_ID_REGULATORY, |
| 8754 | hdd_ctx->config->qdf_trace_enable_regulatory); |
Naveen Rawat | 3cb779e | 2018-02-16 16:36:10 -0800 | [diff] [blame] | 8755 | hdd_qdf_trace_enable(QDF_MODULE_ID_CP_STATS, |
| 8756 | hdd_ctx->config->qdf_trace_enable_cp_stats); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 8757 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8758 | hdd_cfg_print(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8759 | } |
| 8760 | |
| 8761 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8762 | * hdd_context_init() - Initialize HDD context |
| 8763 | * @hdd_ctx: HDD context. |
| 8764 | * |
| 8765 | * Initialize HDD context along with all the feature specific contexts. |
| 8766 | * |
| 8767 | * return: 0 on success and errno on failure. |
| 8768 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8769 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8770 | { |
| 8771 | int ret; |
| 8772 | |
| 8773 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
| 8774 | hdd_ctx->max_intf_count = CSR_ROAM_SESSION_MAX; |
| 8775 | |
| 8776 | hdd_init_ll_stats_ctx(); |
| 8777 | |
| 8778 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 8779 | init_completion(&hdd_ctx->ready_to_suspend); |
| 8780 | |
| 8781 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8782 | qdf_spinlock_create(&hdd_ctx->sta_update_info_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8783 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 8784 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8785 | qdf_list_create(&hdd_ctx->hdd_adapters, MAX_NUMBER_OF_ADAPTERS); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8786 | |
| 8787 | init_completion(&hdd_ctx->set_antenna_mode_cmpl); |
| 8788 | |
| 8789 | ret = hdd_scan_context_init(hdd_ctx); |
| 8790 | if (ret) |
| 8791 | goto list_destroy; |
| 8792 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8793 | hdd_rx_wake_lock_create(hdd_ctx); |
| 8794 | |
| 8795 | ret = hdd_sap_context_init(hdd_ctx); |
| 8796 | if (ret) |
| 8797 | goto scan_destroy; |
| 8798 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8799 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 8800 | |
| 8801 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 8802 | |
| 8803 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 8804 | hdd_ctx->config); |
| 8805 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 8806 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8807 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 8808 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 8809 | "monitor_mode_wakelock"); |
| 8810 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8811 | return 0; |
| 8812 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8813 | sap_destroy: |
| 8814 | hdd_sap_context_destroy(hdd_ctx); |
| 8815 | |
| 8816 | scan_destroy: |
| 8817 | hdd_scan_context_destroy(hdd_ctx); |
| 8818 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8819 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 8820 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 8821 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8822 | return ret; |
| 8823 | } |
| 8824 | |
| 8825 | /** |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8826 | * ie_whitelist_attrs_init() - initialize ie whitelisting attributes |
| 8827 | * @hdd_ctx: pointer to hdd context |
| 8828 | * |
| 8829 | * Return: status of initialization |
| 8830 | * 0 - success |
| 8831 | * negative value - failure |
| 8832 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8833 | static int ie_whitelist_attrs_init(struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8834 | { |
| 8835 | int ret; |
| 8836 | |
| 8837 | if (!hdd_ctx->config->probe_req_ie_whitelist) |
| 8838 | return 0; |
| 8839 | |
| 8840 | if (!hdd_validate_prb_req_ie_bitmap(hdd_ctx)) { |
| 8841 | hdd_err("invalid ie bitmap and ouis: disable ie whitelisting"); |
| 8842 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8843 | return -EINVAL; |
| 8844 | } |
| 8845 | |
| 8846 | /* parse ini string probe req oui */ |
| 8847 | ret = hdd_parse_probe_req_ouis(hdd_ctx); |
| 8848 | if (ret) { |
| 8849 | hdd_err("parsing error: disable ie whitelisting"); |
| 8850 | hdd_ctx->config->probe_req_ie_whitelist = false; |
| 8851 | } |
| 8852 | |
| 8853 | return ret; |
| 8854 | } |
| 8855 | |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8856 | /** |
| 8857 | * hdd_iface_change_callback() - Function invoked when stop modules expires |
| 8858 | * @priv: pointer to hdd context |
| 8859 | * |
| 8860 | * This function is invoked when the timer waiting for the interface change |
| 8861 | * expires, it shall cut-down the power to wlan and stop all the modules. |
| 8862 | * |
| 8863 | * Return: void |
| 8864 | */ |
| 8865 | static void hdd_iface_change_callback(void *priv) |
| 8866 | { |
| 8867 | struct hdd_context *hdd_ctx = (struct hdd_context *) priv; |
| 8868 | int ret; |
| 8869 | int status = wlan_hdd_validate_context(hdd_ctx); |
| 8870 | |
| 8871 | if (status) |
| 8872 | return; |
| 8873 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8874 | hdd_enter(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8875 | hdd_debug("Interface change timer expired close the modules!"); |
| 8876 | ret = hdd_wlan_stop_modules(hdd_ctx, false); |
| 8877 | if (ret) |
| 8878 | hdd_err("Failed to stop modules"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8879 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8880 | } |
| 8881 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8882 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 8883 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8884 | { |
| 8885 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 8886 | wlan_logging_to_console); |
| 8887 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 8888 | } |
| 8889 | #else |
| 8890 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 8891 | { } |
| 8892 | #endif |
| 8893 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8894 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8895 | * hdd_context_create() - Allocate and inialize HDD context. |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8896 | * @dev: Device Pointer to the underlying device |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8897 | * |
| 8898 | * Allocate and initialize HDD context. HDD context is allocated as part of |
| 8899 | * wiphy allocation and then context is initialized. |
| 8900 | * |
| 8901 | * Return: HDD context on success and ERR_PTR on failure |
| 8902 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8903 | static struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8904 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8905 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8906 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8907 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8908 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 8909 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8910 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8911 | hdd_ctx = hdd_cfg80211_wiphy_alloc(sizeof(struct hdd_context)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8912 | if (hdd_ctx == NULL) { |
| 8913 | ret = -ENOMEM; |
| 8914 | goto err_out; |
| 8915 | } |
| 8916 | |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 8917 | qdf_create_delayed_work(&hdd_ctx->iface_idle_work, |
| 8918 | hdd_iface_change_callback, |
| 8919 | (void *)hdd_ctx); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 8920 | |
| 8921 | mutex_init(&hdd_ctx->iface_change_lock); |
| 8922 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8923 | hdd_ctx->parent_dev = dev; |
Sreelakshmi Konamki | b53c629 | 2017-03-01 13:13:23 +0530 | [diff] [blame] | 8924 | hdd_ctx->last_scan_reject_session_id = 0xFF; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8925 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8926 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8927 | if (hdd_ctx->config == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8928 | hdd_err("Failed to alloc memory for HDD config!"); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8929 | ret = -ENOMEM; |
| 8930 | goto err_free_hdd_context; |
| 8931 | } |
| 8932 | |
| 8933 | /* Read and parse the qcom_cfg.ini file */ |
| 8934 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 8935 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 8936 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8937 | WLAN_INI_FILE); |
| 8938 | ret = -EINVAL; |
| 8939 | goto err_free_config; |
| 8940 | } |
| 8941 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 8942 | status = cfg_parse(WLAN_INI_FILE); |
| 8943 | if (QDF_IS_STATUS_ERROR(status)) |
| 8944 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 8945 | WLAN_INI_FILE, status); |
| 8946 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 8947 | ie_whitelist_attrs_init(hdd_ctx); |
| 8948 | |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 8949 | hdd_debug("setting timer multiplier: %u", |
| 8950 | hdd_ctx->config->timer_multiplier); |
| 8951 | qdf_timer_set_multiplier(hdd_ctx->config->timer_multiplier); |
| 8952 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8953 | |
Sravan Kumar Kairam | fece87f | 2016-07-26 14:58:28 +0530 | [diff] [blame] | 8954 | if (hdd_ctx->config->fhostNSOffload) |
| 8955 | hdd_ctx->ns_offload_enable = true; |
| 8956 | |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 8957 | cds_set_fatal_event(hdd_ctx->config->enable_fatal_event); |
| 8958 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8959 | hdd_override_ini_config(hdd_ctx); |
| 8960 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8961 | ret = hdd_context_init(hdd_ctx); |
| 8962 | |
| 8963 | if (ret) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8964 | goto err_free_config; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 8965 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8966 | /* Uses to enabled logging after SSR */ |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 8967 | hdd_ctx->fw_log_settings.enable = hdd_ctx->config->enable_fw_log; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8968 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8969 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8970 | goto skip_multicast_logging; |
| 8971 | |
| 8972 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 8973 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8974 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 8975 | if (ret) |
| 8976 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8977 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8978 | ret = hdd_init_netlink_services(hdd_ctx); |
| 8979 | if (ret) |
| 8980 | goto err_deinit_txrx_histogram; |
| 8981 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8982 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8983 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8984 | skip_multicast_logging: |
| 8985 | hdd_set_trace_level_for_each(hdd_ctx); |
| 8986 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 8987 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 8988 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 8989 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 8990 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8991 | return hdd_ctx; |
| 8992 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 8993 | err_deinit_txrx_histogram: |
| 8994 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 8995 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 8996 | err_deinit_hdd_context: |
| 8997 | hdd_context_deinit(hdd_ctx); |
| 8998 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 8999 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9000 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9001 | |
| 9002 | err_free_hdd_context: |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9003 | mutex_destroy(&hdd_ctx->iface_change_lock); |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9004 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9005 | |
| 9006 | err_out: |
| 9007 | return ERR_PTR(ret); |
| 9008 | } |
| 9009 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9010 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 9011 | /** |
| 9012 | * hdd_open_p2p_interface - Open P2P interface |
| 9013 | * @hdd_ctx: HDD context |
| 9014 | * @rtnl_held: True if RTNL lock held |
| 9015 | * |
| 9016 | * Open P2P interface during probe. This function called to open the P2P |
| 9017 | * interface at probe along with STA interface. |
| 9018 | * |
| 9019 | * Return: 0 on success and errno on failure |
| 9020 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9021 | 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] | 9022 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9023 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9024 | uint8_t *p2p_dev_addr; |
| 9025 | |
| 9026 | if (hdd_ctx->config->isP2pDeviceAddrAdministrated && |
| 9027 | !(hdd_ctx->config->intfMacAddr[0].bytes[0] & 0x02)) { |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9028 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9029 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 9030 | sizeof(tSirMacAddr)); |
| 9031 | |
| 9032 | /* |
| 9033 | * Generate the P2P Device Address. This consists of |
| 9034 | * the device's primary MAC address with the locally |
| 9035 | * administered bit set. |
| 9036 | */ |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9037 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9038 | } else { |
| 9039 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx); |
| 9040 | if (p2p_dev_addr == NULL) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9041 | hdd_err("Failed to allocate mac_address for p2p_device"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9042 | return -ENOSPC; |
| 9043 | } |
| 9044 | |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9045 | qdf_mem_copy(&hdd_ctx->p2p_device_address.bytes[0], |
| 9046 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9047 | } |
| 9048 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9049 | adapter = hdd_open_adapter(hdd_ctx, QDF_P2P_DEVICE_MODE, "p2p%d", |
Jeff Johnson | acbdb1c | 2017-11-02 20:42:02 -0700 | [diff] [blame] | 9050 | &hdd_ctx->p2p_device_address.bytes[0], |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9051 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9052 | |
| 9053 | if (NULL == adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9054 | hdd_err("Failed to do hdd_open_adapter for P2P Device Interface"); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9055 | return -ENOSPC; |
| 9056 | } |
| 9057 | |
| 9058 | return 0; |
| 9059 | } |
| 9060 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9061 | static inline int hdd_open_p2p_interface(struct hdd_context *hdd_ctx, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9062 | bool rtnl_held) |
| 9063 | { |
| 9064 | return 0; |
| 9065 | } |
| 9066 | #endif |
| 9067 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9068 | 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] | 9069 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9070 | struct hdd_adapter *adapter; |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9071 | int ret = 0; |
| 9072 | |
| 9073 | adapter = hdd_open_adapter(hdd_ctx, QDF_OCB_MODE, "wlanocb%d", |
| 9074 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9075 | NET_NAME_UNKNOWN, rtnl_held); |
| 9076 | if (adapter == NULL) { |
| 9077 | hdd_err("Failed to open 802.11p interface"); |
| 9078 | ret = -ENOSPC; |
| 9079 | } |
| 9080 | |
| 9081 | return ret; |
| 9082 | } |
| 9083 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9084 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9085 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9086 | * @adapter: HDD adapter |
| 9087 | * |
| 9088 | * This function initializes the adapter for the station mode. |
| 9089 | * |
| 9090 | * Return: 0 on success or errno on failure. |
| 9091 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9092 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9093 | { |
| 9094 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9095 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9096 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9097 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9098 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9099 | hdd_err("session is already opened, %d", |
| 9100 | adapter->session_id); |
| 9101 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9102 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9103 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9104 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9105 | if (ret) { |
| 9106 | hdd_err("failed to create vdev: %d", ret); |
| 9107 | return ret; |
| 9108 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9109 | status = hdd_init_station_mode(adapter); |
| 9110 | |
| 9111 | if (QDF_STATUS_SUCCESS != status) { |
| 9112 | hdd_err("Error Initializing station mode: %d", status); |
| 9113 | return qdf_status_to_os_return(status); |
| 9114 | } |
| 9115 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9116 | hdd_register_tx_flow_control(adapter, |
| 9117 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9118 | hdd_tx_resume_cb, |
| 9119 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9120 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9121 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9122 | return 0; |
| 9123 | } |
| 9124 | |
| 9125 | /** |
| 9126 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9127 | * @adapter: HDD adapter |
| 9128 | * |
| 9129 | * This function initializes the adapter for the AP mode. |
| 9130 | * |
| 9131 | * Return: 0 on success errno on failure. |
| 9132 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9133 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9134 | { |
| 9135 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9136 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9137 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9138 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9139 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9140 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9141 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9142 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9143 | hdd_err("session is already opened, %d", |
| 9144 | adapter->session_id); |
| 9145 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9146 | } |
| 9147 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9148 | * In SSR case no need to create new sap context. |
| 9149 | * Otherwise create sap context first and then create |
| 9150 | * vdev as while creating the vdev, driver needs to |
| 9151 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9152 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9153 | if (adapter->session.ap.sap_context) { |
| 9154 | is_ssr = true; |
| 9155 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9156 | hdd_err("sap creation failed"); |
| 9157 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9158 | } |
| 9159 | |
| 9160 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9161 | adapter->session.ap.sap_context); |
| 9162 | if (ret) { |
| 9163 | hdd_err("failed to create vdev, status:%d", ret); |
| 9164 | hdd_sap_destroy_ctx(adapter); |
| 9165 | return ret; |
| 9166 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9167 | |
| 9168 | if (adapter->device_mode == QDF_SAP_MODE) |
| 9169 | sme_cli_set_command(adapter->session_id, |
| 9170 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
| 9171 | (bool)(hdd_ctx->config->fine_time_meas_cap & |
| 9172 | WMI_FW_AP_RTT_RESPR), |
| 9173 | VDEV_CMD); |
| 9174 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9175 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9176 | |
| 9177 | if (QDF_STATUS_SUCCESS != status) { |
| 9178 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9179 | return qdf_status_to_os_return(status); |
| 9180 | } |
| 9181 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9182 | hdd_register_tx_flow_control(adapter, |
| 9183 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9184 | hdd_softap_tx_resume_cb, |
| 9185 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9186 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9187 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9188 | return 0; |
| 9189 | } |
| 9190 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9191 | static int hdd_open_concurrent_interface(struct hdd_context *hdd_ctx, |
| 9192 | bool rtnl_held) |
| 9193 | { |
| 9194 | struct hdd_adapter *adapter; |
| 9195 | |
| 9196 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, |
| 9197 | hdd_ctx->config->enableConcurrentSTA, |
| 9198 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9199 | NET_NAME_UNKNOWN, rtnl_held); |
| 9200 | |
| 9201 | if (!adapter) |
| 9202 | return -ENOSPC; |
| 9203 | |
| 9204 | return 0; |
| 9205 | } |
| 9206 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9207 | /** |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9208 | * hdd_open_interfaces - Open all required interfaces |
| 9209 | * hdd_ctx: HDD context |
| 9210 | * rtnl_held: True if RTNL lock is held |
| 9211 | * |
| 9212 | * Open all the interfaces like STA, P2P and OCB based on the configuration. |
| 9213 | * |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9214 | * Return: 0 if all interfaces were created, otherwise negative errno |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9215 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9216 | 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] | 9217 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9218 | struct hdd_adapter *adapter; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9219 | int ret; |
| 9220 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9221 | /* open monitor mode adapter if con_mode is monitor mode */ |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9222 | if (con_mode == QDF_GLOBAL_MONITOR_MODE || |
| 9223 | con_mode == QDF_GLOBAL_FTM_MODE) { |
| 9224 | uint8_t session_type = (con_mode == QDF_GLOBAL_MONITOR_MODE) ? |
| 9225 | QDF_MONITOR_MODE : QDF_FTM_MODE; |
| 9226 | |
| 9227 | adapter = hdd_open_adapter(hdd_ctx, session_type, "wlan%d", |
| 9228 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 9229 | NET_NAME_UNKNOWN, rtnl_held); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9230 | if (!adapter) { |
| 9231 | hdd_err("open adapter failed"); |
| 9232 | return -ENOSPC; |
| 9233 | } |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 9234 | |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 9235 | return 0; |
| 9236 | } |
| 9237 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9238 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_STANDALONE) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9239 | /* Create only 802.11p interface */ |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9240 | return hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9241 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 9242 | adapter = hdd_open_adapter(hdd_ctx, QDF_STA_MODE, "wlan%d", |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9243 | wlan_hdd_get_intf_addr(hdd_ctx), |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 9244 | NET_NAME_UNKNOWN, rtnl_held); |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9245 | |
| 9246 | if (adapter == NULL) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9247 | return -ENOSPC; |
| 9248 | |
Sourav Mohapatra | 57006c7 | 2017-11-19 16:15:55 +0530 | [diff] [blame] | 9249 | if (strlen(hdd_ctx->config->enableConcurrentSTA) != 0) { |
| 9250 | ret = hdd_open_concurrent_interface(hdd_ctx, rtnl_held); |
| 9251 | if (ret) |
| 9252 | hdd_err("Cannot create concurrent STA interface"); |
| 9253 | } |
| 9254 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9255 | ret = hdd_open_p2p_interface(hdd_ctx, rtnl_held); |
| 9256 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9257 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9258 | |
| 9259 | /* Open 802.11p Interface */ |
| 9260 | if (hdd_ctx->config->dot11p_mode == WLAN_HDD_11P_CONCURRENT) { |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9261 | ret = hdd_open_ocb_interface(hdd_ctx, rtnl_held); |
| 9262 | if (ret) |
| 9263 | goto err_close_adapters; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9264 | } |
| 9265 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9266 | return 0; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9267 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9268 | err_close_adapters: |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9269 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 9270 | return ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9271 | } |
| 9272 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9273 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9274 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9275 | /** |
| 9276 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9277 | * @cds_cfg: CDS Configuration |
| 9278 | * @hdd_ctx: Pointer to hdd context |
| 9279 | * |
| 9280 | * Return: none |
| 9281 | */ |
| 9282 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9283 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9284 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9285 | { |
| 9286 | cds_cfg->tx_flow_stop_queue_th = |
| 9287 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 9288 | cds_cfg->tx_flow_start_queue_offset = |
| 9289 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 9290 | } |
| 9291 | #else |
| 9292 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9293 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9294 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9295 | { |
| 9296 | } |
| 9297 | #endif |
| 9298 | |
| 9299 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 9300 | /** |
| 9301 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 9302 | * @cds_cfg: CDS Configuration |
| 9303 | * @hdd_ctx: Pointer to hdd context |
| 9304 | * |
| 9305 | * Return: none |
| 9306 | */ |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9307 | 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] | 9308 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9309 | { |
| 9310 | cds_cfg->ra_ratelimit_interval = |
| 9311 | hdd_ctx->config->RArateLimitInterval; |
| 9312 | cds_cfg->is_ra_ratelimit_enabled = |
| 9313 | hdd_ctx->config->IsRArateLimitEnabled; |
| 9314 | } |
| 9315 | #else |
Anand Kumar | 3b92a91 | 2016-12-05 12:01:26 +0530 | [diff] [blame] | 9316 | 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] | 9317 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9318 | { |
| 9319 | } |
| 9320 | #endif |
| 9321 | |
| 9322 | /** |
| 9323 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9324 | * @hdd_ctx: HDD Context |
| 9325 | * |
| 9326 | * Return: 0 for Success, errno on failure |
| 9327 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9328 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9329 | { |
| 9330 | struct cds_config_info *cds_cfg; |
| 9331 | |
| 9332 | cds_cfg = (struct cds_config_info *)qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9333 | if (!cds_cfg) { |
| 9334 | hdd_err("failed to allocate cds config"); |
| 9335 | return -ENOMEM; |
| 9336 | } |
| 9337 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9338 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Kiran Kumar Lokere | 7006e0a | 2017-03-07 19:28:36 -0800 | [diff] [blame] | 9339 | if (!hdd_ctx->config->nMaxPsPoll || |
| 9340 | !hdd_ctx->config->enablePowersaveOffload) { |
| 9341 | cds_cfg->powersave_offload_enabled = |
| 9342 | hdd_ctx->config->enablePowersaveOffload; |
| 9343 | } else { |
| 9344 | if ((hdd_ctx->config->enablePowersaveOffload == |
| 9345 | PS_QPOWER_NODEEPSLEEP) || |
| 9346 | (hdd_ctx->config->enablePowersaveOffload == |
| 9347 | PS_LEGACY_NODEEPSLEEP)) |
| 9348 | cds_cfg->powersave_offload_enabled = |
| 9349 | PS_LEGACY_NODEEPSLEEP; |
| 9350 | else |
| 9351 | cds_cfg->powersave_offload_enabled = |
| 9352 | PS_LEGACY_DEEPSLEEP; |
| 9353 | hdd_info("Qpower disabled in cds config, %d", |
| 9354 | cds_cfg->powersave_offload_enabled); |
| 9355 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9356 | cds_cfg->sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 9357 | cds_cfg->sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 9358 | cds_cfg->sta_maxlimod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
| 9359 | cds_cfg->wow_enable = hdd_ctx->config->wowEnable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9360 | |
| 9361 | /* |
| 9362 | * Copy the DFS Phyerr Filtering Offload status. |
| 9363 | * This parameter reflects the value of the |
| 9364 | * dfs_phyerr_filter_offload flag as set in the ini. |
| 9365 | */ |
| 9366 | cds_cfg->dfs_phyerr_filter_offload = |
| 9367 | hdd_ctx->config->fDfsPhyerrFilterOffload; |
| 9368 | if (hdd_ctx->config->ssdp) |
| 9369 | cds_cfg->ssdp = hdd_ctx->config->ssdp; |
| 9370 | |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9371 | cds_cfg->force_target_assert_enabled = |
| 9372 | hdd_ctx->config->crash_inject_enabled; |
| 9373 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9374 | cds_cfg->enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
| 9375 | cds_cfg->ap_maxoffload_peers = hdd_ctx->config->apMaxOffloadPeers; |
| 9376 | |
| 9377 | cds_cfg->ap_maxoffload_reorderbuffs = |
| 9378 | hdd_ctx->config->apMaxOffloadReorderBuffs; |
| 9379 | |
| 9380 | cds_cfg->ap_disable_intrabss_fwd = |
| 9381 | hdd_ctx->config->apDisableIntraBssFwd; |
| 9382 | |
| 9383 | cds_cfg->dfs_pri_multiplier = |
| 9384 | hdd_ctx->config->dfsRadarPriMultiplier; |
| 9385 | cds_cfg->reorder_offload = |
| 9386 | hdd_ctx->config->reorderOffloadSupport; |
| 9387 | |
| 9388 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9389 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9390 | if (!is_power_of_2(hdd_ctx->config->IpaUcTxBufCount)) { |
| 9391 | /* IpaUcTxBufCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9392 | hdd_debug("Round down IpaUcTxBufCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9393 | hdd_ctx->config->IpaUcTxBufCount); |
| 9394 | hdd_ctx->config->IpaUcTxBufCount = |
| 9395 | rounddown_pow_of_two( |
| 9396 | hdd_ctx->config->IpaUcTxBufCount); |
| 9397 | if (!hdd_ctx->config->IpaUcTxBufCount) { |
| 9398 | hdd_err("Failed to round down IpaUcTxBufCount"); |
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("IpaUcTxBufCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9402 | hdd_ctx->config->IpaUcTxBufCount); |
| 9403 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9404 | cds_cfg->uc_txbuf_count = hdd_ctx->config->IpaUcTxBufCount; |
| 9405 | cds_cfg->uc_txbuf_size = hdd_ctx->config->IpaUcTxBufSize; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9406 | if (!is_power_of_2(hdd_ctx->config->IpaUcRxIndRingCount)) { |
| 9407 | /* IpaUcRxIndRingCount should be power of 2 */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9408 | hdd_debug("Round down IpaUcRxIndRingCount %d to nearest power of 2", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9409 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9410 | hdd_ctx->config->IpaUcRxIndRingCount = |
| 9411 | rounddown_pow_of_two( |
| 9412 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9413 | if (!hdd_ctx->config->IpaUcRxIndRingCount) { |
| 9414 | hdd_err("Failed to round down IpaUcRxIndRingCount"); |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9415 | goto exit; |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9416 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9417 | hdd_debug("IpaUcRxIndRingCount rounded down to %d", |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9418 | hdd_ctx->config->IpaUcRxIndRingCount); |
| 9419 | } |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9420 | cds_cfg->uc_rxind_ringcount = |
Yun Park | de38078 | 2016-08-17 16:26:54 -0700 | [diff] [blame] | 9421 | hdd_ctx->config->IpaUcRxIndRingCount; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9422 | cds_cfg->uc_tx_partition_base = |
| 9423 | hdd_ctx->config->IpaUcTxPartitionBase; |
| 9424 | cds_cfg->max_scan = hdd_ctx->config->max_scan_count; |
| 9425 | |
| 9426 | cds_cfg->ip_tcp_udp_checksum_offload = |
| 9427 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9428 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9429 | cds_cfg->ce_classify_enabled = |
| 9430 | hdd_ctx->config->ce_classify_enabled; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9431 | cds_cfg->apf_packet_filter_enable = |
| 9432 | hdd_ctx->config->apf_packet_filter_enable; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9433 | cds_cfg->tx_chain_mask_cck = hdd_ctx->config->tx_chain_mask_cck; |
| 9434 | cds_cfg->self_gen_frm_pwr = hdd_ctx->config->self_gen_frm_pwr; |
| 9435 | cds_cfg->max_station = hdd_ctx->config->maxNumberOfPeers; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9436 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Manjunathappa Prakash | fff753c | 2016-09-01 19:34:56 -0700 | [diff] [blame] | 9437 | cds_cfg->flow_steering_enabled = hdd_ctx->config->flow_steering_enable; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9438 | cds_cfg->max_msdus_per_rxinorderind = |
| 9439 | hdd_ctx->config->max_msdus_per_rxinorderind; |
Naveen Rawat | 91df30a | 2016-10-12 21:26:18 -0700 | [diff] [blame] | 9440 | cds_cfg->self_recovery_enabled = hdd_ctx->config->enableSelfRecovery; |
Sandeep Puligilla | afa5289 | 2016-10-26 19:03:16 -0700 | [diff] [blame] | 9441 | cds_cfg->fw_timeout_crash = hdd_ctx->config->fw_timeout_crash; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 9442 | cds_cfg->active_uc_apf_mode = hdd_ctx->config->active_uc_apf_mode; |
| 9443 | 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] | 9444 | cds_cfg->auto_power_save_fail_mode = |
| 9445 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9446 | |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9447 | cds_cfg->ito_repeat_count = hdd_ctx->config->ito_repeat_count; |
Sandeep Puligilla | 819d94f | 2017-10-10 18:33:56 -0700 | [diff] [blame] | 9448 | cds_cfg->bandcapability = hdd_ctx->config->nBandCapability; |
Zhu Jianmin | a2f8e8d | 2018-02-11 16:37:10 +0800 | [diff] [blame] | 9449 | cds_cfg->delay_before_vdev_stop = |
| 9450 | hdd_ctx->config->delay_before_vdev_stop; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9451 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9452 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9453 | hdd_ra_populate_cds_config(cds_cfg, hdd_ctx); |
| 9454 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
| 9455 | hdd_nan_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9456 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9457 | cds_init_ini_config(cds_cfg); |
| 9458 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9459 | |
| 9460 | exit: |
| 9461 | qdf_mem_free(cds_cfg); |
| 9462 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9463 | } |
| 9464 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9465 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9466 | * hdd_update_user_config() - API to update user configuration |
| 9467 | * parameters to obj mgr which are used by multiple components |
| 9468 | * @hdd_ctx: HDD Context |
| 9469 | * |
| 9470 | * Return: 0 for Success, errno on failure |
| 9471 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9472 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9473 | { |
| 9474 | struct wlan_objmgr_psoc_user_config *user_config; |
| 9475 | |
| 9476 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
| 9477 | if (user_config == NULL) { |
| 9478 | hdd_alert("Failed to alloc memory for user_config!"); |
| 9479 | return -ENOMEM; |
| 9480 | } |
| 9481 | |
| 9482 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
| 9483 | user_config->dual_mac_feature_disable = |
| 9484 | hdd_ctx->config->dual_mac_feature_disable; |
| 9485 | user_config->indoor_channel_support = |
| 9486 | hdd_ctx->config->indoor_channel_support; |
| 9487 | user_config->is_11d_support_enabled = |
| 9488 | hdd_ctx->config->Is11dSupportEnabled; |
| 9489 | user_config->is_11h_support_enabled = |
| 9490 | hdd_ctx->config->Is11hSupportEnabled; |
| 9491 | user_config->optimize_chan_avoid_event = |
| 9492 | hdd_ctx->config->goptimize_chan_avoid_event; |
| 9493 | user_config->skip_dfs_chnl_in_p2p_search = |
| 9494 | hdd_ctx->config->skipDfsChnlInP2pSearch; |
Naveen Rawat | 222b2e9 | 2017-03-16 09:52:21 -0700 | [diff] [blame] | 9495 | user_config->band_capability = hdd_ctx->config->nBandCapability; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9496 | wlan_objmgr_psoc_set_user_config(hdd_ctx->hdd_psoc, user_config); |
| 9497 | |
| 9498 | qdf_mem_free(user_config); |
| 9499 | return 0; |
| 9500 | } |
| 9501 | |
| 9502 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9503 | * hdd_init_thermal_info - Initialize thermal level |
| 9504 | * @hdd_ctx: HDD context |
| 9505 | * |
| 9506 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9507 | * which would be called when a configured thermal threshold is hit. |
| 9508 | * |
| 9509 | * Return: 0 on success and errno on failure |
| 9510 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9511 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9512 | { |
| 9513 | tSmeThermalParams thermal_param; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9514 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9515 | mac_handle_t mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9516 | |
| 9517 | thermal_param.smeThermalMgmtEnabled = |
| 9518 | hdd_ctx->config->thermalMitigationEnable; |
| 9519 | thermal_param.smeThrottlePeriod = hdd_ctx->config->throttlePeriod; |
| 9520 | |
Poddar, Siddarth | 8390502 | 2016-04-16 17:56:08 -0700 | [diff] [blame] | 9521 | thermal_param.sme_throttle_duty_cycle_tbl[0] = |
| 9522 | hdd_ctx->config->throttle_dutycycle_level0; |
| 9523 | thermal_param.sme_throttle_duty_cycle_tbl[1] = |
| 9524 | hdd_ctx->config->throttle_dutycycle_level1; |
| 9525 | thermal_param.sme_throttle_duty_cycle_tbl[2] = |
| 9526 | hdd_ctx->config->throttle_dutycycle_level2; |
| 9527 | thermal_param.sme_throttle_duty_cycle_tbl[3] = |
| 9528 | hdd_ctx->config->throttle_dutycycle_level3; |
| 9529 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9530 | thermal_param.smeThermalLevels[0].smeMinTempThreshold = |
| 9531 | hdd_ctx->config->thermalTempMinLevel0; |
| 9532 | thermal_param.smeThermalLevels[0].smeMaxTempThreshold = |
| 9533 | hdd_ctx->config->thermalTempMaxLevel0; |
| 9534 | thermal_param.smeThermalLevels[1].smeMinTempThreshold = |
| 9535 | hdd_ctx->config->thermalTempMinLevel1; |
| 9536 | thermal_param.smeThermalLevels[1].smeMaxTempThreshold = |
| 9537 | hdd_ctx->config->thermalTempMaxLevel1; |
| 9538 | thermal_param.smeThermalLevels[2].smeMinTempThreshold = |
| 9539 | hdd_ctx->config->thermalTempMinLevel2; |
| 9540 | thermal_param.smeThermalLevels[2].smeMaxTempThreshold = |
| 9541 | hdd_ctx->config->thermalTempMaxLevel2; |
| 9542 | thermal_param.smeThermalLevels[3].smeMinTempThreshold = |
| 9543 | hdd_ctx->config->thermalTempMinLevel3; |
| 9544 | thermal_param.smeThermalLevels[3].smeMaxTempThreshold = |
| 9545 | hdd_ctx->config->thermalTempMaxLevel3; |
| 9546 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9547 | mac_handle = hdd_ctx->mac_handle; |
| 9548 | status = sme_init_thermal_info(mac_handle, thermal_param); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9549 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9550 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9551 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9552 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9553 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9554 | hdd_set_thermal_level_cb); |
| 9555 | |
| 9556 | return 0; |
| 9557 | |
| 9558 | } |
| 9559 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9560 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9561 | /** |
| 9562 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9563 | * |
| 9564 | * Hold RTNL lock |
| 9565 | * |
| 9566 | * Return: True if held and false otherwise |
| 9567 | */ |
| 9568 | static inline bool hdd_hold_rtnl_lock(void) |
| 9569 | { |
| 9570 | rtnl_lock(); |
| 9571 | return true; |
| 9572 | } |
| 9573 | |
| 9574 | /** |
| 9575 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9576 | * |
| 9577 | * Release RTNL lock |
| 9578 | * |
| 9579 | * Return: None |
| 9580 | */ |
| 9581 | static inline void hdd_release_rtnl_lock(void) |
| 9582 | { |
| 9583 | rtnl_unlock(); |
| 9584 | } |
| 9585 | #else |
| 9586 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 9587 | static inline void hdd_release_rtnl_lock(void) { } |
| 9588 | #endif |
| 9589 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9590 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9591 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9592 | /* MAX iwpriv command support */ |
| 9593 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9594 | #define PKTLOG_CLEAR_BUFF 4 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9595 | #define MAX_PKTLOG_SIZE 16 |
| 9596 | |
| 9597 | /** |
| 9598 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 9599 | * @hdd_ctx: hdd context |
| 9600 | * @set_value2: pktlog buffer size value |
| 9601 | * |
| 9602 | * |
| 9603 | * Return: 0 for success or error. |
| 9604 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9605 | 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] | 9606 | { |
| 9607 | struct sir_wifi_start_log start_log = { 0 }; |
| 9608 | QDF_STATUS status; |
| 9609 | |
| 9610 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9611 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9612 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9613 | start_log.user_triggered = 1; |
| 9614 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9615 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9616 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9617 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9618 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9619 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9620 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9621 | return -EINVAL; |
| 9622 | } |
| 9623 | |
| 9624 | return 0; |
| 9625 | } |
| 9626 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9627 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9628 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 9629 | * @hdd_ctx: hdd context |
| 9630 | * |
| 9631 | * Return: 0 for success or error. |
| 9632 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9633 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9634 | { |
| 9635 | struct sir_wifi_start_log start_log; |
| 9636 | QDF_STATUS status; |
| 9637 | |
| 9638 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9639 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 9640 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9641 | start_log.user_triggered = 1; |
| 9642 | start_log.size = 0; |
| 9643 | start_log.is_pktlog_buff_clear = true; |
| 9644 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9645 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9646 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9647 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9648 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9649 | return -EINVAL; |
| 9650 | } |
| 9651 | |
| 9652 | return 0; |
| 9653 | } |
| 9654 | |
| 9655 | |
| 9656 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9657 | * hdd_process_pktlog_command() - process pktlog command |
| 9658 | * @hdd_ctx: hdd context |
| 9659 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9660 | * @set_value2: pktlog buffer size value |
| 9661 | * |
| 9662 | * This function process pktlog command. |
| 9663 | * set_value2 only matters when set_value is 3 (set buff size) |
| 9664 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9665 | * |
| 9666 | * Return: 0 for success or error. |
| 9667 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9668 | 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] | 9669 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9670 | { |
| 9671 | int ret; |
| 9672 | bool enable; |
| 9673 | uint8_t user_triggered = 0; |
| 9674 | |
| 9675 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 9676 | if (0 != ret) |
| 9677 | return ret; |
| 9678 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9679 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9680 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9681 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9682 | hdd_err("invalid pktlog value %d", set_value); |
| 9683 | return -EINVAL; |
| 9684 | } |
| 9685 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9686 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 9687 | if (set_value2 <= 0) { |
| 9688 | hdd_err("invalid pktlog size %d", set_value2); |
| 9689 | return -EINVAL; |
| 9690 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
| 9691 | hdd_err("Pktlog buff size is too large. max value is 16MB.\n"); |
| 9692 | return -EINVAL; |
| 9693 | } |
| 9694 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9695 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 9696 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9697 | } |
| 9698 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9699 | /* |
| 9700 | * set_value = 0 then disable packetlog |
| 9701 | * set_value = 1 enable packetlog forcefully |
| 9702 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 9703 | * enable packetlog with AUTO type. |
| 9704 | */ |
| 9705 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 9706 | true : false; |
| 9707 | |
| 9708 | if (1 == set_value) { |
| 9709 | enable = true; |
| 9710 | user_triggered = 1; |
| 9711 | } |
| 9712 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9713 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9714 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 9715 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9716 | /** |
| 9717 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 9718 | * @hdd_ctx: HDD context |
| 9719 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9720 | * @user_triggered: triggered through iwpriv |
| 9721 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9722 | * |
| 9723 | * Return: 0 on success; error number otherwise |
| 9724 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9725 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9726 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9727 | { |
| 9728 | struct sir_wifi_start_log start_log; |
| 9729 | QDF_STATUS status; |
| 9730 | |
| 9731 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 9732 | start_log.verbose_level = |
| 9733 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 9734 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 9735 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 9736 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 9737 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 9738 | /* |
| 9739 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 9740 | * commands. Host uses this flag to decide whether to send pktlog |
| 9741 | * disable command to fw without sending pktlog enable command |
| 9742 | * previously. For eg, If vendor sends pktlog disable command without |
| 9743 | * sending pktlog enable command, then host discards the packet |
| 9744 | * but for iwpriv command, host will send it to fw. |
| 9745 | */ |
| 9746 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9747 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9748 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 9749 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9750 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9751 | return -EINVAL; |
| 9752 | } |
| 9753 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 9754 | if (enable == true) |
| 9755 | hdd_ctx->is_pktlog_enabled = 1; |
| 9756 | else |
| 9757 | hdd_ctx->is_pktlog_enabled = 0; |
| 9758 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 9759 | return 0; |
| 9760 | } |
| 9761 | #endif /* REMOVE_PKT_LOG */ |
| 9762 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9763 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9764 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 9765 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9766 | * @dev: Device Pointer |
| 9767 | * @num: Number of Valid Mac address |
| 9768 | * |
| 9769 | * Return: Pointer to MAC address buffer |
| 9770 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9771 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 9772 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9773 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9774 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9775 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9776 | |
| 9777 | /** |
| 9778 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 9779 | * @hdd_ctx: HDD Context |
| 9780 | * @num: Number of random mac addresses needed |
| 9781 | * |
| 9782 | * Generate random addresses using bit manipulation on the base mac address |
| 9783 | * |
| 9784 | * Return: None |
| 9785 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9786 | 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] | 9787 | { |
| 9788 | uint32_t start_idx = QDF_MAX_CONCURRENCY_PERSONA - num; |
| 9789 | uint32_t iter; |
| 9790 | struct hdd_config *ini = hdd_ctx->config; |
| 9791 | uint8_t *buf = NULL; |
| 9792 | uint8_t macaddr_b3, tmp_br3; |
| 9793 | uint8_t *src = ini->intfMacAddr[0].bytes; |
| 9794 | |
| 9795 | for (iter = start_idx; iter < QDF_MAX_CONCURRENCY_PERSONA; ++iter) { |
| 9796 | buf = ini->intfMacAddr[iter].bytes; |
| 9797 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 9798 | macaddr_b3 = buf[3]; |
| 9799 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + iter) & |
| 9800 | INTF_MACADDR_MASK; |
| 9801 | macaddr_b3 += tmp_br3; |
| 9802 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 9803 | buf[0] |= 0x02; |
| 9804 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9805 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9806 | } |
| 9807 | } |
| 9808 | |
| 9809 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9810 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9811 | * @hdd_ctx: HDD Context |
| 9812 | * |
| 9813 | * API to get mac addresses from platform driver and update the driver |
| 9814 | * structures and configure FW with the base mac address. |
| 9815 | * Return: int |
| 9816 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9817 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9818 | { |
| 9819 | uint32_t no_of_mac_addr, iter; |
| 9820 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 9821 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 9822 | uint8_t *addr, *buf; |
| 9823 | struct device *dev = hdd_ctx->parent_dev; |
| 9824 | struct hdd_config *ini = hdd_ctx->config; |
| 9825 | tSirMacAddr mac_addr; |
| 9826 | QDF_STATUS status; |
| 9827 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9828 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9829 | |
| 9830 | if (no_of_mac_addr == 0 || !addr) { |
| 9831 | hdd_warn("Platform Driver Doesn't have wlan mac addresses"); |
| 9832 | return -EINVAL; |
| 9833 | } |
| 9834 | |
| 9835 | if (no_of_mac_addr > max_mac_addr) |
| 9836 | no_of_mac_addr = max_mac_addr; |
| 9837 | |
| 9838 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 9839 | |
| 9840 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
| 9841 | buf = ini->intfMacAddr[iter].bytes; |
| 9842 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9843 | hdd_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9844 | } |
| 9845 | |
| 9846 | status = sme_set_custom_mac_addr(mac_addr); |
| 9847 | |
| 9848 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9849 | return -EAGAIN; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 9850 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9851 | if (no_of_mac_addr < max_mac_addr) |
| 9852 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 9853 | no_of_mac_addr); |
| 9854 | return 0; |
| 9855 | } |
| 9856 | |
| 9857 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9858 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 9859 | * @hdd_ctx: HDD Context |
| 9860 | * |
| 9861 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 9862 | * will generate its own MAC and update it to FW. |
| 9863 | * |
| 9864 | * Return: 0 for success |
| 9865 | * Non-zero error code for failure |
| 9866 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9867 | 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] | 9868 | { |
| 9869 | tSirMacAddr customMacAddr; |
| 9870 | QDF_STATUS status; |
| 9871 | |
| 9872 | qdf_mem_copy(&customMacAddr, |
| 9873 | &hdd_ctx->config->intfMacAddr[0].bytes[0], |
| 9874 | sizeof(tSirMacAddr)); |
| 9875 | status = sme_set_custom_mac_addr(customMacAddr); |
| 9876 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9877 | return -EAGAIN; |
| 9878 | return 0; |
| 9879 | } |
| 9880 | |
| 9881 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9882 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 9883 | * @hdd_ctx: HDD Context |
| 9884 | * |
| 9885 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 9886 | * is provisioned with mac addresses, driver uses it, else it will use |
| 9887 | * wlan_mac.bin to update HW MAC addresses. |
| 9888 | * |
| 9889 | * Return: None |
| 9890 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9891 | static void hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9892 | { |
| 9893 | QDF_STATUS status; |
| 9894 | int ret; |
| 9895 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 9896 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9897 | if (ret == 0) |
| 9898 | return; |
| 9899 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9900 | hdd_info("MAC is not programmed in platform driver ret: %d, use wlan_mac.bin", |
| 9901 | ret); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9902 | |
| 9903 | status = hdd_update_mac_config(hdd_ctx); |
| 9904 | |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9905 | if (QDF_IS_STATUS_SUCCESS(status)) |
| 9906 | return; |
| 9907 | |
Yuanyuan Liu | 3d62f6a | 2017-06-08 11:08:46 -0700 | [diff] [blame] | 9908 | hdd_info("MAC is not programmed in wlan_mac.bin ret %d, use default MAC", |
| 9909 | status); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9910 | |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9911 | if (hdd_ctx->update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9912 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 9913 | if (ret != 0) { |
| 9914 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
| 9915 | QDF_ASSERT(ret); |
| 9916 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 9917 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 9918 | } |
| 9919 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9920 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9921 | { |
| 9922 | int vdev_id = 0; |
| 9923 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
| 9924 | int value = hdd_ctx->config->smart_chainmask_enabled; |
| 9925 | int vpdev = PDEV_CMD; |
| 9926 | int ret; |
| 9927 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9928 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9929 | if (ret) |
| 9930 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 9931 | |
| 9932 | return ret; |
| 9933 | } |
| 9934 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9935 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9936 | { |
| 9937 | int vdev_id = 0; |
| 9938 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
| 9939 | int value = hdd_ctx->config->alternative_chainmask_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 | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 9944 | if (ret) |
| 9945 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 9946 | ret); |
| 9947 | |
| 9948 | return ret; |
| 9949 | } |
| 9950 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9951 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9952 | { |
| 9953 | int vdev_id = 0; |
| 9954 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
| 9955 | int value = hdd_ctx->config->ani_enabled; |
| 9956 | int vpdev = PDEV_CMD; |
| 9957 | int ret; |
| 9958 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 9959 | ret = sme_cli_set_command(vdev_id, param_id, value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 9960 | if (ret) |
| 9961 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 9962 | |
| 9963 | return ret; |
| 9964 | } |
| 9965 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 9966 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9967 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 9968 | * @hdd_ctx: HDD context |
| 9969 | * |
| 9970 | * Pre configurations to be done at lower layer before calling cds enable. |
| 9971 | * |
| 9972 | * Return: 0 on success and errno on failure. |
| 9973 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9974 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9975 | { |
| 9976 | int ret; |
| 9977 | QDF_STATUS status; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9978 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9979 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 9980 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 9981 | /* Register HL netdev flow control callback */ |
| 9982 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 9983 | /* |
| 9984 | * Set 802.11p config |
| 9985 | * TODO-OCB: This has been temporarily added here to ensure this |
| 9986 | * parameter is set in CSR when we init the channel list. This should |
| 9987 | * be removed once the 5.9 GHz channels are added to the regulatory |
| 9988 | * domain. |
| 9989 | */ |
| 9990 | hdd_set_dot11p_config(hdd_ctx); |
| 9991 | |
| 9992 | /* |
| 9993 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 9994 | * The cfg download must occur before we update the SME config |
| 9995 | * since the SME config operation must access the cfg database |
| 9996 | */ |
| 9997 | status = hdd_set_sme_config(hdd_ctx); |
| 9998 | |
| 9999 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10000 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10001 | ret = qdf_status_to_os_return(status); |
| 10002 | goto out; |
| 10003 | } |
| 10004 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10005 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10006 | if (QDF_STATUS_SUCCESS != status) { |
| 10007 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10008 | ret = qdf_status_to_os_return(status); |
| 10009 | goto out; |
| 10010 | } |
| 10011 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10012 | 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] | 10013 | hdd_ctx->config->tx_chain_mask_1ss, |
| 10014 | PDEV_CMD); |
| 10015 | if (0 != ret) { |
| 10016 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10017 | goto out; |
| 10018 | } |
| 10019 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10020 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10021 | if (ret) |
| 10022 | goto out; |
| 10023 | |
| 10024 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10025 | if (ret) |
| 10026 | goto out; |
| 10027 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10028 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10029 | if (ret) |
| 10030 | goto out; |
| 10031 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10032 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10033 | hdd_ctx->config->arp_ac_category, |
| 10034 | PDEV_CMD); |
| 10035 | if (0 != ret) { |
| 10036 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
| 10037 | hdd_ctx->config->arp_ac_category, ret); |
| 10038 | goto out; |
| 10039 | } |
| 10040 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10041 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10042 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10043 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10044 | ret = qdf_status_to_os_return(status); |
| 10045 | goto out; |
| 10046 | } |
| 10047 | |
| 10048 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10049 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10050 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10051 | ret = -EINVAL; |
| 10052 | goto out; |
| 10053 | } |
| 10054 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10055 | /* |
| 10056 | * Set the MAC Address Currently this is used by HAL to add self sta. |
| 10057 | * Remove this once self sta is added as part of session open. |
| 10058 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10059 | 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] | 10060 | hdd_ctx->config->intfMacAddr[0].bytes, |
| 10061 | sizeof(hdd_ctx->config->intfMacAddr[0])); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10062 | |
Jeff Johnson | bae59f9 | 2018-06-01 17:05:43 -0700 | [diff] [blame] | 10063 | if (QDF_IS_STATUS_ERROR(status)) { |
| 10064 | hdd_err("Failed to set MAC Address, status %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10065 | ret = -EINVAL; |
| 10066 | goto out; |
| 10067 | } |
| 10068 | |
| 10069 | hdd_init_channel_avoidance(hdd_ctx); |
| 10070 | |
Ganesh Kondabattini | 408fb8d | 2017-08-08 22:00:20 +0530 | [diff] [blame] | 10071 | /* update enable sap mandatory chan list */ |
| 10072 | policy_mgr_enable_disable_sap_mandatory_chan_list(hdd_ctx->hdd_psoc, |
| 10073 | hdd_ctx->config->enable_sap_mandatory_chan_list); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10074 | out: |
| 10075 | return ret; |
| 10076 | } |
| 10077 | |
| 10078 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10079 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
| 10080 | * @context_ptr - hdd context pointer |
| 10081 | * @event_ptr - event structure pointer |
| 10082 | * |
| 10083 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10084 | * event back to supplicant to notify the stop reason. |
| 10085 | * |
| 10086 | * Return: None |
| 10087 | */ |
| 10088 | static void wlan_hdd_p2p_lo_event_callback(void *context_ptr, |
| 10089 | void *event_ptr) |
| 10090 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10091 | struct hdd_context *hdd_ctx = (struct hdd_context *)context_ptr; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10092 | struct sir_p2p_lo_event *evt = event_ptr; |
| 10093 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10094 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10095 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10096 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10097 | |
| 10098 | if (hdd_ctx == NULL) { |
| 10099 | hdd_err("Invalid HDD context pointer"); |
| 10100 | return; |
| 10101 | } |
| 10102 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10103 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10104 | if (!adapter) { |
| 10105 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10106 | evt->vdev_id); |
| 10107 | return; |
| 10108 | } |
| 10109 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10110 | vendor_event = |
| 10111 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10112 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10113 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10114 | GFP_KERNEL); |
| 10115 | |
| 10116 | if (!vendor_event) { |
| 10117 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10118 | return; |
| 10119 | } |
| 10120 | |
| 10121 | if (nla_put_u32(vendor_event, |
| 10122 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10123 | evt->reason_code)) { |
| 10124 | hdd_err("nla put failed"); |
| 10125 | kfree_skb(vendor_event); |
| 10126 | return; |
| 10127 | } |
| 10128 | |
| 10129 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10130 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10131 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10132 | } |
| 10133 | |
| 10134 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10135 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10136 | * @hdd_ctx: HDD context |
| 10137 | * |
| 10138 | * This function sends the adaptive dwell time config configuration to the |
| 10139 | * firmware via WMA |
| 10140 | * |
| 10141 | * Return: 0 - success, < 0 - failure |
| 10142 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10143 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10144 | { |
| 10145 | QDF_STATUS status; |
| 10146 | struct adaptive_dwelltime_params dwelltime_params; |
| 10147 | |
| 10148 | dwelltime_params.is_enabled = |
| 10149 | hdd_ctx->config->adaptive_dwell_mode_enabled; |
| 10150 | dwelltime_params.dwelltime_mode = |
| 10151 | hdd_ctx->config->global_adapt_dwelltime_mode; |
| 10152 | dwelltime_params.lpf_weight = |
| 10153 | hdd_ctx->config->adapt_dwell_lpf_weight; |
| 10154 | dwelltime_params.passive_mon_intval = |
| 10155 | hdd_ctx->config->adapt_dwell_passive_mon_intval; |
| 10156 | dwelltime_params.wifi_act_threshold = |
| 10157 | hdd_ctx->config->adapt_dwell_wifi_act_threshold; |
| 10158 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10159 | status = sme_set_adaptive_dwelltime_config(hdd_ctx->mac_handle, |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10160 | &dwelltime_params); |
| 10161 | |
| 10162 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10163 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10164 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10165 | return -EAGAIN; |
| 10166 | } |
| 10167 | return 0; |
| 10168 | } |
| 10169 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10170 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10171 | { |
| 10172 | QDF_STATUS status; |
| 10173 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10174 | uint32_t i = 0; |
| 10175 | uint8_t count = 0, numentries = 0; |
| 10176 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10177 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10178 | |
| 10179 | /* check if DBS is enabled or supported */ |
Bala Venkatesh | c8236ca | 2018-03-09 12:38:29 +0530 | [diff] [blame] | 10180 | if ((hdd_ctx->config->dual_mac_feature_disable == |
| 10181 | DISABLE_DBS_CXN_AND_SCAN) || |
| 10182 | (hdd_ctx->config->dual_mac_feature_disable == |
| 10183 | ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10184 | return -EINVAL; |
| 10185 | |
| 10186 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10187 | dbs_scan_config, &numentries, |
| 10188 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10189 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10190 | |
| 10191 | hdd_info("numentries %hu", numentries); |
| 10192 | if (!numentries) { |
| 10193 | hdd_info("Donot send scan_selection_config"); |
| 10194 | return 0; |
| 10195 | } |
| 10196 | |
| 10197 | /* hdd_set_fw_log_params */ |
| 10198 | dbs_scan_params.num_clients = 0; |
| 10199 | while (count < (numentries - 2)) { |
| 10200 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10201 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10202 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10203 | dbs_scan_config[count + 2]; |
| 10204 | dbs_scan_params.num_clients++; |
| 10205 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10206 | dbs_scan_params.module_id[i], |
| 10207 | dbs_scan_params.num_dbs_scans[i], |
| 10208 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10209 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10210 | i++; |
| 10211 | } |
| 10212 | |
| 10213 | dbs_scan_params.pdev_id = 0; |
| 10214 | |
| 10215 | hdd_debug("clients:%d pdev:%d", |
| 10216 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10217 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10218 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10219 | &dbs_scan_params); |
| 10220 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10221 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10222 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10223 | return -EAGAIN; |
| 10224 | } |
| 10225 | return 0; |
| 10226 | } |
| 10227 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10228 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10229 | /** |
| 10230 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10231 | * @hdd_ctx: HDD context |
| 10232 | * |
| 10233 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10234 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10235 | * |
| 10236 | * Return: 0 on success and errno on failure. |
| 10237 | */ |
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 | QDF_STATUS status; |
| 10241 | |
| 10242 | if (!hdd_ctx->config->WlanAutoShutdown) |
| 10243 | return 0; |
| 10244 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10245 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10246 | wlan_hdd_auto_shutdown_cb); |
| 10247 | if (status != QDF_STATUS_SUCCESS) |
| 10248 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10249 | status); |
| 10250 | |
| 10251 | return qdf_status_to_os_return(status); |
| 10252 | } |
| 10253 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10254 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10255 | { |
| 10256 | return 0; |
| 10257 | } |
| 10258 | #endif |
| 10259 | |
| 10260 | /** |
| 10261 | * hdd_features_init() - Init features |
| 10262 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10263 | * |
| 10264 | * Initialize features and their feature context after WLAN firmware is up. |
| 10265 | * |
| 10266 | * Return: 0 on success and errno on failure. |
| 10267 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10268 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10269 | { |
| 10270 | tSirTxPowerLimit hddtxlimit; |
| 10271 | QDF_STATUS status; |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10272 | struct sme_5g_band_pref_params band_pref_params; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10273 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10274 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10275 | struct hdd_config *cfg; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10276 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10277 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10278 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10279 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10280 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10281 | mac_handle = hdd_ctx->mac_handle; |
| 10282 | sme_setdef_dot11mode(mac_handle); |
| 10283 | sme_set_prefer_80MHz_over_160MHz(mac_handle, |
Kiran Kumar Lokere | 1aa9c9a | 2016-10-05 18:50:59 -0700 | [diff] [blame] | 10284 | hdd_ctx->config->sta_prefer_80MHz_over_160MHz); |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10285 | sme_set_etsi13_srd_ch_in_master_mode(mac_handle, |
| 10286 | cfg-> |
| 10287 | etsi13_srd_chan_in_master_mode); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10288 | |
| 10289 | if (hdd_ctx->config->fIsImpsEnabled) |
| 10290 | hdd_set_idle_ps_config(hdd_ctx, true); |
| 10291 | else |
| 10292 | hdd_set_idle_ps_config(hdd_ctx, false); |
| 10293 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10294 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10295 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
| 10296 | hdd_ctx->config->enable_data_stall_det, PDEV_CMD); |
| 10297 | |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10298 | if (hdd_ctx->config->enable_go_cts2self_for_sta) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10299 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10300 | |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10301 | if (sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap)) |
| 10302 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10303 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10304 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10305 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10306 | |
| 10307 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10308 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10309 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10310 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10311 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10312 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10313 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10314 | if (ret) { |
| 10315 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10316 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10317 | } |
| 10318 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10319 | /** |
| 10320 | * In case of SSR/PDR, if pktlog was enabled manually before |
| 10321 | * SSR/PDR, Then enabled it again automatically after Wlan |
| 10322 | * device up. |
| 10323 | */ |
| 10324 | if (cds_is_driver_recovering()) { |
| 10325 | if (hdd_ctx->is_pktlog_enabled) |
| 10326 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Tiger Yu | f3d5d7f | 2018-03-15 14:48:11 +0800 | [diff] [blame] | 10327 | } |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10328 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10329 | hddtxlimit.txPower2g = hdd_ctx->config->TxPower2g; |
| 10330 | hddtxlimit.txPower5g = hdd_ctx->config->TxPower5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10331 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10332 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10333 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10334 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10335 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10336 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10337 | ret = hdd_register_cb(hdd_ctx); |
| 10338 | if (ret) { |
| 10339 | hdd_err("Failed to register HDD callbacks!"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10340 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10341 | } |
| 10342 | |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10343 | if (hdd_ctx->config->goptimize_chan_avoid_event) { |
| 10344 | status = sme_enable_disable_chanavoidind_event( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10345 | mac_handle, 0); |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10346 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10347 | hdd_err("Failed to disable Chan Avoidance Indication"); |
| 10348 | goto deregister_cb; |
| 10349 | } |
| 10350 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10351 | |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10352 | if (hdd_ctx->config->enable_5g_band_pref) { |
| 10353 | band_pref_params.rssi_boost_threshold_5g = |
| 10354 | hdd_ctx->config->rssi_boost_threshold_5g; |
| 10355 | band_pref_params.rssi_boost_factor_5g = |
| 10356 | hdd_ctx->config->rssi_boost_factor_5g; |
| 10357 | band_pref_params.max_rssi_boost_5g = |
| 10358 | hdd_ctx->config->max_rssi_boost_5g; |
| 10359 | band_pref_params.rssi_penalize_threshold_5g = |
| 10360 | hdd_ctx->config->rssi_penalize_threshold_5g; |
| 10361 | band_pref_params.rssi_penalize_factor_5g = |
| 10362 | hdd_ctx->config->rssi_penalize_factor_5g; |
| 10363 | band_pref_params.max_rssi_penalize_5g = |
| 10364 | hdd_ctx->config->max_rssi_penalize_5g; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10365 | sme_set_5g_band_pref(mac_handle, &band_pref_params); |
Manjeet Singh | a9cae43 | 2017-02-28 11:58:22 +0530 | [diff] [blame] | 10366 | } |
| 10367 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10368 | /* register P2P Listen Offload event callback */ |
| 10369 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10370 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10371 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10372 | |
| 10373 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10374 | |
| 10375 | if (ret) |
| 10376 | goto deregister_cb; |
| 10377 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10378 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10379 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10380 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10381 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10382 | return 0; |
| 10383 | |
| 10384 | deregister_cb: |
| 10385 | hdd_deregister_cb(hdd_ctx); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10386 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10387 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10388 | } |
| 10389 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10390 | /** |
| 10391 | * hdd_features_deinit() - Deinit features |
| 10392 | * @hdd_ctx: HDD context |
| 10393 | * |
| 10394 | * De-Initialize features and their feature context. |
| 10395 | * |
| 10396 | * Return: none. |
| 10397 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10398 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10399 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10400 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10401 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10402 | wlan_hdd_tsf_deinit(hdd_ctx); |
| 10403 | } |
| 10404 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10405 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10406 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10407 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10408 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10409 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10410 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10411 | 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] | 10412 | { |
| 10413 | QDF_STATUS status; |
| 10414 | |
| 10415 | status = ucfg_scan_register_bcn_cb(hdd_ctx->hdd_psoc, |
| 10416 | wlan_cfg80211_inform_bss_frame, |
| 10417 | SCAN_CB_TYPE_INFORM_BCN); |
| 10418 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10419 | hdd_err("failed with status code %08d [x%08x]", |
| 10420 | status, status); |
| 10421 | return status; |
| 10422 | } |
| 10423 | |
| 10424 | return QDF_STATUS_SUCCESS; |
| 10425 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10426 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10427 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10428 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10429 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10430 | * |
| 10431 | * Return: none. |
| 10432 | */ |
| 10433 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10434 | { |
| 10435 | QDF_STATUS status; |
| 10436 | |
| 10437 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 10438 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 10439 | vdev_id); |
| 10440 | /* |
| 10441 | * For Adrastea flow control v2 is based on FW MAP events, |
| 10442 | * so this above callback is not implemented. |
| 10443 | * Hence this is not actual failure. Dont return failure |
| 10444 | */ |
| 10445 | if ((status != QDF_STATUS_SUCCESS) && |
| 10446 | (status != QDF_STATUS_E_INVAL)) { |
| 10447 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 10448 | vdev_id, status); |
| 10449 | } |
| 10450 | } |
| 10451 | |
| 10452 | /** |
| 10453 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 10454 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10455 | * |
| 10456 | * Return: none. |
| 10457 | */ |
| 10458 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 10459 | { |
| 10460 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 10461 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 10462 | } |
| 10463 | |
| 10464 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10465 | * hdd_configure_cds() - Configure cds modules |
| 10466 | * @hdd_ctx: HDD context |
| 10467 | * @adapter: Primary adapter context |
| 10468 | * |
| 10469 | * Enable Cds modules after WLAN firmware is up. |
| 10470 | * |
| 10471 | * Return: 0 on success and errno on failure. |
| 10472 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10473 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10474 | { |
| 10475 | int ret; |
| 10476 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10477 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10478 | mac_handle_t mac_handle; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10479 | uint32_t num_abg_tx_chains = 0; |
| 10480 | uint32_t num_11b_tx_chains = 0; |
| 10481 | uint32_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10482 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10483 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10484 | mac_handle = hdd_ctx->mac_handle; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10485 | if (hdd_ctx->config->is_force_1x1) |
| 10486 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 10487 | 1, PDEV_CMD); |
| 10488 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10489 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 10490 | hdd_chip_pwr_save_fail_detected_cb); |
| 10491 | |
| 10492 | if (hdd_ctx->config->max_mpdus_inampdu) { |
| 10493 | set_value = hdd_ctx->config->max_mpdus_inampdu; |
| 10494 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 10495 | set_value, PDEV_CMD); |
| 10496 | } |
| 10497 | |
| 10498 | if (hdd_ctx->config->enable_rts_sifsbursting) { |
| 10499 | set_value = hdd_ctx->config->enable_rts_sifsbursting; |
| 10500 | sme_cli_set_command(0, |
| 10501 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 10502 | set_value, PDEV_CMD); |
| 10503 | } |
| 10504 | |
| 10505 | if (hdd_ctx->config->sap_get_peer_info) { |
| 10506 | set_value = hdd_ctx->config->sap_get_peer_info; |
| 10507 | sme_cli_set_command(0, |
| 10508 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 10509 | set_value, PDEV_CMD); |
| 10510 | } |
| 10511 | |
| 10512 | num_11b_tx_chains = hdd_ctx->config->num_11b_tx_chains; |
| 10513 | num_11ag_tx_chains = hdd_ctx->config->num_11ag_tx_chains; |
| 10514 | if (!hdd_ctx->config->enable2x2) { |
| 10515 | if (num_11b_tx_chains > 1) |
| 10516 | num_11b_tx_chains = 1; |
| 10517 | if (num_11ag_tx_chains > 1) |
| 10518 | num_11ag_tx_chains = 1; |
| 10519 | } |
| 10520 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10521 | num_11b_tx_chains); |
| 10522 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 10523 | num_11ag_tx_chains); |
| 10524 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 10525 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10526 | |
| 10527 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 10528 | if (ret) { |
| 10529 | hdd_err("Failed to pre-configure cds"); |
| 10530 | goto out; |
| 10531 | } |
| 10532 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10533 | /* Always get latest IPA resources allocated from cds_open and configure |
| 10534 | * IPA module before configuring them to FW. Sequence required as crash |
| 10535 | * observed otherwise. |
| 10536 | */ |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10537 | if (ucfg_ipa_uc_ol_init(hdd_ctx->hdd_pdev, |
| 10538 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 10539 | hdd_err("Failed to setup pipes"); |
| 10540 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 10541 | } |
| 10542 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10543 | /* |
| 10544 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 10545 | * else |
| 10546 | */ |
Jeff Johnson | 8f9dd5f | 2017-09-13 14:16:08 -0700 | [diff] [blame] | 10547 | status = cds_enable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10548 | |
| 10549 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10550 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10551 | goto out; |
| 10552 | } |
| 10553 | |
| 10554 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 10555 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10556 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10557 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10558 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10559 | status = hdd_register_bcn_cb(hdd_ctx); |
| 10560 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 10561 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10562 | goto cds_disable; |
| 10563 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10564 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10565 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10566 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10567 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10568 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10569 | if (hdd_ctx->ol_enable) |
| 10570 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 10571 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10572 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 10573 | 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] | 10574 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 10575 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10576 | status = policy_mgr_register_dp_cb(hdd_ctx->hdd_psoc, &dp_cbs); |
| 10577 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 10578 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10579 | goto cds_disable; |
| 10580 | } |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10581 | status = policy_mgr_register_mode_change_cb(hdd_ctx->hdd_psoc, |
| 10582 | wlan_hdd_send_mode_change_event); |
| 10583 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10584 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 10585 | goto cds_disable; |
| 10586 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 10587 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 10588 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 10589 | hdd_debug("enhance green ap is not enabled"); |
| 10590 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 10591 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 10592 | hdd_debug("Failed to set wow pulse"); |
| 10593 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 10594 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
| 10595 | hdd_ctx->config->gcmp_enabled, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 10596 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
| 10597 | hdd_ctx->config->auto_pwr_save_fail_mode, PDEV_CMD); |
| 10598 | |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 10599 | |
| 10600 | if (hdd_ctx->config->enable_phy_reg_retention) |
| 10601 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
| 10602 | hdd_ctx->config->enable_phy_reg_retention, PDEV_CMD); |
| 10603 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10604 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10605 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10606 | cds_disable: |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10607 | cds_disable(hdd_ctx->hdd_psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 10608 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10609 | out: |
| 10610 | return -EINVAL; |
| 10611 | } |
| 10612 | |
| 10613 | /** |
| 10614 | * hdd_deconfigure_cds() -De-Configure cds |
| 10615 | * @hdd_ctx: HDD context |
| 10616 | * |
| 10617 | * Deconfigure Cds modules before WLAN firmware is down. |
| 10618 | * |
| 10619 | * Return: 0 on success and errno on failure. |
| 10620 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10621 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10622 | { |
| 10623 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10624 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10625 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10626 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10627 | |
| 10628 | /* De-init features */ |
| 10629 | hdd_features_deinit(hdd_ctx); |
| 10630 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10631 | /* De-register the SME callbacks */ |
| 10632 | hdd_deregister_cb(hdd_ctx); |
| 10633 | |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 10634 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->hdd_psoc); |
| 10635 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10636 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
| 10637 | } |
| 10638 | |
Jeff Johnson | ea5c2aa1 | 2017-09-13 14:18:59 -0700 | [diff] [blame] | 10639 | qdf_status = cds_disable(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10640 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10641 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 10642 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10643 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10644 | } |
| 10645 | |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 10646 | 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] | 10647 | hdd_err("Failed to disconnect pipes"); |
| 10648 | ret = -EINVAL; |
| 10649 | } |
| 10650 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10651 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 10652 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10653 | } |
| 10654 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10655 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 10656 | static void hdd_deregister_policy_manager_callback( |
| 10657 | struct wlan_objmgr_psoc *psoc) |
| 10658 | { |
| 10659 | if (QDF_STATUS_SUCCESS != |
| 10660 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 10661 | hdd_err("HDD callback deregister with policy manager failed"); |
| 10662 | } |
| 10663 | } |
| 10664 | #else |
| 10665 | static void hdd_deregister_policy_manager_callback( |
| 10666 | struct wlan_objmgr_psoc *psoc) |
| 10667 | { |
| 10668 | } |
| 10669 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10670 | |
| 10671 | /** |
| 10672 | * hdd_wlan_stop_modules - Single driver state machine for stoping modules |
| 10673 | * @hdd_ctx: HDD context |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10674 | * @ftm_mode: ftm mode |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10675 | * |
| 10676 | * This function maintains the driver state machine it will be invoked from |
| 10677 | * exit, shutdown and con_mode change handler. Depending on the driver state |
| 10678 | * shall perform the stopping/closing of the modules. |
| 10679 | * |
| 10680 | * Return: 0 for success; non-zero for failure |
| 10681 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10682 | 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] | 10683 | { |
| 10684 | void *hif_ctx; |
| 10685 | qdf_device_t qdf_ctx; |
| 10686 | QDF_STATUS qdf_status; |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10687 | int ret = 0; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10688 | bool is_recovery_stop = cds_is_driver_recovering(); |
Liangwei Dong | a78cc1d | 2018-02-01 02:19:30 -0500 | [diff] [blame] | 10689 | bool is_idle_stop = !cds_is_driver_unloading() && !is_recovery_stop && |
| 10690 | !cds_is_driver_loading(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10691 | int active_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10692 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10693 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10694 | hdd_enter(); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10695 | hdd_alert("stop WLAN module: entering driver status=%d", |
| 10696 | hdd_ctx->driver_status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10697 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 10698 | hdd_deregister_policy_manager_callback(hdd_ctx->hdd_psoc); |
| 10699 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10700 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 10701 | if (!qdf_ctx) { |
| 10702 | hdd_err("QDF device context NULL"); |
| 10703 | return -EINVAL; |
| 10704 | } |
| 10705 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10706 | mutex_lock(&hdd_ctx->iface_change_lock); |
| 10707 | hdd_ctx->stop_modules_in_progress = true; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10708 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10709 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10710 | active_threads = cds_return_external_threads_count(); |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10711 | if (active_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10712 | hdd_warn("External threads %d wiphy suspend %d", |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10713 | active_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10714 | |
| 10715 | cds_print_external_threads(); |
| 10716 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10717 | if (is_idle_stop && !ftm_mode) { |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10718 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 10719 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 10720 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 10721 | hdd_prevent_suspend_timeout( |
| 10722 | hdd_ctx->config->iface_change_wait_time, |
| 10723 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 10724 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10725 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10726 | return 0; |
| 10727 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 10728 | } |
| 10729 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10730 | hdd_info("Present Driver Status: %d", hdd_ctx->driver_status); |
| 10731 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 10732 | /* free user wowl patterns */ |
| 10733 | hdd_free_user_wowl_ptrns(); |
| 10734 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10735 | switch (hdd_ctx->driver_status) { |
| 10736 | case DRIVER_MODULES_UNINITIALIZED: |
| 10737 | hdd_info("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10738 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10739 | case DRIVER_MODULES_CLOSED: |
| 10740 | hdd_info("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10741 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10742 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10743 | hdd_info("Wlan transitioning (OPENED <- ENABLED)"); |
| 10744 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 10745 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10746 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10747 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10748 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10749 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10750 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10751 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10752 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10753 | hdd_ctx->driver_status = DRIVER_MODULES_OPENED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10754 | hdd_info("Wlan transitioned (now OPENED)"); |
| 10755 | |
| 10756 | /* fall through */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10757 | case DRIVER_MODULES_OPENED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10758 | hdd_info("Wlan transitioning (CLOSED <- OPENED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10759 | break; |
| 10760 | default: |
| 10761 | hdd_err("Trying to stop wlan in a wrong state: %d", |
| 10762 | hdd_ctx->driver_status); |
| 10763 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10764 | ret = -EINVAL; |
| 10765 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10766 | } |
| 10767 | |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10768 | hdd_sysfs_destroy_version_interface(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10769 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 10770 | |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 10771 | qdf_status = cds_post_disable(); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10772 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10773 | hdd_err("Failed to process post CDS disable Modules! :%d", |
| 10774 | qdf_status); |
| 10775 | ret = -EINVAL; |
| 10776 | QDF_ASSERT(0); |
| 10777 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10778 | |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 10779 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
| 10780 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 10781 | qdf_status = cds_dp_close(hdd_ctx->hdd_psoc); |
| 10782 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 10783 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 10784 | ret = -EINVAL; |
| 10785 | QDF_ASSERT(0); |
| 10786 | } |
| 10787 | |
Jeff Johnson | e4b1459 | 2017-09-13 14:23:33 -0700 | [diff] [blame] | 10788 | qdf_status = cds_close(hdd_ctx->hdd_psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10789 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10790 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
Govind Singh | b048e87 | 2016-09-27 22:07:43 +0530 | [diff] [blame] | 10791 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10792 | QDF_ASSERT(0); |
| 10793 | } |
Krunal Soni | d32c6bc | 2016-10-18 18:00:21 -0700 | [diff] [blame] | 10794 | |
Amar Singhal | 410675c | 2018-01-10 12:14:21 -0800 | [diff] [blame] | 10795 | dispatcher_pdev_close(hdd_ctx->hdd_pdev); |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10796 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 10797 | if (ret) { |
| 10798 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 10799 | QDF_ASSERT(0); |
| 10800 | } |
| 10801 | |
| 10802 | /* |
| 10803 | * Reset total mac phy during module stop such that during |
| 10804 | * next module start same psoc is used to populate new service |
| 10805 | * ready data |
| 10806 | */ |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 10807 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->hdd_psoc); |
| 10808 | if (tgt_hdl) |
| 10809 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 10810 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 10811 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10812 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 10813 | if (!hif_ctx) { |
| 10814 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10815 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10816 | } |
| 10817 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 10818 | if (hdd_ctx->target_hw_name) { |
| 10819 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 10820 | hdd_ctx->target_hw_name = NULL; |
| 10821 | } |
| 10822 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 10823 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10824 | |
| 10825 | ol_cds_free(); |
| 10826 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 10827 | if (is_idle_stop) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10828 | ret = pld_power_off(qdf_ctx->dev); |
| 10829 | if (ret) |
| 10830 | hdd_err("CNSS power down failed put device into Low power mode:%d", |
| 10831 | ret); |
| 10832 | } |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10833 | |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10834 | /* many adapter resources are not freed by design in SSR case */ |
| 10835 | if (!is_recovery_stop) |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 10836 | hdd_check_for_leaks(hdd_ctx); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 10837 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10838 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 10839 | /* Once the firmware sequence is completed reset this flag */ |
| 10840 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10841 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 10842 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10843 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10844 | done: |
| 10845 | hdd_ctx->stop_modules_in_progress = false; |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 10846 | cds_set_module_stop_in_progress(false); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10847 | mutex_unlock(&hdd_ctx->iface_change_lock); |
Yun Park | fec73dc | 2017-09-06 10:40:07 -0700 | [diff] [blame] | 10848 | hdd_alert("stop WLAN module: exit driver status=%d", |
| 10849 | hdd_ctx->driver_status); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 10850 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10851 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10852 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 10853 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10854 | } |
| 10855 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10856 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10857 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 10858 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10859 | * hdd_state_info_dump() - prints state information of hdd layer |
| 10860 | * @buf: buffer pointer |
| 10861 | * @size: size of buffer to be filled |
| 10862 | * |
| 10863 | * This function is used to dump state information of hdd layer |
| 10864 | * |
| 10865 | * Return: None |
| 10866 | */ |
| 10867 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 10868 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10869 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 10870 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10871 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10872 | uint16_t len = 0; |
| 10873 | char *buf = *buf_ptr; |
| 10874 | |
| 10875 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 10876 | if (!hdd_ctx) { |
| 10877 | hdd_err("Failed to get hdd context "); |
| 10878 | return; |
| 10879 | } |
| 10880 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10881 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10882 | |
| 10883 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 10884 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10885 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 10886 | "\n is_scheduler_suspended %d", |
| 10887 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10888 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 10889 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10890 | if (adapter->dev) |
| 10891 | len += scnprintf(buf + len, *size - len, |
| 10892 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 10893 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10894 | "\n device_mode: %d", adapter->device_mode); |
| 10895 | switch (adapter->device_mode) { |
| 10896 | case QDF_STA_MODE: |
| 10897 | case QDF_P2P_CLIENT_MODE: |
| 10898 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 10899 | len += scnprintf(buf + len, *size - len, |
| 10900 | "\n connState: %d", |
| 10901 | hdd_sta_ctx->conn_info.connState); |
| 10902 | break; |
| 10903 | |
| 10904 | default: |
| 10905 | break; |
| 10906 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10907 | } |
| 10908 | |
| 10909 | *size -= len; |
| 10910 | *buf_ptr += len; |
| 10911 | } |
| 10912 | |
| 10913 | /** |
| 10914 | * hdd_register_debug_callback() - registration function for hdd layer |
| 10915 | * to print hdd state information |
| 10916 | * |
| 10917 | * Return: None |
| 10918 | */ |
| 10919 | static void hdd_register_debug_callback(void) |
| 10920 | { |
| 10921 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 10922 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10923 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 10924 | static void hdd_register_debug_callback(void) |
| 10925 | { |
| 10926 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 10927 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 10928 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10929 | /* |
| 10930 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 10931 | * |
| 10932 | * This function is used to create bug report lock |
| 10933 | * |
| 10934 | * Return: None |
| 10935 | */ |
| 10936 | static void wlan_init_bug_report_lock(void) |
| 10937 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 10938 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 10939 | |
| 10940 | p_cds_context = cds_get_global_context(); |
| 10941 | if (!p_cds_context) { |
| 10942 | hdd_err("cds context is NULL"); |
| 10943 | return; |
| 10944 | } |
| 10945 | |
| 10946 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 10947 | } |
| 10948 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10949 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10950 | void hdd_dp_trace_init(struct hdd_config *config) |
| 10951 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10952 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 10953 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 10954 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 10955 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 10956 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 10957 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 10958 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10959 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10960 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 10961 | if (!config->enable_dp_trace) { |
| 10962 | hdd_err("dp trace is disabled from ini"); |
| 10963 | return; |
| 10964 | } |
| 10965 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10966 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 10967 | &num_entries, sizeof(config_params)); |
| 10968 | |
| 10969 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10970 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10971 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 10972 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 10973 | else if (bw_compute_interval > 1000) { |
| 10974 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 10975 | thresh_time_limit = 1; |
| 10976 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10977 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 10978 | |
| 10979 | switch (num_entries) { |
| 10980 | case 4: |
| 10981 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10982 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10983 | case 3: |
| 10984 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10985 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10986 | case 2: |
| 10987 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10988 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10989 | case 1: |
| 10990 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 10991 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10992 | default: |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 10993 | hdd_info("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 10994 | live_mode, thresh, thresh_time_limit, |
| 10995 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 10996 | }; |
| 10997 | |
| 10998 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 10999 | verbosity, proto_bitmap); |
| 11000 | |
| 11001 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11002 | #endif |
| 11003 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11004 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11005 | * hdd_wlan_startup() - HDD init function |
| 11006 | * @dev: Pointer to the underlying device |
| 11007 | * |
| 11008 | * This is the driver startup code executed once a WLAN device has been detected |
| 11009 | * |
| 11010 | * Return: 0 for success, < 0 for failure |
| 11011 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11012 | int hdd_wlan_startup(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11013 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11014 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11015 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11016 | int ret; |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11017 | bool rtnl_held; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11018 | mac_handle_t mac_handle; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11019 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11020 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11021 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11022 | hdd_ctx = hdd_context_create(dev); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11023 | |
| 11024 | if (IS_ERR(hdd_ctx)) |
| 11025 | return PTR_ERR(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11026 | |
Abhishek Singh | e9068f1 | 2017-03-31 14:14:52 +0530 | [diff] [blame] | 11027 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, |
| 11028 | DEFAULT_PSOC_ID); |
| 11029 | if (ret) { |
| 11030 | hdd_err("Psoc creation fails!"); |
| 11031 | QDF_BUG(0); |
| 11032 | goto err_hdd_free_context; |
| 11033 | } |
| 11034 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11035 | qdf_nbuf_init_replenish_timer(); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11036 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11037 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11038 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11039 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11040 | osif_request_manager_init(); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 11041 | qdf_atomic_init(&hdd_ctx->con_mode_flag); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11042 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11043 | hdd_driver_memdump_init(); |
| 11044 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11045 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11046 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11047 | hdd_err("Failed to start modules: %d", ret); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11048 | goto err_memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11049 | } |
| 11050 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11051 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11052 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11053 | mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11054 | hdd_ctx->mac_handle = mac_handle; |
| 11055 | if (!mac_handle) { |
| 11056 | hdd_err("Mac Handle is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11057 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11058 | } |
| 11059 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 11060 | ret = hdd_wiphy_init(hdd_ctx); |
| 11061 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11062 | hdd_err("Failed to initialize wiphy: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11063 | goto err_stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11064 | } |
| 11065 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11066 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11067 | |
Yuanyuan Liu | c98370e | 2016-10-13 11:22:13 -0700 | [diff] [blame] | 11068 | hdd_initialize_mac_address(hdd_ctx); |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11069 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11070 | ret = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11071 | if (ret) { |
| 11072 | hdd_err("register_netdevice_notifier failed: %d", ret); |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 11073 | goto err_wiphy_unregister; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11074 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11075 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11076 | ret = register_reboot_notifier(&system_reboot_notifier); |
| 11077 | if (ret) { |
| 11078 | hdd_err("Failed to register reboot notifier: %d", ret); |
| 11079 | goto err_unregister_netdev; |
| 11080 | } |
| 11081 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11082 | rtnl_held = hdd_hold_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11083 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11084 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 11085 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11086 | hdd_err("Failed to open interfaces: %d", ret); |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11087 | goto err_release_rtnl_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11088 | } |
| 11089 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 11090 | hdd_release_rtnl_lock(); |
| 11091 | rtnl_held = false; |
| 11092 | |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11093 | wlan_hdd_update_11n_mode(hdd_ctx->config); |
| 11094 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11095 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 11096 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 11097 | QDF_TIMER_TYPE_SW, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11098 | hdd_skip_acs_scan_timer_handler, |
| 11099 | (void *)hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11100 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11101 | hdd_err("Failed to init ACS Skip timer"); |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 11102 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11103 | #endif |
| 11104 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 11105 | hdd_bus_bandwidth_init(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11106 | |
Jeff Johnson | 9afc501 | 2016-09-23 13:56:27 -0700 | [diff] [blame] | 11107 | hdd_lpass_notify_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11108 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11109 | if (hdd_ctx->rps) |
| 11110 | hdd_set_rps_cpu_mask(hdd_ctx); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 11111 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11112 | ret = hdd_register_notifiers(hdd_ctx); |
| 11113 | if (ret) |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11114 | goto err_close_adapters; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11115 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11116 | status = wlansap_global_init(); |
| 11117 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11118 | hdd_unregister_notifiers(hdd_ctx); |
| 11119 | goto err_close_adapters; |
| 11120 | } |
| 11121 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11122 | if (hdd_ctx->config->fIsImpsEnabled) |
| 11123 | hdd_set_idle_ps_config(hdd_ctx, true); |
Kiran Kumar Lokere | b0f19c3 | 2017-10-13 12:23:26 -0700 | [diff] [blame] | 11124 | else |
| 11125 | hdd_set_idle_ps_config(hdd_ctx, false); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11126 | |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11127 | if (QDF_GLOBAL_FTM_MODE != hdd_get_conparam()) { |
Dustin Brown | 6f42792 | 2017-09-19 12:19:00 -0700 | [diff] [blame] | 11128 | qdf_sched_delayed_work(&hdd_ctx->iface_idle_work, |
| 11129 | hdd_ctx->config->iface_change_wait_time); |
Mukul Sharma | 07bd875 | 2017-10-10 16:58:14 +0530 | [diff] [blame] | 11130 | hdd_prevent_suspend_timeout( |
| 11131 | hdd_ctx->config->iface_change_wait_time, |
| 11132 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER); |
| 11133 | } |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 11134 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11135 | goto success; |
| 11136 | |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 11137 | err_close_adapters: |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11138 | hdd_close_all_adapters(hdd_ctx, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11139 | |
Jeff Johnson | 46bde38 | 2017-02-01 15:31:16 -0800 | [diff] [blame] | 11140 | err_release_rtnl_lock: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11141 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 11142 | if (rtnl_held) |
| 11143 | hdd_release_rtnl_lock(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11144 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11145 | err_unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11146 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 11147 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11148 | err_wiphy_unregister: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 11149 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11150 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11151 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11152 | err_stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 11153 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11154 | |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11155 | err_memdump_deinit: |
| 11156 | hdd_driver_memdump_deinit(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11157 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11158 | osif_request_manager_deinit(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 11159 | hdd_exit_netlink_services(hdd_ctx); |
| 11160 | |
Dustin Brown | 2091246 | 2017-06-07 13:48:25 -0700 | [diff] [blame] | 11161 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 11162 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11163 | err_hdd_free_context: |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 11164 | if (cds_is_fw_down()) |
| 11165 | hdd_err("Not setting the complete event as fw is down"); |
| 11166 | else |
| 11167 | hdd_start_complete(ret); |
| 11168 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11169 | qdf_nbuf_deinit_replenish_timer(); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 11170 | hdd_context_destroy(hdd_ctx); |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 11171 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11172 | |
| 11173 | success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11174 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11175 | return 0; |
| 11176 | } |
| 11177 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11178 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11179 | * hdd_wlan_update_target_info() - update target type info |
| 11180 | * @hdd_ctx: HDD context |
| 11181 | * @context: hif context |
| 11182 | * |
| 11183 | * Update target info received from firmware in hdd context |
| 11184 | * Return:None |
| 11185 | */ |
| 11186 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11187 | 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] | 11188 | { |
| 11189 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 11190 | |
| 11191 | if (!tgt_info) { |
| 11192 | hdd_err("Target info is Null"); |
| 11193 | return; |
| 11194 | } |
| 11195 | |
| 11196 | hdd_ctx->target_type = tgt_info->target_type; |
| 11197 | } |
| 11198 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11199 | 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] | 11200 | { |
| 11201 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11202 | int status; |
| 11203 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11204 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11205 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11206 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11207 | |
| 11208 | if (!rsp) { |
| 11209 | hdd_err("data is null"); |
| 11210 | return; |
| 11211 | } |
| 11212 | |
| 11213 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11214 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11215 | return; |
| 11216 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11217 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 11218 | if (!request) { |
| 11219 | hdd_err("obselete request"); |
| 11220 | return; |
| 11221 | } |
| 11222 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11223 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
| 11224 | if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 11225 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11226 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11227 | return; |
| 11228 | } |
| 11229 | |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11230 | hdd_info("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 11231 | hdd_info("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 11232 | hdd_info("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 11233 | hdd_info("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 11234 | hdd_info("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 11235 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 11236 | hdd_info("rsp->dad_detected :%x", rsp->dad_detected); |
| 11237 | hdd_info("rsp->connect_status :%x", rsp->connect_status); |
| 11238 | hdd_info("rsp->ba_session_establishment_status :%x", |
| 11239 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11240 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11241 | 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] | 11242 | adapter->dad |= rsp->dad_detected; |
| 11243 | adapter->con_status = rsp->connect_status; |
| 11244 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 11245 | /* Flag true indicates connectivity check stats present. */ |
| 11246 | if (rsp->connect_stats_present) { |
| 11247 | hdd_info("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 11248 | hdd_info("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
| 11249 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 11250 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 11251 | rsp->icmpv4_rsp_recvd; |
| 11252 | } |
| 11253 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 11254 | osif_request_complete(request); |
| 11255 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11256 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11257 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 11258 | } |
| 11259 | |
| 11260 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11261 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11262 | * @hdd_ctx: HDD context |
| 11263 | * |
| 11264 | * Register the HDD callbacks to CDS/SME. |
| 11265 | * |
| 11266 | * Return: 0 for success or Error code for failure |
| 11267 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11268 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11269 | { |
| 11270 | QDF_STATUS status; |
| 11271 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11272 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11273 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11274 | hdd_enter(); |
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 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11277 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11278 | sme_register_oem_data_rsp_callback(mac_handle, |
| 11279 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11280 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11281 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 11282 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11283 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
| 11284 | sme_nan_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11285 | wlan_hdd_cfg80211_nan_callback); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11286 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11287 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11288 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11289 | sme_ext_scan_register_callback(mac_handle, |
| 11290 | wlan_hdd_cfg80211_extscan_callback); |
| 11291 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 11292 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11293 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11294 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 11295 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11296 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11297 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11298 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 11299 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11300 | 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] | 11301 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11302 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 11303 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
| 11304 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11305 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 11306 | hdd_lost_link_info_cb); |
| 11307 | /* print error and not block the startup process */ |
| 11308 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11309 | hdd_err("set lost link info callback failed"); |
| 11310 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11311 | ret = hdd_register_data_stall_detect_cb(); |
| 11312 | if (ret) { |
| 11313 | hdd_err("Register data stall detect detect callback failed."); |
| 11314 | return ret; |
| 11315 | } |
| 11316 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11317 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 11318 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11319 | sme_register_set_connection_info_cb(mac_handle, |
| 11320 | hdd_set_connection_in_progress, |
| 11321 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11322 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11323 | status = sme_congestion_register_callback(mac_handle, |
| 11324 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 11325 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11326 | hdd_err("set congestion callback failed"); |
| 11327 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11328 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 11329 | hdd_bt_activity_cb); |
| 11330 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11331 | hdd_err("set bt activity info callback failed"); |
| 11332 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11333 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 11334 | hdd_tx_queue_cb); |
| 11335 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11336 | hdd_err("Register tx queue callback failed"); |
| 11337 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11338 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11339 | |
| 11340 | return ret; |
| 11341 | } |
| 11342 | |
| 11343 | /** |
| 11344 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 11345 | * @hdd_ctx: HDD context |
| 11346 | * |
| 11347 | * De-Register the HDD callbacks to CDS/SME. |
| 11348 | * |
| 11349 | * Return: void |
| 11350 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11351 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11352 | { |
| 11353 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11354 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11355 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11356 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11357 | hdd_enter(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11358 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11359 | mac_handle = hdd_ctx->mac_handle; |
| 11360 | sme_deregister_tx_queue_cb(mac_handle); |
| 11361 | status = sme_deregister_for_dcc_stats_event(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11362 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11363 | hdd_err("De-register of dcc stats callback failed: %d", |
| 11364 | status); |
| 11365 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11366 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 11367 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11368 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11369 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11370 | wlan_hdd_cfg80211_stats_ext_callback); |
| 11371 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11372 | sme_nan_deregister_callback(mac_handle); |
| 11373 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11374 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11375 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 11376 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11377 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 11378 | ret = hdd_deregister_data_stall_detect_cb(); |
| 11379 | if (ret) |
| 11380 | hdd_err("Failed to de-register data stall detect event callback"); |
| 11381 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11382 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11383 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11384 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 11385 | } |
| 11386 | |
| 11387 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11388 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
| 11389 | * @adapter: Pointer to the HDD |
| 11390 | * @enable: bool value |
| 11391 | * |
| 11392 | * This to take counter measure to handle deauth req from HDD |
| 11393 | * |
| 11394 | * Return: None |
| 11395 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11396 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11397 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11398 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11399 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11400 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11401 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11403 | /* Ignore request to deauth bcmc station */ |
| 11404 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11405 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11406 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11407 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11408 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 11409 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11410 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11411 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11412 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11413 | } |
| 11414 | |
| 11415 | /** |
| 11416 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
| 11417 | * @adapter: Pointer to the HDD |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11418 | * @p_del_sta_params: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11419 | * |
| 11420 | * This to take counter measure to handle deauth req from HDD |
| 11421 | * |
| 11422 | * Return: None |
| 11423 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11424 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | e6bf719 | 2017-11-07 15:16:09 -0800 | [diff] [blame] | 11425 | struct csr_del_sta_params *pDelStaParams) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11426 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11427 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11428 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11429 | /* Ignore request to disassoc bcmc station */ |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11430 | if (pDelStaParams->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11431 | return; |
| 11432 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11433 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Deepthi Gowri | b3bfefd | 2016-09-13 15:14:34 +0530 | [diff] [blame] | 11434 | pDelStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11435 | } |
| 11436 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11437 | /** |
| 11438 | * hdd_issta_p2p_clientconnected() - check if sta or p2p client is connected |
| 11439 | * @hdd_ctx: HDD Context |
| 11440 | * |
| 11441 | * API to find if there is any STA or P2P-Client is connected |
| 11442 | * |
| 11443 | * Return: true if connected; false otherwise |
| 11444 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11445 | QDF_STATUS hdd_issta_p2p_clientconnected(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11446 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11447 | return sme_is_sta_p2p_client_connected(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11448 | } |
| 11449 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11450 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11451 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11452 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11453 | struct hdd_adapter *adapter = NULL; |
| 11454 | struct csr_roam_profile *roam_profile; |
| 11455 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11456 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11457 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11458 | hdd_debug("No active sta session"); |
| 11459 | return; |
| 11460 | } |
| 11461 | |
| 11462 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11463 | roam_profile = hdd_roam_profile(adapter); |
| 11464 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11465 | |
| 11466 | if (cur_adapter->session_id != adapter->session_id && |
| 11467 | adapter->device_mode == QDF_STA_MODE && |
| 11468 | hdd_conn_is_connected(sta_ctx)) { |
| 11469 | hdd_debug("%d Disable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11470 | sme_stop_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11471 | adapter->session_id, |
| 11472 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11473 | } |
| 11474 | } |
| 11475 | } |
| 11476 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11477 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11478 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11479 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 11480 | struct hdd_adapter *adapter = NULL; |
| 11481 | struct csr_roam_profile *roam_profile; |
| 11482 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11483 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11484 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->hdd_psoc)) { |
| 11485 | hdd_debug("No active sta session"); |
| 11486 | return; |
| 11487 | } |
| 11488 | |
| 11489 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11490 | roam_profile = hdd_roam_profile(adapter); |
| 11491 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11492 | |
| 11493 | if (cur_adapter->session_id != adapter->session_id && |
| 11494 | adapter->device_mode == QDF_STA_MODE && |
| 11495 | hdd_conn_is_connected(sta_ctx)) { |
| 11496 | hdd_debug("%d Enable roaming", adapter->session_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11497 | sme_start_roaming(hdd_ctx->mac_handle, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 11498 | adapter->session_id, |
| 11499 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11500 | } |
| 11501 | } |
| 11502 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11503 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11504 | /** |
| 11505 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 11506 | * @skb: sk buffer pointer |
| 11507 | * |
| 11508 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 11509 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 11510 | * |
| 11511 | * Return: None |
| 11512 | */ |
| 11513 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 11514 | { |
| 11515 | #ifdef CNSS_GENL |
| 11516 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 11517 | #else |
| 11518 | nl_srv_bcast(skb); |
| 11519 | #endif |
| 11520 | } |
| 11521 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11522 | 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] | 11523 | { |
| 11524 | struct sk_buff *skb; |
| 11525 | struct nlmsghdr *nlh; |
| 11526 | tAniMsgHdr *ani_hdr; |
| 11527 | void *nl_data = NULL; |
| 11528 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11529 | struct radio_index_tlv *radio_info; |
| 11530 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11531 | |
| 11532 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 11533 | flags = GFP_ATOMIC; |
| 11534 | |
| 11535 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 11536 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11537 | if (skb == NULL) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11538 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11539 | |
| 11540 | nlh = (struct nlmsghdr *)skb->data; |
| 11541 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 11542 | nlh->nlmsg_flags = 0; |
| 11543 | nlh->nlmsg_seq = 0; |
| 11544 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 11545 | |
| 11546 | ani_hdr = NLMSG_DATA(nlh); |
| 11547 | ani_hdr->type = type; |
| 11548 | |
| 11549 | switch (type) { |
| 11550 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 11551 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11552 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11553 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11554 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11555 | ani_hdr->length = 0; |
| 11556 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11557 | break; |
| 11558 | case WLAN_SVC_WLAN_STATUS_IND: |
| 11559 | case WLAN_SVC_WLAN_VERSION_IND: |
| 11560 | case WLAN_SVC_DFS_CAC_START_IND: |
| 11561 | case WLAN_SVC_DFS_CAC_END_IND: |
| 11562 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 11563 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 11564 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 11565 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 11566 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 11567 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11568 | ani_hdr->length = len; |
| 11569 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 11570 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 11571 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11572 | break; |
| 11573 | |
| 11574 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 11575 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11576 | type); |
| 11577 | kfree_skb(skb); |
| 11578 | return; |
| 11579 | } |
| 11580 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11581 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 11582 | * Add radio index at the end of the svc event in TLV format |
| 11583 | * to maintain the backward compatibility with userspace |
| 11584 | * applications. |
| 11585 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11586 | |
| 11587 | tlv_len = 0; |
| 11588 | |
| 11589 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 11590 | < WLAN_NL_MAX_PAYLOAD) { |
| 11591 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 11592 | sizeof(*ani_hdr) + len); |
| 11593 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 11594 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 11595 | radio_info->radio = radio; |
| 11596 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 11597 | hdd_debug("Added radio index tlv - radio index %d", |
| 11598 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11599 | } |
| 11600 | |
| 11601 | nlh->nlmsg_len += tlv_len; |
| 11602 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 11603 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 11604 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11605 | } |
| 11606 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11607 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 11608 | void wlan_hdd_auto_shutdown_cb(void) |
| 11609 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11610 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11611 | |
| 11612 | if (!hdd_ctx) |
| 11613 | return; |
| 11614 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11615 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11616 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 11617 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11618 | } |
| 11619 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11620 | 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] | 11621 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11622 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11623 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11624 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11625 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11626 | mac_handle = hdd_ctx->mac_handle; |
| 11627 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11628 | return; |
| 11629 | |
| 11630 | if (hdd_ctx->config->WlanAutoShutdown == 0) |
| 11631 | return; |
| 11632 | |
| 11633 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11634 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11635 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11636 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11637 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 11638 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 11639 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11640 | return; |
| 11641 | } |
| 11642 | |
| 11643 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11644 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->hdd_psoc)) { |
| 11645 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11646 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11647 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11648 | conn_info.connState == |
| 11649 | eConnectionState_Associated) { |
| 11650 | sta_connected = true; |
| 11651 | break; |
| 11652 | } |
| 11653 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11654 | |
| 11655 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11656 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11657 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11658 | ap_connected = true; |
| 11659 | break; |
| 11660 | } |
| 11661 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11662 | } |
| 11663 | } |
| 11664 | |
| 11665 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11666 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11667 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11668 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11669 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11670 | if (sme_set_auto_shutdown_timer(mac_handle, |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 11671 | hdd_ctx->config->WlanAutoShutdown) |
| 11672 | != QDF_STATUS_SUCCESS) |
| 11673 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 11674 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 11675 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
| 11676 | hdd_ctx->config->WlanAutoShutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11677 | } |
| 11678 | #endif |
| 11679 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11680 | struct hdd_adapter * |
| 11681 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 11682 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11683 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11684 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11685 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11686 | |
| 11687 | con_sap_adapter = NULL; |
| 11688 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11689 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11690 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 11691 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11692 | adapter != this_sap_adapter) { |
| 11693 | if (check_start_bss) { |
| 11694 | if (test_bit(SOFTAP_BSS_STARTED, |
| 11695 | &adapter->event_flags)) { |
| 11696 | con_sap_adapter = adapter; |
| 11697 | break; |
| 11698 | } |
| 11699 | } else { |
| 11700 | con_sap_adapter = adapter; |
| 11701 | break; |
| 11702 | } |
| 11703 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11704 | } |
| 11705 | |
| 11706 | return con_sap_adapter; |
| 11707 | } |
| 11708 | |
| 11709 | #ifdef MSM_PLATFORM |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11710 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11711 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11712 | return adapter->device_mode == QDF_STA_MODE || |
| 11713 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11714 | } |
| 11715 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11716 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11717 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11718 | return adapter->device_mode == QDF_SAP_MODE || |
| 11719 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 11720 | } |
| 11721 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11722 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11723 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11724 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11725 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11726 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 11727 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11728 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
| 11729 | conn_info.connState == eConnectionState_Associated) { |
| 11730 | return true; |
| 11731 | } |
| 11732 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11733 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 11734 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11735 | return true; |
| 11736 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11737 | } |
| 11738 | |
| 11739 | return false; |
| 11740 | } |
| 11741 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11742 | 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] | 11743 | { |
| 11744 | bool is_running; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11745 | |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11746 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11747 | is_running = hdd_ctx->bus_bw_timer_running; |
Poddar, Siddarth | 57f4d3f | 2017-01-27 12:58:37 +0530 | [diff] [blame] | 11748 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11749 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11750 | return is_running; |
| 11751 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11752 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11753 | 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] | 11754 | { |
| 11755 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11756 | hdd_ctx->bus_bw_timer_running = true; |
| 11757 | qdf_timer_start(&hdd_ctx->bus_bw_timer, |
| 11758 | hdd_ctx->config->busBandwidthComputeInterval); |
| 11759 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11760 | } |
| 11761 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11762 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11763 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11764 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11765 | |
| 11766 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11767 | hdd_debug("Bandwidth compute timer already started"); |
| 11768 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11769 | } |
| 11770 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11771 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11772 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11773 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11774 | } |
| 11775 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11776 | 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] | 11777 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11778 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11779 | |
| 11780 | if (hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11781 | hdd_debug("Bandwidth compute timer already started"); |
| 11782 | return; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 11783 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11784 | |
| 11785 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11786 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 11787 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11788 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11789 | } |
| 11790 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11791 | 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] | 11792 | { |
Sravan Kumar Kairam | 9e99e9a | 2018-03-12 19:09:45 +0530 | [diff] [blame] | 11793 | ucfg_ipa_set_perf_level(hdd_ctx->hdd_pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11794 | |
| 11795 | qdf_spinlock_acquire(&hdd_ctx->bus_bw_timer_lock); |
| 11796 | qdf_timer_stop(&hdd_ctx->bus_bw_timer); |
| 11797 | hdd_ctx->bus_bw_timer_running = false; |
| 11798 | qdf_spinlock_release(&hdd_ctx->bus_bw_timer_lock); |
| 11799 | |
| 11800 | hdd_reset_tcp_delack(hdd_ctx); |
| 11801 | } |
| 11802 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11803 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11804 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11805 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11806 | |
| 11807 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11808 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11809 | return; |
| 11810 | } |
| 11811 | |
| 11812 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11813 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11814 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11815 | } |
| 11816 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11817 | 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] | 11818 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11819 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 11820 | |
| 11821 | if (!hdd_bus_bw_compute_timer_is_running(hdd_ctx)) { |
| 11822 | hdd_debug("Bandwidth compute timer already stopped"); |
| 11823 | return; |
| 11824 | } |
| 11825 | |
| 11826 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 11827 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 11828 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11829 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11830 | } |
| 11831 | #endif |
| 11832 | |
| 11833 | /** |
| 11834 | * wlan_hdd_check_custom_con_channel_rules() - This function checks the sap's |
| 11835 | * and sta's operating channel. |
| 11836 | * @sta_adapter: Describe the first argument to foobar. |
| 11837 | * @ap_adapter: Describe the second argument to foobar. |
| 11838 | * @roam_profile: Roam profile of AP to which STA wants to connect. |
| 11839 | * @concurrent_chnl_same: If both SAP and STA channels are same then |
| 11840 | * set this flag to true else false. |
| 11841 | * |
| 11842 | * This function checks the sap's operating channel and sta's operating channel. |
| 11843 | * if both are same then it will return false else it will restart the sap in |
| 11844 | * sta's channel and return true. |
| 11845 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11846 | * Return: QDF_STATUS_SUCCESS or QDF_STATUS_E_FAILURE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11847 | */ |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11848 | QDF_STATUS |
| 11849 | wlan_hdd_check_custom_con_channel_rules(struct hdd_adapter *sta_adapter, |
| 11850 | struct hdd_adapter *ap_adapter, |
Jeff Johnson | 61b5e98 | 2018-03-15 11:33:31 -0700 | [diff] [blame] | 11851 | struct csr_roam_profile *roam_profile, |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 11852 | tScanResultHandle *scan_cache, |
| 11853 | bool *concurrent_chnl_same) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11854 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11855 | struct hdd_ap_ctx *hdd_ap_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11856 | uint8_t channel_id; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11857 | QDF_STATUS status; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 11858 | enum QDF_OPMODE device_mode = ap_adapter->device_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11859 | *concurrent_chnl_same = true; |
| 11860 | |
| 11861 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11862 | status = |
Archana Ramachandran | 2eb7a61 | 2017-03-23 22:58:42 -0700 | [diff] [blame] | 11863 | sme_get_ap_channel_from_scan_cache(roam_profile, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11864 | scan_cache, |
| 11865 | &channel_id); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 11866 | if (QDF_STATUS_SUCCESS == status) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11867 | if ((QDF_SAP_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11868 | (channel_id < SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11869 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11870 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11871 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11872 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11873 | } else if ((QDF_P2P_GO_MODE == device_mode) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11874 | (channel_id >= SIR_11A_CHANNEL_BEGIN)) { |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 11875 | if (hdd_ap_ctx->operating_channel != channel_id) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11876 | *concurrent_chnl_same = false; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11877 | hdd_debug("channels are different"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11878 | } |
| 11879 | } |
| 11880 | } else { |
| 11881 | /* |
| 11882 | * Lets handle worst case scenario here, Scan cache lookup is |
| 11883 | * failed so we have to stop the SAP to avoid any channel |
| 11884 | * discrepancy between SAP's channel and STA's channel. |
| 11885 | * Return the status as failure so caller function could know |
| 11886 | * that scan look up is failed. |
| 11887 | */ |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11888 | hdd_err("Finding AP from scan cache failed"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11889 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11890 | } |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11891 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11892 | } |
| 11893 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11894 | /** |
| 11895 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 11896 | * @ap_adapter: SAP adapter |
| 11897 | * |
| 11898 | * This function will process the stopping of sap adapter. |
| 11899 | * |
| 11900 | * Return: None |
| 11901 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11902 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11903 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11904 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11905 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11906 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11907 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11908 | |
| 11909 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11910 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11911 | return; |
| 11912 | } |
| 11913 | |
| 11914 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11915 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11916 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11917 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 11918 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11919 | mutex_lock(&hdd_ctx->sap_lock); |
| 11920 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 11921 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11922 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11923 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 11924 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11925 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11926 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11927 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11928 | qdf_stop_bss_event, |
| 11929 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11930 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11931 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11932 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11933 | return; |
| 11934 | } |
| 11935 | } |
| 11936 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 11937 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
| 11938 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 11939 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 11940 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 11941 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11942 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11943 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11944 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11945 | } |
| 11946 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11947 | } |
| 11948 | |
| 11949 | /** |
| 11950 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 11951 | * @ap_adapter: SAP adapter |
| 11952 | * |
| 11953 | * This function will process the starting of sap adapter. |
| 11954 | * |
| 11955 | * Return: None |
| 11956 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11957 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11958 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 11959 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 11960 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11961 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11962 | struct hdd_context *hdd_ctx; |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 11963 | tsap_config_t *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11964 | |
| 11965 | if (NULL == ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11966 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11967 | return; |
| 11968 | } |
| 11969 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 11970 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 11971 | hdd_err("SoftAp role has not been enabled"); |
| 11972 | return; |
| 11973 | } |
| 11974 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11975 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 11976 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 11977 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 11978 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11979 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11980 | mutex_lock(&hdd_ctx->sap_lock); |
| 11981 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 11982 | goto end; |
| 11983 | |
| 11984 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 11985 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11986 | goto end; |
| 11987 | } |
| 11988 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 11989 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 11990 | 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] | 11991 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11992 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11993 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11994 | goto end; |
| 11995 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11996 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 11997 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 11998 | SME_CMD_TIMEOUT_VALUE); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 11999 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12000 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12001 | goto end; |
| 12002 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12003 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12004 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12005 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12006 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12007 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 12008 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 12009 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12010 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12011 | true); |
| 12012 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12013 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12014 | |
| 12015 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12016 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12017 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12018 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12019 | /* SAP context and beacon cleanup will happen during driver unload |
| 12020 | * in hdd_stop_adapter |
| 12021 | */ |
| 12022 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12023 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12024 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12025 | |
| 12026 | /** |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12027 | * wlan_hdd_soc_set_antenna_mode_cb() - Callback for set dual |
| 12028 | * mac scan config |
| 12029 | * @status: Status of set antenna mode |
| 12030 | * |
| 12031 | * Callback on setting the dual mac configuration |
| 12032 | * |
| 12033 | * Return: None |
| 12034 | */ |
| 12035 | void wlan_hdd_soc_set_antenna_mode_cb( |
| 12036 | enum set_antenna_mode_status status) |
| 12037 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12038 | struct hdd_context *hdd_ctx; |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12039 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12040 | hdd_debug("Status: %d", status); |
Archana Ramachandran | a20ef81 | 2015-11-13 16:12:13 -0800 | [diff] [blame] | 12041 | |
| 12042 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12043 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
| 12044 | return; |
| 12045 | |
| 12046 | /* Signal the completion of set dual mac config */ |
| 12047 | complete(&hdd_ctx->set_antenna_mode_cmpl); |
| 12048 | } |
| 12049 | |
| 12050 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12051 | * hdd_get_fw_version() - Get FW version |
| 12052 | * @hdd_ctx: pointer to HDD context. |
| 12053 | * @major_spid: FW version - major spid. |
| 12054 | * @minor_spid: FW version - minor spid |
| 12055 | * @ssid: FW version - ssid |
| 12056 | * @crmid: FW version - crmid |
| 12057 | * |
| 12058 | * This function is called to get the firmware build version stored |
| 12059 | * as part of the HDD context |
| 12060 | * |
| 12061 | * Return: None |
| 12062 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12063 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12064 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12065 | uint32_t *siid, uint32_t *crmid) |
| 12066 | { |
| 12067 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12068 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12069 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12070 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12071 | } |
| 12072 | |
| 12073 | #ifdef QCA_CONFIG_SMP |
| 12074 | /** |
| 12075 | * wlan_hdd_get_cpu() - get cpu_index |
| 12076 | * |
| 12077 | * Return: cpu_index |
| 12078 | */ |
| 12079 | int wlan_hdd_get_cpu(void) |
| 12080 | { |
| 12081 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12082 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12083 | put_cpu(); |
| 12084 | return cpu_index; |
| 12085 | } |
| 12086 | #endif |
| 12087 | |
| 12088 | /** |
| 12089 | * hdd_get_fwpath() - get framework path |
| 12090 | * |
| 12091 | * This function is used to get the string written by |
| 12092 | * userspace to start the wlan driver |
| 12093 | * |
| 12094 | * Return: string |
| 12095 | */ |
| 12096 | const char *hdd_get_fwpath(void) |
| 12097 | { |
| 12098 | return fwpath.string; |
| 12099 | } |
| 12100 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12101 | static int hdd_qdf_print_init(void) |
| 12102 | { |
| 12103 | int qdf_print_idx; |
| 12104 | QDF_STATUS status; |
| 12105 | |
| 12106 | status = qdf_print_setup(); |
| 12107 | if (status != QDF_STATUS_SUCCESS) { |
| 12108 | pr_err("qdf_print_setup failed\n"); |
| 12109 | return -EINVAL; |
| 12110 | } |
| 12111 | |
| 12112 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 12113 | |
| 12114 | if (qdf_print_idx < 0) { |
| 12115 | pr_err("qdf_print_ctrl_register failed, ret = %d\n", |
| 12116 | qdf_print_idx); |
| 12117 | return -EINVAL; |
| 12118 | } |
| 12119 | |
| 12120 | qdf_set_pidx(qdf_print_idx); |
| 12121 | |
| 12122 | return 0; |
| 12123 | } |
| 12124 | |
| 12125 | static void hdd_qdf_print_deinit(void) |
| 12126 | { |
| 12127 | int qdf_print_idx; |
| 12128 | |
| 12129 | qdf_print_idx = qdf_get_pidx(); |
| 12130 | qdf_print_ctrl_cleanup(qdf_print_idx); |
| 12131 | } |
| 12132 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12133 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12134 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12135 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12136 | * This function initilizes CDS global context with the help of cds_init. This |
| 12137 | * has to be the first function called after probe to get a valid global |
| 12138 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12139 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12140 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12141 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12142 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12143 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12144 | QDF_STATUS status; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12145 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12146 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12147 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12148 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12149 | hdd_err("Failed to allocate CDS context"); |
| 12150 | ret = -ENOMEM; |
| 12151 | goto err_out; |
| 12152 | } |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12153 | |
| 12154 | wlan_init_bug_report_lock(); |
| 12155 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12156 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12157 | wlan_logging_sock_init_svc(); |
| 12158 | #endif |
| 12159 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12160 | qdf_timer_init(NULL, &hdd_drv_ops_inactivity_timer, |
| 12161 | (void *)hdd_drv_ops_inactivity_handler, NULL, |
| 12162 | QDF_TIMER_TYPE_SW); |
| 12163 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12164 | hdd_trace_init(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 12165 | hdd_qdf_print_init(); |
| 12166 | |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12167 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame^] | 12168 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12169 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12170 | err_out: |
| 12171 | return ret; |
| 12172 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12173 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12174 | /** |
| 12175 | * hdd_deinit() - Deinitialize Driver |
| 12176 | * |
| 12177 | * This function frees CDS global context with the help of cds_deinit. This |
| 12178 | * has to be the last function call in remove callback to free the global |
| 12179 | * context. |
| 12180 | */ |
| 12181 | void hdd_deinit(void) |
| 12182 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame^] | 12183 | wlan_roam_debug_deinit(); |
| 12184 | hdd_qdf_print_deinit(); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 12185 | qdf_timer_free(&hdd_drv_ops_inactivity_timer); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12186 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12187 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12188 | wlan_logging_sock_deinit_svc(); |
| 12189 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame^] | 12190 | |
| 12191 | wlan_destroy_bug_report_lock(); |
| 12192 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12193 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12194 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12195 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12196 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12197 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12198 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12199 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12200 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12201 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12202 | struct file *file) |
| 12203 | { |
| 12204 | return 0; |
| 12205 | } |
| 12206 | |
| 12207 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12208 | const char __user *user_buf, |
| 12209 | size_t count, |
| 12210 | loff_t *f_pos) |
| 12211 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12212 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12213 | static const char wlan_off_str[] = "OFF"; |
| 12214 | static const char wlan_on_str[] = "ON"; |
| 12215 | int ret; |
| 12216 | unsigned long rc; |
| 12217 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12218 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12219 | pr_err("Failed to read buffer\n"); |
| 12220 | return -EINVAL; |
| 12221 | } |
| 12222 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12223 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12224 | pr_debug("Wifi turning off from UI\n"); |
| 12225 | goto exit; |
| 12226 | } |
| 12227 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12228 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) { |
| 12229 | pr_info("Wifi Turning On from UI\n"); |
| 12230 | } |
| 12231 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 12232 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12233 | pr_err("Invalid value received from framework"); |
| 12234 | goto exit; |
| 12235 | } |
| 12236 | |
| 12237 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 12238 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12239 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 12240 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 12241 | if (!rc) { |
| 12242 | hdd_alert("Timed-out waiting in wlan_hdd_state_ctrl_param_write"); |
| 12243 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12244 | return ret; |
| 12245 | } |
| 12246 | |
| 12247 | hdd_start_complete(0); |
| 12248 | } |
| 12249 | |
| 12250 | exit: |
| 12251 | return count; |
| 12252 | } |
| 12253 | |
| 12254 | |
| 12255 | const struct file_operations wlan_hdd_state_fops = { |
| 12256 | .owner = THIS_MODULE, |
| 12257 | .open = wlan_hdd_state_ctrl_param_open, |
| 12258 | .write = wlan_hdd_state_ctrl_param_write, |
| 12259 | }; |
| 12260 | |
| 12261 | static int wlan_hdd_state_ctrl_param_create(void) |
| 12262 | { |
| 12263 | unsigned int wlan_hdd_state_major = 0; |
| 12264 | int ret; |
| 12265 | struct device *dev; |
| 12266 | |
| 12267 | device = MKDEV(wlan_hdd_state_major, 0); |
| 12268 | |
| 12269 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 12270 | if (ret) { |
| 12271 | pr_err("Failed to register qcwlanstate"); |
| 12272 | goto dev_alloc_err; |
| 12273 | } |
| 12274 | wlan_hdd_state_major = MAJOR(device); |
| 12275 | |
| 12276 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 12277 | if (IS_ERR(class)) { |
| 12278 | pr_err("wlan_hdd_state class_create error"); |
| 12279 | goto class_err; |
| 12280 | } |
| 12281 | |
| 12282 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 12283 | if (IS_ERR(dev)) { |
| 12284 | pr_err("wlan_hdd_statedevice_create error"); |
| 12285 | goto err_class_destroy; |
| 12286 | } |
| 12287 | |
| 12288 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 12289 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 12290 | if (ret) { |
| 12291 | pr_err("Failed to add cdev error"); |
| 12292 | goto cdev_add_err; |
| 12293 | } |
| 12294 | |
| 12295 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 12296 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 12297 | |
| 12298 | return 0; |
| 12299 | |
| 12300 | cdev_add_err: |
| 12301 | device_destroy(class, device); |
| 12302 | err_class_destroy: |
| 12303 | class_destroy(class); |
| 12304 | class_err: |
| 12305 | unregister_chrdev_region(device, dev_num); |
| 12306 | dev_alloc_err: |
| 12307 | return -ENODEV; |
| 12308 | } |
| 12309 | |
| 12310 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 12311 | { |
| 12312 | cdev_del(&wlan_hdd_state_cdev); |
| 12313 | device_destroy(class, device); |
| 12314 | class_destroy(class); |
| 12315 | unregister_chrdev_region(device, dev_num); |
| 12316 | |
| 12317 | pr_info("Device node unregistered"); |
| 12318 | } |
| 12319 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12320 | /** |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12321 | * component_init - API to init cld component's |
| 12322 | * |
| 12323 | * Return: None |
| 12324 | */ |
| 12325 | static void component_init(void) |
| 12326 | { |
| 12327 | pmo_init(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12328 | disa_init(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12329 | ucfg_ocb_init(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12330 | ipa_init(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12331 | } |
| 12332 | |
| 12333 | /** |
| 12334 | * component_deinit - API to deinit cld component's |
| 12335 | * |
| 12336 | * Return: None |
| 12337 | */ |
| 12338 | static void component_deinit(void) |
| 12339 | { |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 12340 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12341 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12342 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12343 | disa_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12344 | } |
| 12345 | |
| 12346 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 12347 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12348 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12349 | disa_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12350 | } |
| 12351 | |
| 12352 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 12353 | { |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 12354 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 12355 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12356 | } |
| 12357 | |
| 12358 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12359 | * __hdd_module_init - Module init helper |
| 12360 | * |
| 12361 | * Module init helper function used by both module and static driver. |
| 12362 | * |
| 12363 | * Return: 0 for success, errno on failure |
| 12364 | */ |
| 12365 | static int __hdd_module_init(void) |
| 12366 | { |
| 12367 | int ret = 0; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12368 | |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12369 | pr_err("%s: Loading driver v%s (%s)\n", |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12370 | WLAN_MODULE_NAME, |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 12371 | g_wlan_driver_version, |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 12372 | TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12373 | |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12374 | pld_init(); |
| 12375 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12376 | ret = hdd_init(); |
| 12377 | if (ret) { |
| 12378 | pr_err("hdd_init failed %x\n", ret); |
| 12379 | goto err_hdd_init; |
| 12380 | } |
| 12381 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12382 | dispatcher_init(); |
| 12383 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12384 | /* Ensure to call post objmgr init */ |
| 12385 | component_init(); |
| 12386 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12387 | qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12388 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12389 | hdd_set_conparam((uint32_t) con_mode); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12390 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12391 | ret = wlan_hdd_register_driver(); |
| 12392 | if (ret) { |
Mohit Khanna | fa99aea | 2016-05-12 21:43:13 -0700 | [diff] [blame] | 12393 | pr_err("%s: driver load failure, err %d\n", WLAN_MODULE_NAME, |
| 12394 | ret); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12395 | goto out; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12396 | } |
| 12397 | |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 12398 | ret = wlan_hdd_state_ctrl_param_create(); |
| 12399 | if (ret) { |
| 12400 | pr_err("wlan_hdd_state_create:%x\n", ret); |
| 12401 | goto out; |
| 12402 | } |
| 12403 | |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12404 | pr_info("%s: driver loaded\n", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12405 | |
| 12406 | return 0; |
| 12407 | out: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12408 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Liangwei Dong | 9fcc721 | 2017-10-24 13:43:52 +0800 | [diff] [blame] | 12409 | component_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12410 | dispatcher_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12411 | hdd_deinit(); |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12412 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12413 | err_hdd_init: |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12414 | pld_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12415 | return ret; |
| 12416 | } |
| 12417 | |
| 12418 | /** |
| 12419 | * __hdd_module_exit - Module exit helper |
| 12420 | * |
| 12421 | * Module exit helper function used by both module and static driver. |
| 12422 | */ |
| 12423 | static void __hdd_module_exit(void) |
| 12424 | { |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12425 | 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] | 12426 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12427 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 12428 | QWLAN_VERSIONSTR); |
| 12429 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12430 | if (!hdd_wait_for_recovery_completion()) |
| 12431 | return; |
Arunk Khandavalli | 07ec8f6 | 2016-09-27 21:51:01 +0530 | [diff] [blame] | 12432 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 12433 | cds_set_driver_loaded(false); |
| 12434 | cds_set_unload_in_progress(true); |
| 12435 | |
| 12436 | if (!cds_wait_for_external_threads_completion(__func__)) |
| 12437 | hdd_warn("External threads are still active attempting " |
| 12438 | "driver unload anyway"); |
| 12439 | |
Rajeev Kumar | 3505ae5 | 2018-05-10 18:44:45 -0700 | [diff] [blame] | 12440 | if (hdd_ctx) |
| 12441 | qdf_cancel_delayed_work(&hdd_ctx->iface_idle_work); |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 12442 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12443 | wlan_hdd_unregister_driver(); |
| 12444 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 12445 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12446 | |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 12447 | /* Ensure to call prior to objmgr deinit */ |
| 12448 | component_deinit(); |
| 12449 | |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 12450 | dispatcher_deinit(); |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 12451 | |
| 12452 | hdd_sysfs_destroy_version_interface(); |
| 12453 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12454 | hdd_deinit(); |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 12455 | pld_deinit(); |
| 12456 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12457 | wlan_hdd_state_ctrl_param_destroy(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12458 | } |
| 12459 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12460 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12461 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12462 | * wlan_boot_cb() - Wlan boot callback |
| 12463 | * @kobj: object whose directory we're creating the link in. |
| 12464 | * @attr: attribute the user is interacting with |
| 12465 | * @buff: the buffer containing the user data |
| 12466 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12467 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12468 | * This callback is invoked when the fs is ready to start the |
| 12469 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12470 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12471 | * 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] | 12472 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12473 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12474 | struct kobj_attribute *attr, |
| 12475 | const char *buf, |
| 12476 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12477 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12478 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12479 | if (wlan_loader->loaded_state) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12480 | pr_err("%s: wlan driver already initialized\n", __func__); |
| 12481 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12482 | } |
| 12483 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12484 | if (__hdd_module_init()) { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12485 | pr_err("%s: wlan driver initialization failed\n", __func__); |
| 12486 | return -EIO; |
| 12487 | } |
| 12488 | |
| 12489 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12490 | |
| 12491 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12492 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12493 | |
| 12494 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12495 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 12496 | * |
| 12497 | * Return: None |
| 12498 | * |
| 12499 | */ |
| 12500 | static void hdd_sysfs_cleanup(void) |
| 12501 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12502 | /* remove from group */ |
| 12503 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 12504 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 12505 | wlan_loader->attr_group); |
| 12506 | |
| 12507 | /* unlink the object from parent */ |
| 12508 | kobject_del(wlan_loader->boot_wlan_obj); |
| 12509 | |
| 12510 | /* free the object */ |
| 12511 | kobject_put(wlan_loader->boot_wlan_obj); |
| 12512 | |
| 12513 | kfree(wlan_loader->attr_group); |
| 12514 | kfree(wlan_loader); |
| 12515 | |
| 12516 | wlan_loader = NULL; |
| 12517 | } |
| 12518 | |
| 12519 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12520 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 12521 | * ready |
| 12522 | * |
| 12523 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 12524 | * when the filesystem is ready. |
| 12525 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12526 | * QDF API cannot be used here since this function is called even before |
| 12527 | * initializing WLAN driver. |
| 12528 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12529 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12530 | */ |
| 12531 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12532 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12533 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12534 | |
| 12535 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12536 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12537 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12538 | |
| 12539 | wlan_loader->boot_wlan_obj = NULL; |
| 12540 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 12541 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12542 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12543 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12544 | |
| 12545 | wlan_loader->loaded_state = 0; |
| 12546 | wlan_loader->attr_group->attrs = attrs; |
| 12547 | |
| 12548 | wlan_loader->boot_wlan_obj = kobject_create_and_add("boot_wlan", |
| 12549 | kernel_kobj); |
| 12550 | if (!wlan_loader->boot_wlan_obj) { |
| 12551 | pr_err("%s: sysfs create and add failed\n", __func__); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12552 | goto error_return; |
| 12553 | } |
| 12554 | |
| 12555 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 12556 | wlan_loader->attr_group); |
| 12557 | if (ret) { |
| 12558 | pr_err("%s: sysfs create group failed %d\n", __func__, ret); |
| 12559 | goto error_return; |
| 12560 | } |
| 12561 | |
| 12562 | return 0; |
| 12563 | |
| 12564 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12565 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12566 | |
| 12567 | return ret; |
| 12568 | } |
| 12569 | |
| 12570 | /** |
| 12571 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 12572 | * |
| 12573 | * Return: 0 on success or errno on failure |
| 12574 | */ |
| 12575 | static int wlan_deinit_sysfs(void) |
| 12576 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12577 | if (!wlan_loader) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12578 | hdd_err("wlan loader context is Null!"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12579 | return -EINVAL; |
| 12580 | } |
| 12581 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12582 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12583 | return 0; |
| 12584 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12585 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 12586 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12587 | |
| 12588 | #ifdef MODULE |
| 12589 | /** |
| 12590 | * __hdd_module_init - Module init helper |
| 12591 | * |
| 12592 | * Module init helper function used by both module and static driver. |
| 12593 | * |
| 12594 | * Return: 0 for success, errno on failure |
| 12595 | */ |
| 12596 | static int hdd_module_init(void) |
| 12597 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12598 | if (__hdd_module_init()) { |
| 12599 | pr_err("%s: Failed to register handler\n", __func__); |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12600 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12601 | } |
| 12602 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 12603 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12604 | } |
| 12605 | #else |
| 12606 | static int __init hdd_module_init(void) |
| 12607 | { |
| 12608 | int ret = -EINVAL; |
| 12609 | |
| 12610 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 12611 | if (ret) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12612 | pr_err("Failed to create sysfs entry for loading wlan"); |
| 12613 | |
| 12614 | return ret; |
| 12615 | } |
| 12616 | #endif |
| 12617 | |
| 12618 | |
| 12619 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12620 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12621 | * hdd_module_exit() - Exit function |
| 12622 | * |
| 12623 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 12624 | * |
| 12625 | * Return: None |
| 12626 | */ |
| 12627 | static void __exit hdd_module_exit(void) |
| 12628 | { |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12629 | __hdd_module_exit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12630 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12631 | #else |
| 12632 | static void __exit hdd_module_exit(void) |
| 12633 | { |
| 12634 | __hdd_module_exit(); |
| 12635 | wlan_deinit_sysfs(); |
| 12636 | } |
| 12637 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12638 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12639 | static int fwpath_changed_handler(const char *kmessage, |
| 12640 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12641 | { |
| 12642 | return param_set_copystring(kmessage, kp); |
| 12643 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12644 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12645 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 12646 | static bool is_monitor_mode_supported(void) |
| 12647 | { |
| 12648 | return true; |
| 12649 | } |
| 12650 | #else |
| 12651 | static bool is_monitor_mode_supported(void) |
| 12652 | { |
| 12653 | pr_err("Monitor mode not supported!"); |
| 12654 | return false; |
| 12655 | } |
| 12656 | #endif |
| 12657 | |
| 12658 | #ifdef WLAN_FEATURE_EPPING |
| 12659 | static bool is_epping_mode_supported(void) |
| 12660 | { |
| 12661 | return true; |
| 12662 | } |
| 12663 | #else |
| 12664 | static bool is_epping_mode_supported(void) |
| 12665 | { |
| 12666 | pr_err("Epping mode not supported!"); |
| 12667 | return false; |
| 12668 | } |
| 12669 | #endif |
| 12670 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12671 | /** |
| 12672 | * is_con_mode_valid() check con mode is valid or not |
| 12673 | * @mode: global con mode |
| 12674 | * |
| 12675 | * Return: TRUE on success FALSE on failure |
| 12676 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12677 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12678 | { |
| 12679 | switch (mode) { |
| 12680 | case QDF_GLOBAL_MONITOR_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12681 | return is_monitor_mode_supported(); |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12682 | case QDF_GLOBAL_EPPING_MODE: |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12683 | return is_epping_mode_supported(); |
| 12684 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12685 | case QDF_GLOBAL_MISSION_MODE: |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12686 | return true; |
| 12687 | default: |
| 12688 | return false; |
| 12689 | } |
| 12690 | } |
| 12691 | |
| 12692 | /** |
| 12693 | * hdd_get_adpter_mode() - returns adapter mode based on global con mode |
| 12694 | * @mode: global con mode |
| 12695 | * |
| 12696 | * Return: adapter mode |
| 12697 | */ |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12698 | static enum QDF_OPMODE hdd_get_adpter_mode( |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12699 | enum QDF_GLOBAL_MODE mode) |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12700 | { |
| 12701 | |
| 12702 | switch (mode) { |
| 12703 | case QDF_GLOBAL_MISSION_MODE: |
| 12704 | return QDF_STA_MODE; |
| 12705 | case QDF_GLOBAL_MONITOR_MODE: |
| 12706 | return QDF_MONITOR_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12707 | case QDF_GLOBAL_EPPING_MODE: |
| 12708 | return QDF_EPPING_MODE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12709 | case QDF_GLOBAL_FTM_MODE: |
| 12710 | return QDF_FTM_MODE; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12711 | case QDF_GLOBAL_QVIT_MODE: |
| 12712 | return QDF_QVIT_MODE; |
| 12713 | default: |
| 12714 | return QDF_MAX_NO_OF_MODE; |
| 12715 | } |
| 12716 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12717 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12718 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12719 | enum QDF_GLOBAL_MODE curr_mode) |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12720 | { |
| 12721 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 12722 | return; |
| 12723 | |
| 12724 | switch (curr_mode) { |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12725 | case QDF_GLOBAL_MONITOR_MODE: |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12726 | hdd_info("Release wakelock for monitor mode!"); |
| 12727 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 12728 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
Dundi Raviteja | 0a2a65b | 2018-04-30 12:34:11 +0530 | [diff] [blame] | 12729 | /* fallthrough */ |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12730 | case QDF_GLOBAL_MISSION_MODE: |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12731 | case QDF_GLOBAL_FTM_MODE: |
| 12732 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Sourav Mohapatra | 001cfaf | 2018-02-28 11:30:46 +0530 | [diff] [blame] | 12733 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->hdd_pdev, NULL); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 12734 | hdd_stop_all_adapters(hdd_ctx); |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12735 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12736 | break; |
| 12737 | default: |
| 12738 | break; |
| 12739 | } |
| 12740 | } |
| 12741 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12742 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12743 | enum QDF_GLOBAL_MODE curr_mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12744 | { |
Ashish Kumar Dhanotiya | 0024313 | 2017-01-24 16:37:34 +0530 | [diff] [blame] | 12745 | int driver_status; |
| 12746 | |
| 12747 | driver_status = hdd_ctx->driver_status; |
| 12748 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12749 | switch (curr_mode) { |
| 12750 | case QDF_GLOBAL_MISSION_MODE: |
| 12751 | case QDF_GLOBAL_MONITOR_MODE: |
| 12752 | case QDF_GLOBAL_FTM_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12753 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 12754 | hdd_close_all_adapters(hdd_ctx, false); |
| 12755 | break; |
| 12756 | case QDF_GLOBAL_EPPING_MODE: |
| 12757 | epping_disable(); |
| 12758 | epping_close(); |
| 12759 | break; |
| 12760 | default: |
| 12761 | return; |
| 12762 | } |
| 12763 | } |
| 12764 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12765 | static int hdd_register_req_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12766 | enum QDF_GLOBAL_MODE mode) |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12767 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12768 | struct hdd_adapter *adapter; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12769 | int ret = 0; |
| 12770 | bool rtnl_held; |
| 12771 | qdf_device_t qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 12772 | QDF_STATUS status; |
| 12773 | |
| 12774 | if (!qdf_dev) { |
| 12775 | hdd_err("qdf device context is Null return!"); |
| 12776 | return -EINVAL; |
| 12777 | } |
| 12778 | |
| 12779 | rtnl_held = hdd_hold_rtnl_lock(); |
| 12780 | switch (mode) { |
| 12781 | case QDF_GLOBAL_MISSION_MODE: |
Jeff Johnson | 957bc27 | 2017-02-02 08:54:48 -0800 | [diff] [blame] | 12782 | ret = hdd_open_interfaces(hdd_ctx, rtnl_held); |
| 12783 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12784 | hdd_err("Failed to open interfaces: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12785 | break; |
| 12786 | case QDF_GLOBAL_FTM_MODE: |
| 12787 | adapter = hdd_open_adapter(hdd_ctx, QDF_FTM_MODE, "wlan%d", |
| 12788 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12789 | NET_NAME_UNKNOWN, rtnl_held); |
| 12790 | if (adapter == NULL) |
| 12791 | ret = -EINVAL; |
| 12792 | break; |
| 12793 | case QDF_GLOBAL_MONITOR_MODE: |
| 12794 | adapter = hdd_open_adapter(hdd_ctx, QDF_MONITOR_MODE, "wlan%d", |
| 12795 | wlan_hdd_get_intf_addr(hdd_ctx), |
| 12796 | NET_NAME_UNKNOWN, rtnl_held); |
| 12797 | if (adapter == NULL) |
| 12798 | ret = -EINVAL; |
| 12799 | break; |
| 12800 | case QDF_GLOBAL_EPPING_MODE: |
| 12801 | status = epping_open(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12802 | if (status != QDF_STATUS_SUCCESS) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12803 | hdd_err("Failed to open in eeping mode: %d", status); |
| 12804 | ret = -EINVAL; |
| 12805 | break; |
| 12806 | } |
| 12807 | ret = epping_enable(qdf_dev->dev); |
| 12808 | if (ret) { |
| 12809 | hdd_err("Failed to enable in epping mode : %d", ret); |
| 12810 | epping_close(); |
| 12811 | } |
| 12812 | break; |
| 12813 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12814 | hdd_err("Mode not supported"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12815 | ret = -ENOTSUPP; |
| 12816 | break; |
| 12817 | } |
| 12818 | hdd_release_rtnl_lock(); |
| 12819 | rtnl_held = false; |
| 12820 | return ret; |
| 12821 | } |
| 12822 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12823 | /** |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12824 | * __con_mode_handler() - Handles module param con_mode change |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12825 | * @kmessage: con mode name on which driver to be bring up |
| 12826 | * @kp: The associated kernel parameter |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12827 | * @hdd_ctx: Pointer to the global HDD context |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12828 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12829 | * This function is invoked when user updates con mode using sys entry, |
| 12830 | * to initialize and bring-up driver in that specific mode. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12831 | * |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12832 | * Return - 0 on success and failure code on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12833 | */ |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12834 | static int __con_mode_handler(const char *kmessage, |
| 12835 | const struct kernel_param *kp, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12836 | struct hdd_context *hdd_ctx) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12837 | { |
| 12838 | int ret; |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 12839 | enum QDF_GLOBAL_MODE curr_mode; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 12840 | enum QDF_OPMODE adapter_mode; |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12841 | int new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12842 | |
Dustin Brown | ab6029b | 2017-05-24 13:04:19 -0700 | [diff] [blame] | 12843 | hdd_info("con_mode handler: %s", kmessage); |
| 12844 | |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 12845 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12846 | if (ret) |
| 12847 | return ret; |
| 12848 | |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12849 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 1); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12850 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12851 | ret = kstrtoint(kmessage, 0, &new_con_mode); |
| 12852 | if (ret) { |
| 12853 | hdd_err("Failed to parse con_mode '%s'", kmessage); |
| 12854 | goto reset_flags; |
| 12855 | } |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12856 | mutex_lock(&hdd_init_deinit_lock); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12857 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12858 | if (!is_con_mode_valid(new_con_mode)) { |
| 12859 | hdd_err("invalid con_mode %d", new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12860 | ret = -EINVAL; |
| 12861 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12862 | } |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12863 | |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12864 | curr_mode = hdd_get_conparam(); |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12865 | if (curr_mode == new_con_mode) { |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12866 | hdd_err("curr mode: %d is same as user triggered mode %d", |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12867 | curr_mode, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12868 | ret = 0; |
| 12869 | goto reset_flags; |
Hanumanth Reddy Pothula | 7d51b1d | 2016-09-21 19:11:20 +0530 | [diff] [blame] | 12870 | } |
| 12871 | |
Dustin Brown | 27cd994 | 2017-09-27 16:11:44 -0700 | [diff] [blame] | 12872 | /* ensure adapters are stopped */ |
| 12873 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 12874 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12875 | ret = hdd_wlan_stop_modules(hdd_ctx, true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12876 | if (ret) { |
| 12877 | hdd_err("Stop wlan modules failed"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12878 | goto reset_flags; |
| 12879 | } |
| 12880 | |
Dustin Brown | dd4e50f | 2018-05-24 15:43:42 -0700 | [diff] [blame] | 12881 | /* Cleanup present mode before switching to new mode */ |
| 12882 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
Ashish Kumar Dhanotiya | cda5766 | 2017-08-14 14:45:25 +0530 | [diff] [blame] | 12883 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12884 | hdd_set_conparam(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12885 | |
| 12886 | /* Register for new con_mode & then kick_start modules again */ |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12887 | ret = hdd_register_req_mode(hdd_ctx, new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12888 | if (ret) { |
| 12889 | hdd_err("Failed to register for new mode"); |
| 12890 | goto reset_flags; |
| 12891 | } |
| 12892 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12893 | adapter_mode = hdd_get_adpter_mode(new_con_mode); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12894 | if (adapter_mode == QDF_MAX_NO_OF_MODE) { |
| 12895 | hdd_err("invalid adapter"); |
| 12896 | ret = -EINVAL; |
| 12897 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12898 | } |
| 12899 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12900 | ret = hdd_wlan_start_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12901 | if (ret) { |
| 12902 | hdd_err("Start wlan modules failed: %d", ret); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12903 | goto reset_flags; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12904 | } |
| 12905 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12906 | if (new_con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 12907 | struct hdd_adapter *adapter = |
| 12908 | hdd_get_adapter(hdd_ctx, adapter_mode); |
| 12909 | |
| 12910 | if (!adapter) { |
| 12911 | hdd_err("Failed to get adapter:%d", adapter_mode); |
| 12912 | goto reset_flags; |
| 12913 | } |
| 12914 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12915 | if (hdd_start_adapter(adapter)) { |
| 12916 | hdd_err("Failed to start %s adapter", kmessage); |
| 12917 | ret = -EINVAL; |
| 12918 | goto reset_flags; |
| 12919 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12920 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 12921 | hdd_info("Acquire wakelock for monitor mode!"); |
| 12922 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 12923 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 12924 | } |
| 12925 | |
Dustin Brown | 20024e3 | 2018-01-03 12:34:58 -0800 | [diff] [blame] | 12926 | /* con_mode is a global module parameter */ |
| 12927 | con_mode = new_con_mode; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12928 | hdd_info("Mode successfully changed to %s", kmessage); |
| 12929 | ret = 0; |
| 12930 | |
| 12931 | reset_flags: |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12932 | mutex_unlock(&hdd_init_deinit_lock); |
Sourav Mohapatra | 421d42b | 2017-12-29 16:33:23 +0530 | [diff] [blame] | 12933 | qdf_atomic_set(&hdd_ctx->con_mode_flag, 0); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12934 | return ret; |
| 12935 | } |
| 12936 | |
| 12937 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12938 | 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] | 12939 | { |
| 12940 | int ret; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12941 | struct hdd_context *hdd_ctx; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12942 | |
| 12943 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12944 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 12945 | if (ret) |
| 12946 | return ret; |
| 12947 | |
Ashish Kumar Dhanotiya | 759b327 | 2018-05-18 17:49:46 +0530 | [diff] [blame] | 12948 | if (!cds_wait_for_external_threads_completion(__func__)) { |
| 12949 | hdd_warn("External threads are still active, can not change mode"); |
| 12950 | return -EAGAIN; |
| 12951 | } |
| 12952 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 12953 | cds_ssr_protect(__func__); |
| 12954 | ret = __con_mode_handler(kmessage, kp, hdd_ctx); |
| 12955 | cds_ssr_unprotect(__func__); |
| 12956 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12957 | return ret; |
| 12958 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12959 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12960 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12961 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 12962 | { |
| 12963 | int ret; |
| 12964 | |
| 12965 | ret = param_set_int(kmessage, kp); |
| 12966 | |
| 12967 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 12968 | pr_err("Only FTM mode supported!"); |
| 12969 | return -ENOTSUPP; |
| 12970 | } |
| 12971 | |
| 12972 | hdd_set_conparam(con_mode_ftm); |
| 12973 | con_mode = con_mode_ftm; |
| 12974 | |
| 12975 | return ret; |
| 12976 | } |
| 12977 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12978 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12979 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 12980 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12981 | { |
| 12982 | int ret; |
| 12983 | |
| 12984 | ret = param_set_int(kmessage, kp); |
| 12985 | |
| 12986 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 12987 | pr_err("Only Monitor mode supported!"); |
| 12988 | return -ENOTSUPP; |
| 12989 | } |
| 12990 | |
| 12991 | hdd_set_conparam(con_mode_monitor); |
| 12992 | con_mode = con_mode_monitor; |
| 12993 | |
| 12994 | return ret; |
| 12995 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 12996 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 12997 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12998 | /** |
| 12999 | * hdd_get_conparam() - driver exit point |
| 13000 | * |
| 13001 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 13002 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13003 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13004 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13005 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13006 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 13007 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13008 | } |
| 13009 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13010 | void hdd_set_conparam(uint32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13011 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 13012 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13013 | } |
| 13014 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13015 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13016 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 13017 | * @hdd_ctx: HDD context |
| 13018 | * |
| 13019 | * Cleans up the pre cac interface, if it exists |
| 13020 | * |
| 13021 | * Return: None |
| 13022 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13023 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13024 | { |
| 13025 | uint8_t session_id; |
| 13026 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 13027 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13028 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13029 | 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] | 13030 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13031 | hdd_err("failed to get pre cac vdev id"); |
| 13032 | return; |
| 13033 | } |
| 13034 | |
| 13035 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, session_id); |
| 13036 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 13037 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 13038 | return; |
| 13039 | } |
| 13040 | |
| 13041 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 13042 | wlan_hdd_sap_pre_cac_failure, |
| 13043 | (void *)precac_adapter); |
| 13044 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 13045 | |
| 13046 | } |
| 13047 | |
| 13048 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13049 | * hdd_update_ol_config - API to update ol configuration parameters |
| 13050 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13051 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13052 | * Return: void |
| 13053 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13054 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13055 | { |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13056 | struct ol_config_info cfg; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13057 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13058 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13059 | if (!ol_ctx) |
| 13060 | return; |
| 13061 | |
| 13062 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
| 13063 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 13064 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 13065 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 13066 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13067 | |
| 13068 | ol_init_ini_config(ol_ctx, &cfg); |
| 13069 | } |
| 13070 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13071 | #ifdef FEATURE_RUNTIME_PM |
| 13072 | /** |
| 13073 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 13074 | * @hdd_ctx: hdd context |
| 13075 | * @cfg: pointer to the configuration memory being populated |
| 13076 | * |
| 13077 | * Return: void |
| 13078 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13079 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13080 | struct hif_config_info *cfg) |
| 13081 | { |
| 13082 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
| 13083 | cfg->runtime_pm_delay = hdd_ctx->config->runtime_pm_delay; |
| 13084 | } |
| 13085 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13086 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13087 | struct hif_config_info *cfg) |
| 13088 | { |
| 13089 | } |
| 13090 | #endif |
| 13091 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13092 | /** |
| 13093 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 13094 | * @hdd_ctx: HDD Context |
| 13095 | * |
| 13096 | * Return: void |
| 13097 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13098 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13099 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 13100 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13101 | struct hif_config_info cfg; |
| 13102 | |
| 13103 | if (!scn) |
| 13104 | return; |
| 13105 | |
| 13106 | cfg.enable_self_recovery = hdd_ctx->config->enableSelfRecovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 13107 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13108 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 13109 | |
| 13110 | if (hdd_ctx->config->prevent_link_down) |
| 13111 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13112 | } |
| 13113 | |
| 13114 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13115 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 13116 | * datapath |
| 13117 | * @hdd_ctx: HDD Context |
| 13118 | * |
| 13119 | * Return: 0 for success/errno for failure |
| 13120 | */ |
| 13121 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 13122 | { |
| 13123 | struct cdp_config_params params; |
| 13124 | QDF_STATUS status; |
| 13125 | |
| 13126 | params.tso_enable = hdd_ctx->config->tso_enable; |
| 13127 | params.lro_enable = hdd_ctx->config->lro_enable; |
| 13128 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 13129 | params.tx_flow_stop_queue_threshold = |
| 13130 | hdd_ctx->config->TxFlowStopQueueThreshold; |
| 13131 | params.tx_flow_start_queue_offset = |
| 13132 | hdd_ctx->config->TxFlowStartQueueOffset; |
| 13133 | #endif |
| 13134 | params.flow_steering_enable = hdd_ctx->config->flow_steering_enable; |
| 13135 | params.napi_enable = hdd_ctx->napi_enable; |
| 13136 | params.tcp_udp_checksumoffload = |
| 13137 | hdd_ctx->config->enable_ip_tcp_udp_checksum_offload; |
| 13138 | |
| 13139 | status = cdp_update_config_parameters( |
| 13140 | cds_get_context(QDF_MODULE_ID_SOC), |
| 13141 | ¶ms); |
| 13142 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 13143 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13144 | return status; |
| 13145 | } |
| 13146 | |
| 13147 | return 0; |
| 13148 | } |
| 13149 | |
| 13150 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13151 | * hdd_update_config() - Initialize driver per module ini parameters |
| 13152 | * @hdd_ctx: HDD Context |
| 13153 | * |
| 13154 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13155 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13156 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13157 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13158 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13159 | int ret; |
| 13160 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 13161 | hdd_update_ol_config(hdd_ctx); |
| 13162 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13163 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 13164 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 13165 | else |
| 13166 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 13167 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 13168 | |
| 13169 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 13170 | } |
| 13171 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13172 | #ifdef FEATURE_WLAN_RA_FILTERING |
| 13173 | /** |
| 13174 | * hdd_ra_populate_cds_config() - Populate RA filtering cds configuration |
| 13175 | * @psoc_cfg: pmo psoc Configuration |
| 13176 | * @hdd_ctx: Pointer to hdd context |
| 13177 | * |
| 13178 | * Return: none |
| 13179 | */ |
| 13180 | static inline void hdd_ra_populate_pmo_config( |
| 13181 | struct pmo_psoc_cfg *psoc_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13182 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13183 | { |
| 13184 | psoc_cfg->ra_ratelimit_interval = |
| 13185 | hdd_ctx->config->RArateLimitInterval; |
| 13186 | psoc_cfg->ra_ratelimit_enable = |
| 13187 | hdd_ctx->config->IsRArateLimitEnabled; |
| 13188 | } |
| 13189 | #else |
| 13190 | static inline void hdd_ra_populate_pmo_config( |
| 13191 | struct cds_config_info *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13192 | struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13193 | { |
| 13194 | } |
| 13195 | #endif |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13196 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13197 | /** |
| 13198 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 13199 | * @hdd_ctx: HDD context |
| 13200 | * |
| 13201 | * Return: void |
| 13202 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13203 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13204 | { |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13205 | struct pmo_psoc_cfg psoc_cfg; |
| 13206 | QDF_STATUS status; |
| 13207 | |
| 13208 | /* |
| 13209 | * Value of hdd_ctx->wowEnable can be, |
| 13210 | * 0 - Disable both magic pattern match and pattern byte match. |
| 13211 | * 1 - Enable magic pattern match on all interfaces. |
| 13212 | * 2 - Enable pattern byte match on all interfaces. |
| 13213 | * 3 - Enable both magic patter and pattern byte match on |
| 13214 | * all interfaces. |
| 13215 | */ |
| 13216 | psoc_cfg.magic_ptrn_enable = |
| 13217 | (hdd_ctx->config->wowEnable & 0x01) ? true : false; |
| 13218 | psoc_cfg.ptrn_match_enable_all_vdev = |
| 13219 | (hdd_ctx->config->wowEnable & 0x02) ? true : false; |
Nachiket Kukade | e547a48 | 2018-05-22 16:43:30 +0530 | [diff] [blame] | 13220 | psoc_cfg.apf_enable = hdd_ctx->config->apf_packet_filter_enable; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13221 | psoc_cfg.arp_offload_enable = hdd_ctx->config->fhostArpOffload; |
Nachiket Kukade | f080407 | 2018-02-27 18:20:07 +0530 | [diff] [blame] | 13222 | 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] | 13223 | psoc_cfg.ns_offload_enable_dynamic = hdd_ctx->config->fhostNSOffload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13224 | psoc_cfg.ns_offload_enable_static = hdd_ctx->config->fhostNSOffload; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13225 | psoc_cfg.packet_filter_enabled = !hdd_ctx->config->disablePacketFilter; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13226 | psoc_cfg.ssdp = hdd_ctx->config->ssdp; |
| 13227 | psoc_cfg.enable_mc_list = hdd_ctx->config->fEnableMCAddrList; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13228 | psoc_cfg.active_mode_offload = hdd_ctx->config->active_mode_offload; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13229 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 13230 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13231 | psoc_cfg.sta_dynamic_dtim = hdd_ctx->config->enableDynamicDTIM; |
| 13232 | psoc_cfg.sta_mod_dtim = hdd_ctx->config->enableModulatedDTIM; |
| 13233 | psoc_cfg.sta_max_li_mod_dtim = hdd_ctx->config->fMaxLIModulatedDTIM; |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13234 | psoc_cfg.power_save_mode = hdd_ctx->config->enablePowersaveOffload; |
Ravi Kumar Bokka | 05c14e5 | 2017-03-27 14:48:23 +0530 | [diff] [blame] | 13235 | psoc_cfg.auto_power_save_fail_mode = |
| 13236 | hdd_ctx->config->auto_pwr_save_fail_mode; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13237 | |
| 13238 | hdd_ra_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 13239 | hdd_nan_populate_pmo_config(&psoc_cfg, hdd_ctx); |
| 13240 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13241 | |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 13242 | status = ucfg_pmo_update_psoc_config(hdd_ctx->hdd_psoc, &psoc_cfg); |
| 13243 | if (QDF_IS_STATUS_ERROR(status)) |
| 13244 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 13245 | |
| 13246 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13247 | } |
| 13248 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13249 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 13250 | static inline void hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
| 13251 | struct hdd_config *cfg) |
| 13252 | { |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13253 | struct nlo_mawc_params *mawc_cfg = &pno_cfg->mawc_params; |
| 13254 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13255 | pno_cfg->channel_prediction = cfg->pno_channel_prediction; |
| 13256 | pno_cfg->top_k_num_of_channels = cfg->top_k_num_of_channels; |
| 13257 | pno_cfg->stationary_thresh = cfg->stationary_thresh; |
| 13258 | pno_cfg->adaptive_dwell_mode = cfg->adaptive_dwell_mode_enabled; |
| 13259 | pno_cfg->channel_prediction_full_scan = |
| 13260 | cfg->channel_prediction_full_scan; |
Varun Reddy Yeturu | bba32e9 | 2017-09-06 13:31:40 -0700 | [diff] [blame] | 13261 | mawc_cfg->enable = cfg->MAWCEnabled && cfg->mawc_nlo_enabled; |
| 13262 | mawc_cfg->exp_backoff_ratio = cfg->mawc_nlo_exp_backoff_ratio; |
| 13263 | mawc_cfg->init_scan_interval = cfg->mawc_nlo_init_scan_interval; |
| 13264 | mawc_cfg->max_scan_interval = cfg->mawc_nlo_max_scan_interval; |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13265 | } |
| 13266 | #else |
| 13267 | static inline void |
| 13268 | hdd_update_pno_config(struct pno_user_cfg *pno_cfg, |
Jeff Johnson | 33a0792 | 2017-10-05 09:08:46 -0700 | [diff] [blame] | 13269 | struct hdd_config *cfg) |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13270 | { |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13271 | } |
| 13272 | #endif |
| 13273 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13274 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
| 13275 | struct hdd_config *cfg) |
| 13276 | { |
| 13277 | uint8_t i = 0; |
| 13278 | |
| 13279 | ie_whitelist->white_list = cfg->probe_req_ie_whitelist; |
| 13280 | if (!ie_whitelist->white_list) |
| 13281 | return; |
| 13282 | |
| 13283 | ie_whitelist->ie_bitmap[0] = cfg->probe_req_ie_bitmap_0; |
| 13284 | ie_whitelist->ie_bitmap[1] = cfg->probe_req_ie_bitmap_1; |
| 13285 | ie_whitelist->ie_bitmap[2] = cfg->probe_req_ie_bitmap_2; |
| 13286 | ie_whitelist->ie_bitmap[3] = cfg->probe_req_ie_bitmap_3; |
| 13287 | ie_whitelist->ie_bitmap[4] = cfg->probe_req_ie_bitmap_4; |
| 13288 | ie_whitelist->ie_bitmap[5] = cfg->probe_req_ie_bitmap_5; |
| 13289 | ie_whitelist->ie_bitmap[6] = cfg->probe_req_ie_bitmap_6; |
| 13290 | ie_whitelist->ie_bitmap[7] = cfg->probe_req_ie_bitmap_7; |
| 13291 | |
| 13292 | ie_whitelist->num_vendor_oui = cfg->no_of_probe_req_ouis; |
| 13293 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
| 13294 | ie_whitelist->voui[i] = cfg->probe_req_voui[i]; |
| 13295 | } |
| 13296 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13297 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 13298 | { |
| 13299 | uint8_t i, score; |
| 13300 | |
| 13301 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 13302 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 13303 | if (score > MAX_INDEX_SCORE) |
| 13304 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 13305 | MAX_INDEX_SCORE, i); |
| 13306 | } |
| 13307 | |
| 13308 | return per_index_score; |
| 13309 | } |
| 13310 | |
| 13311 | /** |
| 13312 | * hdd_update_score_config - API to update candidate scoring related params |
| 13313 | * configuration parameters |
| 13314 | * @score_config: score config to update |
| 13315 | * @cfg: config params |
| 13316 | * |
| 13317 | * Return: 0 if success else err |
| 13318 | */ |
| 13319 | static void hdd_update_score_config( |
| 13320 | struct scoring_config *score_config, struct hdd_config *cfg) |
| 13321 | { |
| 13322 | int total_weight; |
| 13323 | |
| 13324 | score_config->weight_cfg.rssi_weightage = cfg->rssi_weightage; |
| 13325 | score_config->weight_cfg.ht_caps_weightage = cfg->ht_caps_weightage; |
| 13326 | score_config->weight_cfg.vht_caps_weightage = |
| 13327 | cfg->vht_caps_weightage; |
| 13328 | score_config->weight_cfg.he_caps_weightage = |
| 13329 | cfg->he_caps_weightage; |
| 13330 | score_config->weight_cfg.chan_width_weightage = |
| 13331 | cfg->chan_width_weightage; |
| 13332 | score_config->weight_cfg.chan_band_weightage = |
| 13333 | cfg->chan_band_weightage; |
| 13334 | score_config->weight_cfg.nss_weightage = cfg->nss_weightage; |
| 13335 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13336 | cfg->beamforming_cap_weightage; |
| 13337 | score_config->weight_cfg.pcl_weightage = cfg->pcl_weightage; |
| 13338 | score_config->weight_cfg.channel_congestion_weightage = |
| 13339 | cfg->channel_congestion_weightage; |
| 13340 | score_config->weight_cfg.oce_wan_weightage = cfg->oce_wan_weightage; |
| 13341 | |
| 13342 | total_weight = score_config->weight_cfg.rssi_weightage + |
| 13343 | score_config->weight_cfg.ht_caps_weightage + |
| 13344 | score_config->weight_cfg.vht_caps_weightage + |
| 13345 | score_config->weight_cfg.he_caps_weightage + |
| 13346 | score_config->weight_cfg.chan_width_weightage + |
| 13347 | score_config->weight_cfg.chan_band_weightage + |
| 13348 | score_config->weight_cfg.nss_weightage + |
| 13349 | score_config->weight_cfg.beamforming_cap_weightage + |
| 13350 | score_config->weight_cfg.pcl_weightage + |
| 13351 | score_config->weight_cfg.channel_congestion_weightage + |
| 13352 | score_config->weight_cfg.oce_wan_weightage; |
| 13353 | |
| 13354 | if (total_weight > BEST_CANDIDATE_MAX_WEIGHT) { |
| 13355 | hdd_err("total weight is greater than %d fallback to default values", |
| 13356 | BEST_CANDIDATE_MAX_WEIGHT); |
| 13357 | |
| 13358 | score_config->weight_cfg.rssi_weightage = RSSI_WEIGHTAGE; |
| 13359 | score_config->weight_cfg.ht_caps_weightage = |
| 13360 | HT_CAPABILITY_WEIGHTAGE; |
| 13361 | score_config->weight_cfg.vht_caps_weightage = VHT_CAP_WEIGHTAGE; |
| 13362 | score_config->weight_cfg.he_caps_weightage = HE_CAP_WEIGHTAGE; |
| 13363 | score_config->weight_cfg.chan_width_weightage = |
| 13364 | CHAN_WIDTH_WEIGHTAGE; |
| 13365 | score_config->weight_cfg.chan_band_weightage = |
| 13366 | CHAN_BAND_WEIGHTAGE; |
| 13367 | score_config->weight_cfg.nss_weightage = NSS_WEIGHTAGE; |
| 13368 | score_config->weight_cfg.beamforming_cap_weightage = |
| 13369 | BEAMFORMING_CAP_WEIGHTAGE; |
| 13370 | score_config->weight_cfg.pcl_weightage = PCL_WEIGHT; |
| 13371 | score_config->weight_cfg.channel_congestion_weightage = |
| 13372 | CHANNEL_CONGESTION_WEIGHTAGE; |
| 13373 | score_config->weight_cfg.oce_wan_weightage = OCE_WAN_WEIGHTAGE; |
| 13374 | } |
| 13375 | |
| 13376 | score_config->bandwidth_weight_per_index = |
| 13377 | hdd_limit_max_per_index_score( |
| 13378 | cfg->bandwidth_weight_per_index); |
| 13379 | score_config->nss_weight_per_index = |
| 13380 | hdd_limit_max_per_index_score(cfg->nss_weight_per_index); |
| 13381 | score_config->band_weight_per_index = |
| 13382 | hdd_limit_max_per_index_score(cfg->band_weight_per_index); |
| 13383 | |
| 13384 | score_config->rssi_score.best_rssi_threshold = |
| 13385 | cfg->best_rssi_threshold; |
| 13386 | score_config->rssi_score.good_rssi_threshold = |
| 13387 | cfg->good_rssi_threshold; |
| 13388 | score_config->rssi_score.bad_rssi_threshold = |
| 13389 | cfg->bad_rssi_threshold; |
| 13390 | score_config->rssi_score.good_rssi_pcnt = cfg->good_rssi_pcnt; |
| 13391 | score_config->rssi_score.bad_rssi_pcnt = cfg->bad_rssi_pcnt; |
| 13392 | score_config->rssi_score.good_rssi_bucket_size = |
| 13393 | cfg->good_rssi_bucket_size; |
| 13394 | score_config->rssi_score.bad_rssi_bucket_size = |
| 13395 | cfg->bad_rssi_bucket_size; |
| 13396 | score_config->rssi_score.rssi_pref_5g_rssi_thresh = |
| 13397 | cfg->rssi_pref_5g_rssi_thresh; |
| 13398 | |
| 13399 | score_config->esp_qbss_scoring.num_slot = cfg->num_esp_qbss_slots; |
| 13400 | score_config->esp_qbss_scoring.score_pcnt3_to_0 = |
| 13401 | hdd_limit_max_per_index_score( |
| 13402 | cfg->esp_qbss_score_slots3_to_0); |
| 13403 | score_config->esp_qbss_scoring.score_pcnt7_to_4 = |
| 13404 | hdd_limit_max_per_index_score( |
| 13405 | cfg->esp_qbss_score_slots7_to_4); |
| 13406 | score_config->esp_qbss_scoring.score_pcnt11_to_8 = |
| 13407 | hdd_limit_max_per_index_score( |
| 13408 | cfg->esp_qbss_score_slots11_to_8); |
| 13409 | score_config->esp_qbss_scoring.score_pcnt15_to_12 = |
| 13410 | hdd_limit_max_per_index_score( |
| 13411 | cfg->esp_qbss_score_slots15_to_12); |
| 13412 | |
| 13413 | score_config->oce_wan_scoring.num_slot = cfg->num_oce_wan_slots; |
| 13414 | score_config->oce_wan_scoring.score_pcnt3_to_0 = |
| 13415 | hdd_limit_max_per_index_score( |
| 13416 | cfg->oce_wan_score_slots3_to_0); |
| 13417 | score_config->oce_wan_scoring.score_pcnt7_to_4 = |
| 13418 | hdd_limit_max_per_index_score( |
| 13419 | cfg->oce_wan_score_slots7_to_4); |
| 13420 | score_config->oce_wan_scoring.score_pcnt11_to_8 = |
| 13421 | hdd_limit_max_per_index_score( |
| 13422 | cfg->oce_wan_score_slots11_to_8); |
| 13423 | score_config->oce_wan_scoring.score_pcnt15_to_12 = |
| 13424 | hdd_limit_max_per_index_score( |
| 13425 | cfg->oce_wan_score_slots15_to_12); |
| 13426 | |
| 13427 | |
| 13428 | score_config->cb_mode_24G = cfg->nChannelBondingMode24GHz; |
| 13429 | score_config->cb_mode_5G = cfg->nChannelBondingMode5GHz; |
| 13430 | score_config->nss = cfg->enable2x2 ? 2 : 1; |
| 13431 | |
| 13432 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 13433 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 13434 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 13435 | score_config->he_cap = 1; |
| 13436 | |
| 13437 | if (score_config->he_cap || |
| 13438 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 13439 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 13440 | score_config->vht_cap = 1; |
| 13441 | |
| 13442 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 13443 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 13444 | score_config->ht_cap = 1; |
| 13445 | |
| 13446 | if (score_config->vht_cap && cfg->enableVhtFor24GHzBand) |
| 13447 | score_config->vht_24G_cap = 1; |
| 13448 | |
| 13449 | if (cfg->enableTxBF) |
| 13450 | score_config->beamformee_cap = 1; |
| 13451 | |
| 13452 | } |
| 13453 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13454 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13455 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 13456 | * @hdd_ctx: HDD context |
| 13457 | * |
| 13458 | * Return: 0 if success else err |
| 13459 | */ |
| 13460 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 13461 | { |
| 13462 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13463 | struct hdd_config *cfg = hdd_ctx->config; |
| 13464 | struct dfs_user_config dfs_cfg; |
| 13465 | QDF_STATUS status; |
| 13466 | |
| 13467 | dfs_cfg.dfs_is_phyerr_filter_offload = !!cfg->fDfsPhyerrFilterOffload; |
| 13468 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 13469 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13470 | hdd_err("failed dfs psoc configuration"); |
| 13471 | return -EINVAL; |
| 13472 | } |
| 13473 | |
| 13474 | return 0; |
| 13475 | } |
| 13476 | |
| 13477 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13478 | * hdd_update_scan_config - API to update scan configuration parameters |
| 13479 | * @hdd_ctx: HDD context |
| 13480 | * |
| 13481 | * Return: 0 if success else err |
| 13482 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13483 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13484 | { |
| 13485 | struct wlan_objmgr_psoc *psoc = hdd_ctx->hdd_psoc; |
| 13486 | struct scan_user_cfg scan_cfg; |
| 13487 | struct hdd_config *cfg = hdd_ctx->config; |
| 13488 | QDF_STATUS status; |
| 13489 | |
| 13490 | scan_cfg.active_dwell = cfg->nActiveMaxChnTime; |
| 13491 | scan_cfg.passive_dwell = cfg->nPassiveMaxChnTime; |
| 13492 | scan_cfg.conc_active_dwell = cfg->nActiveMaxChnTimeConc; |
| 13493 | scan_cfg.conc_passive_dwell = cfg->nPassiveMaxChnTimeConc; |
| 13494 | scan_cfg.conc_max_rest_time = cfg->nRestTimeConc; |
| 13495 | scan_cfg.conc_min_rest_time = cfg->min_rest_time_conc; |
| 13496 | scan_cfg.conc_idle_time = cfg->idle_time_conc; |
Abhishek Singh | 158fe25 | 2017-03-23 11:09:34 +0530 | [diff] [blame] | 13497 | /* convert to ms */ |
| 13498 | scan_cfg.scan_cache_aging_time = |
| 13499 | cfg->scanAgingTimeout * 1000; |
| 13500 | scan_cfg.prefer_5ghz = cfg->nRoamPrefer5GHz; |
| 13501 | scan_cfg.select_5ghz_margin = cfg->nSelect5GHzMargin; |
| 13502 | scan_cfg.scan_bucket_threshold = cfg->first_scan_bucket_threshold; |
| 13503 | scan_cfg.rssi_cat_gap = cfg->nRssiCatGap; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13504 | scan_cfg.scan_dwell_time_mode = cfg->scan_adaptive_dwell_mode; |
Kapil Gupta | fa9a8c6 | 2017-04-10 15:25:40 +0530 | [diff] [blame] | 13505 | scan_cfg.is_snr_monitoring_enabled = cfg->fEnableSNRMonitoring; |
Jeff Johnson | 81c00d0 | 2017-11-07 12:34:36 -0800 | [diff] [blame] | 13506 | scan_cfg.usr_cfg_probe_rpt_time = cfg->scan_probe_repeat_time; |
| 13507 | scan_cfg.usr_cfg_num_probes = cfg->scan_num_probes; |
Abhishek Singh | b58164a | 2017-07-19 18:47:23 +0530 | [diff] [blame] | 13508 | scan_cfg.is_bssid_hint_priority = cfg->is_bssid_hint_priority; |
Kiran Kumar Lokere | d547fdd | 2017-09-13 17:20:55 -0700 | [diff] [blame] | 13509 | scan_cfg.enable_mac_spoofing = cfg->enable_mac_spoofing; |
Abhishek Singh | c87bb04 | 2018-01-30 17:10:42 +0530 | [diff] [blame] | 13510 | scan_cfg.sta_miracast_mcc_rest_time = |
| 13511 | cfg->sta_miracast_mcc_rest_time_val; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13512 | |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13513 | hdd_update_pno_config(&scan_cfg.pno_cfg, cfg); |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 13514 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, cfg); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 13515 | hdd_update_score_config(&scan_cfg.score_config, cfg); |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 13516 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13517 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 13518 | if (status != QDF_STATUS_SUCCESS) { |
| 13519 | hdd_err("failed pmo psoc configuration"); |
| 13520 | return -EINVAL; |
| 13521 | } |
| 13522 | |
| 13523 | return 0; |
| 13524 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13525 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13526 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13527 | { |
| 13528 | int ret; |
| 13529 | |
| 13530 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13531 | if (ret) |
| 13532 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13533 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 13534 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13535 | if (ret) |
| 13536 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13537 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 13538 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 13539 | if (ret) |
| 13540 | return ret; |
| 13541 | |
| 13542 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 13543 | if (ret) |
| 13544 | return ret; |
| 13545 | |
| 13546 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 13547 | |
| 13548 | return ret; |
| 13549 | } |
| 13550 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13551 | /** |
| 13552 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 13553 | * @mode : cfg80211 DFS mode |
| 13554 | * |
| 13555 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 13556 | */ |
| 13557 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 13558 | { |
| 13559 | switch (mode) { |
| 13560 | case DFS_MODE_ENABLE: |
| 13561 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13562 | case DFS_MODE_DISABLE: |
| 13563 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13564 | case DFS_MODE_DEPRIORITIZE: |
| 13565 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13566 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13567 | hdd_debug("ACS dfs mode is NONE"); |
| 13568 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13569 | } |
| 13570 | } |
| 13571 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13572 | /** |
| 13573 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 13574 | * @hddctx: pointer to hdd context |
| 13575 | * @set_value: enable/disable |
| 13576 | * |
| 13577 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 13578 | * Host(even though it is duplicate). When Host send vendor command |
| 13579 | * disable,FW doesn't perform any action. Whenever any change in |
| 13580 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 13581 | * |
| 13582 | * return - 0 on success, appropriate error values on failure. |
| 13583 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13584 | 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] | 13585 | { |
| 13586 | QDF_STATUS status; |
| 13587 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13588 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13589 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13590 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13591 | if (!hdd_ctx->config->goptimize_chan_avoid_event) { |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13592 | hdd_warn("goptimize_chan_avoid_event ini param disabled"); |
| 13593 | return -EINVAL; |
| 13594 | } |
| 13595 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13596 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 13597 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 13598 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 13599 | hdd_err("Failed to send chan avoid command to SME"); |
| 13600 | return -EINVAL; |
| 13601 | } |
| 13602 | return 0; |
| 13603 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 13604 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13605 | /** |
| 13606 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 13607 | * @value: value to set |
| 13608 | * |
| 13609 | * This function will set the passed value to roaming in progress flag. |
| 13610 | * |
| 13611 | * Return: None |
| 13612 | */ |
| 13613 | void hdd_set_roaming_in_progress(bool value) |
| 13614 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13615 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13616 | |
| 13617 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13618 | if (!hdd_ctx) { |
| 13619 | hdd_err("HDD context is NULL"); |
| 13620 | return; |
| 13621 | } |
| 13622 | |
| 13623 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 13624 | hdd_debug("Roaming in Progress set to %d", value); |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13625 | } |
| 13626 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13627 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13628 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13629 | if (!hdd_ctx) { |
| 13630 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13631 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13632 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 13633 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13634 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 13635 | |
| 13636 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 13637 | } |
| 13638 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13639 | /** |
| 13640 | * hdd_is_connection_in_progress() - check if connection is in |
| 13641 | * progress |
| 13642 | * @session_id: session id |
| 13643 | * @reason: scan reject reason |
| 13644 | * |
| 13645 | * Go through each adapter and check if Connection is in progress |
| 13646 | * |
| 13647 | * Return: true if connection is in progress else false |
| 13648 | */ |
| 13649 | bool hdd_is_connection_in_progress(uint8_t *session_id, |
| 13650 | enum scan_reject_states *reason) |
| 13651 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 13652 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13653 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13654 | uint8_t sta_id = 0; |
| 13655 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13656 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13657 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13658 | |
| 13659 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13660 | if (!hdd_ctx) { |
| 13661 | hdd_err("HDD context is NULL"); |
| 13662 | return false; |
| 13663 | } |
| 13664 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13665 | mac_handle = hdd_ctx->mac_handle; |
| 13666 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13667 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 13668 | hdd_debug("Adapter with device mode %s(%d) exists", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13669 | hdd_device_mode_to_string(adapter->device_mode), |
| 13670 | adapter->device_mode); |
| 13671 | if (((QDF_STA_MODE == adapter->device_mode) |
| 13672 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 13673 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 13674 | && (eConnectionState_Connecting == |
| 13675 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
| 13676 | conn_info.connState)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13677 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13678 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13679 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13680 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13681 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13682 | *reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13683 | } |
| 13684 | return true; |
| 13685 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 13686 | /* |
| 13687 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 13688 | * hdd_is_roaming_in_progress is for LFR3 |
| 13689 | */ |
| 13690 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 13691 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13692 | mac_handle, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13693 | adapter->session_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 13694 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13695 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13696 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13697 | adapter->session_id); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13698 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13699 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13700 | *reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13701 | } |
| 13702 | return true; |
| 13703 | } |
| 13704 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 13705 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 13706 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 13707 | hdd_sta_ctx = |
| 13708 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 13709 | if ((eConnectionState_Associated == |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 13710 | hdd_sta_ctx->conn_info.connState) |
| 13711 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13712 | mac_handle, adapter->session_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13713 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 13714 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13715 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13716 | " is in middle of WPS/EAPOL exchange.", |
| 13717 | MAC_ADDR_ARRAY(sta_mac)); |
| 13718 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13719 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13720 | *reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13721 | } |
| 13722 | return true; |
| 13723 | } |
| 13724 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 13725 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 13726 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 13727 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13728 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13729 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13730 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13731 | continue; |
| 13732 | |
| 13733 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 13734 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 13735 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13736 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13737 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
| 13738 | MAC_ADDR_ARRAY(sta_mac)); |
| 13739 | if (session_id && reason) { |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13740 | *session_id = adapter->session_id; |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13741 | *reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13742 | } |
| 13743 | return true; |
| 13744 | } |
| 13745 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 13746 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13747 | return true; |
| 13748 | } |
| 13749 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13750 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 13751 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13752 | return false; |
| 13753 | } |
| 13754 | |
| 13755 | /** |
| 13756 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13757 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13758 | * |
| 13759 | * Return: None |
| 13760 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13761 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13762 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 13763 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 13764 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13765 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13766 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | e4c11db | 2018-05-05 23:22:32 -0700 | [diff] [blame] | 13767 | tsap_config_t *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13768 | void *sap_ctx; |
| 13769 | |
| 13770 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 13771 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 13772 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13773 | |
| 13774 | mutex_lock(&hdd_ctx->sap_lock); |
| 13775 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 13776 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13777 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 13778 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 13779 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 13780 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13781 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13782 | qdf_stop_bss_event, |
| 13783 | SME_CMD_TIMEOUT_VALUE); |
| 13784 | |
| 13785 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13786 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13787 | goto end; |
| 13788 | } |
| 13789 | } |
| 13790 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13791 | policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13792 | ap_adapter->device_mode, ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13793 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13794 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13795 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13796 | |
| 13797 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13798 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13799 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13800 | eUPDATE_IE_ALL); |
| 13801 | goto end; |
| 13802 | } |
| 13803 | |
| 13804 | qdf_event_reset(&hostapd_state->qdf_event); |
| 13805 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 13806 | sap_config, |
| 13807 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13808 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13809 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13810 | eUPDATE_IE_ALL); |
| 13811 | goto end; |
| 13812 | } |
| 13813 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13814 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13815 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 13816 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13817 | SME_CMD_TIMEOUT_VALUE); |
| 13818 | wlansap_reset_sap_config_add_ie(sap_config, |
| 13819 | eUPDATE_IE_ALL); |
| 13820 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13821 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13822 | goto end; |
| 13823 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13824 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13825 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13826 | if (hostapd_state->bss_state == BSS_START) { |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13827 | policy_mgr_incr_active_session(hdd_ctx->hdd_psoc, |
| 13828 | ap_adapter->device_mode, |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13829 | ap_adapter->session_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 13830 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 13831 | ap_adapter->device_mode, |
| 13832 | true); |
| 13833 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13834 | } |
| 13835 | end: |
| 13836 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13837 | } |
| 13838 | |
| 13839 | /** |
| 13840 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 13841 | * with non dfs acs |
| 13842 | * |
| 13843 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 13844 | * |
| 13845 | * Return: None |
| 13846 | */ |
| 13847 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 13848 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13849 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13850 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 13851 | struct cds_context *cds_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13852 | |
| 13853 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13854 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13855 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13856 | return; |
| 13857 | } |
| 13858 | |
| 13859 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 13860 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13861 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13862 | return; |
| 13863 | } |
| 13864 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13865 | if (policy_mgr_get_concurrency_mode(hdd_ctx->hdd_psoc) |
| 13866 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13867 | hdd_info("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13868 | return; |
| 13869 | } |
| 13870 | |
| 13871 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 13872 | if (ap_adapter != NULL && test_bit(SOFTAP_BSS_STARTED, |
| 13873 | &ap_adapter->event_flags) && |
| 13874 | wlan_reg_is_dfs_ch(hdd_ctx->hdd_pdev, |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13875 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13876 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13877 | 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] | 13878 | ap_adapter->session.ap.sap_config.channel = |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13879 | AUTO_CHANNEL_SELECT; |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 13880 | ap_adapter->session.ap.sap_config. |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13881 | acs_cfg.acs_mode = true; |
| 13882 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 13883 | hdd_restart_sap(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13884 | } |
| 13885 | } |
| 13886 | |
| 13887 | /** |
| 13888 | * hdd_set_connection_in_progress() - to set the connection in |
| 13889 | * progress flag |
| 13890 | * @value: value to set |
| 13891 | * |
| 13892 | * This function will set the passed value to connection in progress flag. |
| 13893 | * If value is previously being set to true then no need to set it again. |
| 13894 | * |
| 13895 | * Return: true if value is being set correctly and false otherwise. |
| 13896 | */ |
| 13897 | bool hdd_set_connection_in_progress(bool value) |
| 13898 | { |
| 13899 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13900 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13901 | |
| 13902 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13903 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 13904 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 13905 | return false; |
| 13906 | } |
| 13907 | |
| 13908 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 13909 | /* |
| 13910 | * if the value is set to true previously and if someone is |
| 13911 | * trying to make it true again then it could be some race |
| 13912 | * condition being triggered. Avoid this situation by returning |
| 13913 | * false |
| 13914 | */ |
| 13915 | if (hdd_ctx->connection_in_progress && value) |
| 13916 | status = false; |
| 13917 | else |
| 13918 | hdd_ctx->connection_in_progress = value; |
| 13919 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 13920 | return status; |
| 13921 | } |
| 13922 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13923 | 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] | 13924 | { |
| 13925 | if (!adapter) { |
| 13926 | hdd_err("Invalid adapter"); |
| 13927 | return -EINVAL; |
| 13928 | } |
| 13929 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13930 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13931 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 13932 | set_value, VDEV_CMD); |
| 13933 | return 0; |
| 13934 | |
| 13935 | } |
| 13936 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13937 | 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] | 13938 | { |
| 13939 | if (!adapter) { |
| 13940 | hdd_err("Invalid adapter"); |
| 13941 | return -EINVAL; |
| 13942 | } |
| 13943 | |
| 13944 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 1b780e4 | 2017-10-31 14:11:45 -0700 | [diff] [blame] | 13945 | sme_cli_set_command(adapter->session_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 13946 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 13947 | set_value, VDEV_CMD); |
| 13948 | return 0; |
| 13949 | } |
| 13950 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13951 | 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] | 13952 | *psoc, uint8_t vdev_id) |
| 13953 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13954 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 13955 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 13956 | |
| 13957 | /* |
| 13958 | * Currently PSOC is not being used. But this logic will |
| 13959 | * change once we have the converged implementation of |
| 13960 | * HDD context per PSOC in place. This would break if |
| 13961 | * multiple vdev objects reuse the vdev id. |
| 13962 | */ |
| 13963 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 13964 | if (!adapter) |
| 13965 | hdd_err("Get adapter by vdev id failed"); |
| 13966 | |
| 13967 | return adapter; |
| 13968 | } |
| 13969 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 13970 | 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] | 13971 | int8_t *rssi, int8_t *snr) |
| 13972 | { |
| 13973 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13974 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13975 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13976 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13977 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 13978 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 13979 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 13980 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 13981 | if (QDF_STATUS_SUCCESS != status) { |
| 13982 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 13983 | return -EINVAL; |
| 13984 | } |
| 13985 | |
| 13986 | return 0; |
| 13987 | } |
| 13988 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13989 | /** |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 13990 | * hdd_set_limit_off_chan_for_tos() - set limit off-channel command parameters |
| 13991 | * @adapter - HDD adapter |
| 13992 | * @tos - type of service |
| 13993 | * @status - status of the traffic |
| 13994 | * |
| 13995 | * Return: 0 on success and non zero value on failure |
| 13996 | */ |
| 13997 | |
| 13998 | int hdd_set_limit_off_chan_for_tos(struct hdd_adapter *adapter, enum tos tos, |
| 13999 | bool is_tos_active) |
| 14000 | { |
| 14001 | int ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14002 | struct hdd_context *hdd_ctx; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14003 | uint32_t max_off_chan_time = 0; |
| 14004 | QDF_STATUS status; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14005 | int ret; |
| 14006 | |
| 14007 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14008 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14009 | |
| 14010 | if (ret < 0) { |
| 14011 | hdd_err("failed to set limit off chan params"); |
| 14012 | return ret; |
| 14013 | } |
| 14014 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14015 | ac_bit = limit_off_chan_tbl[tos][HDD_AC_BIT_INDX]; |
| 14016 | |
| 14017 | if (is_tos_active) |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 14018 | adapter->active_ac |= ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14019 | else |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 14020 | adapter->active_ac &= ~ac_bit; |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14021 | |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 14022 | if (adapter->active_ac) { |
| 14023 | if (adapter->active_ac & HDD_AC_VO_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14024 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14025 | limit_off_chan_tbl[TOS_VO][HDD_DWELL_TIME_INDX]; |
| 14026 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14027 | PM_LATENCY); |
Ganesh Kondabattini | 1a2aed8 | 2017-09-28 12:21:58 +0530 | [diff] [blame] | 14028 | } else if (adapter->active_ac & HDD_AC_VI_BIT) { |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14029 | max_off_chan_time = |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14030 | limit_off_chan_tbl[TOS_VI][HDD_DWELL_TIME_INDX]; |
| 14031 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14032 | PM_LATENCY); |
| 14033 | } else { |
| 14034 | /*ignore this command if only BE/BK is active */ |
| 14035 | is_tos_active = false; |
| 14036 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14037 | hdd_ctx->config->conc_system_pref); |
| 14038 | } |
| 14039 | } else { |
| 14040 | /* No active tos */ |
| 14041 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14042 | hdd_ctx->config->conc_system_pref); |
| 14043 | } |
| 14044 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14045 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14046 | adapter->session_id, |
| 14047 | is_tos_active, |
| 14048 | max_off_chan_time, |
| 14049 | hdd_ctx->config->nRestTimeConc, |
| 14050 | true); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14051 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14052 | hdd_err("failed to set limit off chan params"); |
| 14053 | ret = -EINVAL; |
| 14054 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14055 | |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14056 | return ret; |
| 14057 | } |
| 14058 | |
| 14059 | /** |
| 14060 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14061 | * @adapter - HDD adapter |
| 14062 | * |
| 14063 | * Return: 0 on success and non zero value on failure |
| 14064 | */ |
| 14065 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14066 | { |
| 14067 | struct hdd_context *hdd_ctx; |
| 14068 | int ret; |
| 14069 | QDF_STATUS status; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14070 | |
| 14071 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 14072 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 14073 | if (ret < 0) |
| 14074 | return ret; |
| 14075 | |
| 14076 | /* set the system preferece to default */ |
| 14077 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->hdd_psoc, |
| 14078 | hdd_ctx->config->conc_system_pref); |
| 14079 | |
| 14080 | /* clear the bitmap */ |
| 14081 | adapter->active_ac = 0; |
| 14082 | |
| 14083 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14084 | adapter->session_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14085 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14086 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
| 14087 | adapter->session_id, |
| 14088 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14089 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14090 | hdd_err("failed to reset limit off chan params"); |
| 14091 | ret = -EINVAL; |
| 14092 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14093 | |
| 14094 | return ret; |
| 14095 | } |
| 14096 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14097 | /** |
| 14098 | * hdd_start_driver_ops_timer() - Starts driver ops inactivity timer |
| 14099 | * @drv_op: Enum indicating driver op |
| 14100 | * |
| 14101 | * Return: none |
| 14102 | */ |
| 14103 | void hdd_start_driver_ops_timer(int drv_op) |
| 14104 | { |
| 14105 | memset(drv_ops_string, 0, MAX_OPS_NAME_STRING_SIZE); |
| 14106 | switch (drv_op) { |
| 14107 | case eHDD_DRV_OP_PROBE: |
| 14108 | memcpy(drv_ops_string, "probe", sizeof("probe")); |
| 14109 | break; |
| 14110 | case eHDD_DRV_OP_REMOVE: |
| 14111 | memcpy(drv_ops_string, "remove", sizeof("remove")); |
| 14112 | break; |
| 14113 | case eHDD_DRV_OP_SHUTDOWN: |
| 14114 | memcpy(drv_ops_string, "shutdown", sizeof("shutdown")); |
| 14115 | break; |
| 14116 | case eHDD_DRV_OP_REINIT: |
| 14117 | memcpy(drv_ops_string, "reinit", sizeof("reinit")); |
| 14118 | break; |
Arunk Khandavalli | e9ef42a | 2017-10-04 14:49:51 +0530 | [diff] [blame] | 14119 | case eHDD_DRV_OP_IFF_UP: |
| 14120 | memcpy(drv_ops_string, "iff_up", sizeof("iff_up")); |
| 14121 | break; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14122 | } |
| 14123 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14124 | hdd_drv_ops_task = current; |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14125 | qdf_timer_start(&hdd_drv_ops_inactivity_timer, |
Dustin Brown | cfc54fe | 2018-06-18 16:17:41 -0700 | [diff] [blame] | 14126 | HDD_OPS_INACTIVITY_TIMEOUT * qdf_timer_get_multiplier()); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14127 | } |
| 14128 | |
| 14129 | /** |
| 14130 | * hdd_stop_driver_ops_timer() - Stops driver ops inactivity timer |
| 14131 | * |
| 14132 | * Return: none |
| 14133 | */ |
| 14134 | void hdd_stop_driver_ops_timer(void) |
| 14135 | { |
| 14136 | qdf_timer_sync_cancel(&hdd_drv_ops_inactivity_timer); |
| 14137 | } |
| 14138 | |
| 14139 | /** |
| 14140 | * hdd_drv_ops_inactivity_handler() - Timeout handler for driver ops |
| 14141 | * inactivity timer |
| 14142 | * |
| 14143 | * Return: None |
| 14144 | */ |
| 14145 | void hdd_drv_ops_inactivity_handler(void) |
| 14146 | { |
Rajeev Kumar | 4471f1b | 2018-06-08 14:18:28 -0700 | [diff] [blame] | 14147 | 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] | 14148 | __func__, HDD_OPS_INACTIVITY_TIMEOUT/1000, drv_ops_string); |
| 14149 | |
Dustin Brown | 45ed4bb | 2017-12-18 12:00:13 -0800 | [diff] [blame] | 14150 | if (hdd_drv_ops_task) { |
| 14151 | printk("Call stack for \"%s\"\n", hdd_drv_ops_task->comm); |
| 14152 | qdf_print_thread_trace(hdd_drv_ops_task); |
| 14153 | } else { |
| 14154 | hdd_err("hdd_drv_ops_task is null"); |
| 14155 | } |
| 14156 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14157 | /* Driver shutdown is stuck, no recovery possible at this point */ |
| 14158 | if (0 == qdf_mem_cmp(&drv_ops_string[0], "shutdown", |
| 14159 | sizeof("shutdown"))) |
| 14160 | QDF_BUG(0); |
| 14161 | |
Rajeev Kumar | 1e57b9c | 2018-01-04 16:17:10 -0800 | [diff] [blame] | 14162 | if (cds_is_fw_down()) { |
| 14163 | hdd_err("FW is down"); |
| 14164 | return; |
| 14165 | } |
| 14166 | |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14167 | if (cds_is_self_recovery_enabled()) |
Anurag Chouhan | 4085ff7 | 2017-10-05 18:09:56 +0530 | [diff] [blame] | 14168 | cds_trigger_recovery(QDF_REASON_UNSPECIFIED); |
Nachiket Kukade | be8850b | 2017-09-18 15:37:00 +0530 | [diff] [blame] | 14169 | else |
| 14170 | QDF_BUG(0); |
| 14171 | } |
| 14172 | |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14173 | void hdd_pld_ipa_uc_shutdown_pipes(void) |
| 14174 | { |
| 14175 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14176 | |
| 14177 | if (!hdd_ctx) |
| 14178 | return; |
| 14179 | |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 14180 | ucfg_ipa_uc_force_pipe_shutdown(hdd_ctx->hdd_pdev); |
Sravan Kumar Kairam | d80c766 | 2017-10-03 16:11:05 +0530 | [diff] [blame] | 14181 | } |
| 14182 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14183 | /** |
| 14184 | * hdd_set_rx_mode_rps() - Enable/disable RPS in SAP mode |
| 14185 | * @struct hdd_context *hdd_ctx |
| 14186 | * @struct hdd_adapter *padapter |
| 14187 | * @bool enble |
| 14188 | * |
| 14189 | * Return: none |
| 14190 | */ |
| 14191 | void hdd_set_rx_mode_rps(bool enable) |
| 14192 | { |
| 14193 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14194 | struct hdd_context *hdd_ctx; |
| 14195 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14196 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 14197 | if (!cds_cfg) |
| 14198 | return; |
| 14199 | |
| 14200 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14201 | if (!hdd_ctx) |
| 14202 | return; |
| 14203 | |
| 14204 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 14205 | if (!adapter) |
| 14206 | return; |
| 14207 | |
| 14208 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 14209 | if (enable && !cds_cfg->rps_enabled) |
| 14210 | hdd_send_rps_ind(adapter); |
| 14211 | else if (!enable && cds_cfg->rps_enabled) |
| 14212 | hdd_send_rps_disable_ind(adapter); |
| 14213 | } |
| 14214 | } |
| 14215 | |
Hanumanth Reddy Pothula | 3862ca9 | 2018-01-12 16:44:10 +0530 | [diff] [blame] | 14216 | bool hdd_is_cli_iface_up(struct hdd_context *hdd_ctx) |
| 14217 | { |
| 14218 | struct hdd_adapter *adapter = NULL; |
| 14219 | |
| 14220 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 14221 | if ((adapter->device_mode == QDF_STA_MODE || |
| 14222 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
| 14223 | qdf_atomic_test_bit(DEVICE_IFACE_OPENED, |
| 14224 | &adapter->event_flags)){ |
| 14225 | return true; |
| 14226 | } |
| 14227 | } |
| 14228 | |
| 14229 | return false; |
| 14230 | } |
| 14231 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14232 | /* Register the module init/exit functions */ |
| 14233 | module_init(hdd_module_init); |
| 14234 | module_exit(hdd_module_exit); |
| 14235 | |
| 14236 | MODULE_LICENSE("Dual BSD/GPL"); |
| 14237 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 14238 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 14239 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14240 | static const struct kernel_param_ops con_mode_ops = { |
| 14241 | .set = con_mode_handler, |
| 14242 | .get = param_get_int, |
| 14243 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14244 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14245 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 14246 | .set = con_mode_handler_ftm, |
| 14247 | .get = param_get_int, |
| 14248 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14249 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14250 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14251 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 14252 | .set = con_mode_handler_monitor, |
| 14253 | .get = param_get_int, |
| 14254 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14255 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14256 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14257 | static const struct kernel_param_ops fwpath_ops = { |
| 14258 | .set = fwpath_changed_handler, |
| 14259 | .get = param_get_string, |
| 14260 | }; |
| 14261 | |
| 14262 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 14263 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14264 | |
| 14265 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 14266 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 14267 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14268 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14269 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 14270 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14271 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14272 | |
| 14273 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 14274 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 14275 | |
| 14276 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14277 | |
| 14278 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 14279 | |
| 14280 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |