Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | 30e9bb6 | 2018-12-27 20:57:09 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2019 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 */ |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 27 | #include <wbuff.h> |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 28 | #include "cfg_ucfg_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 29 | #include <wlan_hdd_includes.h> |
| 30 | #include <cds_api.h> |
| 31 | #include <cds_sched.h> |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 32 | #include <linux/cpu.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 33 | #include <linux/etherdevice.h> |
| 34 | #include <linux/firmware.h> |
| 35 | #include <wlan_hdd_tx_rx.h> |
| 36 | #include <wni_api.h> |
| 37 | #include <wlan_hdd_cfg.h> |
| 38 | #include <wlan_ptt_sock_svc.h> |
| 39 | #include <dbglog_host.h> |
| 40 | #include <wlan_logging_sock_svc.h> |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 41 | #include <wlan_roam_debug.h> |
Dustin Brown | 6412d1f | 2019-02-05 14:52:29 -0800 | [diff] [blame] | 42 | #include "osif_sync.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 43 | #include <wlan_hdd_wowl.h> |
| 44 | #include <wlan_hdd_misc.h> |
| 45 | #include <wlan_hdd_wext.h> |
| 46 | #include "wlan_hdd_trace.h" |
| 47 | #include "wlan_hdd_ioctl.h" |
| 48 | #include "wlan_hdd_ftm.h" |
| 49 | #include "wlan_hdd_power.h" |
| 50 | #include "wlan_hdd_stats.h" |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 51 | #include "wlan_hdd_scan.h" |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 52 | #include "wlan_policy_mgr_ucfg.h" |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 53 | #include <wlan_osif_request_manager.h> |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 54 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 55 | #include "qdf_debug_domain.h" |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 56 | #endif |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 57 | #include "qdf_delayed_work.h" |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 58 | #include "qdf_periodic_work.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 59 | #include "qdf_str.h" |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 60 | #include "qdf_talloc.h" |
Dustin Brown | d424194 | 2018-02-26 12:51:37 -0800 | [diff] [blame] | 61 | #include "qdf_trace.h" |
| 62 | #include "qdf_types.h" |
Manjunathappa Prakash | 3454fd6 | 2016-04-01 08:52:06 -0700 | [diff] [blame] | 63 | #include <cdp_txrx_peer_ops.h> |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 64 | #include <cdp_txrx_misc.h> |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 65 | #include <cdp_txrx_stats.h> |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 66 | #include "cdp_txrx_flow_ctrl_legacy.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 67 | |
| 68 | #include <net/addrconf.h> |
| 69 | #include <linux/wireless.h> |
| 70 | #include <net/cfg80211.h> |
| 71 | #include <linux/inetdevice.h> |
| 72 | #include <net/addrconf.h> |
| 73 | #include "wlan_hdd_cfg80211.h" |
| 74 | #include "wlan_hdd_ext_scan.h" |
| 75 | #include "wlan_hdd_p2p.h" |
| 76 | #include <linux/rtnetlink.h> |
| 77 | #include "sap_api.h" |
| 78 | #include <linux/semaphore.h> |
| 79 | #include <linux/ctype.h> |
| 80 | #include <linux/compat.h> |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 81 | #include <linux/reboot.h> |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 82 | #include <linux/ethtool.h> |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 83 | |
| 84 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
| 85 | #include "qdf_periodic_work.h" |
| 86 | #endif |
| 87 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 88 | #ifdef MSM_PLATFORM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 89 | #include <soc/qcom/subsystem_restart.h> |
| 90 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | #include <wlan_hdd_hostapd.h> |
| 92 | #include <wlan_hdd_softap_tx_rx.h> |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 93 | #include <wlan_hdd_green_ap.h> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 94 | #include "qwlan_version.h" |
| 95 | #include "wma_types.h" |
| 96 | #include "wlan_hdd_tdls.h" |
| 97 | #ifdef FEATURE_WLAN_CH_AVOID |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 98 | #include "cds_regdomain.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 99 | #endif /* FEATURE_WLAN_CH_AVOID */ |
Dustin Brown | ce46d1d | 2017-08-15 13:34:24 -0700 | [diff] [blame] | 100 | #include "cdp_txrx_flow_ctrl_v2.h" |
Yuanyuan Liu | 1d8045c | 2016-04-06 16:40:49 -0700 | [diff] [blame] | 101 | #include "pld_common.h" |
Tushnim Bhattacharyya | 15596cf | 2016-02-12 11:57:02 -0800 | [diff] [blame] | 102 | #include "wlan_hdd_ocb.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | #include "wlan_hdd_nan.h" |
| 104 | #include "wlan_hdd_debugfs.h" |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 105 | #include "wlan_hdd_debugfs_csr.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 106 | #include "wlan_hdd_driver_ops.h" |
| 107 | #include "epping_main.h" |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 108 | #include "wlan_hdd_data_stall_detection.h" |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 109 | #include "wlan_hdd_mpta_helper.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 110 | |
| 111 | #include <wlan_hdd_ipa.h> |
| 112 | #include "hif.h" |
| 113 | #include "wma.h" |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 114 | #include "wlan_policy_mgr_api.h" |
Manikandan Mohan | dcc21ba | 2016-03-15 14:31:56 -0700 | [diff] [blame] | 115 | #include "wlan_hdd_tsf.h" |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 116 | #include "bmi.h" |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 117 | #include <wlan_hdd_regulatory.h> |
Jeff Johnson | 2b0a7b8 | 2016-05-18 15:08:02 -0700 | [diff] [blame] | 118 | #include "wlan_hdd_lpass.h" |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 119 | #include "wlan_nan_api.h" |
Orhan K AKYILDIZ | 1481aff | 2016-05-16 12:40:13 -0700 | [diff] [blame] | 120 | #include <wlan_hdd_napi.h> |
Padma, Santhosh Kumar | d7cc079 | 2016-06-28 18:54:12 +0530 | [diff] [blame] | 121 | #include "wlan_hdd_disa.h" |
Rajeev Kumar | 97767a0 | 2016-11-30 11:20:40 -0800 | [diff] [blame] | 122 | #include <dispatcher_init_deinit.h> |
Rajeev Kumar | 699debf | 2017-01-06 14:17:00 -0800 | [diff] [blame] | 123 | #include "wlan_hdd_object_manager.h" |
yeshwanth sriram guntuka | 310b3ac | 2016-11-15 23:25:26 +0530 | [diff] [blame] | 124 | #include "cds_utils.h" |
Venkata Sharath Chandra Manchala | 0d44d45 | 2016-11-23 17:48:15 -0800 | [diff] [blame] | 125 | #include <cdp_txrx_handle.h> |
Sandeep Puligilla | fdd201e | 2017-02-02 18:43:46 -0800 | [diff] [blame] | 126 | #include <qca_vendor.h> |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 127 | #include "wlan_pmo_ucfg_api.h" |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 128 | #include "sir_api.h" |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 129 | #include "os_if_wifi_pos.h" |
| 130 | #include "wifi_pos_api.h" |
| 131 | #include "wlan_hdd_oemdata.h" |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 132 | #include "wlan_hdd_he.h" |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 133 | #include "os_if_nan.h" |
| 134 | #include "nan_public_structs.h" |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 135 | #include "nan_ucfg_api.h" |
Kiran Kumar Lokere | 3beeb95 | 2017-05-02 18:40:24 -0700 | [diff] [blame] | 136 | #include "wlan_reg_ucfg_api.h" |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 137 | #include "wlan_dfs_ucfg_api.h" |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 138 | #include "wlan_hdd_rx_monitor.h" |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 139 | #include "sme_power_save_api.h" |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 140 | #include "enet.h" |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 141 | #include <cdp_txrx_cmn_struct.h> |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 142 | #include <dp_txrx.h> |
Amar Singhal | 0928b19 | 2017-12-01 10:50:54 -0800 | [diff] [blame] | 143 | #include "wlan_hdd_sysfs.h" |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 144 | #include "wlan_disa_ucfg_api.h" |
Wu Gao | 52084c1 | 2018-05-17 20:47:11 +0800 | [diff] [blame] | 145 | #include "wlan_disa_obj_mgmt_api.h" |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 146 | #include "wlan_action_oui_ucfg_api.h" |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 147 | #include "wlan_ipa_ucfg_api.h" |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 148 | #include <target_if.h> |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 149 | #include "wlan_hdd_nud_tracking.h" |
Nachiket Kukade | d0dd62e | 2018-05-21 18:39:22 +0530 | [diff] [blame] | 150 | #include "wlan_hdd_apf.h" |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 151 | #include "wlan_hdd_twt.h" |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 152 | #include "qc_sap_ioctl.h" |
Sandeep Puligilla | c5609d5 | 2018-05-17 19:23:41 -0700 | [diff] [blame] | 153 | #include "wlan_mlme_main.h" |
Wu Gao | e568979 | 2018-07-05 19:20:13 +0800 | [diff] [blame] | 154 | #include "wlan_p2p_cfg_api.h" |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 155 | #include "wlan_cfg80211_p2p.h" |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 156 | #include "wlan_tdls_cfg_api.h" |
Qiwei Cai | e689a26 | 2018-07-26 15:50:22 +0800 | [diff] [blame] | 157 | #include <wlan_hdd_rssi_monitor.h> |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 158 | #include "wlan_mlme_ucfg_api.h" |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 159 | #include "wlan_fwol_ucfg_api.h" |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 160 | #include "wlan_policy_mgr_ucfg.h" |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 161 | #ifdef CNSS_GENL |
| 162 | #include <net/cnss_nl.h> |
| 163 | #endif |
Amar Singhal | 5cccafe | 2017-02-15 12:42:58 -0800 | [diff] [blame] | 164 | #include "wlan_reg_ucfg_api.h" |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 165 | #include "wlan_ocb_ucfg_api.h" |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 166 | #include <wlan_hdd_spectralscan.h> |
gaurank kathpalia | 4a205fc | 2018-09-15 00:59:15 +0530 | [diff] [blame] | 167 | #include "wlan_green_ap_ucfg_api.h" |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 168 | #include <wlan_p2p_ucfg_api.h> |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 169 | #include <target_type.h> |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 170 | #include <wlan_hdd_debugfs_coex.h> |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 171 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 172 | #ifdef MODULE |
| 173 | #define WLAN_MODULE_NAME module_name(THIS_MODULE) |
| 174 | #else |
| 175 | #define WLAN_MODULE_NAME "wlan" |
| 176 | #endif |
| 177 | |
| 178 | #ifdef TIMER_MANAGER |
| 179 | #define TIMER_MANAGER_STR " +TIMER_MANAGER" |
| 180 | #else |
| 181 | #define TIMER_MANAGER_STR "" |
| 182 | #endif |
| 183 | |
| 184 | #ifdef MEMORY_DEBUG |
| 185 | #define MEMORY_DEBUG_STR " +MEMORY_DEBUG" |
| 186 | #else |
| 187 | #define MEMORY_DEBUG_STR "" |
| 188 | #endif |
| 189 | |
Dustin Brown | c1034df | 2018-02-07 14:51:32 -0800 | [diff] [blame] | 190 | #ifdef PANIC_ON_BUG |
| 191 | #define PANIC_ON_BUG_STR " +PANIC_ON_BUG" |
| 192 | #else |
| 193 | #define PANIC_ON_BUG_STR "" |
| 194 | #endif |
| 195 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 196 | bool g_is_system_reboot_triggered; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 197 | int wlan_start_ret_val; |
| 198 | static DECLARE_COMPLETION(wlan_start_comp); |
| 199 | static unsigned int dev_num = 1; |
| 200 | static struct cdev wlan_hdd_state_cdev; |
| 201 | static struct class *class; |
| 202 | static dev_t device; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 203 | #ifndef MODULE |
| 204 | static struct gwlan_loader *wlan_loader; |
| 205 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
| 206 | struct kobj_attribute *attr, |
| 207 | const char *buf, size_t count); |
| 208 | struct gwlan_loader { |
| 209 | bool loaded_state; |
| 210 | struct kobject *boot_wlan_obj; |
| 211 | struct attribute_group *attr_group; |
| 212 | }; |
| 213 | |
| 214 | static struct kobj_attribute wlan_boot_attribute = |
| 215 | __ATTR(boot_wlan, 0220, NULL, wlan_boot_cb); |
| 216 | |
| 217 | static struct attribute *attrs[] = { |
| 218 | &wlan_boot_attribute.attr, |
| 219 | NULL, |
| 220 | }; |
| 221 | |
| 222 | #define MODULE_INITIALIZED 1 |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 223 | |
| 224 | #ifdef MULTI_IF_NAME |
| 225 | #define WLAN_LOADER_NAME "boot_" MULTI_IF_NAME |
| 226 | #else |
| 227 | #define WLAN_LOADER_NAME "boot_wlan" |
| 228 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 229 | #endif |
| 230 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 231 | /* the Android framework expects this param even though we don't use it */ |
| 232 | #define BUF_LEN 20 |
| 233 | static char fwpath_buffer[BUF_LEN]; |
| 234 | static struct kparam_string fwpath = { |
| 235 | .string = fwpath_buffer, |
| 236 | .maxlen = BUF_LEN, |
| 237 | }; |
| 238 | |
| 239 | static char *country_code; |
| 240 | static int enable_11d = -1; |
| 241 | static int enable_dfs_chan_scan = -1; |
| 242 | |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 243 | #define WLAN_NLINK_CESIUM 30 |
| 244 | |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 245 | static qdf_wake_lock_t wlan_wake_lock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 246 | |
| 247 | #define WOW_MAX_FILTER_LISTS 1 |
| 248 | #define WOW_MAX_FILTERS_PER_LIST 4 |
| 249 | #define WOW_MIN_PATTERN_SIZE 6 |
| 250 | #define WOW_MAX_PATTERN_SIZE 64 |
| 251 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 252 | /* max peer can be tdls peers + self peer + bss peer */ |
| 253 | #define HDD_MAX_VDEV_PEER_COUNT (HDD_MAX_NUM_TDLS_STA + 2) |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 254 | #define IS_IDLE_STOP (!cds_is_driver_unloading() && \ |
| 255 | !cds_is_driver_recovering() && !cds_is_driver_loading()) |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 256 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 257 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 258 | static const struct wiphy_wowlan_support wowlan_support_reg_init = { |
| 259 | .flags = WIPHY_WOWLAN_ANY | |
| 260 | WIPHY_WOWLAN_MAGIC_PKT | |
| 261 | WIPHY_WOWLAN_DISCONNECT | |
| 262 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 263 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 264 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 265 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 266 | WIPHY_WOWLAN_RFKILL_RELEASE, |
| 267 | .n_patterns = WOW_MAX_FILTER_LISTS * WOW_MAX_FILTERS_PER_LIST, |
| 268 | .pattern_min_len = WOW_MIN_PATTERN_SIZE, |
| 269 | .pattern_max_len = WOW_MAX_PATTERN_SIZE, |
| 270 | }; |
| 271 | #endif |
| 272 | |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 273 | static const struct category_info cinfo[MAX_SUPPORTED_CATEGORY] = { |
| 274 | [QDF_MODULE_ID_TLSHIM] = {QDF_TRACE_LEVEL_ALL}, |
| 275 | [QDF_MODULE_ID_WMI] = {QDF_TRACE_LEVEL_ALL}, |
| 276 | [QDF_MODULE_ID_HTT] = {QDF_TRACE_LEVEL_ALL}, |
| 277 | [QDF_MODULE_ID_HDD] = {QDF_TRACE_LEVEL_ALL}, |
| 278 | [QDF_MODULE_ID_SME] = {QDF_TRACE_LEVEL_ALL}, |
| 279 | [QDF_MODULE_ID_PE] = {QDF_TRACE_LEVEL_ALL}, |
| 280 | [QDF_MODULE_ID_WMA] = {QDF_TRACE_LEVEL_ALL}, |
| 281 | [QDF_MODULE_ID_SYS] = {QDF_TRACE_LEVEL_ALL}, |
| 282 | [QDF_MODULE_ID_QDF] = {QDF_TRACE_LEVEL_ALL}, |
| 283 | [QDF_MODULE_ID_SAP] = {QDF_TRACE_LEVEL_ALL}, |
| 284 | [QDF_MODULE_ID_HDD_SOFTAP] = {QDF_TRACE_LEVEL_ALL}, |
| 285 | [QDF_MODULE_ID_HDD_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 286 | [QDF_MODULE_ID_HDD_SAP_DATA] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 287 | [QDF_MODULE_ID_HIF] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 288 | [QDF_MODULE_ID_HTC] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 289 | [QDF_MODULE_ID_TXRX] = {QDF_DATA_PATH_TRACE_LEVEL}, |
| 290 | [QDF_MODULE_ID_QDF_DEVICE] = {QDF_TRACE_LEVEL_ALL}, |
| 291 | [QDF_MODULE_ID_CFG] = {QDF_TRACE_LEVEL_ALL}, |
| 292 | [QDF_MODULE_ID_BMI] = {QDF_TRACE_LEVEL_ALL}, |
| 293 | [QDF_MODULE_ID_EPPING] = {QDF_TRACE_LEVEL_ALL}, |
| 294 | [QDF_MODULE_ID_QVIT] = {QDF_TRACE_LEVEL_ALL}, |
| 295 | [QDF_MODULE_ID_DP] = {QDF_TRACE_LEVEL_ALL}, |
| 296 | [QDF_MODULE_ID_SOC] = {QDF_TRACE_LEVEL_ALL}, |
| 297 | [QDF_MODULE_ID_OS_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 298 | [QDF_MODULE_ID_TARGET_IF] = {QDF_TRACE_LEVEL_ALL}, |
| 299 | [QDF_MODULE_ID_SCHEDULER] = {QDF_TRACE_LEVEL_ALL}, |
| 300 | [QDF_MODULE_ID_MGMT_TXRX] = {QDF_TRACE_LEVEL_ALL}, |
| 301 | [QDF_MODULE_ID_PMO] = {QDF_TRACE_LEVEL_ALL}, |
| 302 | [QDF_MODULE_ID_SCAN] = {QDF_TRACE_LEVEL_ALL}, |
| 303 | [QDF_MODULE_ID_POLICY_MGR] = {QDF_TRACE_LEVEL_ALL}, |
| 304 | [QDF_MODULE_ID_P2P] = {QDF_TRACE_LEVEL_ALL}, |
| 305 | [QDF_MODULE_ID_TDLS] = {QDF_TRACE_LEVEL_ALL}, |
| 306 | [QDF_MODULE_ID_REGULATORY] = {QDF_TRACE_LEVEL_ALL}, |
| 307 | [QDF_MODULE_ID_SERIALIZATION] = {QDF_TRACE_LEVEL_ALL}, |
Arif Hussain | fde76e7 | 2017-09-05 16:58:23 -0700 | [diff] [blame] | 308 | [QDF_MODULE_ID_DFS] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar | ca8ef9d | 2017-10-06 10:43:21 -0700 | [diff] [blame] | 309 | [QDF_MODULE_ID_OBJ_MGR] = {QDF_TRACE_LEVEL_ALL}, |
Deepak Dhamdhere | f918d42 | 2017-07-06 12:56:29 -0700 | [diff] [blame] | 310 | [QDF_MODULE_ID_ROAM_DEBUG] = {QDF_TRACE_LEVEL_ALL}, |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 311 | [QDF_MODULE_ID_GREEN_AP] = {QDF_TRACE_LEVEL_ALL}, |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 312 | [QDF_MODULE_ID_OCB] = {QDF_TRACE_LEVEL_ALL}, |
Sravan Kumar Kairam | 1309e7e | 2018-03-13 09:29:52 +0530 | [diff] [blame] | 313 | [QDF_MODULE_ID_IPA] = {QDF_TRACE_LEVEL_ALL}, |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 314 | [QDF_MODULE_ID_ACTION_OUI] = {QDF_TRACE_LEVEL_ALL}, |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 315 | [QDF_MODULE_ID_CONFIG] = {QDF_TRACE_LEVEL_ALL}, |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 316 | [QDF_MODULE_ID_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 8d039c8 | 2018-07-11 20:41:14 +0530 | [diff] [blame] | 317 | [QDF_MODULE_ID_TARGET] = {QDF_TRACE_LEVEL_ALL}, |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 318 | [QDF_MODULE_ID_CRYPTO] = {QDF_TRACE_LEVEL_ALL}, |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 319 | [QDF_MODULE_ID_FWOL] = {QDF_TRACE_LEVEL_ALL}, |
Abhishek Singh | 0b0105f | 2018-09-25 10:44:16 +0530 | [diff] [blame] | 320 | [QDF_MODULE_ID_SM_ENGINE] = {QDF_TRACE_LEVEL_ALL}, |
| 321 | [QDF_MODULE_ID_CMN_MLME] = {QDF_TRACE_LEVEL_ALL}, |
Nachiket Kukade | 089b983 | 2018-12-12 16:38:17 +0530 | [diff] [blame] | 322 | [QDF_MODULE_ID_NAN] = {QDF_TRACE_LEVEL_ALL}, |
Ashish Kumar Dhanotiya | 6ed4434 | 2019-02-07 21:11:00 +0530 | [diff] [blame] | 323 | [QDF_MODULE_ID_CP_STATS] = {QDF_TRACE_LEVEL_ALL}, |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 324 | }; |
| 325 | |
Ashish Kumar Dhanotiya | cf11bae | 2017-04-04 03:29:47 +0530 | [diff] [blame] | 326 | struct notifier_block hdd_netdev_notifier; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 327 | struct notifier_block system_reboot_notifier; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 328 | |
| 329 | struct sock *cesium_nl_srv_sock; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 330 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 331 | static void wlan_hdd_auto_shutdown_cb(void); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 332 | #endif |
| 333 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 334 | void hdd_start_complete(int ret) |
| 335 | { |
| 336 | wlan_start_ret_val = ret; |
| 337 | |
| 338 | complete(&wlan_start_comp); |
| 339 | } |
| 340 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 341 | /** |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 342 | * hdd_set_rps_cpu_mask - set RPS CPU mask for interfaces |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 343 | * @hdd_ctx: pointer to struct hdd_context |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 344 | * |
| 345 | * Return: none |
| 346 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 347 | static void hdd_set_rps_cpu_mask(struct hdd_context *hdd_ctx) |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 348 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 349 | struct hdd_adapter *adapter; |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 350 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 351 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 352 | hdd_send_rps_ind(adapter); |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 353 | } |
| 354 | |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 355 | #ifdef QCA_HL_NETDEV_FLOW_CONTROL |
| 356 | void wlan_hdd_mod_fc_timer(struct hdd_adapter *adapter, |
| 357 | enum netif_action_type action) |
| 358 | { |
| 359 | if (!adapter->tx_flow_timer_initialized) |
| 360 | return; |
| 361 | |
| 362 | if (action == WLAN_WAKE_NON_PRIORITY_QUEUE) { |
| 363 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
Ajit Pal Singh | e6da1de | 2018-12-27 16:20:45 +0530 | [diff] [blame] | 364 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = false; |
| 365 | adapter->hdd_stats.tx_rx_stats.txflow_unpause_cnt++; |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 366 | } else if (action == WLAN_STOP_NON_PRIORITY_QUEUE) { |
| 367 | QDF_STATUS status = |
| 368 | qdf_mc_timer_start(&adapter->tx_flow_control_timer, |
| 369 | WLAN_HDD_TX_FLOW_CONTROL_OS_Q_BLOCK_TIME); |
| 370 | |
| 371 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 372 | hdd_err("Failed to start tx_flow_control_timer"); |
| 373 | else |
| 374 | adapter-> |
| 375 | hdd_stats.tx_rx_stats.txflow_timer_cnt++; |
| 376 | |
| 377 | adapter->hdd_stats.tx_rx_stats.txflow_pause_cnt++; |
| 378 | adapter->hdd_stats.tx_rx_stats.is_txflow_paused = true; |
| 379 | } |
| 380 | } |
| 381 | #endif /* QCA_HL_NETDEV_FLOW_CONTROL */ |
| 382 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 383 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 384 | void wlan_hdd_update_tcp_rx_param(struct hdd_context *hdd_ctx, void *data) |
| 385 | { |
| 386 | if (!hdd_ctx) { |
| 387 | hdd_err("HDD context is null"); |
| 388 | return; |
| 389 | } |
| 390 | |
| 391 | if (!data) { |
| 392 | hdd_err("Data is null"); |
| 393 | return; |
| 394 | } |
| 395 | if (hdd_ctx->config->enable_tcp_param_update) |
| 396 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 1); |
| 397 | else |
| 398 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 399 | WLAN_SVC_WLAN_TP_IND, |
| 400 | data, |
| 401 | sizeof(struct wlan_rx_tp_data)); |
| 402 | } |
| 403 | |
| 404 | void wlan_hdd_update_tcp_tx_param(struct hdd_context *hdd_ctx, void *data) |
| 405 | { |
| 406 | enum wlan_tp_level next_tx_level; |
| 407 | struct wlan_tx_tp_data *tx_tp_data; |
| 408 | |
| 409 | if (!hdd_ctx) { |
| 410 | hdd_err("HDD context is null"); |
| 411 | return; |
| 412 | } |
| 413 | |
| 414 | if (!data) { |
| 415 | hdd_err("Data is null"); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | tx_tp_data = (struct wlan_tx_tp_data *)data; |
| 420 | next_tx_level = tx_tp_data->level; |
| 421 | |
| 422 | if (hdd_ctx->config->enable_tcp_param_update) |
| 423 | wlan_hdd_send_tcp_param_update_event(hdd_ctx, data, 0); |
| 424 | else |
| 425 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 426 | WLAN_SVC_WLAN_TP_TX_IND, |
| 427 | &next_tx_level, |
| 428 | sizeof(next_tx_level)); |
| 429 | } |
| 430 | |
| 431 | /** |
| 432 | * wlan_hdd_send_tcp_param_update_event() - Send vendor event to update |
| 433 | * TCP parameter through Wi-Fi HAL |
| 434 | * @hdd_ctx: Pointer to HDD context |
| 435 | * @data: Parameters to update |
| 436 | * @dir: Direction(tx/rx) to update |
| 437 | * |
| 438 | * Return: None |
| 439 | */ |
| 440 | void wlan_hdd_send_tcp_param_update_event(struct hdd_context *hdd_ctx, |
| 441 | void *data, |
| 442 | uint8_t dir) |
| 443 | { |
| 444 | struct sk_buff *vendor_event; |
| 445 | uint32_t event_len; |
| 446 | bool tcp_limit_output = false; |
| 447 | bool tcp_del_ack_ind_enabled = false; |
| 448 | bool tcp_adv_win_scl_enabled = false; |
| 449 | enum wlan_tp_level next_tp_level = WLAN_SVC_TP_NONE; |
| 450 | |
| 451 | event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN; |
| 452 | |
| 453 | if (dir == 0) /*TX Flow */ { |
| 454 | struct wlan_tx_tp_data *tx_tp_data = |
| 455 | (struct wlan_tx_tp_data *)data; |
| 456 | |
| 457 | next_tp_level = tx_tp_data->level; |
| 458 | |
| 459 | if (tx_tp_data->tcp_limit_output) { |
| 460 | /* TCP_LIMIT_OUTPUT_BYTES */ |
| 461 | event_len += sizeof(uint32_t); |
| 462 | tcp_limit_output = true; |
| 463 | } |
| 464 | } else if (dir == 1) /* RX Flow */ { |
| 465 | struct wlan_rx_tp_data *rx_tp_data = |
| 466 | (struct wlan_rx_tp_data *)data; |
| 467 | |
| 468 | next_tp_level = rx_tp_data->level; |
| 469 | |
| 470 | if (rx_tp_data->rx_tp_flags & TCP_DEL_ACK_IND_MASK) { |
| 471 | event_len += sizeof(uint32_t); /* TCP_DELACK_SEG */ |
| 472 | tcp_del_ack_ind_enabled = true; |
| 473 | } |
| 474 | if (rx_tp_data->rx_tp_flags & TCP_ADV_WIN_SCL_MASK) { |
| 475 | event_len += sizeof(uint32_t); /* TCP_ADV_WIN_SCALE */ |
| 476 | tcp_adv_win_scl_enabled = true; |
| 477 | } |
| 478 | } else { |
| 479 | hdd_err("Invalid Direction [%d]", dir); |
| 480 | return; |
| 481 | } |
| 482 | |
| 483 | vendor_event = |
| 484 | cfg80211_vendor_event_alloc( |
| 485 | hdd_ctx->wiphy, |
| 486 | NULL, event_len, |
| 487 | QCA_NL80211_VENDOR_SUBCMD_THROUGHPUT_CHANGE_EVENT_INDEX, |
| 488 | GFP_KERNEL); |
| 489 | |
| 490 | if (!vendor_event) { |
| 491 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | if (nla_put_u8( |
| 496 | vendor_event, |
| 497 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_DIRECTION, |
| 498 | dir)) |
| 499 | goto tcp_param_change_nla_failed; |
| 500 | |
| 501 | if (nla_put_u8( |
| 502 | vendor_event, |
| 503 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_THROUGHPUT_LEVEL, |
| 504 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 505 | QCA_WLAN_THROUGHPUT_LEVEL_LOW : |
| 506 | QCA_WLAN_THROUGHPUT_LEVEL_HIGH))) |
| 507 | goto tcp_param_change_nla_failed; |
| 508 | |
| 509 | if (tcp_limit_output && |
| 510 | nla_put_u32( |
| 511 | vendor_event, |
| 512 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_LIMIT_OUTPUT_BYTES, |
| 513 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 514 | TCP_LIMIT_OUTPUT_BYTES_LOW : |
| 515 | TCP_LIMIT_OUTPUT_BYTES_HI))) |
| 516 | goto tcp_param_change_nla_failed; |
| 517 | |
| 518 | if (tcp_del_ack_ind_enabled && |
| 519 | (nla_put_u32( |
| 520 | vendor_event, |
| 521 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_DELACK_SEG, |
| 522 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 523 | TCP_DEL_ACK_LOW : TCP_DEL_ACK_HI)))) |
| 524 | goto tcp_param_change_nla_failed; |
| 525 | |
| 526 | if (tcp_adv_win_scl_enabled && |
| 527 | (nla_put_u32( |
| 528 | vendor_event, |
| 529 | QCA_WLAN_VENDOR_ATTR_THROUGHPUT_CHANGE_TCP_ADV_WIN_SCALE, |
| 530 | (next_tp_level == WLAN_SVC_TP_LOW ? |
| 531 | WIN_SCALE_LOW : WIN_SCALE_HI)))) |
| 532 | goto tcp_param_change_nla_failed; |
| 533 | |
| 534 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
| 535 | return; |
| 536 | |
| 537 | tcp_param_change_nla_failed: |
| 538 | hdd_err("nla_put api failed"); |
| 539 | kfree_skb(vendor_event); |
| 540 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 541 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 542 | |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 543 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 544 | * wlan_hdd_txrx_pause_cb() - pause callback from txrx layer |
| 545 | * @vdev_id: vdev_id |
| 546 | * @action: action type |
| 547 | * @reason: reason type |
| 548 | * |
| 549 | * Return: none |
| 550 | */ |
| 551 | void wlan_hdd_txrx_pause_cb(uint8_t vdev_id, |
| 552 | enum netif_action_type action, enum netif_reason_type reason) |
| 553 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 554 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 555 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 556 | |
| 557 | if (!hdd_ctx) { |
| 558 | hdd_err("hdd ctx is NULL"); |
| 559 | return; |
| 560 | } |
| 561 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Ajit Pal Singh | 106c141 | 2018-04-18 18:08:49 +0530 | [diff] [blame] | 562 | wlan_hdd_mod_fc_timer(adapter, action); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 563 | wlan_hdd_netif_queue_control(adapter, action, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | /* |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 567 | * Store WLAN driver version and timestamp info in global variables such that |
| 568 | * crash debugger can extract them from driver debug symbol and crashdump for |
| 569 | * post processing |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 570 | */ |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 571 | #ifdef BUILD_TAG |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 572 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR "; " BUILD_TAG; |
Dustin Brown | 96cd963 | 2017-11-13 12:45:04 -0800 | [diff] [blame] | 573 | #else |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 574 | uint8_t g_wlan_driver_version[] = QWLAN_VERSIONSTR TIMER_MANAGER_STR MEMORY_DEBUG_STR PANIC_ON_BUG_STR; |
Naveen Rawat | 9383625 | 2017-06-20 16:30:59 -0700 | [diff] [blame] | 575 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 576 | |
| 577 | /** |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 578 | * hdd_get_valid_chan() - return current chan list from regulatory. |
| 579 | * @hdd_ctx: HDD context |
| 580 | * @chan_list: buf hold returned chan list |
| 581 | * @chan_num: input buf size and output returned chan num |
| 582 | * |
| 583 | * This function helps get current available chan list from regulatory |
| 584 | * module. It excludes the "disabled" and "invalid" channels. |
| 585 | * |
| 586 | * Return: 0 for success. |
| 587 | */ |
| 588 | static int hdd_get_valid_chan(struct hdd_context *hdd_ctx, |
| 589 | uint8_t *chan_list, |
| 590 | uint32_t *chan_num) |
| 591 | { |
| 592 | int i = 0, j = 0; |
| 593 | struct regulatory_channel *cur_chan_list; |
| 594 | struct wlan_objmgr_pdev *pdev; |
| 595 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 596 | if (!hdd_ctx || !hdd_ctx->pdev || !chan_list || !chan_num) |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 597 | return -EINVAL; |
| 598 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 599 | pdev = hdd_ctx->pdev; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 600 | cur_chan_list = qdf_mem_malloc(NUM_CHANNELS * |
| 601 | sizeof(struct regulatory_channel)); |
| 602 | if (!cur_chan_list) |
| 603 | return -ENOMEM; |
| 604 | |
| 605 | if (wlan_reg_get_current_chan_list(pdev, cur_chan_list) != |
| 606 | QDF_STATUS_SUCCESS) { |
| 607 | qdf_mem_free(cur_chan_list); |
| 608 | return -EINVAL; |
| 609 | } |
| 610 | |
| 611 | for (i = 0; i < NUM_CHANNELS; i++) { |
| 612 | uint32_t ch = cur_chan_list[i].chan_num; |
| 613 | enum channel_state state = wlan_reg_get_channel_state(pdev, |
| 614 | ch); |
| 615 | |
| 616 | if (state != CHANNEL_STATE_DISABLE && |
| 617 | state != CHANNEL_STATE_INVALID && |
| 618 | j < *chan_num) { |
| 619 | chan_list[j] = (uint8_t)ch; |
| 620 | j++; |
| 621 | } |
| 622 | } |
| 623 | *chan_num = j; |
| 624 | qdf_mem_free(cur_chan_list); |
| 625 | return 0; |
| 626 | } |
| 627 | |
| 628 | /** |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 629 | * hdd_validate_channel_and_bandwidth() - Validate the channel-bandwidth combo |
| 630 | * @adapter: HDD adapter |
| 631 | * @chan_number: Channel number |
| 632 | * @chan_bw: Bandwidth |
| 633 | * |
| 634 | * Checks if the given bandwidth is valid for the given channel number. |
| 635 | * |
| 636 | * Return: 0 for success, non-zero for failure |
| 637 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 638 | int hdd_validate_channel_and_bandwidth(struct hdd_adapter *adapter, |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 639 | uint32_t chan_number, |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 640 | enum phy_ch_width chan_bw) |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 641 | { |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 642 | uint8_t chan[NUM_CHANNELS]; |
| 643 | uint32_t len = NUM_CHANNELS, i; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 644 | bool found = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 645 | mac_handle_t mac_handle; |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 646 | int ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 647 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 648 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 649 | if (!mac_handle) { |
| 650 | hdd_err("Invalid MAC handle"); |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 651 | return -EINVAL; |
| 652 | } |
| 653 | |
Liangwei Dong | 17bf266 | 2018-01-05 02:02:05 -0500 | [diff] [blame] | 654 | ret = hdd_get_valid_chan(adapter->hdd_ctx, chan, |
| 655 | &len); |
| 656 | if (ret) { |
| 657 | hdd_err("error %d in getting valid channel list", ret); |
| 658 | return ret; |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 659 | } |
| 660 | |
| 661 | for (i = 0; i < len; i++) { |
| 662 | if (chan[i] == chan_number) { |
| 663 | found = true; |
| 664 | break; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | if (found == false) { |
| 669 | hdd_err("Channel not in driver's valid channel list"); |
| 670 | return -EOPNOTSUPP; |
| 671 | } |
| 672 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 673 | if ((!WLAN_REG_IS_24GHZ_CH(chan_number)) && |
| 674 | (!WLAN_REG_IS_5GHZ_CH(chan_number))) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 675 | hdd_err("CH %d is not in 2.4GHz or 5GHz", chan_number); |
| 676 | return -EINVAL; |
| 677 | } |
| 678 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 679 | if (WLAN_REG_IS_24GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 680 | if (chan_bw == CH_WIDTH_80MHZ) { |
| 681 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 682 | return -EINVAL; |
| 683 | } |
| 684 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 14) && |
| 685 | (chan_bw != CH_WIDTH_MAX)) { |
| 686 | hdd_err("Only BW20 possible on channel 14"); |
| 687 | return -EINVAL; |
| 688 | } |
| 689 | } |
| 690 | |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 691 | if (WLAN_REG_IS_5GHZ_CH(chan_number)) { |
Chandrasekaran, Manishekar | 794a098 | 2016-01-12 19:42:20 +0530 | [diff] [blame] | 692 | if ((chan_bw != CH_WIDTH_20MHZ) && (chan_number == 165) && |
| 693 | (chan_bw != CH_WIDTH_MAX)) { |
| 694 | hdd_err("Only BW20 possible on channel 165"); |
| 695 | return -EINVAL; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | return 0; |
| 700 | } |
| 701 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 702 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 703 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 704 | { |
| 705 | struct netdev_notifier_info *info = context; |
| 706 | |
| 707 | return info->dev; |
| 708 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 709 | #else |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 710 | static inline struct net_device *hdd_net_dev_from_notifier(void *context) |
| 711 | { |
| 712 | return context; |
| 713 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 714 | #endif |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 715 | |
| 716 | static int __hdd_netdev_notifier_call(struct net_device *net_dev, |
| 717 | unsigned long state) |
| 718 | { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 719 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 720 | struct hdd_context *hdd_ctx; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 721 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 722 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 723 | hdd_enter_dev(net_dev); |
Jeff Johnson | 3c3994a | 2016-02-11 08:12:30 -0800 | [diff] [blame] | 724 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 725 | if (!net_dev->ieee80211_ptr) { |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 726 | hdd_debug("ieee80211_ptr is null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 727 | return NOTIFY_DONE; |
| 728 | } |
| 729 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 730 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 731 | if (!hdd_ctx) { |
| 732 | hdd_err("HDD Context is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 733 | return NOTIFY_DONE; |
| 734 | } |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 735 | |
| 736 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 737 | hdd_debug("%s: Driver module is closed", __func__); |
Jingxiang Ge | 9db9d23 | 2017-10-14 17:22:15 +0800 | [diff] [blame] | 738 | return NOTIFY_DONE; |
| 739 | } |
| 740 | |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 741 | /* Make sure that this callback corresponds to our device. */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 742 | adapter = hdd_get_adapter_by_iface_name(hdd_ctx, net_dev->name); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 743 | if (!adapter) { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 744 | hdd_debug("failed to look up adapter for '%s'", net_dev->name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 745 | return NOTIFY_DONE; |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 746 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 747 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 748 | if (adapter != WLAN_HDD_GET_PRIV_PTR(net_dev)) { |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 749 | hdd_err("HDD adapter mismatch!"); |
| 750 | return NOTIFY_DONE; |
| 751 | } |
| 752 | |
Dustin Brown | aeb5564 | 2018-07-30 17:20:32 -0700 | [diff] [blame] | 753 | if (cds_is_driver_recovering()) { |
| 754 | hdd_debug("Driver is recovering"); |
| 755 | return NOTIFY_DONE; |
| 756 | } |
| 757 | |
| 758 | if (cds_is_driver_in_bad_state()) { |
| 759 | hdd_debug("Driver is in failed recovery state"); |
Visweswara Tanuku | 6bc52de | 2018-04-09 18:38:30 +0530 | [diff] [blame] | 760 | return NOTIFY_DONE; |
| 761 | } |
| 762 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 763 | hdd_debug("%s New Net Device State = %lu", net_dev->name, state); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 764 | |
| 765 | switch (state) { |
| 766 | case NETDEV_REGISTER: |
| 767 | break; |
| 768 | |
| 769 | case NETDEV_UNREGISTER: |
| 770 | break; |
| 771 | |
| 772 | case NETDEV_UP: |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 773 | sme_ch_avoid_update_req(hdd_ctx->mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 774 | break; |
| 775 | |
| 776 | case NETDEV_DOWN: |
| 777 | break; |
| 778 | |
| 779 | case NETDEV_CHANGE: |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 780 | if (adapter->is_link_up_service_needed) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 781 | complete(&adapter->linkup_event_var); |
| 782 | break; |
| 783 | |
| 784 | case NETDEV_GOING_DOWN: |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 785 | vdev = hdd_objmgr_get_vdev(adapter); |
| 786 | if (!vdev) |
| 787 | break; |
| 788 | if (ucfg_scan_get_vdev_status(vdev) != |
Sandeep Puligilla | 5f86d99 | 2017-10-29 14:58:53 -0700 | [diff] [blame] | 789 | SCAN_NOT_IN_PROGRESS) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 790 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 791 | adapter->vdev_id, INVALID_SCAN_ID, |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 792 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 793 | } |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 794 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 795 | cds_flush_work(&adapter->scan_block_work); |
| 796 | /* Need to clean up blocked scan request */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 797 | wlan_hdd_cfg80211_scan_block(adapter); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 798 | hdd_debug("Scan is not Pending from user"); |
Arunk Khandavalli | f0c0d76 | 2017-12-07 10:18:50 +0530 | [diff] [blame] | 799 | /* |
| 800 | * After NETDEV_GOING_DOWN, kernel calls hdd_stop.Irrespective |
| 801 | * of return status of hdd_stop call, kernel resets the IFF_UP |
| 802 | * flag after which driver does not send the cfg80211_scan_done. |
| 803 | * Ensure to cleanup the scan queue in NETDEV_GOING_DOWN |
| 804 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 805 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 806 | break; |
| 807 | |
| 808 | default: |
| 809 | break; |
| 810 | } |
| 811 | |
| 812 | return NOTIFY_DONE; |
| 813 | } |
| 814 | |
| 815 | /** |
| 816 | * hdd_netdev_notifier_call() - netdev notifier callback function |
| 817 | * @nb: pointer to notifier block |
| 818 | * @state: state |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 819 | * @context: notifier callback context pointer |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 820 | * |
| 821 | * Return: 0 on success, error number otherwise. |
| 822 | */ |
| 823 | static int hdd_netdev_notifier_call(struct notifier_block *nb, |
| 824 | unsigned long state, |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 825 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 826 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 827 | struct net_device *net_dev = hdd_net_dev_from_notifier(context); |
| 828 | struct osif_vdev_sync *vdev_sync; |
| 829 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 830 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 831 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 832 | if (errno) |
| 833 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 834 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 835 | errno = __hdd_netdev_notifier_call(net_dev, state); |
| 836 | |
| 837 | osif_vdev_sync_op_stop(vdev_sync); |
| 838 | |
| 839 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 840 | } |
| 841 | |
| 842 | struct notifier_block hdd_netdev_notifier = { |
| 843 | .notifier_call = hdd_netdev_notifier_call, |
| 844 | }; |
| 845 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 846 | static int system_reboot_notifier_call(struct notifier_block *nb, |
| 847 | unsigned long msg_type, void *_unused) |
| 848 | { |
| 849 | switch (msg_type) { |
| 850 | case SYS_DOWN: |
| 851 | case SYS_HALT: |
| 852 | case SYS_POWER_OFF: |
| 853 | g_is_system_reboot_triggered = true; |
| 854 | hdd_info("reboot, reason: %ld", msg_type); |
| 855 | break; |
| 856 | default: |
| 857 | break; |
| 858 | } |
| 859 | |
| 860 | return NOTIFY_OK; |
| 861 | } |
| 862 | |
| 863 | struct notifier_block system_reboot_notifier = { |
| 864 | .notifier_call = system_reboot_notifier_call, |
| 865 | }; |
| 866 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 867 | /* variable to hold the insmod parameters */ |
| 868 | static int con_mode; |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 869 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 870 | static int con_mode_ftm; |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 871 | int con_mode_epping; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 872 | int con_mode_monitor; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 873 | |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 874 | /* Variable to hold connection mode including module parameter con_mode */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 875 | static int curr_con_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 876 | |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 877 | /** |
| 878 | * hdd_map_nl_chan_width() - Map NL channel width to internal representation |
| 879 | * @ch_width: NL channel width |
| 880 | * |
| 881 | * Converts the NL channel width to the driver's internal representation |
| 882 | * |
| 883 | * Return: Converted channel width. In case of non matching NL channel width, |
| 884 | * CH_WIDTH_MAX will be returned. |
| 885 | */ |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 886 | 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] | 887 | { |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 888 | uint8_t fw_ch_bw; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 889 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 890 | fw_ch_bw = wma_get_vht_ch_width(); |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 891 | switch (ch_width) { |
| 892 | case NL80211_CHAN_WIDTH_20_NOHT: |
| 893 | case NL80211_CHAN_WIDTH_20: |
| 894 | return CH_WIDTH_20MHZ; |
| 895 | case NL80211_CHAN_WIDTH_40: |
| 896 | return CH_WIDTH_40MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 897 | case NL80211_CHAN_WIDTH_80: |
| 898 | return CH_WIDTH_80MHZ; |
| 899 | case NL80211_CHAN_WIDTH_80P80: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 900 | if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ) |
| 901 | return CH_WIDTH_80P80MHZ; |
| 902 | else if (fw_ch_bw == WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 903 | return CH_WIDTH_160MHZ; |
| 904 | else |
| 905 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 906 | case NL80211_CHAN_WIDTH_160: |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 907 | if (fw_ch_bw >= WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ) |
| 908 | return CH_WIDTH_160MHZ; |
| 909 | else |
| 910 | return CH_WIDTH_80MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 911 | case NL80211_CHAN_WIDTH_5: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 912 | return CH_WIDTH_5MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 913 | case NL80211_CHAN_WIDTH_10: |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 914 | return CH_WIDTH_10MHZ; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 915 | default: |
| 916 | hdd_err("Invalid channel width %d, setting to default", |
| 917 | ch_width); |
Kiran Kumar Lokere | 1364467 | 2016-02-29 15:40:10 -0800 | [diff] [blame] | 918 | return CH_WIDTH_INVALID; |
Chandrasekaran, Manishekar | a74bb02 | 2016-01-12 18:37:43 +0530 | [diff] [blame] | 919 | } |
| 920 | } |
| 921 | |
Dustin Brown | 56377e1 | 2018-10-10 17:04:04 -0700 | [diff] [blame] | 922 | QDF_STATUS hdd_nl_to_qdf_iface_type(enum nl80211_iftype nl_type, |
| 923 | enum QDF_OPMODE *out_qdf_type) |
| 924 | { |
| 925 | switch (nl_type) { |
| 926 | case NL80211_IFTYPE_ADHOC: |
| 927 | *out_qdf_type = QDF_IBSS_MODE; |
| 928 | break; |
| 929 | case NL80211_IFTYPE_AP: |
| 930 | *out_qdf_type = QDF_SAP_MODE; |
| 931 | break; |
| 932 | case NL80211_IFTYPE_MONITOR: |
| 933 | *out_qdf_type = QDF_MONITOR_MODE; |
| 934 | break; |
| 935 | case NL80211_IFTYPE_OCB: |
| 936 | *out_qdf_type = QDF_OCB_MODE; |
| 937 | break; |
| 938 | case NL80211_IFTYPE_P2P_CLIENT: |
| 939 | *out_qdf_type = QDF_P2P_CLIENT_MODE; |
| 940 | break; |
| 941 | case NL80211_IFTYPE_P2P_DEVICE: |
| 942 | *out_qdf_type = QDF_P2P_DEVICE_MODE; |
| 943 | break; |
| 944 | case NL80211_IFTYPE_P2P_GO: |
| 945 | *out_qdf_type = QDF_P2P_GO_MODE; |
| 946 | break; |
| 947 | case NL80211_IFTYPE_STATION: |
| 948 | *out_qdf_type = QDF_STA_MODE; |
| 949 | break; |
| 950 | case NL80211_IFTYPE_WDS: |
| 951 | *out_qdf_type = QDF_WDS_MODE; |
| 952 | break; |
| 953 | default: |
| 954 | hdd_err("Invalid nl80211 interface type %d", nl_type); |
| 955 | return QDF_STATUS_E_INVAL; |
| 956 | } |
| 957 | |
| 958 | return QDF_STATUS_SUCCESS; |
| 959 | } |
| 960 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 961 | uint8_t wlan_hdd_find_opclass(mac_handle_t mac_handle, uint8_t channel, |
| 962 | uint8_t bw_offset) |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 963 | { |
| 964 | uint8_t opclass = 0; |
| 965 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 966 | sme_get_opclass(mac_handle, channel, bw_offset, &opclass); |
Masti, Narayanraddi | c4a7ab8 | 2015-11-25 15:41:10 +0530 | [diff] [blame] | 967 | return opclass; |
| 968 | } |
| 969 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 970 | /** |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 971 | * hdd_qdf_trace_enable() - configure initial QDF Trace enable |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 972 | * @module_id: Module whose trace level is being configured |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 973 | * @bitmask: Bitmask of log levels to be enabled |
| 974 | * |
| 975 | * Called immediately after the cfg.ini is read in order to configure |
| 976 | * the desired trace levels. |
| 977 | * |
| 978 | * Return: None |
| 979 | */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 980 | 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] | 981 | { |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 982 | QDF_TRACE_LEVEL level; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 983 | int qdf_print_idx = -1; |
| 984 | int status = -1; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 985 | /* |
| 986 | * if the bitmask is the default value, then a bitmask was not |
| 987 | * specified in cfg.ini, so leave the logging level alone (it |
| 988 | * will remain at the "compiled in" default value) |
| 989 | */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 990 | if (CFG_QDF_TRACE_ENABLE_DEFAULT == bitmask) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 991 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 993 | qdf_print_idx = qdf_get_pidx(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 994 | |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 995 | /* a mask was specified. start by disabling all logging */ |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 996 | status = qdf_print_set_category_verbose(qdf_print_idx, module_id, |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 997 | QDF_TRACE_LEVEL_NONE, 0); |
| 998 | |
| 999 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1000 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1001 | /* now cycle through the bitmask until all "set" bits are serviced */ |
Ashish Kumar Dhanotiya | 83f286b | 2017-09-15 19:52:58 +0530 | [diff] [blame] | 1002 | level = QDF_TRACE_LEVEL_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1003 | while (0 != bitmask) { |
| 1004 | if (bitmask & 1) { |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1005 | status = qdf_print_set_category_verbose(qdf_print_idx, |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1006 | module_id, level, 1); |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 1007 | if (QDF_STATUS_SUCCESS != status) |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1008 | return -EINVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1009 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1010 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1011 | level++; |
| 1012 | bitmask >>= 1; |
| 1013 | } |
Ashish Kumar Dhanotiya | 53c2f69 | 2017-02-08 00:25:11 +0530 | [diff] [blame] | 1014 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1015 | } |
| 1016 | |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1017 | int __wlan_hdd_validate_context(struct hdd_context *hdd_ctx, const char *func) |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1018 | { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1019 | if (!hdd_ctx) { |
| 1020 | hdd_err("HDD context is null (via %s)", func); |
| 1021 | return -ENODEV; |
| 1022 | } |
| 1023 | |
| 1024 | if (!hdd_ctx->config) { |
| 1025 | hdd_err("HDD config is null (via %s)", func); |
Chris Guo | 1751acf | 2017-07-03 14:09:01 +0800 | [diff] [blame] | 1026 | return -ENODEV; |
| 1027 | } |
| 1028 | |
| 1029 | if (cds_is_driver_recovering()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1030 | hdd_debug("Recovery in progress (via %s); state:0x%x", |
| 1031 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1032 | return -EAGAIN; |
| 1033 | } |
| 1034 | |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1035 | if (cds_is_load_or_unload_in_progress()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1036 | hdd_debug("Load/unload in progress (via %s); state:0x%x", |
| 1037 | func, cds_get_driver_state()); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1038 | return -EAGAIN; |
Yue Ma | 9f275d9 | 2017-09-14 16:58:41 -0700 | [diff] [blame] | 1039 | } |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 1040 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1041 | if (cds_is_driver_in_bad_state()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1042 | hdd_debug("Driver in bad state (via %s); state:0x%x", |
| 1043 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1044 | return -EAGAIN; |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1045 | } |
| 1046 | |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1047 | if (cds_is_fw_down()) { |
Dustin Brown | da351e3 | 2018-07-23 15:48:22 -0700 | [diff] [blame] | 1048 | hdd_debug("FW is down (via %s); state:0x%x", |
| 1049 | func, cds_get_driver_state()); |
Sourav Mohapatra | 21b3c98 | 2018-04-03 17:33:03 +0530 | [diff] [blame] | 1050 | return -EAGAIN; |
Arunk Khandavalli | 2859fa1 | 2018-02-14 10:46:26 +0530 | [diff] [blame] | 1051 | } |
| 1052 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1053 | return 0; |
| 1054 | } |
| 1055 | |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1056 | int __hdd_validate_adapter(struct hdd_adapter *adapter, const char *func) |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1057 | { |
| 1058 | if (!adapter) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1059 | hdd_err("adapter is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1060 | return -EINVAL; |
| 1061 | } |
| 1062 | |
| 1063 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1064 | hdd_err("bad adapter magic (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1065 | return -EINVAL; |
| 1066 | } |
| 1067 | |
| 1068 | if (!adapter->dev) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1069 | hdd_err("adapter net_device is null (via %s)", func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1070 | return -EINVAL; |
| 1071 | } |
| 1072 | |
| 1073 | if (!(adapter->dev->flags & IFF_UP)) { |
Dustin Brown | a8700cc | 2018-08-07 12:04:47 -0700 | [diff] [blame] | 1074 | hdd_debug_rl("adapter '%s' is not up (via %s)", |
| 1075 | adapter->dev->name, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1076 | return -EAGAIN; |
| 1077 | } |
| 1078 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1079 | return __wlan_hdd_validate_vdev_id(adapter->vdev_id, func); |
Dustin Brown | f13b8c3 | 2017-05-19 17:23:08 -0700 | [diff] [blame] | 1080 | } |
| 1081 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1082 | int __wlan_hdd_validate_vdev_id(uint8_t vdev_id, const char *func) |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1083 | { |
Srinivas Girigowda | d8697d4 | 2019-03-08 15:34:39 -0800 | [diff] [blame] | 1084 | if (vdev_id == WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1085 | hdd_debug_rl("adapter is not up (via %s)", func); |
| 1086 | return -EINVAL; |
| 1087 | } |
| 1088 | |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 1089 | if (vdev_id >= WLAN_MAX_VDEVS) { |
| 1090 | hdd_err("bad vdev Id:%u (via %s)", vdev_id, func); |
Dustin Brown | 6350061 | 2018-08-07 11:36:09 -0700 | [diff] [blame] | 1091 | return -EINVAL; |
| 1092 | } |
| 1093 | |
| 1094 | return 0; |
| 1095 | } |
| 1096 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 1097 | QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr, |
| 1098 | const char *func) |
| 1099 | { |
| 1100 | if (!mac_addr) { |
| 1101 | hdd_err("Received NULL mac address (via %s)", func); |
| 1102 | return QDF_STATUS_E_INVAL; |
| 1103 | } |
| 1104 | |
| 1105 | if (qdf_is_macaddr_zero(mac_addr)) { |
| 1106 | hdd_err("MAC is all zero (via %s)", func); |
| 1107 | return QDF_STATUS_E_INVAL; |
| 1108 | } |
| 1109 | |
| 1110 | if (qdf_is_macaddr_broadcast(mac_addr)) { |
| 1111 | hdd_err("MAC is Broadcast (via %s)", func); |
| 1112 | return QDF_STATUS_E_INVAL; |
| 1113 | } |
| 1114 | |
| 1115 | if (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) { |
| 1116 | hdd_err("MAC is Multicast (via %s)", func); |
| 1117 | return QDF_STATUS_E_INVAL; |
| 1118 | } |
| 1119 | |
| 1120 | return QDF_STATUS_SUCCESS; |
| 1121 | } |
| 1122 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1123 | /** |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1124 | * wlan_hdd_validate_modules_state() - Check modules status |
| 1125 | * @hdd_ctx: HDD context pointer |
| 1126 | * |
| 1127 | * Check's the driver module's state and returns true if the |
| 1128 | * modules are enabled returns false if modules are closed. |
| 1129 | * |
| 1130 | * Return: True if modules are enabled or false. |
| 1131 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1132 | bool wlan_hdd_validate_modules_state(struct hdd_context *hdd_ctx) |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1133 | { |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1134 | if (hdd_ctx->driver_status != DRIVER_MODULES_ENABLED) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 1135 | hdd_info("Modules not enabled, Present status: %d", |
| 1136 | hdd_ctx->driver_status); |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1137 | return false; |
| 1138 | } |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 1139 | |
Arun Khandavalli | ca892f6 | 2017-05-26 14:25:50 +0530 | [diff] [blame] | 1140 | return true; |
| 1141 | } |
| 1142 | |
| 1143 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1144 | * 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] | 1145 | * @struct hdd_adapter Hdd adapter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1146 | * |
| 1147 | * This function sets the IBSS power save config parameters to WMA |
| 1148 | * which will send it to firmware if FW supports IBSS power save |
| 1149 | * before vdev start. |
| 1150 | * |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1151 | * 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] | 1152 | * on failure. |
| 1153 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 1154 | QDF_STATUS hdd_set_ibss_power_save_params(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1155 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1156 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1157 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 1158 | if (!hdd_ctx) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1159 | hdd_err("HDD context is null"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1160 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1161 | } |
| 1162 | |
Manikandan Mohan | 2bd0977 | 2018-11-28 18:27:32 -0800 | [diff] [blame] | 1163 | return ucfg_mlme_ibss_power_save_setup(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 1164 | adapter->vdev_id); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1165 | } |
| 1166 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1167 | #ifdef FEATURE_RUNTIME_PM |
| 1168 | /** |
| 1169 | * hdd_runtime_suspend_context_init() - API to initialize HDD Runtime Contexts |
| 1170 | * @hdd_ctx: HDD context |
| 1171 | * |
| 1172 | * Return: None |
| 1173 | */ |
| 1174 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) |
| 1175 | { |
| 1176 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1177 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1178 | qdf_runtime_lock_init(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1179 | qdf_runtime_lock_init(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1180 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1181 | wlan_scan_runtime_pm_init(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
| 1184 | /** |
| 1185 | * hdd_runtime_suspend_context_deinit() - API to deinit HDD runtime context |
| 1186 | * @hdd_ctx: HDD Context |
| 1187 | * |
| 1188 | * Return: None |
| 1189 | */ |
| 1190 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) |
| 1191 | { |
| 1192 | struct hdd_runtime_pm_context *ctx = &hdd_ctx->runtime_context; |
| 1193 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1194 | qdf_runtime_lock_deinit(&ctx->dfs); |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 1195 | qdf_runtime_lock_deinit(&ctx->connect); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1196 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1197 | wlan_scan_runtime_pm_deinit(hdd_ctx->pdev); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1198 | } |
| 1199 | |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1200 | #else /* FEATURE_RUNTIME_PM */ |
| 1201 | static void hdd_runtime_suspend_context_init(struct hdd_context *hdd_ctx) {} |
| 1202 | static void hdd_runtime_suspend_context_deinit(struct hdd_context *hdd_ctx) {} |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 1203 | #endif /* FEATURE_RUNTIME_PM */ |
| 1204 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1205 | #define INTF_MACADDR_MASK 0x7 |
| 1206 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1207 | void hdd_update_macaddr(struct hdd_context *hdd_ctx, |
| 1208 | struct qdf_mac_addr hw_macaddr, bool generate_mac_auto) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1209 | { |
| 1210 | int8_t i; |
| 1211 | uint8_t macaddr_b3, tmp_br3; |
| 1212 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1213 | /* |
| 1214 | * If "generate_mac_auto" is true, it indicates that all the |
| 1215 | * addresses are derived addresses, else the first addresses |
| 1216 | * is not derived address (It is provided by fw). |
| 1217 | */ |
| 1218 | if (!generate_mac_auto) { |
| 1219 | qdf_mem_copy(hdd_ctx->provisioned_mac_addr[0].bytes, |
| 1220 | hw_macaddr.bytes, QDF_MAC_ADDR_SIZE); |
| 1221 | hdd_ctx->num_provisioned_addr++; |
| 1222 | hdd_info("hdd_ctx->provisioned_mac_addr[0]: " |
| 1223 | MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1224 | QDF_MAC_ADDR_ARRAY(hdd_ctx-> |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1225 | provisioned_mac_addr[0].bytes)); |
| 1226 | } else { |
| 1227 | qdf_mem_copy(hdd_ctx->derived_mac_addr[0].bytes, |
| 1228 | hw_macaddr.bytes, |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 1229 | QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1230 | hdd_ctx->num_derived_addr++; |
| 1231 | hdd_info("hdd_ctx->derived_mac_addr[0]: " |
| 1232 | MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1233 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[0].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1234 | } |
| 1235 | for (i = hdd_ctx->num_derived_addr; i < (QDF_MAX_CONCURRENCY_PERSONA - |
| 1236 | hdd_ctx->num_provisioned_addr); |
| 1237 | i++) { |
| 1238 | qdf_mem_copy(hdd_ctx->derived_mac_addr[i].bytes, |
| 1239 | hw_macaddr.bytes, |
| 1240 | QDF_MAC_ADDR_SIZE); |
| 1241 | macaddr_b3 = hdd_ctx->derived_mac_addr[i].bytes[3]; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + i) & |
| 1243 | INTF_MACADDR_MASK; |
| 1244 | macaddr_b3 += tmp_br3; |
| 1245 | |
| 1246 | /* XOR-ing bit-24 of the mac address. This will give enough |
| 1247 | * mac address range before collision |
| 1248 | */ |
| 1249 | macaddr_b3 ^= (1 << 7); |
| 1250 | |
| 1251 | /* Set locally administered bit */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1252 | hdd_ctx->derived_mac_addr[i].bytes[0] |= 0x02; |
| 1253 | hdd_ctx->derived_mac_addr[i].bytes[3] = macaddr_b3; |
| 1254 | hdd_info("hdd_ctx->derived_mac_addr[%d]: " |
| 1255 | MAC_ADDRESS_STR, i, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 1256 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1257 | hdd_ctx->num_derived_addr++; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1258 | } |
| 1259 | } |
| 1260 | |
Jeff Johnson | 2de5879 | 2019-02-08 07:49:17 -0800 | [diff] [blame] | 1261 | #ifdef FEATURE_WLAN_TDLS |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1262 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1263 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1264 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1265 | struct tdls_start_params tdls_cfg; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1266 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1267 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 1268 | |
| 1269 | /* Populate the nss chain params from ini for this vdev type */ |
| 1270 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 1271 | QDF_TDLS_MODE, |
| 1272 | hdd_ctx->num_rf_chains); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1273 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1274 | cfg_tdls_set_vdev_nss_2g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1275 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1276 | cfg_tdls_set_vdev_nss_5g(hdd_ctx->psoc, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1277 | vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]); |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1278 | hdd_init_tdls_config(&tdls_cfg); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1279 | tdls_cfg.tdls_del_all_peers = eWNI_SME_DEL_ALL_TDLS_PEERS; |
| 1280 | tdls_cfg.tdls_update_dp_vdev_flags = CDP_UPDATE_TDLS_FLAGS; |
| 1281 | tdls_cfg.tdls_event_cb = wlan_cfg80211_tdls_event_callback; |
| 1282 | tdls_cfg.tdls_evt_cb_data = psoc; |
Jeff Johnson | 1d40f5b | 2018-03-02 08:35:53 -0800 | [diff] [blame] | 1283 | tdls_cfg.tdls_peer_context = hdd_ctx; |
| 1284 | tdls_cfg.tdls_reg_peer = hdd_tdls_register_peer; |
| 1285 | tdls_cfg.tdls_dereg_peer = hdd_tdls_deregister_peer; |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1286 | tdls_cfg.tdls_wmm_cb = hdd_wmm_is_acm_allowed; |
| 1287 | tdls_cfg.tdls_wmm_cb_data = psoc; |
| 1288 | tdls_cfg.tdls_rx_cb = wlan_cfg80211_tdls_rx_callback; |
| 1289 | tdls_cfg.tdls_rx_cb_data = psoc; |
| 1290 | tdls_cfg.tdls_dp_vdev_update = hdd_update_dp_vdev_flags; |
| 1291 | |
| 1292 | status = ucfg_tdls_update_config(psoc, &tdls_cfg); |
| 1293 | if (status != QDF_STATUS_SUCCESS) { |
| 1294 | hdd_err("failed pmo psoc configuration"); |
| 1295 | return -EINVAL; |
| 1296 | } |
| 1297 | |
| 1298 | hdd_ctx->tdls_umac_comp_active = true; |
| 1299 | /* enable napier specific tdls data path */ |
| 1300 | hdd_ctx->tdls_nap_active = true; |
| 1301 | |
| 1302 | return 0; |
| 1303 | } |
Jeff Johnson | 74c6bb2 | 2019-02-15 10:15:07 -0800 | [diff] [blame] | 1304 | #else |
| 1305 | static int hdd_update_tdls_config(struct hdd_context *hdd_ctx) |
| 1306 | { |
| 1307 | return 0; |
| 1308 | } |
| 1309 | #endif |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1310 | |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1311 | #ifdef WLAN_FEATURE_ROAM_OFFLOAD |
| 1312 | static void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1313 | struct wma_tgt_services *cfg) |
| 1314 | { |
| 1315 | bool roam_offload_enable; |
| 1316 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1317 | ucfg_mlme_get_roaming_offload(hdd_ctx->psoc, &roam_offload_enable); |
| 1318 | ucfg_mlme_set_roaming_offload(hdd_ctx->psoc, |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1319 | roam_offload_enable & |
| 1320 | cfg->en_roam_offload); |
| 1321 | } |
| 1322 | #else |
| 1323 | static inline void hdd_update_roam_offload(struct hdd_context *hdd_ctx, |
| 1324 | struct wma_tgt_services *cfg) |
| 1325 | { |
| 1326 | } |
| 1327 | #endif |
| 1328 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1329 | static void hdd_update_tgt_services(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1330 | struct wma_tgt_services *cfg) |
| 1331 | { |
| 1332 | struct hdd_config *config = hdd_ctx->config; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1333 | bool arp_offload_enable; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1334 | bool mawc_enabled; |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1335 | #ifdef FEATURE_WLAN_TDLS |
| 1336 | bool tdls_support; |
| 1337 | bool tdls_off_channel; |
| 1338 | bool tdls_buffer_sta; |
| 1339 | uint32_t tdls_uapsd_mask; |
| 1340 | #endif |
jiad | 7b8a5e0 | 2018-11-26 16:37:57 +0800 | [diff] [blame] | 1341 | bool value; |
| 1342 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1343 | /* Set up UAPSD */ |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 1344 | ucfg_mlme_set_sap_uapsd_flag(hdd_ctx->psoc, cfg->uapsd); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1345 | |
Krishna Kumaar Natarajan | 4f1d772 | 2017-03-03 21:12:51 -0800 | [diff] [blame] | 1346 | /* 11AX mode support */ |
| 1347 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 1348 | config->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) && !cfg->en_11ax) |
| 1349 | config->dot11Mode = eHDD_DOT11_MODE_11ac; |
| 1350 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1351 | /* 11AC mode support */ |
| 1352 | if ((config->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 1353 | config->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) && !cfg->en_11ac) |
| 1354 | config->dot11Mode = eHDD_DOT11_MODE_AUTO; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1355 | |
| 1356 | /* ARP offload: override user setting if invalid */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 1357 | arp_offload_enable = |
| 1358 | ucfg_pmo_is_arp_offload_enabled(hdd_ctx->psoc); |
| 1359 | ucfg_pmo_set_arp_offload_enabled(hdd_ctx->psoc, |
| 1360 | arp_offload_enable & cfg->arp_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1361 | #ifdef FEATURE_WLAN_SCAN_PNO |
| 1362 | /* PNO offload */ |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1363 | hdd_debug("PNO Capability in f/w = %d", cfg->pno_offload); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1364 | if (cfg->pno_offload) |
Pragaspathi Thilagaraj | 24789d3 | 2018-12-10 22:28:03 +0530 | [diff] [blame] | 1365 | ucfg_scan_set_pno_offload(hdd_ctx->psoc, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1366 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1367 | #ifdef FEATURE_WLAN_TDLS |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1368 | cfg_tdls_get_support_enable(hdd_ctx->psoc, &tdls_support); |
| 1369 | cfg_tdls_set_support_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1370 | tdls_support & cfg->en_tdls); |
| 1371 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1372 | cfg_tdls_get_off_channel_enable(hdd_ctx->psoc, &tdls_off_channel); |
| 1373 | cfg_tdls_set_off_channel_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1374 | tdls_off_channel && |
| 1375 | cfg->en_tdls_offchan); |
| 1376 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1377 | cfg_tdls_get_buffer_sta_enable(hdd_ctx->psoc, &tdls_buffer_sta); |
| 1378 | cfg_tdls_set_buffer_sta_enable(hdd_ctx->psoc, |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1379 | tdls_buffer_sta && |
| 1380 | cfg->en_tdls_uapsd_buf_sta); |
| 1381 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1382 | cfg_tdls_get_uapsd_mask(hdd_ctx->psoc, &tdls_uapsd_mask); |
Wu Gao | bdb7f27 | 2018-07-05 19:33:26 +0800 | [diff] [blame] | 1383 | if (tdls_uapsd_mask && cfg->en_tdls_uapsd_sleep_sta) |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1384 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, true); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 1385 | else |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1386 | cfg_tdls_set_sleep_sta_enable(hdd_ctx->psoc, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1387 | #endif |
Wu Gao | ca416ff | 2018-09-17 11:05:07 +0800 | [diff] [blame] | 1388 | hdd_update_roam_offload(hdd_ctx, cfg); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1389 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 1390 | if (ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value) == |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 1391 | QDF_STATUS_SUCCESS) |
| 1392 | value &= cfg->get_peer_info_enabled; |
| 1393 | |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 1394 | ucfg_mlme_is_mawc_enabled(hdd_ctx->psoc, &mawc_enabled); |
| 1395 | ucfg_mlme_set_mawc_enabled(hdd_ctx->psoc, |
| 1396 | mawc_enabled & cfg->is_fw_mawc_capable); |
Kabilan Kannan | 44a5837 | 2017-12-06 18:16:11 -0800 | [diff] [blame] | 1397 | hdd_update_tdls_config(hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1398 | sme_update_tgt_services(hdd_ctx->mac_handle, cfg); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1399 | } |
| 1400 | |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1401 | /** |
| 1402 | * hdd_update_vdev_nss() - sets the vdev nss |
| 1403 | * @hdd_ctx: HDD context |
| 1404 | * |
| 1405 | * Sets the Nss per vdev type based on INI |
| 1406 | * |
| 1407 | * Return: None |
| 1408 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1409 | static void hdd_update_vdev_nss(struct hdd_context *hdd_ctx) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1410 | { |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1411 | uint8_t max_supp_nss = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1412 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1413 | QDF_STATUS status; |
| 1414 | bool bval; |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1415 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1416 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1417 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1418 | hdd_err("unable to get vht_enable2x2"); |
| 1419 | |
| 1420 | if (bval && !cds_is_sub_20_mhz_enabled()) |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1421 | max_supp_nss = 2; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1422 | |
| 1423 | hdd_debug("max nss %d", max_supp_nss); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1424 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1425 | mac_handle = hdd_ctx->mac_handle; |
| 1426 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1427 | NSS_CHAINS_BAND_2GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1428 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1429 | sme_update_vdev_type_nss(mac_handle, max_supp_nss, |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 1430 | NSS_CHAINS_BAND_5GHZ); |
Kiran Kumar Lokere | 666bf85 | 2016-05-02 12:23:02 -0700 | [diff] [blame] | 1431 | } |
| 1432 | |
Nitesh Shah | db5ea0d | 2017-03-22 15:17:47 +0530 | [diff] [blame] | 1433 | /** |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1434 | * hdd_update_wiphy_vhtcap() - Updates wiphy vhtcap fields |
| 1435 | * @hdd_ctx: HDD context |
| 1436 | * |
| 1437 | * Updates wiphy vhtcap fields |
| 1438 | * |
| 1439 | * Return: None |
| 1440 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1441 | static void hdd_update_wiphy_vhtcap(struct hdd_context *hdd_ctx) |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1442 | { |
| 1443 | struct ieee80211_supported_band *band_5g = |
| 1444 | hdd_ctx->wiphy->bands[NL80211_BAND_5GHZ]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1445 | QDF_STATUS status; |
| 1446 | uint8_t value = 0, value1 = 0; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1447 | |
| 1448 | if (!band_5g) { |
| 1449 | hdd_debug("5GHz band disabled, skipping capability population"); |
| 1450 | return; |
| 1451 | } |
| 1452 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1453 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1454 | &value); |
| 1455 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1456 | hdd_err("unable to get tx_bfee_ant_supp"); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1457 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1458 | band_5g->vht_cap.cap |= |
| 1459 | (value << IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1460 | |
| 1461 | value1 = NUM_OF_SOUNDING_DIMENSIONS; |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1462 | band_5g->vht_cap.cap |= |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1463 | (value1 << IEEE80211_VHT_CAP_SOUNDING_DIMENSIONS_SHIFT); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1464 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 1465 | hdd_debug("Updated wiphy vhtcap:0x%x, CSNAntSupp:%d, NumSoundDim:%d", |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1466 | band_5g->vht_cap.cap, value, value1); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 1467 | } |
| 1468 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1469 | static void hdd_update_tgt_ht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1470 | struct wma_tgt_ht_cap *cfg) |
| 1471 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1472 | QDF_STATUS status; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1473 | qdf_size_t value_len; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1474 | uint32_t value; |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1475 | uint8_t mpdu_density; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1476 | struct mlme_ht_capabilities_info ht_cap_info; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1477 | uint8_t mcs_set[SIZE_OF_SUPPORTED_MCS_SET]; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1478 | bool b_enable1x1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1480 | /* get the MPDU density */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1481 | status = ucfg_mlme_get_ht_mpdu_density(hdd_ctx->psoc, &mpdu_density); |
| 1482 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1483 | hdd_err("could not get HT MPDU Density"); |
| 1484 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1485 | } |
| 1486 | |
| 1487 | /* |
| 1488 | * MPDU density: |
| 1489 | * override user's setting if value is larger |
| 1490 | * than the one supported by target |
| 1491 | */ |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 1492 | if (mpdu_density > cfg->mpdu_density) { |
| 1493 | status = ucfg_mlme_set_ht_mpdu_density(hdd_ctx->psoc, |
| 1494 | cfg->mpdu_density); |
| 1495 | if (QDF_IS_STATUS_ERROR(status)) |
| 1496 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | /* get the HT capability info */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1500 | status = ucfg_mlme_get_ht_cap_info(hdd_ctx->psoc, &ht_cap_info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1501 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1502 | hdd_err("could not get HT capability info"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1503 | return; |
| 1504 | } |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 1505 | |
| 1506 | /* check and update RX STBC */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1507 | if (ht_cap_info.rx_stbc && !cfg->ht_rx_stbc) |
| 1508 | ht_cap_info.rx_stbc = cfg->ht_rx_stbc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1509 | |
| 1510 | /* Set the LDPC capability */ |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1511 | ht_cap_info.adv_coding_cap = cfg->ht_rx_ldpc; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1512 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1513 | if (ht_cap_info.short_gi_20_mhz && !cfg->ht_sgi_20) |
| 1514 | ht_cap_info.short_gi_20_mhz = cfg->ht_sgi_20; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1515 | |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1516 | if (ht_cap_info.short_gi_40_mhz && !cfg->ht_sgi_40) |
| 1517 | ht_cap_info.short_gi_40_mhz = cfg->ht_sgi_40; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1518 | |
| 1519 | hdd_ctx->num_rf_chains = cfg->num_rf_chains; |
| 1520 | hdd_ctx->ht_tx_stbc_supported = cfg->ht_tx_stbc; |
| 1521 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1522 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &b_enable1x1); |
| 1523 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1524 | hdd_err("unable to get vht_enable2x2"); |
| 1525 | |
| 1526 | b_enable1x1 = b_enable1x1 && (cfg->num_rf_chains == 2); |
| 1527 | |
| 1528 | status = ucfg_mlme_set_vht_enable2x2(hdd_ctx->psoc, b_enable1x1); |
| 1529 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1530 | hdd_err("unable to set vht_enable2x2"); |
| 1531 | |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1532 | if (!b_enable1x1) { |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1533 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1534 | |
| 1535 | /* 1x1 */ |
| 1536 | /* Update Rx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1537 | status = ucfg_mlme_cfg_set_vht_rx_supp_data_rate( |
| 1538 | hdd_ctx->psoc, |
| 1539 | VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1540 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1541 | hdd_err("Failed to set rx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1542 | /* Update Tx Highest Long GI data Rate */ |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1543 | status = ucfg_mlme_cfg_set_vht_tx_supp_data_rate( |
| 1544 | hdd_ctx->psoc, |
| 1545 | VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1); |
| 1546 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1547 | hdd_err("Failed to set tx_supp_data_rate"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1548 | } |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1549 | if (!(cfg->ht_tx_stbc && b_enable1x1)) |
Vignesh Viswanathan | 7818250 | 2018-08-06 15:13:30 +0530 | [diff] [blame] | 1550 | ht_cap_info.tx_stbc = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1551 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1552 | status = ucfg_mlme_set_ht_cap_info(hdd_ctx->psoc, ht_cap_info); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1553 | if (status != QDF_STATUS_SUCCESS) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1554 | hdd_err("could not set HT capability to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | #define WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES 0xff |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1556 | value_len = SIZE_OF_SUPPORTED_MCS_SET; |
| 1557 | if (ucfg_mlme_get_supported_mcs_set( |
| 1558 | hdd_ctx->psoc, mcs_set, |
| 1559 | &value_len) == QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1560 | hdd_debug("Read MCS rate set"); |
gaurank kathpalia | 18b4936 | 2018-04-15 23:12:03 +0530 | [diff] [blame] | 1561 | if (cfg->num_rf_chains > SIZE_OF_SUPPORTED_MCS_SET) |
| 1562 | cfg->num_rf_chains = SIZE_OF_SUPPORTED_MCS_SET; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1563 | |
| 1564 | if (b_enable1x1) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1565 | for (value = 0; value < cfg->num_rf_chains; value++) |
| 1566 | mcs_set[value] = |
| 1567 | WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES; |
| 1568 | |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 1569 | status = ucfg_mlme_set_supported_mcs_set( |
| 1570 | hdd_ctx->psoc, |
| 1571 | mcs_set, |
| 1572 | (qdf_size_t)SIZE_OF_SUPPORTED_MCS_SET); |
| 1573 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1574 | hdd_err("could not set MCS SET to CCM"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1575 | } |
| 1576 | } |
| 1577 | #undef WLAN_HDD_RX_MCS_ALL_NSTREAM_RATES |
| 1578 | } |
| 1579 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1580 | static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1581 | struct wma_tgt_vht_cap *cfg) |
| 1582 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1583 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1584 | struct wiphy *wiphy = hdd_ctx->wiphy; |
| 1585 | struct ieee80211_supported_band *band_5g = |
Srinivas Girigowda | 11c28e0 | 2017-06-27 20:06:21 -0700 | [diff] [blame] | 1586 | wiphy->bands[HDD_NL80211_BAND_5GHZ]; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1587 | uint32_t ch_width = eHT_CHANNEL_WIDTH_80MHZ; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1588 | struct wma_caps_per_phy caps_per_phy; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1589 | uint8_t val = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1590 | |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1591 | if (!band_5g) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1592 | hdd_debug("5GHz band disabled, skipping capability population"); |
Dustin Brown | 5e06bd3 | 2016-10-04 12:49:10 -0700 | [diff] [blame] | 1593 | return; |
| 1594 | } |
| 1595 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1596 | status = ucfg_mlme_update_vht_cap(hdd_ctx->psoc, cfg); |
| 1597 | if (QDF_IS_STATUS_ERROR(status)) |
| 1598 | hdd_err("could not update vht capabilities"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1599 | |
| 1600 | if (WMI_VHT_CAP_MAX_MPDU_LEN_11454 == cfg->vht_max_mpdu) |
| 1601 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_11454; |
| 1602 | else if (WMI_VHT_CAP_MAX_MPDU_LEN_7935 == cfg->vht_max_mpdu) |
| 1603 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_7991; |
| 1604 | else |
| 1605 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MAX_MPDU_LENGTH_3895; |
| 1606 | |
| 1607 | |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1608 | if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_80P80MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1609 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1610 | VHT_CAP_160_AND_80P80_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1611 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1612 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1613 | band_5g->vht_cap.cap |= |
| 1614 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1615 | ch_width = eHT_CHANNEL_WIDTH_80P80MHZ; |
| 1616 | } else if (cfg->supp_chan_width & (1 << eHT_CHANNEL_WIDTH_160MHZ)) { |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1617 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, |
| 1618 | VHT_CAP_160_SUPP); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1619 | if (QDF_IS_STATUS_ERROR(status)) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1620 | hdd_err("could not set the VHT CAP 160"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1621 | band_5g->vht_cap.cap |= |
| 1622 | IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ; |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1623 | ch_width = eHT_CHANNEL_WIDTH_160MHZ; |
| 1624 | } |
Kiran Kumar Lokere | 4bbbd0d | 2017-02-07 00:06:43 -0800 | [diff] [blame] | 1625 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1626 | status = |
| 1627 | ucfg_mlme_cfg_get_vht_chan_width(hdd_ctx->psoc, &val); |
| 1628 | if (QDF_IS_STATUS_ERROR(status)) |
| 1629 | hdd_err("could not get channel_width"); |
| 1630 | |
| 1631 | val = QDF_MIN(val, ch_width); |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1632 | status = ucfg_mlme_set_vht_ch_width(hdd_ctx->psoc, val); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1633 | if (QDF_IS_STATUS_ERROR(status)) |
| 1634 | hdd_err("could not set the channel width"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1635 | |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1636 | if (cfg->vht_rx_ldpc & WMI_VHT_CAP_RX_LDPC) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
Sandeep Puligilla | 305d509 | 2018-04-16 14:40:50 -0700 | [diff] [blame] | 1638 | hdd_debug("VHT RxLDPC capability is set"); |
| 1639 | } else { |
| 1640 | /* |
| 1641 | * Get the RX LDPC capability for the NON DBS |
| 1642 | * hardware mode for 5G band |
| 1643 | */ |
| 1644 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1645 | HW_MODE_DBS_NONE, CDS_BAND_5GHZ); |
| 1646 | if ((QDF_IS_STATUS_SUCCESS(status)) && |
| 1647 | (caps_per_phy.vht_5g & WMI_VHT_CAP_RX_LDPC)) { |
| 1648 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXLDPC; |
| 1649 | hdd_debug("VHT RX LDPC capability is set"); |
| 1650 | } |
| 1651 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1652 | |
| 1653 | if (cfg->vht_short_gi_80 & WMI_VHT_CAP_SGI_80MHZ) |
| 1654 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_80; |
| 1655 | if (cfg->vht_short_gi_160 & WMI_VHT_CAP_SGI_160MHZ) |
| 1656 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SHORT_GI_160; |
| 1657 | |
| 1658 | if (cfg->vht_tx_stbc & WMI_VHT_CAP_TX_STBC) |
| 1659 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_TXSTBC; |
| 1660 | |
| 1661 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_1SS) |
| 1662 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_1; |
| 1663 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_2SS) |
| 1664 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_2; |
| 1665 | if (cfg->vht_rx_stbc & WMI_VHT_CAP_RX_STBC_3SS) |
| 1666 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_RXSTBC_3; |
| 1667 | |
| 1668 | band_5g->vht_cap.cap |= |
| 1669 | (cfg->vht_max_ampdu_len_exp << |
| 1670 | IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT); |
| 1671 | |
| 1672 | if (cfg->vht_su_bformer & WMI_VHT_CAP_SU_BFORMER) |
| 1673 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE; |
| 1674 | if (cfg->vht_su_bformee & WMI_VHT_CAP_SU_BFORMEE) |
| 1675 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE; |
| 1676 | if (cfg->vht_mu_bformer & WMI_VHT_CAP_MU_BFORMER) |
| 1677 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE; |
| 1678 | if (cfg->vht_mu_bformee & WMI_VHT_CAP_MU_BFORMEE) |
| 1679 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE; |
| 1680 | |
| 1681 | if (cfg->vht_txop_ps & WMI_VHT_CAP_TXOP_PS) |
| 1682 | band_5g->vht_cap.cap |= IEEE80211_VHT_CAP_VHT_TXOP_PS; |
| 1683 | |
| 1684 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1685 | |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1686 | /** |
| 1687 | * hdd_generate_macaddr_auto() - Auto-generate mac address |
| 1688 | * @hdd_ctx: Pointer to the HDD context |
| 1689 | * |
| 1690 | * Auto-generate mac address using device serial number. |
| 1691 | * Keep the first 3 bytes of OUI as before and replace |
| 1692 | * the last 3 bytes with the lower 3 bytes of serial number. |
| 1693 | * |
| 1694 | * Return: 0 for success |
| 1695 | * Non zero failure code for errors |
| 1696 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 1697 | static int hdd_generate_macaddr_auto(struct hdd_context *hdd_ctx) |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1698 | { |
| 1699 | unsigned int serialno = 0; |
| 1700 | struct qdf_mac_addr mac_addr = { |
| 1701 | {0x00, 0x0A, 0xF5, 0x00, 0x00, 0x00} |
| 1702 | }; |
| 1703 | |
Yuanyuan Liu | f97e822 | 2016-09-21 10:31:38 -0700 | [diff] [blame] | 1704 | serialno = pld_socinfo_get_serial_number(hdd_ctx->parent_dev); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1705 | if (serialno == 0) |
| 1706 | return -EINVAL; |
| 1707 | |
| 1708 | serialno &= 0x00ffffff; |
| 1709 | |
| 1710 | mac_addr.bytes[3] = (serialno >> 16) & 0xff; |
| 1711 | mac_addr.bytes[4] = (serialno >> 8) & 0xff; |
| 1712 | mac_addr.bytes[5] = serialno & 0xff; |
| 1713 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1714 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
Yuanyuan Liu | 5bdfad7 | 2016-07-21 10:33:04 -0700 | [diff] [blame] | 1715 | return 0; |
| 1716 | } |
| 1717 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1718 | static void hdd_sar_target_config(struct hdd_context *hdd_ctx, |
| 1719 | struct wma_tgt_cfg *cfg) |
| 1720 | { |
| 1721 | hdd_ctx->sar_version = cfg->sar_version; |
| 1722 | } |
| 1723 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1724 | static void hdd_update_vhtcap_2g(struct hdd_context *hdd_ctx) |
| 1725 | { |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1726 | uint32_t chip_mode = 0; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1727 | QDF_STATUS status; |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1728 | bool b2g_vht_cfg = false; |
| 1729 | bool b2g_vht_target = false; |
| 1730 | struct wma_caps_per_phy caps_per_phy; |
| 1731 | struct wmi_unified *wmi_handle; |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1732 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1733 | wmi_handle = get_wmi_unified_hdl_from_psoc(hdd_ctx->psoc); |
| 1734 | if (!wmi_handle) { |
| 1735 | hdd_err("wmi handle is NULL"); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1736 | return; |
| 1737 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1738 | |
| 1739 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &b2g_vht_cfg); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1740 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1741 | hdd_err("Failed to get 2g vht mode"); |
| 1742 | return; |
| 1743 | } |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1744 | if (wmi_service_enabled(wmi_handle, wmi_service_ext_msg)) { |
| 1745 | status = wma_get_caps_for_phyidx_hwmode(&caps_per_phy, |
| 1746 | HW_MODE_DBS_NONE, |
| 1747 | CDS_BAND_ALL); |
| 1748 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1749 | hdd_err("Failed to get phy caps"); |
| 1750 | return; |
| 1751 | } |
| 1752 | if (caps_per_phy.vht_2g) |
| 1753 | b2g_vht_target = true; |
| 1754 | } else { |
| 1755 | status = wlan_reg_get_chip_mode(hdd_ctx->pdev, &chip_mode); |
| 1756 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1757 | hdd_err("Failed to get chip mode"); |
| 1758 | return; |
| 1759 | } |
| 1760 | b2g_vht_target = |
| 1761 | (chip_mode & WMI_HOST_REGDMN_MODE_11AC_VHT20_2G) ? |
| 1762 | true : false; |
| 1763 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1764 | |
Jianmin Zhu | 2f9e753 | 2019-01-21 15:39:50 +0800 | [diff] [blame] | 1765 | b2g_vht_cfg = b2g_vht_cfg && b2g_vht_target; |
| 1766 | hdd_debug("vht 2g target: %d, cfg: %d", b2g_vht_target, b2g_vht_cfg); |
| 1767 | status = ucfg_mlme_set_vht_for_24ghz(hdd_ctx->psoc, b2g_vht_cfg); |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1768 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1769 | hdd_err("Failed to update 2g vht mode"); |
| 1770 | return; |
| 1771 | } |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 1772 | } |
| 1773 | |
Jeff Johnson | 8abc593 | 2018-06-02 22:51:37 -0700 | [diff] [blame] | 1774 | 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] | 1775 | { |
Rajeev Kumar | f49dfdb | 2017-01-13 15:40:35 -0800 | [diff] [blame] | 1776 | int ret; |
Jeff Johnson | ea70b94 | 2018-07-02 09:42:31 -0700 | [diff] [blame] | 1777 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1778 | uint8_t temp_band_cap, band_capability; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1779 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1780 | uint8_t antenna_mode; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1781 | uint8_t sub_20_chan_width; |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1782 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 1783 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1784 | bool bval = false; |
| 1785 | uint8_t value = 0; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1786 | uint32_t fine_time_meas_cap = 0; |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1787 | enum nss_chains_band_info band; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1788 | |
gaurank kathpalia | 843f7c3 | 2018-07-02 18:04:14 +0530 | [diff] [blame] | 1789 | if (!hdd_ctx) { |
| 1790 | hdd_err("HDD context is NULL"); |
| 1791 | return; |
| 1792 | } |
Dustin Brown | bd68fe1 | 2017-11-21 15:28:52 -0800 | [diff] [blame] | 1793 | ret = hdd_objmgr_create_and_store_pdev(hdd_ctx); |
| 1794 | if (ret) { |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1795 | QDF_DEBUG_PANIC("Failed to create pdev; errno:%d", ret); |
| 1796 | return; |
| 1797 | } |
| 1798 | |
| 1799 | hdd_debug("New pdev has been created with pdev_id = %u", |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1800 | hdd_ctx->pdev->pdev_objmgr.wlan_pdev_id); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1801 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1802 | status = dispatcher_pdev_open(hdd_ctx->pdev); |
Dustin Brown | 64204d2 | 2018-08-15 16:35:19 -0700 | [diff] [blame] | 1803 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1804 | QDF_DEBUG_PANIC("dispatcher pdev open failed; status:%d", |
| 1805 | status); |
| 1806 | return; |
Selvaraj, Sridhar | 0672a12 | 2016-12-29 16:11:48 +0530 | [diff] [blame] | 1807 | } |
Kiran Kumar Lokere | a3de226 | 2017-04-12 12:15:04 -0700 | [diff] [blame] | 1808 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 1809 | status = hdd_component_pdev_open(hdd_ctx->pdev); |
| 1810 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1811 | QDF_DEBUG_PANIC("hdd component pdev open failed; status:%d", |
| 1812 | status); |
| 1813 | return; |
| 1814 | } |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1815 | cdp_pdev_set_ctrl_pdev(cds_get_context(QDF_MODULE_ID_SOC), |
| 1816 | cds_get_context(QDF_MODULE_ID_TXRX), |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1817 | (struct cdp_ctrl_objmgr_pdev *)hdd_ctx->pdev); |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1818 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1819 | wlan_pdev_set_dp_handle(hdd_ctx->pdev, |
Sravan Kumar Kairam | cb5fd01 | 2018-07-04 17:43:22 +0530 | [diff] [blame] | 1820 | cds_get_context(QDF_MODULE_ID_TXRX)); |
| 1821 | |
Will Huang | 0724417 | 2018-05-14 14:23:30 +0800 | [diff] [blame] | 1822 | hdd_objmgr_update_tgt_max_vdev_psoc(hdd_ctx, cfg->max_intf_count); |
| 1823 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1824 | ucfg_ipa_set_dp_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1825 | cds_get_context(QDF_MODULE_ID_SOC)); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 1826 | ucfg_ipa_set_txrx_handle(hdd_ctx->psoc, |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1827 | cds_get_context(QDF_MODULE_ID_TXRX)); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1828 | ucfg_ipa_reg_sap_xmit_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1829 | hdd_softap_hard_start_xmit); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 1830 | ucfg_ipa_reg_send_to_nw_cb(hdd_ctx->pdev, |
Sravan Kumar Kairam | 858073b | 2018-03-13 09:03:32 +0530 | [diff] [blame] | 1831 | hdd_ipa_send_skb_to_network); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 1832 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1833 | status = ucfg_mlme_get_sub_20_chan_width(hdd_ctx->psoc, |
| 1834 | &sub_20_chan_width); |
| 1835 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1836 | hdd_err("Failed to get sub_20_chan_width config"); |
| 1837 | return; |
| 1838 | } |
| 1839 | |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1840 | if (cds_cfg) { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1841 | if (sub_20_chan_width != |
| 1842 | WLAN_SUB_20_CH_WIDTH_NONE && !cfg->sub_20_support) { |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1843 | hdd_err("User requested sub 20 MHz channel width but unsupported by FW."); |
| 1844 | cds_cfg->sub_20_channel_width = |
| 1845 | WLAN_SUB_20_CH_WIDTH_NONE; |
| 1846 | } else { |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 1847 | cds_cfg->sub_20_channel_width = sub_20_chan_width; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 1848 | } |
| 1849 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1850 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1851 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 1852 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1853 | hdd_err("Failed to get MLME band capability"); |
| 1854 | return; |
| 1855 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1856 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1857 | /* first store the INI band capability */ |
| 1858 | temp_band_cap = band_capability; |
| 1859 | |
| 1860 | band_capability = cfg->band_cap; |
Vignesh Viswanathan | 731186f | 2017-09-18 13:47:37 +0530 | [diff] [blame] | 1861 | hdd_ctx->is_fils_roaming_supported = |
| 1862 | cfg->services.is_fils_roaming_supported; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1863 | |
Vignesh Viswanathan | 694e28e | 2018-01-18 20:53:57 +0530 | [diff] [blame] | 1864 | hdd_ctx->config->is_11k_offload_supported = |
| 1865 | cfg->services.is_11k_offload_supported; |
| 1866 | |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 1867 | /* |
| 1868 | * now overwrite the target band capability with INI |
| 1869 | * setting if INI setting is a subset |
| 1870 | */ |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1871 | if ((band_capability == BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1872 | (temp_band_cap != BAND_ALL)) |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1873 | band_capability = temp_band_cap; |
| 1874 | else if ((band_capability != BAND_ALL) && |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1875 | (temp_band_cap != BAND_ALL) && |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1876 | (band_capability != temp_band_cap)) { |
Jeff Johnson | b8969cb | 2016-08-15 12:38:19 -0700 | [diff] [blame] | 1877 | hdd_warn("ini BandCapability not supported by the target"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1878 | } |
| 1879 | |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 1880 | status = ucfg_mlme_set_band_capability(hdd_ctx->psoc, band_capability); |
| 1881 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1882 | hdd_err("Failed to set MLME Band Capability"); |
| 1883 | return; |
| 1884 | } |
| 1885 | |
| 1886 | hdd_ctx->curr_band = band_capability; |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 1887 | |
Qun Zhang | 043635a | 2019-02-27 15:19:29 +0800 | [diff] [blame] | 1888 | status = wlan_hdd_update_wiphy_supported_band(hdd_ctx); |
| 1889 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1890 | hdd_err("Failed to update wiphy band info"); |
| 1891 | return; |
| 1892 | } |
| 1893 | |
Hanumanth Reddy Pothula | 2a8a740 | 2017-07-03 14:06:11 +0530 | [diff] [blame] | 1894 | if (!cds_is_driver_recovering() || cds_is_driver_in_bad_state()) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1895 | hdd_ctx->reg.reg_domain = cfg->reg_domain; |
| 1896 | hdd_ctx->reg.eeprom_rd_ext = cfg->eeprom_rd_ext; |
| 1897 | } |
| 1898 | |
| 1899 | /* This can be extended to other configurations like ht, vht cap... */ |
| 1900 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 1901 | if (!qdf_is_macaddr_zero(&cfg->hw_macaddr)) |
| 1902 | qdf_mem_copy(&hdd_ctx->hw_macaddr, &cfg->hw_macaddr, |
| 1903 | QDF_MAC_ADDR_SIZE); |
| 1904 | else |
| 1905 | hdd_info("hw_mac is zero"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1906 | |
| 1907 | hdd_ctx->target_fw_version = cfg->target_fw_version; |
Sandeep Puligilla | 3d6a8e2 | 2016-10-11 18:57:14 -0700 | [diff] [blame] | 1908 | hdd_ctx->target_fw_vers_ext = cfg->target_fw_vers_ext; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1909 | |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 1910 | hdd_ctx->hw_bd_id = cfg->hw_bd_id; |
| 1911 | qdf_mem_copy(&hdd_ctx->hw_bd_info, &cfg->hw_bd_info, |
| 1912 | sizeof(cfg->hw_bd_info)); |
| 1913 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1914 | if (cfg->max_intf_count > WLAN_MAX_VDEVS) { |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1915 | hdd_err("fw max vdevs (%u) > host max vdevs (%u); using %u", |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 1916 | cfg->max_intf_count, WLAN_MAX_VDEVS, WLAN_MAX_VDEVS); |
| 1917 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 1918 | } else { |
| 1919 | hdd_ctx->max_intf_count = cfg->max_intf_count; |
| 1920 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1921 | |
Jeff Johnson | f917638 | 2018-07-17 19:15:58 -0700 | [diff] [blame] | 1922 | hdd_sar_target_config(hdd_ctx, cfg); |
Jeff Johnson | c875e24 | 2016-09-23 18:12:34 -0700 | [diff] [blame] | 1923 | hdd_lpass_target_config(hdd_ctx, cfg); |
Ryan Hsu | 3c8f79f | 2015-12-02 16:45:09 -0800 | [diff] [blame] | 1924 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1925 | hdd_ctx->ap_arpns_support = cfg->ap_arpns_support; |
| 1926 | hdd_update_tgt_services(hdd_ctx, &cfg->services); |
| 1927 | |
| 1928 | hdd_update_tgt_ht_cap(hdd_ctx, &cfg->ht_cap); |
| 1929 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1930 | hdd_update_tgt_vht_cap(hdd_ctx, &cfg->vht_cap); |
Krishna Kumaar Natarajan | ed1efd9 | 2016-09-24 18:05:47 -0700 | [diff] [blame] | 1931 | if (cfg->services.en_11ax) { |
| 1932 | hdd_info("11AX: 11ax is enabled - update HDD config"); |
| 1933 | hdd_update_tgt_he_cap(hdd_ctx, cfg); |
| 1934 | } |
Varun Reddy Yeturu | e93d246 | 2018-05-22 13:54:52 -0700 | [diff] [blame] | 1935 | hdd_update_tgt_twt_cap(hdd_ctx, cfg); |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1936 | |
gaurank kathpalia | fa7ad0a | 2019-03-12 19:17:56 +0530 | [diff] [blame] | 1937 | for (band = NSS_CHAINS_BAND_2GHZ; band < NSS_CHAINS_BAND_MAX; band++) { |
| 1938 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1939 | QDF_STA_MODE, band); |
| 1940 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1941 | QDF_SAP_MODE, band); |
| 1942 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1943 | QDF_TDLS_MODE, band); |
| 1944 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1945 | QDF_P2P_DEVICE_MODE, |
| 1946 | band); |
| 1947 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1948 | QDF_OCB_MODE, band); |
| 1949 | sme_modify_nss_chains_tgt_cfg(hdd_ctx->mac_handle, |
| 1950 | QDF_TDLS_MODE, band); |
| 1951 | } |
| 1952 | |
Tushnim Bhattacharyya | f44a9d8 | 2016-07-05 10:52:06 -0700 | [diff] [blame] | 1953 | hdd_update_vdev_nss(hdd_ctx); |
| 1954 | |
gaurank kathpalia | 5fcefa9 | 2018-10-24 15:03:15 +0530 | [diff] [blame] | 1955 | hdd_ctx->dynamic_nss_chains_support = |
| 1956 | cfg->dynamic_nss_chains_support; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1957 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, &fine_time_meas_cap); |
| 1958 | fine_time_meas_cap &= cfg->fine_time_measurement_cap; |
| 1959 | status = ucfg_mlme_set_fine_time_meas_cap(hdd_ctx->psoc, |
| 1960 | fine_time_meas_cap); |
| 1961 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1962 | hdd_err("failed to set fine_time_meas_cap, 0x%x, ox%x", |
| 1963 | fine_time_meas_cap, cfg->fine_time_measurement_cap); |
| 1964 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 1965 | &fine_time_meas_cap); |
| 1966 | } |
| 1967 | |
Krunal Soni | e353194 | 2016-04-12 17:43:53 -0700 | [diff] [blame] | 1968 | hdd_ctx->fine_time_meas_cap_target = cfg->fine_time_measurement_cap; |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 1969 | hdd_debug("fine_time_meas_cap: 0x%x", fine_time_meas_cap); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1970 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1971 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 1972 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 1973 | hdd_err("unable to get vht_enable2x2"); |
| 1974 | |
| 1975 | antenna_mode = (bval == 0x01) ? |
Nitesh Shah | e50711f | 2017-04-26 16:30:45 +0530 | [diff] [blame] | 1976 | HDD_ANTENNA_MODE_2X2 : HDD_ANTENNA_MODE_1X1; |
| 1977 | hdd_update_smps_antenna_mode(hdd_ctx, antenna_mode); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 1978 | hdd_debug("Init current antenna mode: %d", |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1979 | hdd_ctx->current_antenna_mode); |
Archana Ramachandran | 393f379 | 2015-11-13 17:13:21 -0800 | [diff] [blame] | 1980 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 1981 | hdd_ctx->rcpi_enabled = cfg->rcpi_enabled; |
Arun Khandavalli | 3dd06de | 2016-08-17 10:20:29 +0530 | [diff] [blame] | 1982 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1983 | status = ucfg_mlme_cfg_get_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
Abhinav Kumar | e057b41 | 2018-10-09 17:28:16 +0530 | [diff] [blame] | 1984 | &value); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1985 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1986 | status = false; |
| 1987 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1988 | } |
| 1989 | |
| 1990 | if ((value > |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 1991 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF) && |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 1992 | !cfg->tx_bfee_8ss_enabled) { |
| 1993 | status = |
| 1994 | ucfg_mlme_cfg_set_vht_tx_bfee_ant_supp(hdd_ctx->psoc, |
| 1995 | WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED_FW_DEF); |
| 1996 | if (QDF_IS_STATUS_ERROR(status)) { |
| 1997 | status = false; |
| 1998 | hdd_err("set tx_bfee_ant_supp failed"); |
| 1999 | } |
| 2000 | } |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2001 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 2002 | mac_handle = hdd_ctx->mac_handle; |
Nachiket Kukade | 8b4bfd8 | 2017-05-25 18:34:48 +0530 | [diff] [blame] | 2003 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 2004 | hdd_debug("txBFCsnValue %d", value); |
Nachiket Kukade | 33c34e3 | 2017-07-07 18:45:04 +0530 | [diff] [blame] | 2005 | |
| 2006 | /* |
| 2007 | * Update txBFCsnValue and NumSoundingDim values to vhtcap in wiphy |
| 2008 | */ |
| 2009 | hdd_update_wiphy_vhtcap(hdd_ctx); |
Manjeet Singh | 70d3d93 | 2016-12-20 20:41:10 +0530 | [diff] [blame] | 2010 | |
Jianmin Zhu | c8bfffb | 2019-01-15 12:40:03 +0800 | [diff] [blame] | 2011 | hdd_update_vhtcap_2g(hdd_ctx); |
| 2012 | |
Rajeev Kumar Sirasanagandla | 4787300 | 2016-09-09 13:46:09 +0530 | [diff] [blame] | 2013 | hdd_ctx->wmi_max_len = cfg->wmi_max_len; |
| 2014 | |
Ashish Kumar Dhanotiya | 908925d | 2019-03-01 17:35:30 +0530 | [diff] [blame] | 2015 | wlan_config_sched_scan_plans_to_wiphy(hdd_ctx->wiphy, hdd_ctx->psoc); |
Yue Ma | cd359b7 | 2017-10-03 15:21:00 -0700 | [diff] [blame] | 2016 | /* |
| 2017 | * This needs to be done after HDD pdev is created and stored since |
| 2018 | * it will access the HDD pdev object lock. |
| 2019 | */ |
| 2020 | hdd_runtime_suspend_context_init(hdd_ctx); |
| 2021 | |
Deepak Dhamdhere | 13230d3 | 2016-05-26 00:46:53 -0700 | [diff] [blame] | 2022 | /* Configure NAN datapath features */ |
| 2023 | hdd_nan_datapath_target_config(hdd_ctx, cfg); |
Nachiket Kukade | 85aa378 | 2018-11-02 20:12:34 +0530 | [diff] [blame] | 2024 | ucfg_nan_set_tgt_caps(hdd_ctx->psoc, &cfg->nan_caps); |
Arif Hussain | 759a023 | 2017-03-20 13:17:18 -0700 | [diff] [blame] | 2025 | hdd_ctx->dfs_cac_offload = cfg->dfs_cac_offload; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 2026 | hdd_ctx->lte_coex_ant_share = cfg->services.lte_coex_ant_share; |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 2027 | hdd_ctx->obss_scan_offload = cfg->services.obss_scan_offload; |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2028 | status = ucfg_mlme_set_obss_detection_offload_enabled( |
| 2029 | hdd_ctx->psoc, cfg->obss_detection_offloaded); |
Arif Hussain | ee10f90 | 2017-12-27 16:30:17 -0800 | [diff] [blame] | 2030 | if (QDF_IS_STATUS_ERROR(status)) |
| 2031 | hdd_err("Couldn't pass WNI_CFG_OBSS_DETECTION_OFFLOAD to CFG"); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2032 | |
Wu Gao | 5f76408 | 2019-01-04 15:54:38 +0800 | [diff] [blame] | 2033 | status = ucfg_mlme_set_obss_color_collision_offload_enabled( |
| 2034 | hdd_ctx->psoc, cfg->obss_color_collision_offloaded); |
Arif Hussain | 05fb487 | 2018-01-03 16:02:55 -0800 | [diff] [blame] | 2035 | if (QDF_IS_STATUS_ERROR(status)) |
| 2036 | hdd_err("Failed to set WNI_CFG_OBSS_COLOR_COLLISION_OFFLOAD"); |
Arif Hussain | 5068908 | 2019-03-26 12:07:58 -0700 | [diff] [blame] | 2037 | |
| 2038 | ucfg_mlme_get_bcast_twt(hdd_ctx->psoc, &bval); |
| 2039 | if (bval) |
| 2040 | ucfg_mlme_set_bcast_twt(hdd_ctx->psoc, cfg->bcast_twt_support); |
| 2041 | else |
| 2042 | hdd_debug("bcast twt is disable in ini, fw cap %d", |
| 2043 | cfg->bcast_twt_support); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2044 | } |
| 2045 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2046 | bool hdd_dfs_indicate_radar(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2047 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2048 | struct hdd_adapter *adapter; |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 2049 | struct hdd_ap_ctx *ap_ctx; |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2050 | bool dfs_disable_channel_switch = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2051 | |
Jiachao Wu | f610d91 | 2018-01-23 17:47:32 +0800 | [diff] [blame] | 2052 | if (!hdd_ctx) { |
| 2053 | hdd_info("Couldn't get hdd_ctx"); |
| 2054 | return true; |
| 2055 | } |
| 2056 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2057 | ucfg_mlme_get_dfs_disable_channel_switch(hdd_ctx->psoc, |
| 2058 | &dfs_disable_channel_switch); |
| 2059 | if (dfs_disable_channel_switch) { |
Jeff Johnson | 36e74c4 | 2017-09-18 08:15:42 -0700 | [diff] [blame] | 2060 | hdd_info("skip tx block hdd_ctx=%pK, disableDFSChSwitch=%d", |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 2061 | hdd_ctx, dfs_disable_channel_switch); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2062 | return true; |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2063 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2064 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 2065 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2066 | ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 2067 | |
| 2068 | if ((QDF_SAP_MODE == adapter->device_mode || |
| 2069 | QDF_P2P_GO_MODE == adapter->device_mode) && |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 2070 | (wlan_reg_is_passive_or_disable_ch(hdd_ctx->pdev, |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 2071 | ap_ctx->operating_channel))) { |
Arif Hussain | cd15163 | 2017-02-11 16:57:19 -0800 | [diff] [blame] | 2072 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->dfs_cac_block_tx = |
| 2073 | true; |
Jeff Johnson | 7eb6e84 | 2019-02-23 14:33:34 -0800 | [diff] [blame] | 2074 | hdd_info("tx blocked for vdev: %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2075 | adapter->vdev_id); |
bings | 6fb9bf6 | 2018-07-05 14:01:53 +0800 | [diff] [blame] | 2076 | if (adapter->txrx_vdev) |
| 2077 | cdp_fc_vdev_flush( |
| 2078 | cds_get_context(QDF_MODULE_ID_SOC), |
bings | 0e03a98 | 2018-05-09 08:40:59 +0800 | [diff] [blame] | 2079 | adapter->txrx_vdev); |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2080 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2081 | } |
Edhar, Mahesh Kumar | 695468e | 2015-10-19 12:06:20 +0530 | [diff] [blame] | 2082 | |
| 2083 | return true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2084 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2085 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2086 | bool hdd_is_valid_mac_address(const uint8_t *mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2087 | { |
| 2088 | int xdigit = 0; |
| 2089 | int separator = 0; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 2090 | |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2091 | while (*mac_addr) { |
| 2092 | if (isxdigit(*mac_addr)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2093 | xdigit++; |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2094 | } else if (':' == *mac_addr) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2095 | if (0 == xdigit || ((xdigit / 2) - 1) != separator) |
| 2096 | break; |
| 2097 | |
| 2098 | ++separator; |
| 2099 | } else { |
| 2100 | /* Invalid MAC found */ |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2101 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2102 | } |
Jeff Johnson | 030cd90 | 2018-11-11 10:19:40 -0800 | [diff] [blame] | 2103 | ++mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 2104 | } |
| 2105 | return xdigit == 12 && (separator == 5 || separator == 0); |
| 2106 | } |
| 2107 | |
| 2108 | /** |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2109 | * hdd_mon_mode_ether_setup() - Update monitor mode struct net_device. |
| 2110 | * @dev: Handle to struct net_device to be updated. |
| 2111 | * |
| 2112 | * Return: None |
| 2113 | */ |
| 2114 | static void hdd_mon_mode_ether_setup(struct net_device *dev) |
| 2115 | { |
| 2116 | dev->header_ops = NULL; |
| 2117 | dev->type = ARPHRD_IEEE80211_RADIOTAP; |
| 2118 | dev->hard_header_len = ETH_HLEN; |
| 2119 | dev->mtu = ETH_DATA_LEN; |
| 2120 | dev->addr_len = ETH_ALEN; |
| 2121 | dev->tx_queue_len = 1000; /* Ethernet wants good queues */ |
| 2122 | dev->flags = IFF_BROADCAST|IFF_MULTICAST; |
| 2123 | dev->priv_flags |= IFF_TX_SKB_SHARING; |
| 2124 | |
| 2125 | memset(dev->broadcast, 0xFF, ETH_ALEN); |
| 2126 | } |
| 2127 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2128 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2129 | /** |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2130 | * hdd_mon_turn_off_ps_and_wow() - Update monitor mode struct net_device. |
| 2131 | * @hdd_ctx: Pointer to HDD context. |
| 2132 | * |
| 2133 | * Return: None |
| 2134 | */ |
| 2135 | static void hdd_mon_turn_off_ps_and_wow(struct hdd_context *hdd_ctx) |
| 2136 | { |
| 2137 | ucfg_pmo_set_power_save_mode(hdd_ctx->psoc, PS_NOT_SUPPORTED); |
| 2138 | ucfg_pmo_set_wow_enable(hdd_ctx->psoc, PMO_WOW_DISABLE_BOTH); |
| 2139 | } |
| 2140 | |
| 2141 | /** |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2142 | * __hdd__mon_open() - HDD Open function |
| 2143 | * @dev: Pointer to net_device structure |
| 2144 | * |
| 2145 | * This is called in response to ifconfig up |
| 2146 | * |
| 2147 | * Return: 0 for success; non-zero for failure |
| 2148 | */ |
| 2149 | static int __hdd_mon_open(struct net_device *dev) |
| 2150 | { |
| 2151 | int ret; |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2152 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 2153 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2154 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2155 | hdd_enter_dev(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2156 | |
| 2157 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 2158 | if (ret) |
| 2159 | return ret; |
| 2160 | |
Arun Khandavalli | f5c0e0c | 2016-09-07 20:39:21 +0530 | [diff] [blame] | 2161 | hdd_mon_mode_ether_setup(dev); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2162 | |
| 2163 | if (con_mode == QDF_GLOBAL_MONITOR_MODE) { |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 2164 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2165 | if (ret) { |
| 2166 | hdd_err("Failed to start WLAN modules return"); |
| 2167 | return ret; |
| 2168 | } |
| 2169 | hdd_err("hdd_wlan_start_modules() successful !"); |
| 2170 | |
| 2171 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 2172 | ret = hdd_start_adapter(adapter); |
| 2173 | if (ret) { |
| 2174 | hdd_err("Failed to start adapter :%d", |
| 2175 | adapter->device_mode); |
| 2176 | return ret; |
| 2177 | } |
| 2178 | hdd_err("hdd_start_adapters() successful !"); |
| 2179 | } |
chenguo | 7130396 | 2018-10-24 19:44:34 +0800 | [diff] [blame] | 2180 | hdd_mon_turn_off_ps_and_wow(hdd_ctx); |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 2181 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 2182 | } |
| 2183 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2184 | ret = hdd_set_mon_rx_cb(dev); |
Ravi Joshi | 4f09595 | 2017-06-29 15:39:19 -0700 | [diff] [blame] | 2185 | |
| 2186 | if (!ret) |
| 2187 | ret = hdd_enable_monitor_mode(dev); |
| 2188 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2189 | return ret; |
| 2190 | } |
| 2191 | |
| 2192 | /** |
| 2193 | * hdd_mon_open() - Wrapper function for __hdd_mon_open to protect it from SSR |
| 2194 | * @dev: Pointer to net_device structure |
| 2195 | * |
| 2196 | * This is called in response to ifconfig up |
| 2197 | * |
| 2198 | * Return: 0 for success; non-zero for failure |
| 2199 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2200 | static int hdd_mon_open(struct net_device *net_dev) |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2201 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2202 | int errno; |
| 2203 | struct osif_vdev_sync *vdev_sync; |
| 2204 | |
| 2205 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 2206 | if (errno) |
| 2207 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2208 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2209 | errno = __hdd_mon_open(net_dev); |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2210 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 2211 | osif_vdev_sync_trans_stop(vdev_sync); |
| 2212 | |
| 2213 | return errno; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2214 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 2215 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2216 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2217 | static QDF_STATUS |
| 2218 | wlan_hdd_update_dbs_scan_and_fw_mode_config(void) |
| 2219 | { |
| 2220 | struct policy_mgr_dual_mac_config cfg = {0}; |
| 2221 | QDF_STATUS status; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2222 | uint32_t chnl_sel_logic_conc = 0; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2223 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2224 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2225 | |
| 2226 | if (!hdd_ctx) { |
| 2227 | hdd_err("HDD context is NULL"); |
| 2228 | return QDF_STATUS_E_FAILURE; |
| 2229 | } |
| 2230 | |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2231 | /* |
| 2232 | * ROME platform doesn't support any DBS related commands in FW, |
| 2233 | * so if driver sends wmi command with dual_mac_config with all set to |
| 2234 | * 0 then FW wouldn't respond back and driver would timeout on waiting |
| 2235 | * for response. Check if FW supports DBS to eliminate ROME vs |
| 2236 | * NON-ROME platform. |
| 2237 | */ |
| 2238 | if (!policy_mgr_find_if_fw_supports_dbs(hdd_ctx->psoc)) |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2239 | return QDF_STATUS_SUCCESS; |
| 2240 | |
| 2241 | cfg.scan_config = 0; |
| 2242 | cfg.fw_mode_config = 0; |
| 2243 | cfg.set_dual_mac_cb = policy_mgr_soc_set_dual_mac_cfg_cb; |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2244 | if (policy_mgr_is_hw_dbs_capable(hdd_ctx->psoc)) { |
| 2245 | status = |
| 2246 | ucfg_policy_mgr_get_chnl_select_plcy(hdd_ctx->psoc, |
| 2247 | &chnl_sel_logic_conc); |
| 2248 | if (status != QDF_STATUS_SUCCESS) { |
| 2249 | hdd_err("can't get chnl sel policy, use def"); |
| 2250 | return status; |
| 2251 | } |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2252 | } |
| 2253 | status = |
| 2254 | ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 2255 | &dual_mac_feature); |
| 2256 | if (status != QDF_STATUS_SUCCESS) { |
| 2257 | hdd_err("ucfg_policy_mgr_get_dual_mac_feature failed, use def"); |
| 2258 | return status; |
| 2259 | } |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2260 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2261 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2262 | status = policy_mgr_get_updated_scan_and_fw_mode_config( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2263 | hdd_ctx->psoc, &cfg.scan_config, |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2264 | &cfg.fw_mode_config, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 2265 | dual_mac_feature, |
Krunal Soni | e64b17e | 2018-12-13 16:00:02 -0800 | [diff] [blame] | 2266 | chnl_sel_logic_conc); |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2267 | |
| 2268 | if (status != QDF_STATUS_SUCCESS) { |
| 2269 | hdd_err("wma_get_updated_scan_and_fw_mode_config failed %d", |
| 2270 | status); |
| 2271 | return status; |
| 2272 | } |
| 2273 | } |
| 2274 | |
| 2275 | hdd_debug("send scan_cfg: 0x%x fw_mode_cfg: 0x%x to fw", |
| 2276 | cfg.scan_config, cfg.fw_mode_config); |
| 2277 | |
| 2278 | status = sme_soc_set_dual_mac_config(cfg); |
| 2279 | if (status != QDF_STATUS_SUCCESS) { |
| 2280 | hdd_err("sme_soc_set_dual_mac_config failed %d", status); |
| 2281 | return status; |
| 2282 | } |
| 2283 | |
| 2284 | return QDF_STATUS_SUCCESS; |
| 2285 | } |
| 2286 | |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 2287 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2288 | * hdd_start_adapter() - Wrapper function for device specific adapter |
| 2289 | * @adapter: pointer to HDD adapter |
| 2290 | * |
| 2291 | * This function is called to start the device specific adapter for |
| 2292 | * the mode passed in the adapter's device_mode. |
| 2293 | * |
| 2294 | * Return: 0 for success; non-zero for failure |
| 2295 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2296 | int hdd_start_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2297 | { |
| 2298 | |
| 2299 | int ret; |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 2300 | enum QDF_OPMODE device_mode = adapter->device_mode; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2301 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 2302 | hdd_enter_dev(adapter->dev); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 2303 | hdd_debug("Start_adapter for mode : %d", adapter->device_mode); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2304 | |
| 2305 | switch (device_mode) { |
| 2306 | case QDF_P2P_CLIENT_MODE: |
| 2307 | case QDF_P2P_DEVICE_MODE: |
| 2308 | case QDF_OCB_MODE: |
| 2309 | case QDF_STA_MODE: |
| 2310 | case QDF_MONITOR_MODE: |
| 2311 | ret = hdd_start_station_adapter(adapter); |
| 2312 | if (ret) |
| 2313 | goto err_start_adapter; |
Alok Kumar | 81e1d73 | 2018-09-04 11:10:36 +0530 | [diff] [blame] | 2314 | |
| 2315 | hdd_nud_ignore_tracking(adapter, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2316 | break; |
| 2317 | case QDF_P2P_GO_MODE: |
| 2318 | case QDF_SAP_MODE: |
| 2319 | ret = hdd_start_ap_adapter(adapter); |
| 2320 | if (ret) |
| 2321 | goto err_start_adapter; |
| 2322 | break; |
Arun Khandavalli | b2f6c26 | 2016-08-18 19:07:19 +0530 | [diff] [blame] | 2323 | case QDF_IBSS_MODE: |
| 2324 | /* |
| 2325 | * For IBSS interface is initialized as part of |
| 2326 | * hdd_init_station_mode() |
| 2327 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2328 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2329 | case QDF_FTM_MODE: |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2330 | /* vdevs are dynamically managed by firmware in FTM */ |
| 2331 | goto exit_with_success; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2332 | default: |
| 2333 | hdd_err("Invalid session type %d", device_mode); |
| 2334 | QDF_ASSERT(0); |
| 2335 | goto err_start_adapter; |
| 2336 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2337 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2338 | if (hdd_set_fw_params(adapter)) |
| 2339 | hdd_err("Failed to set the FW params for the adapter!"); |
| 2340 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 2341 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) { |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2342 | ret = wlan_hdd_cfg80211_register_frames(adapter); |
| 2343 | if (ret < 0) { |
| 2344 | hdd_err("Failed to register frames - ret %d", ret); |
| 2345 | goto err_start_adapter; |
| 2346 | } |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2347 | } |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2348 | |
Zhu Jianmin | 6a7b702 | 2018-03-10 21:42:21 +0800 | [diff] [blame] | 2349 | wlan_hdd_update_dbs_scan_and_fw_mode_config(); |
Ganesh Kondabattini | 0dc1a6e | 2017-07-29 12:59:19 +0530 | [diff] [blame] | 2350 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2351 | exit_with_success: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2352 | hdd_exit(); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2353 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2354 | return 0; |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 2355 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2356 | err_start_adapter: |
| 2357 | return -EINVAL; |
| 2358 | } |
| 2359 | |
| 2360 | /** |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2361 | * hdd_enable_power_management() - API to Enable Power Management |
| 2362 | * |
| 2363 | * API invokes Bus Interface Layer power management functionality |
| 2364 | * |
| 2365 | * Return: None |
| 2366 | */ |
| 2367 | static void hdd_enable_power_management(void) |
| 2368 | { |
| 2369 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2370 | |
| 2371 | if (!hif_ctx) { |
| 2372 | hdd_err("Bus Interface Context is Invalid"); |
| 2373 | return; |
| 2374 | } |
| 2375 | |
| 2376 | hif_enable_power_management(hif_ctx, cds_is_packet_log_enabled()); |
| 2377 | } |
| 2378 | |
| 2379 | /** |
| 2380 | * hdd_disable_power_management() - API to disable Power Management |
| 2381 | * |
| 2382 | * API disable Bus Interface Layer Power management functionality |
| 2383 | * |
| 2384 | * Return: None |
| 2385 | */ |
| 2386 | static void hdd_disable_power_management(void) |
| 2387 | { |
| 2388 | void *hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 2389 | |
| 2390 | if (!hif_ctx) { |
| 2391 | hdd_err("Bus Interface Context is Invalid"); |
| 2392 | return; |
| 2393 | } |
| 2394 | |
| 2395 | hif_disable_power_management(hif_ctx); |
| 2396 | } |
| 2397 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2398 | void hdd_update_hw_sw_info(struct hdd_context *hdd_ctx) |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2399 | { |
| 2400 | void *hif_sc; |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2401 | size_t target_hw_name_len; |
| 2402 | const char *target_hw_name; |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2403 | uint8_t *buf; |
| 2404 | uint32_t buf_len; |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2405 | |
| 2406 | hif_sc = cds_get_context(QDF_MODULE_ID_HIF); |
| 2407 | if (!hif_sc) { |
| 2408 | hdd_err("HIF context is NULL"); |
| 2409 | return; |
| 2410 | } |
| 2411 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2412 | hif_get_hw_info(hif_sc, &hdd_ctx->target_hw_version, |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2413 | &hdd_ctx->target_hw_revision, |
Dustin Brown | 6f17a02 | 2017-07-19 13:40:55 -0700 | [diff] [blame] | 2414 | &target_hw_name); |
| 2415 | |
| 2416 | if (hdd_ctx->target_hw_name) |
| 2417 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 2418 | |
| 2419 | target_hw_name_len = strlen(target_hw_name) + 1; |
| 2420 | hdd_ctx->target_hw_name = qdf_mem_malloc(target_hw_name_len); |
| 2421 | if (hdd_ctx->target_hw_name) |
| 2422 | qdf_mem_copy(hdd_ctx->target_hw_name, target_hw_name, |
| 2423 | target_hw_name_len); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2424 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2425 | buf = qdf_mem_malloc(WE_MAX_STR_LEN); |
| 2426 | if (buf) { |
| 2427 | buf_len = hdd_wlan_get_version(hdd_ctx, WE_MAX_STR_LEN, buf); |
| 2428 | hdd_info("%s", buf); |
| 2429 | qdf_mem_free(buf); |
| 2430 | } |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2431 | } |
| 2432 | |
| 2433 | /** |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2434 | * hdd_update_cds_ac_specs_params() - update cds ac_specs params |
| 2435 | * @hdd_ctx: Pointer to hdd context |
| 2436 | * |
| 2437 | * Return: none |
| 2438 | */ |
| 2439 | static void |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2440 | hdd_update_cds_ac_specs_params(struct hdd_context *hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2441 | { |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2442 | uint8_t tx_sched_wrr_param[TX_SCHED_WRR_PARAMS_NUM] = {0}; |
| 2443 | qdf_size_t out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2444 | int i; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 2445 | struct cds_context *cds_ctx; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2446 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2447 | if (!hdd_ctx) |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2448 | return; |
| 2449 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 2450 | if (!hdd_ctx->config) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2451 | /* Do nothing if hdd_ctx is invalid */ |
| 2452 | hdd_err("%s: Warning: hdd_ctx->cfg_ini is NULL", __func__); |
| 2453 | return; |
| 2454 | } |
| 2455 | |
| 2456 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 2457 | |
| 2458 | if (!cds_ctx) { |
| 2459 | hdd_err("Invalid CDS Context"); |
| 2460 | return; |
| 2461 | } |
| 2462 | |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2463 | for (i = 0; i < QCA_WLAN_AC_ALL; i++) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2464 | switch (i) { |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2465 | case QCA_WLAN_AC_BE: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2466 | qdf_uint8_array_parse( |
| 2467 | cfg_get(hdd_ctx->psoc, |
| 2468 | CFG_DP_ENABLE_TX_SCHED_WRR_BE), |
| 2469 | tx_sched_wrr_param, |
| 2470 | sizeof(tx_sched_wrr_param), |
| 2471 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2472 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2473 | case QCA_WLAN_AC_BK: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2474 | qdf_uint8_array_parse( |
| 2475 | cfg_get(hdd_ctx->psoc, |
| 2476 | CFG_DP_ENABLE_TX_SCHED_WRR_BK), |
| 2477 | tx_sched_wrr_param, |
| 2478 | sizeof(tx_sched_wrr_param), |
| 2479 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2480 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2481 | case QCA_WLAN_AC_VI: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2482 | qdf_uint8_array_parse( |
| 2483 | cfg_get(hdd_ctx->psoc, |
| 2484 | CFG_DP_ENABLE_TX_SCHED_WRR_VI), |
| 2485 | tx_sched_wrr_param, |
| 2486 | sizeof(tx_sched_wrr_param), |
| 2487 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2488 | break; |
Srinivas Girigowda | d462f3b | 2019-03-25 14:05:33 -0700 | [diff] [blame] | 2489 | case QCA_WLAN_AC_VO: |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2490 | qdf_uint8_array_parse( |
| 2491 | cfg_get(hdd_ctx->psoc, |
| 2492 | CFG_DP_ENABLE_TX_SCHED_WRR_VO), |
| 2493 | tx_sched_wrr_param, |
| 2494 | sizeof(tx_sched_wrr_param), |
| 2495 | &out_size); |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2496 | break; |
| 2497 | default: |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2498 | break; |
| 2499 | } |
| 2500 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2501 | if (out_size == TX_SCHED_WRR_PARAMS_NUM) { |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2502 | cds_ctx->ac_specs[i].wrr_skip_weight = |
| 2503 | tx_sched_wrr_param[0]; |
| 2504 | cds_ctx->ac_specs[i].credit_threshold = |
| 2505 | tx_sched_wrr_param[1]; |
| 2506 | cds_ctx->ac_specs[i].send_limit = |
| 2507 | tx_sched_wrr_param[2]; |
| 2508 | cds_ctx->ac_specs[i].credit_reserve = |
| 2509 | tx_sched_wrr_param[3]; |
| 2510 | cds_ctx->ac_specs[i].discard_weight = |
| 2511 | tx_sched_wrr_param[4]; |
| 2512 | } |
| 2513 | |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 2514 | out_size = 0; |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2515 | } |
| 2516 | } |
| 2517 | |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2518 | uint32_t hdd_wlan_get_version(struct hdd_context *hdd_ctx, |
| 2519 | const size_t version_len, uint8_t *version) |
| 2520 | { |
| 2521 | uint32_t size; |
| 2522 | uint32_t msp_id = 0, mspid = 0, siid = 0, crmid = 0, sub_id = 0; |
| 2523 | |
| 2524 | if (!hdd_ctx) { |
| 2525 | hdd_err("Invalid context, HDD context is null"); |
| 2526 | return 0; |
| 2527 | } |
| 2528 | |
Ashish Kumar Dhanotiya | 7353f88 | 2018-05-15 12:50:19 +0530 | [diff] [blame] | 2529 | if (!version || version_len == 0) { |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2530 | hdd_err("Invalid buffer pointr or buffer len\n"); |
| 2531 | return 0; |
| 2532 | } |
| 2533 | |
| 2534 | msp_id = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 2535 | mspid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 2536 | siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 2537 | crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 2538 | sub_id = (hdd_ctx->target_fw_vers_ext & 0xf0000000) >> 28; |
| 2539 | |
| 2540 | size = scnprintf(version, version_len, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2541 | "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] | 2542 | QWLAN_VERSIONSTR, |
| 2543 | msp_id, mspid, siid, crmid, sub_id, |
Ryan Hsu | c691855 | 2018-05-16 13:29:59 -0700 | [diff] [blame] | 2544 | hdd_ctx->target_hw_name, |
| 2545 | hdd_ctx->hw_bd_info.bdf_version, |
| 2546 | hdd_ctx->hw_bd_info.ref_design_id, |
| 2547 | hdd_ctx->hw_bd_info.customer_id, |
| 2548 | hdd_ctx->hw_bd_info.project_id, |
| 2549 | hdd_ctx->hw_bd_info.board_data_rev); |
Ryan Hsu | aadba07 | 2018-04-20 13:01:53 -0700 | [diff] [blame] | 2550 | |
| 2551 | return size; |
| 2552 | } |
| 2553 | |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2554 | int hdd_set_11ax_rate(struct hdd_adapter *adapter, int set_value, |
| 2555 | struct sap_config *sap_config) |
| 2556 | { |
| 2557 | uint8_t preamble = 0, nss = 0, rix = 0; |
| 2558 | int ret; |
| 2559 | mac_handle_t mac_handle = adapter->hdd_ctx->mac_handle; |
| 2560 | |
| 2561 | if (!sap_config) { |
| 2562 | if (!sme_is_feature_supported_by_fw(DOT11AX)) { |
| 2563 | hdd_err("Target does not support 11ax"); |
| 2564 | return -EIO; |
| 2565 | } |
| 2566 | } else if (sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax && |
| 2567 | sap_config->SapHw_mode != eCSR_DOT11_MODE_11ax_ONLY) { |
| 2568 | hdd_err("Invalid hw mode, SAP hw_mode= 0x%x, ch = %d", |
| 2569 | sap_config->SapHw_mode, sap_config->channel); |
| 2570 | return -EIO; |
| 2571 | } |
| 2572 | |
| 2573 | if (set_value != 0xff) { |
| 2574 | rix = RC_2_RATE_IDX_11AX(set_value); |
| 2575 | preamble = WMI_RATE_PREAMBLE_HE; |
| 2576 | nss = HT_RC_2_STREAMS_11AX(set_value); |
| 2577 | |
| 2578 | set_value = hdd_assemble_rate_code(preamble, nss, rix); |
| 2579 | } else { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2580 | ret = sme_set_auto_rate_he_ltf(mac_handle, adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2581 | QCA_WLAN_HE_LTF_AUTO); |
| 2582 | } |
| 2583 | |
| 2584 | hdd_info("SET_11AX_RATE val %d rix %d preamble %x nss %d", |
| 2585 | set_value, rix, preamble, nss); |
| 2586 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 2587 | ret = wma_cli_set_command(adapter->vdev_id, |
Rachit Kankane | 0dc3e85 | 2018-05-07 17:33:42 +0530 | [diff] [blame] | 2588 | WMI_VDEV_PARAM_FIXED_RATE, |
| 2589 | set_value, VDEV_CMD); |
| 2590 | |
| 2591 | return ret; |
| 2592 | } |
| 2593 | |
| 2594 | int hdd_assemble_rate_code(uint8_t preamble, uint8_t nss, uint8_t rate) |
| 2595 | { |
| 2596 | int set_value; |
| 2597 | |
| 2598 | if (sme_is_feature_supported_by_fw(DOT11AX)) |
| 2599 | set_value = WMI_ASSEMBLE_RATECODE_V1(rate, nss, preamble); |
| 2600 | else |
| 2601 | set_value = (preamble << 6) | (nss << 4) | rate; |
| 2602 | |
| 2603 | return set_value; |
| 2604 | } |
| 2605 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2606 | #ifdef FEATURE_WLAN_WAPI |
| 2607 | /** |
| 2608 | * hdd_wapi_security_sta_exist() - return wapi security sta exist or not |
| 2609 | * |
| 2610 | * This API returns the wapi security station exist or not |
| 2611 | * |
| 2612 | * Return: true - wapi security station exist |
| 2613 | */ |
| 2614 | static bool hdd_wapi_security_sta_exist(void) |
| 2615 | { |
| 2616 | struct hdd_adapter *adapter = NULL; |
| 2617 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2618 | |
| 2619 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2620 | if ((adapter->device_mode == QDF_STA_MODE) && |
| 2621 | adapter->wapi_info.wapi_mode && |
| 2622 | (adapter->wapi_info.wapi_auth_mode != WAPI_AUTH_MODE_OPEN)) |
| 2623 | return true; |
| 2624 | } |
| 2625 | return false; |
| 2626 | } |
| 2627 | #else |
| 2628 | static bool hdd_wapi_security_sta_exist(void) |
| 2629 | { |
| 2630 | return false; |
| 2631 | } |
| 2632 | #endif |
| 2633 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2634 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2635 | static enum policy_mgr_con_mode wlan_hdd_get_mode_for_non_connected_vdev( |
| 2636 | struct wlan_objmgr_psoc *psoc, uint8_t vdev_id) |
| 2637 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 2638 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 2639 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2640 | |
| 2641 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 2642 | if (!adapter) { |
| 2643 | hdd_err("Adapter is NULL"); |
| 2644 | return PM_MAX_NUM_OF_MODE; |
| 2645 | } |
| 2646 | |
| 2647 | return policy_mgr_convert_device_mode_to_qdf_type( |
| 2648 | adapter->device_mode); |
| 2649 | } |
| 2650 | |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2651 | /** |
| 2652 | * hdd_is_chan_switch_in_progress() - Check if any adapter has channel switch in |
| 2653 | * progress |
| 2654 | * |
| 2655 | * Return: true, if any adapter has channel switch in |
| 2656 | * progress else false |
| 2657 | */ |
| 2658 | static bool hdd_is_chan_switch_in_progress(void) |
| 2659 | { |
| 2660 | struct hdd_adapter *adapter = NULL; |
| 2661 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 2662 | |
| 2663 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 2664 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 2665 | adapter->device_mode == QDF_P2P_GO_MODE) && |
| 2666 | qdf_atomic_read(&adapter->ch_switch_in_progress)) { |
| 2667 | hdd_debug("channel switch progress for vdev_id %d", |
| 2668 | adapter->vdev_id); |
| 2669 | return true; |
| 2670 | } |
| 2671 | } |
| 2672 | |
| 2673 | return false; |
| 2674 | } |
| 2675 | |
| 2676 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2677 | static void hdd_register_policy_manager_callback( |
| 2678 | struct wlan_objmgr_psoc *psoc) |
| 2679 | { |
| 2680 | struct policy_mgr_hdd_cbacks hdd_cbacks; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 2681 | |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2682 | qdf_mem_zero(&hdd_cbacks, sizeof(hdd_cbacks)); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2683 | hdd_cbacks.sap_restart_chan_switch_cb = |
Jeff Johnson | 2381294 | 2017-10-06 11:33:55 -0700 | [diff] [blame] | 2684 | hdd_sap_restart_chan_switch_cb; |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2685 | hdd_cbacks.wlan_hdd_get_channel_for_sap_restart = |
| 2686 | wlan_hdd_get_channel_for_sap_restart; |
Tushnim Bhattacharyya | 9fb2e42 | 2017-03-23 09:49:10 -0700 | [diff] [blame] | 2687 | hdd_cbacks.get_mode_for_non_connected_vdev = |
| 2688 | wlan_hdd_get_mode_for_non_connected_vdev; |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 2689 | hdd_cbacks.hdd_get_device_mode = hdd_get_device_mode; |
Liangwei Dong | 3fa5cba | 2018-07-16 06:41:55 -0400 | [diff] [blame] | 2690 | hdd_cbacks.hdd_wapi_security_sta_exist = |
| 2691 | hdd_wapi_security_sta_exist; |
Abhishek Singh | 3bbf6cb | 2019-03-28 14:05:43 +0530 | [diff] [blame] | 2692 | hdd_cbacks.hdd_is_chan_switch_in_progress = |
| 2693 | hdd_is_chan_switch_in_progress; |
| 2694 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2695 | if (QDF_STATUS_SUCCESS != |
| 2696 | policy_mgr_register_hdd_cb(psoc, &hdd_cbacks)) { |
| 2697 | hdd_err("HDD callback registration with policy manager failed"); |
| 2698 | } |
| 2699 | } |
| 2700 | #else |
| 2701 | static void hdd_register_policy_manager_callback( |
| 2702 | struct wlan_objmgr_psoc *psoc) |
| 2703 | { |
| 2704 | } |
| 2705 | #endif |
| 2706 | |
Nachiket Kukade | 2fb1fdb | 2019-01-08 15:35:27 +0530 | [diff] [blame] | 2707 | #ifdef WLAN_FEATURE_NAN |
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; |
Naveen Rawat | b3143ea | 2017-03-26 22:25:46 -0700 | [diff] [blame] | 2720 | cb_obj.peer_departed_ind = hdd_ndp_peer_departed_handler; |
Naveen Rawat | 37f62c8 | 2017-03-26 22:24:43 -0700 | [diff] [blame] | 2721 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2722 | os_if_nan_register_hdd_callbacks(hdd_ctx->psoc, &cb_obj); |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2723 | } |
jiad | ff1ac13 | 2018-11-26 16:27:48 +0800 | [diff] [blame] | 2724 | #else |
| 2725 | static inline void hdd_nan_register_callbacks(struct hdd_context *hdd_ctx) |
| 2726 | { |
| 2727 | } |
| 2728 | #endif |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2729 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2730 | #ifdef CONFIG_LEAK_DETECTION |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2731 | /** |
| 2732 | * hdd_check_for_leaks() - Perform runtime memory leak checks |
Dustin Brown | a6246dd | 2018-05-24 14:35:58 -0700 | [diff] [blame] | 2733 | * @hdd_ctx: the global HDD context |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2734 | * @is_ssr: true if SSR is in progress |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2735 | * |
| 2736 | * This API triggers runtime memory leak detection. This feature enforces the |
| 2737 | * policy that any memory allocated at runtime must also be released at runtime. |
| 2738 | * |
| 2739 | * Allocating memory at runtime and releasing it at unload is effectively a |
| 2740 | * memory leak for configurations which never unload (e.g. LONU, statically |
| 2741 | * compiled driver). Such memory leaks are NOT false positives, and must be |
| 2742 | * fixed. |
| 2743 | * |
| 2744 | * Return: None |
| 2745 | */ |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2746 | static void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2747 | { |
Dustin Brown | 4c5b990 | 2017-12-19 11:17:19 -0800 | [diff] [blame] | 2748 | /* DO NOT REMOVE these checks; for false positives, read above first */ |
| 2749 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2750 | wlan_objmgr_psoc_check_for_peer_leaks(hdd_ctx->psoc); |
| 2751 | wlan_objmgr_psoc_check_for_vdev_leaks(hdd_ctx->psoc); |
| 2752 | wlan_objmgr_psoc_check_for_pdev_leaks(hdd_ctx->psoc); |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2753 | |
| 2754 | /* many adapter resources are not freed by design during SSR */ |
| 2755 | if (is_ssr) |
| 2756 | return; |
| 2757 | |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 2758 | qdf_delayed_work_check_for_leaks(); |
Dustin Brown | 677e086 | 2017-10-10 16:30:09 -0700 | [diff] [blame] | 2759 | qdf_mc_timer_check_for_leaks(); |
Dustin Brown | 8e71150 | 2017-12-07 16:49:11 -0800 | [diff] [blame] | 2760 | qdf_nbuf_map_check_for_leaks(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 2761 | qdf_periodic_work_check_for_leaks(); |
Dustin Brown | e6b9d5a | 2017-12-14 15:18:49 -0800 | [diff] [blame] | 2762 | qdf_mem_check_for_leaks(); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2763 | } |
| 2764 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2765 | #define hdd_debug_domain_set(domain) qdf_debug_domain_set(domain) |
| 2766 | #else |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 2767 | static inline void hdd_check_for_leaks(struct hdd_context *hdd_ctx, bool is_ssr) |
| 2768 | { } |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2769 | |
| 2770 | #define hdd_debug_domain_set(domain) |
| 2771 | #endif /* CONFIG_LEAK_DETECTION */ |
| 2772 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2773 | /** |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 2774 | * hdd_update_country_code - Update country code |
| 2775 | * @hdd_ctx: HDD context |
| 2776 | * |
| 2777 | * Update country code based on module parameter country_code |
| 2778 | * |
| 2779 | * Return: 0 on success and errno on failure |
| 2780 | */ |
| 2781 | static int hdd_update_country_code(struct hdd_context *hdd_ctx) |
| 2782 | { |
| 2783 | if (!country_code) |
| 2784 | return 0; |
| 2785 | |
| 2786 | return hdd_reg_set_country(hdd_ctx, country_code); |
| 2787 | } |
| 2788 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2789 | int hdd_wlan_start_modules(struct hdd_context *hdd_ctx, bool reinit) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2790 | { |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 2791 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2792 | qdf_device_t qdf_dev; |
| 2793 | QDF_STATUS status; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2794 | bool unint = false; |
| 2795 | void *hif_ctx; |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2796 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2797 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2798 | qdf_dev = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 2799 | if (!qdf_dev) { |
| 2800 | hdd_err("QDF Device Context is Invalid return"); |
| 2801 | return -EINVAL; |
| 2802 | } |
| 2803 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 2804 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2805 | |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2806 | if (hdd_ctx->driver_status == DRIVER_MODULES_ENABLED) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2807 | hdd_debug("Driver modules already Enabled"); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2808 | hdd_exit(); |
Arun Khandavalli | 5a62a82 | 2017-11-14 19:43:00 +0530 | [diff] [blame] | 2809 | return 0; |
| 2810 | } |
| 2811 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2812 | switch (hdd_ctx->driver_status) { |
| 2813 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2814 | hdd_info("Wlan transitioning (UNINITIALIZED -> CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2815 | unint = true; |
| 2816 | /* Fall through dont add break here */ |
| 2817 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2818 | hdd_info("Wlan transitioning (CLOSED -> ENABLED)"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2819 | |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 2820 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_ACTIVE); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 2821 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2822 | if (!reinit && !unint) { |
| 2823 | ret = pld_power_on(qdf_dev->dev); |
| 2824 | if (ret) { |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2825 | hdd_err("Failed to power up device; errno:%d", |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2826 | ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2827 | goto release_lock; |
| 2828 | } |
| 2829 | } |
Yuanyuan Liu | f8fe4bc | 2017-06-07 16:55:58 -0700 | [diff] [blame] | 2830 | |
| 2831 | pld_set_fw_log_mode(hdd_ctx->parent_dev, |
| 2832 | hdd_ctx->config->enable_fw_log); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2833 | ret = hdd_hif_open(qdf_dev->dev, qdf_dev->drv_hdl, qdf_dev->bid, |
| 2834 | qdf_dev->bus_type, |
| 2835 | (reinit == true) ? HIF_ENABLE_TYPE_REINIT : |
| 2836 | HIF_ENABLE_TYPE_PROBE); |
| 2837 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2838 | hdd_err("Failed to open hif; errno: %d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2839 | goto power_down; |
| 2840 | } |
| 2841 | |
| 2842 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2843 | if (!hif_ctx) { |
| 2844 | hdd_err("hif context is null!!"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2845 | ret = -EINVAL; |
Arun Khandavalli | 1318b99 | 2016-08-09 11:04:57 +0530 | [diff] [blame] | 2846 | goto power_down; |
| 2847 | } |
| 2848 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2849 | status = ol_cds_init(qdf_dev, hif_ctx); |
| 2850 | if (status != QDF_STATUS_SUCCESS) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2851 | hdd_err("No Memory to Create BMI Context; status: %d", |
| 2852 | status); |
| 2853 | ret = qdf_status_to_os_return(status); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2854 | goto hif_close; |
| 2855 | } |
| 2856 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 2857 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) { |
| 2858 | status = epping_open(); |
| 2859 | if (status) { |
| 2860 | hdd_err("Failed to open in epping mode: %d", |
| 2861 | status); |
| 2862 | ret = -EINVAL; |
| 2863 | goto cds_free; |
| 2864 | } |
| 2865 | |
| 2866 | status = epping_enable(qdf_dev->dev, false); |
| 2867 | if (status) { |
| 2868 | hdd_err("Failed to enable in epping mode : %d", |
| 2869 | status); |
| 2870 | epping_close(); |
| 2871 | goto cds_free; |
| 2872 | } |
| 2873 | |
| 2874 | hdd_info("epping mode enabled"); |
| 2875 | break; |
| 2876 | } |
| 2877 | |
jitiphil | 4c256a3 | 2018-09-07 08:51:52 +0530 | [diff] [blame] | 2878 | ucfg_ipa_component_config_update(hdd_ctx->psoc); |
Sravan Kumar Kairam | d01b445 | 2018-03-07 17:37:09 +0530 | [diff] [blame] | 2879 | |
gbian | 62edd7e | 2017-03-07 13:12:13 +0800 | [diff] [blame] | 2880 | hdd_update_cds_ac_specs_params(hdd_ctx); |
| 2881 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2882 | status = hdd_component_psoc_open(hdd_ctx->psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2883 | if (QDF_IS_STATUS_ERROR(status)) { |
| 2884 | hdd_err("Failed to Open legacy components; status: %d", |
| 2885 | status); |
| 2886 | ret = qdf_status_to_os_return(status); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 2887 | goto cds_free; |
| 2888 | } |
| 2889 | |
| 2890 | ret = hdd_update_config(hdd_ctx); |
| 2891 | if (ret) { |
| 2892 | hdd_err("Failed to update configuration; errno: %d", |
| 2893 | ret); |
| 2894 | goto cds_free; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 2895 | } |
| 2896 | |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 2897 | status = wbuff_module_init(); |
| 2898 | if (QDF_IS_STATUS_ERROR(status)) |
| 2899 | hdd_err("WBUFF init unsuccessful; status: %d", status); |
| 2900 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2901 | status = cds_open(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2902 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2903 | hdd_err("Failed to Open CDS; status: %d", status); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 2904 | ret = qdf_status_to_os_return(status); |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 2905 | goto psoc_close; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2906 | } |
| 2907 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 2908 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 2909 | |
Manjunathappa Prakash | b6b4ff1 | 2018-06-04 12:32:33 -0700 | [diff] [blame] | 2910 | if (hdd_ctx->config->rx_thread_affinity_mask) |
| 2911 | cds_set_rx_thread_cpu_mask( |
| 2912 | hdd_ctx->config->rx_thread_affinity_mask); |
| 2913 | |
| 2914 | /* initialize components configurations after psoc open */ |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2915 | ret = hdd_update_components_config(hdd_ctx); |
| 2916 | if (ret) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2917 | hdd_err("Failed to update component configs; errno: %d", |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2918 | ret); |
| 2919 | goto close; |
| 2920 | } |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2921 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2922 | status = cds_dp_open(hdd_ctx->psoc); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2923 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2924 | hdd_err("Failed to Open cds post open; status: %d", |
| 2925 | status); |
| 2926 | ret = qdf_status_to_os_return(status); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2927 | goto close; |
| 2928 | } |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 2929 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2930 | ret = hdd_register_cb(hdd_ctx); |
| 2931 | if (ret) { |
| 2932 | hdd_err("Failed to register HDD callbacks!"); |
| 2933 | goto cds_txrx_free; |
| 2934 | } |
| 2935 | |
Naveen Rawat | cb5c540 | 2017-03-22 10:12:19 -0700 | [diff] [blame] | 2936 | /* |
| 2937 | * NAN compoenet requires certian operations like, open adapter, |
| 2938 | * close adapter, etc. to be initiated by HDD, for those |
| 2939 | * register HDD callbacks with UMAC's NAN componenet. |
| 2940 | */ |
| 2941 | hdd_nan_register_callbacks(hdd_ctx); |
| 2942 | |
Jeff Johnson | 3a28012 | 2017-09-13 07:42:00 -0700 | [diff] [blame] | 2943 | status = cds_pre_enable(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2944 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2945 | hdd_err("Failed to pre-enable CDS; status: %d", status); |
| 2946 | ret = qdf_status_to_os_return(status); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2947 | goto deregister_cb; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2948 | } |
| 2949 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2950 | hdd_register_policy_manager_callback( |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2951 | hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 2952 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2953 | hdd_sysfs_create_driver_root_obj(); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2954 | hdd_sysfs_create_version_interface(hdd_ctx->psoc); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2955 | hdd_sysfs_create_powerstats_interface(); |
Arunk Khandavalli | 67193d5 | 2017-02-21 12:03:48 +0530 | [diff] [blame] | 2956 | hdd_update_hw_sw_info(hdd_ctx); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2957 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2958 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 2959 | hdd_err("in ftm mode, no need to configure cds modules"); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2960 | ret = -EINVAL; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 2961 | break; |
| 2962 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2963 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 2964 | ret = hdd_configure_cds(hdd_ctx); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2965 | if (ret) { |
| 2966 | hdd_err("Failed to Enable cds modules; errno: %d", ret); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2967 | goto destroy_driver_sysfs; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2968 | } |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2969 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 2970 | hdd_enable_power_management(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2971 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2972 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2973 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2974 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 2975 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2976 | hdd_ctx->driver_status); |
Dustin Brown | dca3969 | 2017-11-09 15:30:25 -0800 | [diff] [blame] | 2977 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2978 | goto release_lock; |
| 2979 | } |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2980 | |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 2981 | hdd_ctx->driver_status = DRIVER_MODULES_ENABLED; |
| 2982 | hdd_info("Wlan transitioned (now ENABLED)"); |
| 2983 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 2984 | hdd_exit(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 2985 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 2986 | return 0; |
| 2987 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 2988 | destroy_driver_sysfs: |
| 2989 | hdd_sysfs_destroy_powerstats_interface(); |
| 2990 | hdd_sysfs_destroy_version_interface(); |
| 2991 | hdd_sysfs_destroy_driver_root_obj(); |
Rajeev Kumar | be02124 | 2017-02-16 16:12:23 -0800 | [diff] [blame] | 2992 | cds_post_disable(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 2993 | |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 2994 | deregister_cb: |
| 2995 | hdd_deregister_cb(hdd_ctx); |
| 2996 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 2997 | cds_txrx_free: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 2998 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 2999 | |
| 3000 | if (tgt_hdl && target_psoc_get_wmi_ready(tgt_hdl)) { |
| 3001 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 3002 | dispatcher_pdev_close(hdd_ctx->pdev); |
Jingxiang Ge | 95912f8 | 2018-04-19 12:01:26 +0800 | [diff] [blame] | 3003 | hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 3004 | } |
| 3005 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3006 | cds_dp_close(hdd_ctx->psoc); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3007 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3008 | close: |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3009 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 3010 | hdd_info("Wlan transition aborted (now CLOSED)"); |
| 3011 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3012 | cds_close(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3013 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 3014 | psoc_close: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3015 | hdd_component_psoc_close(hdd_ctx->psoc); |
Dustin Brown | 28b1789 | 2017-10-10 13:29:38 -0700 | [diff] [blame] | 3016 | cds_deinit_ini_config(); |
| 3017 | |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 3018 | cds_free: |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3019 | ol_cds_free(); |
| 3020 | |
| 3021 | hif_close: |
Jeff Johnson | 60dc2b1 | 2017-09-28 14:56:02 -0700 | [diff] [blame] | 3022 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 3023 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3024 | power_down: |
| 3025 | if (!reinit && !unint) |
| 3026 | pld_power_off(qdf_dev->dev); |
| 3027 | release_lock: |
Abhinav Kumar | 7ae9b7b | 2017-12-19 15:11:54 +0530 | [diff] [blame] | 3028 | if (hdd_ctx->target_hw_name) { |
| 3029 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 3030 | hdd_ctx->target_hw_name = NULL; |
| 3031 | } |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 3032 | |
| 3033 | hdd_check_for_leaks(hdd_ctx, reinit); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 3034 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 3035 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3036 | hdd_exit(); |
Rajeev Kumar | a3f672f | 2017-02-16 13:59:37 -0800 | [diff] [blame] | 3037 | |
Srinivas Girigowda | bafb8b7 | 2017-10-11 17:52:32 -0700 | [diff] [blame] | 3038 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3039 | } |
| 3040 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3041 | #ifdef WIFI_POS_CONVERGED |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3042 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3043 | { |
| 3044 | int ret = os_if_wifi_pos_register_nl(); |
| 3045 | |
| 3046 | if (ret) |
| 3047 | hdd_err("os_if_wifi_pos_register_nl failed"); |
| 3048 | |
| 3049 | return ret; |
| 3050 | } |
| 3051 | |
| 3052 | static int hdd_deactivate_wifi_pos(void) |
| 3053 | { |
| 3054 | int ret = os_if_wifi_pos_deregister_nl(); |
| 3055 | |
| 3056 | if (ret) |
| 3057 | hdd_err("os_if_wifi_pos_deregister_nl failed"); |
| 3058 | |
| 3059 | return ret; |
| 3060 | } |
| 3061 | |
| 3062 | /** |
| 3063 | * hdd_populate_wifi_pos_cfg - populates wifi_pos parameters |
| 3064 | * @hdd_ctx: hdd context |
| 3065 | * |
| 3066 | * Return: status of operation |
| 3067 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3068 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3069 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3070 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3071 | uint16_t neighbor_scan_max_chan_time; |
| 3072 | uint16_t neighbor_scan_min_chan_time; |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3073 | |
| 3074 | wifi_pos_set_oem_target_type(psoc, hdd_ctx->target_type); |
| 3075 | wifi_pos_set_oem_fw_version(psoc, hdd_ctx->target_fw_version); |
| 3076 | wifi_pos_set_drv_ver_major(psoc, QWLAN_VERSION_MAJOR); |
| 3077 | wifi_pos_set_drv_ver_minor(psoc, QWLAN_VERSION_MINOR); |
| 3078 | wifi_pos_set_drv_ver_patch(psoc, QWLAN_VERSION_PATCH); |
| 3079 | wifi_pos_set_drv_ver_build(psoc, QWLAN_VERSION_BUILD); |
Wu Gao | 1ab0558 | 2018-11-08 16:22:49 +0800 | [diff] [blame] | 3080 | ucfg_mlme_get_neighbor_scan_max_chan_time(psoc, |
| 3081 | &neighbor_scan_max_chan_time); |
| 3082 | ucfg_mlme_get_neighbor_scan_min_chan_time(psoc, |
| 3083 | &neighbor_scan_min_chan_time); |
| 3084 | wifi_pos_set_dwell_time_min(psoc, neighbor_scan_min_chan_time); |
| 3085 | wifi_pos_set_dwell_time_max(psoc, neighbor_scan_max_chan_time); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3086 | } |
| 3087 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3088 | static int hdd_activate_wifi_pos(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3089 | { |
| 3090 | return oem_activate_service(hdd_ctx); |
| 3091 | } |
| 3092 | |
| 3093 | static int hdd_deactivate_wifi_pos(void) |
| 3094 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 3095 | return oem_deactivate_service(); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3096 | } |
| 3097 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3098 | static void hdd_populate_wifi_pos_cfg(struct hdd_context *hdd_ctx) |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3099 | { |
| 3100 | } |
| 3101 | #endif |
| 3102 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3103 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3104 | * __hdd_open() - HDD Open function |
| 3105 | * @dev: Pointer to net_device structure |
| 3106 | * |
| 3107 | * This is called in response to ifconfig up |
| 3108 | * |
| 3109 | * Return: 0 for success; non-zero for failure |
| 3110 | */ |
| 3111 | static int __hdd_open(struct net_device *dev) |
| 3112 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3113 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3114 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3115 | int ret; |
| 3116 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3117 | hdd_enter_dev(dev); |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3118 | |
| 3119 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3120 | TRACE_CODE_HDD_OPEN_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3121 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3122 | |
Ashish Kumar Dhanotiya | 15a7db5 | 2017-08-03 10:27:34 +0530 | [diff] [blame] | 3123 | /* Nothing to be done if device is unloading */ |
| 3124 | if (cds_is_driver_unloading()) { |
| 3125 | hdd_err("Driver is unloading can not open the hdd"); |
| 3126 | return -EBUSY; |
| 3127 | } |
| 3128 | |
Dustin Brown | 0184775 | 2017-10-25 13:56:27 -0700 | [diff] [blame] | 3129 | if (cds_is_driver_recovering()) { |
| 3130 | hdd_err("WLAN is currently recovering; Please try again."); |
| 3131 | return -EBUSY; |
| 3132 | } |
| 3133 | |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3134 | /* |
| 3135 | * This scenario can be hit in cases where in the wlan driver after |
| 3136 | * registering the netdevices and there is a failure in driver |
| 3137 | * initialization. So return error gracefully because the netdevices |
| 3138 | * will be de-registered as part of the load failure. |
| 3139 | */ |
| 3140 | |
| 3141 | if (!cds_is_driver_loaded()) { |
| 3142 | hdd_err("Failed to start the wlan driver!!"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3143 | return -EIO; |
Arunk Khandavalli | 16d8425 | 2017-06-21 15:26:29 +0530 | [diff] [blame] | 3144 | } |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 3145 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 3146 | ret = hdd_psoc_idle_restart(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3147 | if (ret) { |
| 3148 | hdd_err("Failed to start WLAN modules return"); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3149 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3150 | } |
| 3151 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3152 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 3153 | ret = hdd_start_adapter(adapter); |
| 3154 | if (ret) { |
| 3155 | hdd_err("Failed to start adapter :%d", |
| 3156 | adapter->device_mode); |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3157 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3158 | } |
| 3159 | } |
| 3160 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3161 | set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 3162 | 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] | 3163 | hdd_debug("Enabling Tx Queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3164 | /* Enable TX queues only when we are connected */ |
| 3165 | wlan_hdd_netif_queue_control(adapter, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3166 | WLAN_START_ALL_NETIF_QUEUE, |
| 3167 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3168 | } |
| 3169 | |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3170 | /* Enable carrier and transmit queues for NDI */ |
| 3171 | if (WLAN_HDD_IS_NDI(adapter)) { |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 3172 | hdd_debug("Enabling Tx Queues"); |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3173 | wlan_hdd_netif_queue_control(adapter, |
| 3174 | WLAN_START_ALL_NETIF_QUEUE_N_CARRIER, |
| 3175 | WLAN_CONTROL_PATH); |
| 3176 | } |
| 3177 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3178 | hdd_populate_wifi_pos_cfg(hdd_ctx); |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3179 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 3180 | |
Dustin Brown | 3da3a83 | 2019-03-19 15:51:54 -0700 | [diff] [blame] | 3181 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3182 | } |
| 3183 | |
| 3184 | /** |
| 3185 | * hdd_open() - Wrapper function for __hdd_open to protect it from SSR |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3186 | * @net_dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3187 | * |
| 3188 | * This is called in response to ifconfig up |
| 3189 | * |
| 3190 | * Return: 0 for success; non-zero for failure |
| 3191 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3192 | static int hdd_open(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3193 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3194 | int errno; |
| 3195 | struct osif_vdev_sync *vdev_sync; |
| 3196 | |
| 3197 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3198 | if (errno) |
| 3199 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3200 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3201 | errno = __hdd_open(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3202 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3203 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3204 | |
| 3205 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3206 | } |
| 3207 | |
| 3208 | /** |
| 3209 | * __hdd_stop() - HDD stop function |
| 3210 | * @dev: Pointer to net_device structure |
| 3211 | * |
| 3212 | * This is called in response to ifconfig down |
| 3213 | * |
| 3214 | * Return: 0 for success; non-zero for failure |
| 3215 | */ |
| 3216 | static int __hdd_stop(struct net_device *dev) |
| 3217 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3218 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3219 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3220 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3221 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3222 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3223 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3224 | |
Ashish Kumar Dhanotiya | f10aa5f | 2018-12-28 21:29:56 +0530 | [diff] [blame] | 3225 | qdf_mtrace(QDF_MODULE_ID_HDD, QDF_MODULE_ID_HDD, |
| 3226 | TRACE_CODE_HDD_STOP_REQUEST, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3227 | adapter->vdev_id, adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3228 | |
| 3229 | ret = wlan_hdd_validate_context(hdd_ctx); |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3230 | if (ret) { |
| 3231 | set_bit(DOWN_DURING_SSR, &adapter->event_flags); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3232 | return ret; |
Arunk Khandavalli | 987c8d5 | 2018-06-21 17:40:31 +0530 | [diff] [blame] | 3233 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3234 | |
| 3235 | /* Nothing to be done if the interface is not opened */ |
| 3236 | if (false == test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) { |
Jeff Johnson | 1346fab | 2016-08-15 13:09:42 -0700 | [diff] [blame] | 3237 | hdd_err("NETDEV Interface is not OPENED"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3238 | return -ENODEV; |
| 3239 | } |
| 3240 | |
| 3241 | /* Make sure the interface is marked as closed */ |
| 3242 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3243 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3244 | mac_handle = hdd_ctx->mac_handle; |
| 3245 | |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3246 | hdd_debug("Disabling Auto Power save timer"); |
| 3247 | sme_ps_disable_auto_ps_timer( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 3248 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3249 | adapter->vdev_id); |
Mukul Sharma | d16c202 | 2017-07-25 18:56:12 +0530 | [diff] [blame] | 3250 | |
| 3251 | /* |
| 3252 | * Disable TX on the interface, after this hard_start_xmit() will not |
| 3253 | * be called on that interface |
| 3254 | */ |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 3255 | hdd_debug("Disabling queues, adapter device mode: %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 3256 | qdf_opmode_str(adapter->device_mode), adapter->device_mode); |
Kabilan Kannan | 8dac350 | 2017-10-30 12:40:27 -0700 | [diff] [blame] | 3257 | |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 3258 | wlan_hdd_netif_queue_control(adapter, |
| 3259 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 3260 | WLAN_CONTROL_PATH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3261 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 3262 | if (adapter->device_mode == QDF_STA_MODE) |
| 3263 | hdd_lpass_notify_stop(hdd_ctx); |
| 3264 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3265 | /* |
Naveen Rawat | 286def5 | 2016-09-23 15:38:02 -0700 | [diff] [blame] | 3266 | * NAN data interface is different in some sense. The traffic on NDI is |
| 3267 | * bursty in nature and depends on the need to transfer. The service |
| 3268 | * layer may down the interface after the usage and up again when |
| 3269 | * required. In some sense, the NDI is expected to be available |
| 3270 | * (like SAP) iface until NDI delete request is issued by the service |
| 3271 | * layer. Skip BSS termination and adapter deletion for NAN Data |
| 3272 | * interface (NDI). |
| 3273 | */ |
| 3274 | if (WLAN_HDD_IS_NDI(adapter)) |
| 3275 | return 0; |
| 3276 | |
| 3277 | /* |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3278 | * The interface is marked as down for outside world (aka kernel) |
| 3279 | * But the driver is pretty much alive inside. The driver needs to |
| 3280 | * tear down the existing connection on the netdev (session) |
| 3281 | * cleanup the data pipes and wait until the control plane is stabilized |
| 3282 | * for this interface. The call also needs to wait until the above |
| 3283 | * mentioned actions are completed before returning to the caller. |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3284 | * Notice that hdd_stop_adapter is requested not to close the session |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3285 | * That is intentional to be able to scan if it is a STA/P2P interface |
| 3286 | */ |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 3287 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3288 | |
| 3289 | /* DeInit the adapter. This ensures datapath cleanup as well */ |
| 3290 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
| 3291 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3292 | if (!hdd_is_any_interface_open(hdd_ctx)) |
| 3293 | hdd_psoc_idle_timer_start(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 3294 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3295 | hdd_exit(); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 3296 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3297 | return 0; |
| 3298 | } |
| 3299 | |
| 3300 | /** |
| 3301 | * hdd_stop() - Wrapper function for __hdd_stop to protect it from SSR |
| 3302 | * @dev: pointer to net_device structure |
| 3303 | * |
| 3304 | * This is called in response to ifconfig down |
| 3305 | * |
| 3306 | * Return: 0 for success and error number for failure |
| 3307 | */ |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3308 | static int hdd_stop(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3309 | { |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3310 | int errno; |
| 3311 | struct osif_vdev_sync *vdev_sync; |
| 3312 | |
| 3313 | errno = osif_vdev_sync_trans_start(net_dev, &vdev_sync); |
| 3314 | if (errno) |
| 3315 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3316 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3317 | errno = __hdd_stop(net_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3318 | |
Dustin Brown | 0e1e162 | 2019-01-17 11:00:22 -0800 | [diff] [blame] | 3319 | osif_vdev_sync_trans_stop(vdev_sync); |
| 3320 | |
| 3321 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3322 | } |
| 3323 | |
| 3324 | /** |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3325 | * hdd_uninit() - HDD uninit function |
| 3326 | * @dev: Pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3327 | * |
| 3328 | * This is called during the netdev unregister to uninitialize all data |
| 3329 | * associated with the device |
| 3330 | * |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3331 | * This function must be protected by a transition |
| 3332 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3333 | * Return: None |
| 3334 | */ |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3335 | static void hdd_uninit(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3336 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3337 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Jeff Johnson | 399c627 | 2017-08-30 10:51:00 -0700 | [diff] [blame] | 3338 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3339 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3340 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3341 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3342 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) { |
| 3343 | hdd_err("Invalid magic"); |
| 3344 | goto exit; |
| 3345 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3346 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3347 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3348 | if (!hdd_ctx) { |
| 3349 | hdd_err("NULL hdd_ctx"); |
| 3350 | goto exit; |
| 3351 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3352 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3353 | if (dev != adapter->dev) |
| 3354 | hdd_err("Invalid device reference"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3355 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3356 | hdd_deinit_adapter(hdd_ctx, adapter, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3357 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3358 | /* after uninit our adapter structure will no longer be valid */ |
| 3359 | adapter->dev = NULL; |
| 3360 | adapter->magic = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3361 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 3362 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3363 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 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 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3388 | if (!cesium_nl_srv_sock) { |
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 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3398 | if (cesium_nl_srv_sock) { |
Rajeev Kumar | 8e3e283 | 2015-11-06 16:02:54 -0800 | [diff] [blame] | 3399 | netlink_kernel_release(cesium_nl_srv_sock); |
| 3400 | cesium_nl_srv_sock = NULL; |
| 3401 | } |
| 3402 | } |
| 3403 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3404 | void hdd_update_dynamic_mac(struct hdd_context *hdd_ctx, |
| 3405 | struct qdf_mac_addr *curr_mac_addr, |
| 3406 | struct qdf_mac_addr *new_mac_addr) |
| 3407 | { |
| 3408 | uint8_t i; |
| 3409 | |
| 3410 | hdd_enter(); |
| 3411 | |
| 3412 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3413 | if (!qdf_mem_cmp( |
| 3414 | curr_mac_addr->bytes, |
| 3415 | &hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes[0], |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3416 | sizeof(struct qdf_mac_addr))) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3417 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[i].dynamic_mac, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3418 | new_mac_addr->bytes, |
| 3419 | sizeof(struct qdf_mac_addr)); |
| 3420 | break; |
| 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | hdd_exit(); |
| 3425 | } |
| 3426 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3427 | /** |
| 3428 | * __hdd_set_mac_address() - set the user specified mac address |
| 3429 | * @dev: Pointer to the net device. |
| 3430 | * @addr: Pointer to the sockaddr. |
| 3431 | * |
| 3432 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3433 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3434 | * |
| 3435 | * Return: 0 for success, non zero for failure |
| 3436 | */ |
| 3437 | static int __hdd_set_mac_address(struct net_device *dev, void *addr) |
| 3438 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3439 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Ashish Kumar Dhanotiya | e533f6c | 2018-06-19 21:16:07 +0530 | [diff] [blame] | 3440 | struct hdd_adapter *adapter_temp; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3441 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3442 | struct sockaddr *psta_mac_addr = addr; |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3443 | QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3444 | int ret; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3445 | struct qdf_mac_addr mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3446 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3447 | hdd_enter_dev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3448 | |
Hanumanth Reddy Pothula | 5c7a781 | 2018-03-09 12:55:32 +0530 | [diff] [blame] | 3449 | if (netif_running(dev)) { |
| 3450 | hdd_err("On iface up, set mac address change isn't supported"); |
| 3451 | return -EBUSY; |
| 3452 | } |
| 3453 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3454 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 3455 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 3456 | if (0 != ret) |
| 3457 | return ret; |
| 3458 | |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3459 | 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] | 3460 | adapter_temp = hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes); |
| 3461 | if (adapter_temp) { |
| 3462 | if (!qdf_str_cmp(adapter_temp->dev->name, dev->name)) |
| 3463 | return 0; |
| 3464 | hdd_err("%s adapter exist with same address " MAC_ADDRESS_STR, |
| 3465 | adapter_temp->dev->name, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3466 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes)); |
Ashish Kumar Dhanotiya | f974f33 | 2018-04-19 16:03:15 +0530 | [diff] [blame] | 3467 | return -EINVAL; |
| 3468 | } |
| 3469 | |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 3470 | qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr); |
| 3471 | if (QDF_IS_STATUS_ERROR(qdf_ret_status)) |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3472 | return -EINVAL; |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3473 | |
Ashish Kumar Dhanotiya | 8bfef12 | 2018-04-18 16:48:27 +0530 | [diff] [blame] | 3474 | hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3475 | QDF_MAC_ADDR_ARRAY(mac_addr.bytes), dev->name); |
Ashish Kumar Dhanotiya | aa0ca60 | 2018-02-21 17:42:55 +0530 | [diff] [blame] | 3476 | |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3477 | hdd_update_dynamic_mac(hdd_ctx, &adapter->mac_addr, &mac_addr); |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 3478 | memcpy(&adapter->mac_addr, psta_mac_addr->sa_data, ETH_ALEN); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3479 | memcpy(dev->dev_addr, psta_mac_addr->sa_data, ETH_ALEN); |
| 3480 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3481 | hdd_exit(); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 3482 | return qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3483 | } |
| 3484 | |
| 3485 | /** |
| 3486 | * hdd_set_mac_address() - Wrapper function to protect __hdd_set_mac_address() |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3487 | * function from SSR |
| 3488 | * @net_dev: pointer to net_device structure |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3489 | * @addr: Pointer to the sockaddr |
| 3490 | * |
| 3491 | * This function sets the user specified mac address using |
Jeff Johnson | 06095fb | 2018-05-06 16:16:42 -0700 | [diff] [blame] | 3492 | * the command ifconfig wlanX hw ether <mac address>. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3493 | * |
| 3494 | * Return: 0 for success. |
| 3495 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3496 | static int hdd_set_mac_address(struct net_device *net_dev, void *addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3497 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3498 | struct osif_vdev_sync *vdev_sync; |
| 3499 | int errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3500 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3501 | errno = osif_vdev_sync_op_start(net_dev, &vdev_sync); |
| 3502 | if (errno) |
| 3503 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3504 | |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3505 | errno = __hdd_set_mac_address(net_dev, addr); |
| 3506 | |
| 3507 | osif_vdev_sync_op_stop(vdev_sync); |
| 3508 | |
| 3509 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3510 | } |
| 3511 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3512 | static uint8_t *wlan_hdd_get_derived_intf_addr(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3513 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3514 | int i, j; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3515 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3516 | i = qdf_ffz(hdd_ctx->derived_intf_addr_mask); |
| 3517 | if (i < 0 || i >= hdd_ctx->num_derived_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3518 | return NULL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3519 | qdf_atomic_set_bit(i, &hdd_ctx->derived_intf_addr_mask); |
| 3520 | hdd_info("Assigning MAC from derived list" MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3521 | QDF_MAC_ADDR_ARRAY(hdd_ctx->derived_mac_addr[i].bytes)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3522 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3523 | /* Copy the mac in dynamic mac list at first free position */ |
| 3524 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3525 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3526 | dynamic_mac_list[j].dynamic_mac)) |
| 3527 | break; |
| 3528 | } |
| 3529 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3530 | hdd_err("Max interfaces are up"); |
| 3531 | return NULL; |
| 3532 | } |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 3533 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3534 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3535 | &hdd_ctx->derived_mac_addr[i].bytes, |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 3536 | sizeof(struct qdf_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3537 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = false; |
| 3538 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3539 | |
| 3540 | return hdd_ctx->derived_mac_addr[i].bytes; |
| 3541 | } |
| 3542 | |
| 3543 | static uint8_t *wlan_hdd_get_provisioned_intf_addr(struct hdd_context *hdd_ctx) |
| 3544 | { |
| 3545 | int i, j; |
| 3546 | |
| 3547 | i = qdf_ffz(hdd_ctx->provisioned_intf_addr_mask); |
| 3548 | if (i < 0 || i >= hdd_ctx->num_provisioned_addr) |
| 3549 | return NULL; |
| 3550 | qdf_atomic_set_bit(i, &hdd_ctx->provisioned_intf_addr_mask); |
| 3551 | hdd_info("Assigning MAC from provisioned list" MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3552 | QDF_MAC_ADDR_ARRAY(hdd_ctx->provisioned_mac_addr[i].bytes)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3553 | |
| 3554 | /* Copy the mac in dynamic mac list at first free position */ |
| 3555 | for (j = 0; j < QDF_MAX_CONCURRENCY_PERSONA; j++) { |
| 3556 | if (qdf_is_macaddr_zero(&hdd_ctx-> |
| 3557 | dynamic_mac_list[j].dynamic_mac)) |
| 3558 | break; |
| 3559 | } |
| 3560 | if (j == QDF_MAX_CONCURRENCY_PERSONA) { |
| 3561 | hdd_err("Max interfaces are up"); |
| 3562 | return NULL; |
| 3563 | } |
| 3564 | |
| 3565 | qdf_mem_copy(&hdd_ctx->dynamic_mac_list[j].dynamic_mac.bytes, |
| 3566 | &hdd_ctx->provisioned_mac_addr[i].bytes, |
| 3567 | sizeof(struct qdf_mac_addr)); |
| 3568 | hdd_ctx->dynamic_mac_list[j].is_provisioned_mac = true; |
| 3569 | hdd_ctx->dynamic_mac_list[j].bit_position = i; |
| 3570 | return hdd_ctx->provisioned_mac_addr[i].bytes; |
| 3571 | } |
| 3572 | |
| 3573 | uint8_t *wlan_hdd_get_intf_addr(struct hdd_context *hdd_ctx, |
| 3574 | enum QDF_OPMODE interface_type) |
| 3575 | { |
| 3576 | uint8_t *mac_addr = NULL; |
| 3577 | |
| 3578 | if (qdf_atomic_test_bit(interface_type, |
| 3579 | (unsigned long *) |
| 3580 | (&hdd_ctx->config->provisioned_intf_pool))) |
| 3581 | mac_addr = wlan_hdd_get_provisioned_intf_addr(hdd_ctx); |
| 3582 | |
| 3583 | if ((!mac_addr) && |
| 3584 | (qdf_atomic_test_bit(interface_type, |
| 3585 | (unsigned long *) |
| 3586 | (&hdd_ctx->config->derived_intf_pool)))) |
| 3587 | mac_addr = wlan_hdd_get_derived_intf_addr(hdd_ctx); |
| 3588 | |
| 3589 | if (!mac_addr) |
| 3590 | hdd_err("MAC is not available in both the lists"); |
| 3591 | return mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3592 | } |
| 3593 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 3594 | void wlan_hdd_release_intf_addr(struct hdd_context *hdd_ctx, |
| 3595 | uint8_t *releaseAddr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3596 | { |
| 3597 | int i; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3598 | int mac_pos_in_mask; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3599 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3600 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3601 | if (!memcmp(releaseAddr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3602 | hdd_ctx->dynamic_mac_list[i].dynamic_mac.bytes, |
| 3603 | QDF_MAC_ADDR_SIZE)) { |
| 3604 | mac_pos_in_mask = |
| 3605 | hdd_ctx->dynamic_mac_list[i].bit_position; |
| 3606 | if (hdd_ctx->dynamic_mac_list[i].is_provisioned_mac) { |
| 3607 | qdf_atomic_clear_bit( |
| 3608 | mac_pos_in_mask, |
| 3609 | &hdd_ctx-> |
| 3610 | provisioned_intf_addr_mask); |
| 3611 | hdd_info("Releasing MAC from provisioned list"); |
| 3612 | hdd_info( |
| 3613 | MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3614 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3615 | } else { |
| 3616 | qdf_atomic_clear_bit( |
| 3617 | mac_pos_in_mask, &hdd_ctx-> |
| 3618 | derived_intf_addr_mask); |
| 3619 | hdd_info("Releasing MAC from derived list"); |
| 3620 | hdd_info(MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3621 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3622 | } |
| 3623 | qdf_zero_macaddr(&hdd_ctx-> |
| 3624 | dynamic_mac_list[i].dynamic_mac); |
| 3625 | hdd_ctx->dynamic_mac_list[i].is_provisioned_mac = |
| 3626 | false; |
| 3627 | hdd_ctx->dynamic_mac_list[i].bit_position = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3628 | break; |
| 3629 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3630 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3631 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 3632 | if (i == QDF_MAX_CONCURRENCY_PERSONA) |
| 3633 | hdd_err("Releasing non existing MAC" MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3634 | QDF_MAC_ADDR_ARRAY(releaseAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3635 | } |
| 3636 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3637 | /** |
| 3638 | * __hdd_set_multicast_list() - set the multicast address list |
| 3639 | * @dev: Pointer to the WLAN device. |
| 3640 | * @skb: Pointer to OS packet (sk_buff). |
| 3641 | * |
| 3642 | * This funciton sets the multicast address list. |
| 3643 | * |
| 3644 | * Return: None |
| 3645 | */ |
| 3646 | static void __hdd_set_multicast_list(struct net_device *dev) |
| 3647 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3648 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3649 | int i = 0, errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3650 | struct netdev_hw_addr *ha; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 3651 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3652 | struct pmo_mc_addr_list_params *mc_list_request = NULL; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 3653 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3654 | int mc_count = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3655 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 3656 | hdd_enter_dev(dev); |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 3657 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3658 | goto out; |
Mukul Sharma | 51c4494 | 2015-10-30 19:30:19 +0530 | [diff] [blame] | 3659 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3660 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 3661 | if (errno) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3662 | goto out; |
| 3663 | |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3664 | errno = hdd_validate_adapter(adapter); |
| 3665 | if (errno) |
Dustin Brown | c788acb | 2017-08-01 17:43:51 -0700 | [diff] [blame] | 3666 | goto out; |
| 3667 | |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3668 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) { |
| 3669 | hdd_err("%s: Driver module is closed", __func__); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3670 | goto out; |
Arunk Khandavalli | 6a22788 | 2017-12-12 19:31:08 +0530 | [diff] [blame] | 3671 | } |
| 3672 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3673 | mc_list_request = qdf_mem_malloc(sizeof(*mc_list_request)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 3674 | if (!mc_list_request) |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3675 | goto out; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3676 | |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3677 | /* Delete already configured multicast address list */ |
| 3678 | if (adapter->mc_addr_list.mc_cnt > 0) { |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3679 | hdd_debug("clear previously configured MC address list"); |
Hanumanth Reddy Pothula | ca84ec5 | 2017-02-21 12:09:45 +0530 | [diff] [blame] | 3680 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3681 | pmo_mc_list_change_notify); |
| 3682 | } |
| 3683 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3684 | if (dev->flags & IFF_ALLMULTI) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3685 | hdd_debug("allow all multicast frames"); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3686 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3687 | pmo_mc_list_change_notify); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3688 | } else { |
| 3689 | mc_count = netdev_mc_count(dev); |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3690 | if (mc_count > ucfg_pmo_max_mc_addr_supported(psoc)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3691 | hdd_debug("Exceeded max MC filter addresses (%d). Allowing all MC frames by disabling MC address filtering", |
Wu Gao | d7dd6e4 | 2018-10-16 17:22:56 +0800 | [diff] [blame] | 3692 | ucfg_pmo_max_mc_addr_supported(psoc)); |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3693 | hdd_disable_and_flush_mc_addr_list(adapter, |
| 3694 | pmo_mc_list_change_notify); |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3695 | adapter->mc_addr_list.mc_cnt = 0; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3696 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3697 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3698 | netdev_for_each_mc_addr(ha, dev) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3699 | hdd_debug("ha_addr[%d] "MAC_ADDRESS_STR, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 3700 | i, QDF_MAC_ADDR_ARRAY(ha->addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3701 | if (i == mc_count) |
| 3702 | break; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3703 | memset(&(mc_list_request->mc_addr[i].bytes), |
| 3704 | 0, ETH_ALEN); |
| 3705 | memcpy(&(mc_list_request->mc_addr[i].bytes), |
| 3706 | ha->addr, ETH_ALEN); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3707 | hdd_debug("mlist[%d] = %pM", i, |
| 3708 | mc_list_request->mc_addr[i].bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3709 | i++; |
| 3710 | } |
| 3711 | } |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3712 | |
stonez | df2bdfd | 2018-11-20 14:45:06 +0800 | [diff] [blame] | 3713 | adapter->mc_addr_list.mc_cnt = mc_count; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3714 | mc_list_request->psoc = psoc; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3715 | mc_list_request->vdev_id = adapter->vdev_id; |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3716 | mc_list_request->count = mc_count; |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3717 | |
| 3718 | errno = hdd_cache_mc_addr_list(mc_list_request); |
| 3719 | if (errno) { |
| 3720 | hdd_err("Failed to cache MC address list for vdev %u; errno:%d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3721 | adapter->vdev_id, errno); |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3722 | goto free_req; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3723 | } |
Dustin Brown | 0f87448 | 2018-06-13 14:39:22 -0700 | [diff] [blame] | 3724 | |
| 3725 | hdd_enable_mc_addr_filtering(adapter, pmo_mc_list_change_notify); |
| 3726 | |
| 3727 | free_req: |
| 3728 | qdf_mem_free(mc_list_request); |
| 3729 | |
Mukul Sharma | ff2ac2e | 2017-01-16 15:51:29 +0530 | [diff] [blame] | 3730 | out: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3731 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3732 | } |
| 3733 | |
| 3734 | /** |
| 3735 | * hdd_set_multicast_list() - SSR wrapper function for __hdd_set_multicast_list |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3736 | * @net_dev: pointer to net_device |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3737 | * |
| 3738 | * Return: none |
| 3739 | */ |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3740 | static void hdd_set_multicast_list(struct net_device *net_dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3741 | { |
Dustin Brown | 98f7c82 | 2019-03-06 12:25:49 -0800 | [diff] [blame] | 3742 | struct osif_vdev_sync *vdev_sync; |
| 3743 | |
| 3744 | if (osif_vdev_sync_op_start(net_dev, &vdev_sync)) |
| 3745 | return; |
| 3746 | |
| 3747 | __hdd_set_multicast_list(net_dev); |
| 3748 | |
| 3749 | osif_vdev_sync_op_stop(vdev_sync); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3750 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3751 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3752 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3753 | static const struct ethtool_ops wlan_ethtool_ops = { |
| 3754 | .get_ts_info = wlan_get_ts_info, |
| 3755 | }; |
| 3756 | #endif |
| 3757 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3758 | static const struct net_device_ops wlan_drv_ops = { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3759 | .ndo_open = hdd_open, |
| 3760 | .ndo_stop = hdd_stop, |
| 3761 | .ndo_uninit = hdd_uninit, |
| 3762 | .ndo_start_xmit = hdd_hard_start_xmit, |
| 3763 | .ndo_tx_timeout = hdd_tx_timeout, |
| 3764 | .ndo_get_stats = hdd_get_stats, |
| 3765 | .ndo_do_ioctl = hdd_ioctl, |
| 3766 | .ndo_set_mac_address = hdd_set_mac_address, |
| 3767 | .ndo_select_queue = hdd_select_queue, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3768 | .ndo_set_rx_mode = hdd_set_multicast_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3769 | }; |
| 3770 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3771 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3772 | /* Monitor mode net_device_ops, doesnot Tx and most of operations. */ |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 3773 | static const struct net_device_ops wlan_mon_drv_ops = { |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3774 | .ndo_open = hdd_mon_open, |
| 3775 | .ndo_stop = hdd_stop, |
| 3776 | .ndo_get_stats = hdd_get_stats, |
| 3777 | }; |
| 3778 | |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3779 | #ifdef WLAN_FEATURE_TSF_PTP |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3780 | /** |
| 3781 | * hdd_set_station_ops() - update net_device ops for monitor mode |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3782 | * @dev: Handle to struct net_device to be updated. |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3783 | * Return: None |
| 3784 | */ |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3785 | void hdd_set_station_ops(struct net_device *dev) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3786 | { |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3787 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) { |
| 3788 | dev->netdev_ops = &wlan_mon_drv_ops; |
| 3789 | } else { |
| 3790 | dev->netdev_ops = &wlan_drv_ops; |
| 3791 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3792 | } |
| 3793 | } |
| 3794 | #else |
| 3795 | void hdd_set_station_ops(struct net_device *dev) |
| 3796 | { |
| 3797 | if (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3798 | dev->netdev_ops = &wlan_mon_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3799 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 3800 | dev->netdev_ops = &wlan_drv_ops; |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3801 | } |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3802 | |
| 3803 | #endif |
| 3804 | #else |
| 3805 | #ifdef WLAN_FEATURE_TSF_PTP |
| 3806 | void hdd_set_station_ops(struct net_device *dev) |
| 3807 | { |
| 3808 | dev->netdev_ops = &wlan_drv_ops; |
| 3809 | dev->ethtool_ops = &wlan_ethtool_ops; |
| 3810 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 3811 | #else |
| 3812 | void hdd_set_station_ops(struct net_device *dev) |
| 3813 | { |
| 3814 | dev->netdev_ops = &wlan_drv_ops; |
| 3815 | } |
| 3816 | #endif |
Subrat Dash | 5f36fbe | 2019-02-12 16:28:14 +0530 | [diff] [blame] | 3817 | #endif |
Manjunathappa Prakash | 59f861d | 2016-04-21 10:33:31 -0700 | [diff] [blame] | 3818 | |
| 3819 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3820 | * hdd_alloc_station_adapter() - allocate the station hdd adapter |
| 3821 | * @hdd_ctx: global hdd context |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3822 | * @mac_addr: mac address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3823 | * @name: User-visible name of the interface |
| 3824 | * |
| 3825 | * hdd adapter pointer would point to the netdev->priv space, this function |
Jeff Johnson | 6201829 | 2018-05-06 16:18:35 -0700 | [diff] [blame] | 3826 | * would retrieve the pointer, and setup the hdd adapter configuration. |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3827 | * |
| 3828 | * Return: the pointer to hdd adapter, otherwise NULL |
| 3829 | */ |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3830 | static struct hdd_adapter * |
| 3831 | hdd_alloc_station_adapter(struct hdd_context *hdd_ctx, tSirMacAddr mac_addr, |
| 3832 | unsigned char name_assign_type, const char *name) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3833 | { |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3834 | struct net_device *dev; |
| 3835 | struct hdd_adapter *adapter; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 3836 | struct hdd_station_ctx *sta_ctx; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3837 | QDF_STATUS qdf_status; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3838 | |
| 3839 | /* cfg80211 initialization and registration */ |
| 3840 | dev = alloc_netdev_mq(sizeof(*adapter), name, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 3841 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 17, 0)) || defined(WITH_BACKPORTS) |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3842 | name_assign_type, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3843 | #endif |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3844 | (cds_get_conparam() == QDF_GLOBAL_MONITOR_MODE ? |
| 3845 | hdd_mon_mode_ether_setup : ether_setup), |
| 3846 | NUM_TX_QUEUES); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3847 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3848 | if (!dev) { |
| 3849 | hdd_err("Failed to allocate new net_device '%s'", name); |
| 3850 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3851 | } |
| 3852 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3853 | adapter = netdev_priv(dev); |
| 3854 | |
| 3855 | qdf_mem_zero(adapter, sizeof(*adapter)); |
| 3856 | sta_ctx = &adapter->session.station; |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 3857 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 3858 | sizeof(sta_ctx->conn_info.sta_id), |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3859 | HDD_WLAN_INVALID_STA_ID); |
| 3860 | adapter->dev = dev; |
| 3861 | adapter->hdd_ctx = hdd_ctx; |
| 3862 | adapter->magic = WLAN_HDD_ADAPTER_MAGIC; |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 3863 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3864 | |
| 3865 | qdf_status = qdf_event_create(&adapter->qdf_session_open_event); |
| 3866 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3867 | goto free_net_dev; |
| 3868 | |
| 3869 | qdf_status = qdf_event_create(&adapter->qdf_session_close_event); |
| 3870 | if (QDF_IS_STATUS_ERROR(qdf_status)) |
| 3871 | goto free_net_dev; |
| 3872 | |
| 3873 | adapter->offloads_configured = false; |
| 3874 | adapter->is_link_up_service_needed = false; |
| 3875 | adapter->disconnection_in_progress = false; |
| 3876 | adapter->send_mode_change = true; |
| 3877 | |
| 3878 | /* Init the net_device structure */ |
| 3879 | strlcpy(dev->name, name, IFNAMSIZ); |
| 3880 | |
| 3881 | qdf_mem_copy(dev->dev_addr, mac_addr, sizeof(tSirMacAddr)); |
| 3882 | qdf_mem_copy(adapter->mac_addr.bytes, mac_addr, sizeof(tSirMacAddr)); |
| 3883 | dev->watchdog_timeo = HDD_TX_TIMEOUT; |
| 3884 | |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3885 | hdd_set_station_ops(adapter->dev); |
| 3886 | |
| 3887 | hdd_dev_setup_destructor(dev); |
| 3888 | dev->ieee80211_ptr = &adapter->wdev; |
| 3889 | dev->tx_queue_len = HDD_NETDEV_TX_QUEUE_LEN; |
| 3890 | adapter->wdev.wiphy = hdd_ctx->wiphy; |
| 3891 | adapter->wdev.netdev = dev; |
| 3892 | |
| 3893 | /* set dev's parent to underlying device */ |
| 3894 | SET_NETDEV_DEV(dev, hdd_ctx->parent_dev); |
| 3895 | hdd_wmm_init(adapter); |
| 3896 | spin_lock_init(&adapter->pause_map_lock); |
| 3897 | adapter->start_time = qdf_system_ticks(); |
| 3898 | adapter->last_time = adapter->start_time; |
| 3899 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3900 | return adapter; |
Dustin Brown | ef5fc2d | 2018-09-11 11:02:00 -0700 | [diff] [blame] | 3901 | |
| 3902 | free_net_dev: |
| 3903 | free_netdev(adapter->dev); |
| 3904 | |
| 3905 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3906 | } |
| 3907 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 3908 | 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] | 3909 | { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3910 | struct net_device *dev = adapter->dev; |
| 3911 | int ret; |
| 3912 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 3913 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3914 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 3915 | if (rtnl_held) { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3916 | if (strnchr(dev->name, IFNAMSIZ - 1, '%')) { |
| 3917 | |
| 3918 | ret = dev_alloc_name(dev, dev->name); |
| 3919 | if (ret < 0) { |
| 3920 | hdd_err( |
| 3921 | "unable to get dev name: %s, err = 0x%x", |
| 3922 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3923 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3924 | } |
| 3925 | } |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3926 | |
| 3927 | ret = register_netdevice(dev); |
| 3928 | if (ret) { |
| 3929 | hdd_err("register_netdevice(%s) failed, err = 0x%x", |
| 3930 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3931 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3932 | } |
| 3933 | } else { |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3934 | ret = register_netdev(dev); |
| 3935 | if (ret) { |
| 3936 | hdd_err("register_netdev(%s) failed, err = 0x%x", |
| 3937 | dev->name, ret); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3938 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3939 | } |
| 3940 | } |
| 3941 | set_bit(NET_DEVICE_REGISTERED, &adapter->event_flags); |
| 3942 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 3943 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 3944 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3945 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3946 | } |
| 3947 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3948 | QDF_STATUS hdd_sme_open_session_callback(uint8_t vdev_id, |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3949 | QDF_STATUS qdf_status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3950 | { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3951 | struct hdd_adapter *adapter; |
| 3952 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3953 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3954 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3955 | if (!hdd_ctx) { |
| 3956 | hdd_err("Invalid HDD_CTX"); |
| 3957 | return QDF_STATUS_E_FAILURE; |
| 3958 | } |
| 3959 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3960 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3961 | if (!adapter) { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3962 | hdd_err("NULL adapter for %d", vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3963 | return QDF_STATUS_E_INVAL; |
| 3964 | } |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 3965 | |
| 3966 | if (qdf_status == QDF_STATUS_SUCCESS) |
| 3967 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 3968 | |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 3969 | qdf_event_set(&adapter->qdf_session_open_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 3970 | hdd_debug("session %d opened", adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3971 | |
| 3972 | return QDF_STATUS_SUCCESS; |
| 3973 | } |
| 3974 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3975 | QDF_STATUS hdd_sme_close_session_callback(uint8_t vdev_id) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 3976 | { |
| 3977 | struct hdd_adapter *adapter; |
| 3978 | struct hdd_context *hdd_ctx; |
| 3979 | |
| 3980 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 3981 | if (!hdd_ctx) { |
| 3982 | hdd_err("Invalid HDD_CTX"); |
| 3983 | return QDF_STATUS_E_FAILURE; |
| 3984 | } |
| 3985 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 3986 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 3987 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3988 | hdd_err("NULL adapter"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3989 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3990 | } |
| 3991 | |
| 3992 | if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 3993 | hdd_err("Invalid magic"); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 3994 | return QDF_STATUS_NOT_INITIALIZED; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3995 | } |
| 3996 | |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 3997 | /* |
| 3998 | * For NAN Data interface, the close session results in the final |
| 3999 | * indication to the userspace |
| 4000 | */ |
Rakesh Sunki | 3480f96 | 2016-08-29 17:29:53 -0700 | [diff] [blame] | 4001 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4002 | hdd_ndp_session_end_handler(adapter); |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 4003 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4004 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4005 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4006 | /* |
| 4007 | * We can be blocked while waiting for scheduled work to be |
| 4008 | * flushed, and the adapter structure can potentially be freed, in |
| 4009 | * which case the magic will have been reset. So make sure the |
| 4010 | * magic is still good, and hence the adapter structure is still |
| 4011 | * valid, before signaling completion |
| 4012 | */ |
| 4013 | if (WLAN_HDD_ADAPTER_MAGIC == adapter->magic) |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4014 | qdf_event_set(&adapter->qdf_session_close_event); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4015 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4016 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4017 | } |
| 4018 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4019 | int hdd_vdev_ready(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4020 | { |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4021 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4022 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4023 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4024 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4025 | if (!vdev) |
| 4026 | return -EINVAL; |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4027 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4028 | status = pmo_vdev_ready(vdev); |
| 4029 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4030 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4031 | return qdf_status_to_os_return(status); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4032 | } |
| 4033 | |
| 4034 | status = ucfg_reg_11d_vdev_created_update(vdev); |
| 4035 | if (QDF_IS_STATUS_ERROR(status)) { |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4036 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4037 | return qdf_status_to_os_return(status); |
| 4038 | } |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4039 | |
| 4040 | if (wma_capability_enhanced_mcast_filter()) |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4041 | status = ucfg_pmo_enhanced_mc_filter_enable(vdev); |
Dustin Brown | 8d8d9fe | 2017-07-18 16:01:25 -0700 | [diff] [blame] | 4042 | else |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4043 | status = ucfg_pmo_enhanced_mc_filter_disable(vdev); |
| 4044 | |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4045 | hdd_objmgr_put_vdev(vdev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4046 | |
| 4047 | return qdf_status_to_os_return(status); |
| 4048 | } |
| 4049 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4050 | int hdd_vdev_destroy(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4051 | { |
| 4052 | QDF_STATUS status; |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4053 | int errno; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4054 | struct hdd_context *hdd_ctx; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4055 | uint8_t vdev_id; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4056 | struct wlan_objmgr_vdev *vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4057 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4058 | vdev_id = adapter->vdev_id; |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4059 | hdd_info("destroying vdev %d", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4060 | |
| 4061 | /* vdev created sanity check */ |
| 4062 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4063 | hdd_err("vdev %u does not exist", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4064 | return -EINVAL; |
| 4065 | } |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4066 | |
Abhishek Singh | 628bb6f | 2019-03-26 14:52:40 +0530 | [diff] [blame] | 4067 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4068 | |
| 4069 | /* |
| 4070 | * if this is the last active connection check & stop the |
| 4071 | * opportunistic timer first |
| 4072 | */ |
| 4073 | if ((policy_mgr_get_connection_count(hdd_ctx->psoc) == 1 && |
| 4074 | policy_mgr_mode_specific_connection_count(hdd_ctx->psoc, |
| 4075 | policy_mgr_convert_device_mode_to_qdf_type( |
| 4076 | adapter->device_mode), NULL) == 1) || |
| 4077 | !policy_mgr_get_connection_count(hdd_ctx->psoc)) |
| 4078 | policy_mgr_check_and_stop_opportunistic_timer(hdd_ctx->psoc, |
| 4079 | adapter->vdev_id); |
| 4080 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4081 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4082 | if (!vdev) |
| 4083 | return -EINVAL; |
Ashish Kumar Dhanotiya | 68ee2e4 | 2018-11-19 21:15:14 +0530 | [diff] [blame] | 4084 | |
| 4085 | ucfg_pmo_del_wow_pattern(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4086 | status = ucfg_reg_11d_vdev_delete_update(vdev); |
Abhishek Singh | 935e477 | 2018-11-21 14:14:10 +0530 | [diff] [blame] | 4087 | ucfg_scan_vdev_set_disable(vdev, REASON_VDEV_DOWN); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4088 | hdd_objmgr_put_vdev(vdev); |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4089 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4090 | /* close sme session (destroy vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4091 | qdf_event_reset(&adapter->qdf_session_close_event); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4092 | status = sme_close_session(hdd_ctx->mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4093 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4094 | hdd_err("failed to close sme session; status:%d", status); |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4095 | goto release_vdev; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4096 | } |
| 4097 | |
| 4098 | /* block on a completion variable until sme session is closed */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4099 | status = qdf_wait_for_event_completion( |
| 4100 | &adapter->qdf_session_close_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4101 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4102 | |
| 4103 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4104 | clear_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4105 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4106 | if (adapter->device_mode == QDF_NDI_MODE) |
| 4107 | hdd_ndp_session_end_handler(adapter); |
Dustin Brown | 2da29eb | 2018-07-13 14:23:12 -0700 | [diff] [blame] | 4108 | |
| 4109 | if (status == QDF_STATUS_E_TIMEOUT) |
| 4110 | hdd_err("timed out waiting for sme close session"); |
| 4111 | else if (adapter->qdf_session_close_event.force_set) |
| 4112 | hdd_info("SSR occurred during sme close session"); |
| 4113 | else |
| 4114 | hdd_err("failed to wait for sme close session; status:%u", |
| 4115 | status); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4116 | } |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4117 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 4118 | release_vdev: |
Jiachao Wu | 2c42c22 | 2018-01-15 18:13:19 +0800 | [diff] [blame] | 4119 | |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4120 | /* do vdev logical destroy via objmgr */ |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4121 | errno = hdd_objmgr_release_and_destroy_vdev(adapter); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4122 | if (errno) { |
Dustin Brown | b277dd6 | 2018-01-26 15:17:33 -0800 | [diff] [blame] | 4123 | hdd_err("failed to destroy objmgr vdev; errno:%d", errno); |
Sandeep Puligilla | ef41536 | 2017-08-30 16:37:13 -0700 | [diff] [blame] | 4124 | return errno; |
| 4125 | } |
| 4126 | |
Rajeev Kumar | 6e0cbff | 2017-12-01 18:14:30 -0800 | [diff] [blame] | 4127 | hdd_info("vdev %d destroyed successfully", vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4128 | |
| 4129 | return 0; |
| 4130 | } |
| 4131 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4132 | static int hdd_set_sme_session_param(struct hdd_adapter *adapter, |
| 4133 | struct sme_session_params *session_param, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4134 | csr_roam_complete_cb callback, |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4135 | void *callback_ctx) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4136 | { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4137 | uint32_t type; |
| 4138 | uint32_t sub_type; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4139 | QDF_STATUS status; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4140 | |
| 4141 | /* determine vdev (sub)type */ |
| 4142 | status = cds_get_vdev_types(adapter->device_mode, &type, &sub_type); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4143 | if (QDF_STATUS_SUCCESS != status) { |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4144 | hdd_err("failed to get vdev type: %d", status); |
| 4145 | return qdf_status_to_os_return(status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4146 | } |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4147 | session_param->sme_session_id = adapter->vdev_id; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4148 | session_param->self_mac_addr = (uint8_t *)&adapter->mac_addr; |
| 4149 | session_param->type_of_persona = type; |
| 4150 | session_param->subtype_of_persona = sub_type; |
| 4151 | session_param->session_open_cb = hdd_sme_open_session_callback; |
| 4152 | session_param->session_close_cb = hdd_sme_close_session_callback; |
| 4153 | session_param->callback = callback; |
| 4154 | session_param->callback_ctx = callback_ctx; |
| 4155 | |
| 4156 | return 0; |
| 4157 | } |
| 4158 | |
gaurank kathpalia | 6c4b50c | 2019-02-28 14:07:48 +0530 | [diff] [blame] | 4159 | void |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4160 | hdd_store_nss_chains_cfg_in_vdev(struct hdd_adapter *adapter) |
| 4161 | { |
| 4162 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
| 4163 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 4164 | |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4165 | /* Populate the nss chain params from ini for this vdev type */ |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4166 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 4167 | adapter->device_mode, |
| 4168 | hdd_ctx->num_rf_chains); |
gaurank kathpalia | b414bce | 2018-11-09 18:44:46 +0530 | [diff] [blame] | 4169 | |
| 4170 | /* Store the nss chain config into the vdev */ |
| 4171 | sme_store_nss_chains_cfg_in_vdev(adapter->vdev, &vdev_ini_cfg); |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4172 | } |
gaurank kathpalia | 6982d47 | 2018-10-31 21:54:15 +0530 | [diff] [blame] | 4173 | |
| 4174 | bool hdd_is_vdev_in_conn_state(struct hdd_adapter *adapter) |
| 4175 | { |
| 4176 | switch (adapter->device_mode) { |
| 4177 | case QDF_STA_MODE: |
| 4178 | case QDF_P2P_CLIENT_MODE: |
| 4179 | case QDF_P2P_DEVICE_MODE: |
| 4180 | return hdd_conn_is_connected( |
| 4181 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)); |
| 4182 | case QDF_SAP_MODE: |
| 4183 | case QDF_P2P_GO_MODE: |
| 4184 | return (test_bit(SOFTAP_BSS_STARTED, |
| 4185 | &adapter->event_flags)); |
| 4186 | default: |
| 4187 | hdd_err("Device mode %d invalid", adapter->device_mode); |
| 4188 | return 0; |
| 4189 | } |
| 4190 | |
| 4191 | return 0; |
| 4192 | } |
| 4193 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4194 | int hdd_vdev_create(struct hdd_adapter *adapter, |
Jeff Johnson | 6a18c96 | 2018-07-01 09:09:37 -0700 | [diff] [blame] | 4195 | csr_roam_complete_cb callback, void *ctx) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4196 | { |
| 4197 | QDF_STATUS status; |
| 4198 | int errno; |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4199 | bool bval; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4200 | struct hdd_context *hdd_ctx; |
| 4201 | struct sme_session_params sme_session_params = {0}; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4202 | struct wlan_objmgr_vdev *vdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4203 | |
| 4204 | hdd_info("creating new vdev"); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4205 | |
| 4206 | /* do vdev create via objmgr */ |
| 4207 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 4208 | errno = hdd_objmgr_create_and_store_vdev(hdd_ctx->pdev, adapter); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4209 | if (errno) { |
| 4210 | hdd_err("failed to create objmgr vdev: %d", errno); |
| 4211 | return errno; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4212 | } |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4213 | |
| 4214 | /* Open a SME session (prepare vdev in firmware via legacy API) */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4215 | status = qdf_event_reset(&adapter->qdf_session_open_event); |
| 4216 | if (QDF_STATUS_SUCCESS != status) { |
| 4217 | hdd_err("failed to reinit session open event"); |
| 4218 | return -EINVAL; |
| 4219 | } |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4220 | errno = hdd_set_sme_session_param(adapter, &sme_session_params, |
| 4221 | callback, ctx); |
| 4222 | if (errno) { |
| 4223 | hdd_err("failed to populating SME params"); |
| 4224 | goto objmgr_vdev_destroy_procedure; |
| 4225 | } |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4226 | status = sme_open_session(hdd_ctx->mac_handle, &sme_session_params); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4227 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4228 | hdd_err("failed to open sme session: %d", status); |
| 4229 | errno = qdf_status_to_os_return(status); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4230 | goto objmgr_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4231 | } |
| 4232 | |
| 4233 | /* block on a completion variable until sme session is opened */ |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4234 | status = qdf_wait_for_event_completion(&adapter->qdf_session_open_event, |
Abhishek Singh | 13bf0ce | 2018-10-24 14:26:14 +0530 | [diff] [blame] | 4235 | SME_CMD_VDEV_CREATE_DELETE_TIMEOUT); |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4236 | if (QDF_STATUS_SUCCESS != status) { |
| 4237 | if (adapter->qdf_session_open_event.force_set) { |
| 4238 | /* |
| 4239 | * SSR/PDR has caused shutdown, which has forcefully |
| 4240 | * set the event. Return without the closing session. |
| 4241 | */ |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 4242 | adapter->vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4243 | hdd_err("Session open event forcefully set"); |
| 4244 | return -EINVAL; |
Nachiket Kukade | 08b9f29 | 2017-11-17 18:27:37 +0530 | [diff] [blame] | 4245 | } |
Jeff Johnson | c66d310 | 2018-02-28 11:58:26 -0800 | [diff] [blame] | 4246 | |
| 4247 | if (QDF_STATUS_E_TIMEOUT == status) |
| 4248 | hdd_err("Session failed to open within timeout period"); |
| 4249 | else |
| 4250 | hdd_err("Failed to wait for session open event(status-%d)", |
| 4251 | status); |
| 4252 | errno = -ETIMEDOUT; |
| 4253 | set_bit(SME_SESSION_OPENED, &adapter->event_flags); |
| 4254 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4255 | } |
| 4256 | |
Pragaspathi Thilagaraj | 3551caa | 2018-09-26 15:52:56 +0530 | [diff] [blame] | 4257 | if (!test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 4258 | hdd_err("Session failed to open due to vdev create failure"); |
| 4259 | errno = -EINVAL; |
| 4260 | goto objmgr_vdev_destroy_procedure; |
| 4261 | } |
| 4262 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4263 | /* firmware ready for component communication, raise vdev_ready event */ |
| 4264 | errno = hdd_vdev_ready(adapter); |
| 4265 | if (errno) { |
| 4266 | hdd_err("failed to dispatch vdev ready event: %d", errno); |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4267 | goto hdd_vdev_destroy_procedure; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4268 | } |
| 4269 | |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4270 | if (adapter->device_mode == QDF_STA_MODE) { |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4271 | bval = false; |
| 4272 | status = ucfg_mlme_get_rtt_mac_randomization(hdd_ctx->psoc, |
| 4273 | &bval); |
| 4274 | if (QDF_IS_STATUS_ERROR(status)) |
| 4275 | hdd_err("unable to get RTT MAC randomization value"); |
| 4276 | |
| 4277 | hdd_debug("setting RTT mac randomization param: %d", bval); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4278 | errno = sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4279 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_INITIATOR_RANDOM_MAC, |
Karthik Kantamneni | 9180c75 | 2018-11-14 12:14:17 +0530 | [diff] [blame] | 4280 | bval, |
Naveen Rawat | 2b43089 | 2018-03-13 13:58:18 -0700 | [diff] [blame] | 4281 | VDEV_CMD); |
| 4282 | if (0 != errno) |
| 4283 | hdd_err("RTT mac randomization param set failed %d", |
| 4284 | errno); |
| 4285 | } |
| 4286 | |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4287 | if (adapter->device_mode == QDF_STA_MODE || |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4288 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
| 4289 | vdev = hdd_objmgr_get_vdev(adapter); |
| 4290 | if (!vdev) |
| 4291 | goto hdd_vdev_destroy_procedure; |
| 4292 | wlan_vdev_set_max_peer_count(vdev, HDD_MAX_VDEV_PEER_COUNT); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 4293 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4294 | } |
Bala Venkatesh | 110b03e | 2018-07-10 16:02:08 +0530 | [diff] [blame] | 4295 | |
gaurank kathpalia | 78af193 | 2018-10-27 20:33:10 +0530 | [diff] [blame] | 4296 | hdd_store_nss_chains_cfg_in_vdev(adapter); |
| 4297 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4298 | hdd_info("vdev %d created successfully", adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4299 | |
| 4300 | return 0; |
| 4301 | |
| 4302 | /* |
| 4303 | * Due to legacy constraints, we need to destroy in the same order as |
| 4304 | * create. So, split error handling into 2 cases to accommodate. |
| 4305 | */ |
| 4306 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4307 | objmgr_vdev_destroy_procedure: |
Dustin Brown | 7d043f6 | 2017-03-27 12:07:36 -0700 | [diff] [blame] | 4308 | QDF_BUG(!hdd_objmgr_release_and_destroy_vdev(adapter)); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4309 | |
| 4310 | return errno; |
| 4311 | |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4312 | hdd_vdev_destroy_procedure: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4313 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
| 4314 | |
| 4315 | return errno; |
| 4316 | } |
| 4317 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4318 | QDF_STATUS hdd_init_station_mode(struct hdd_adapter *adapter) |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4319 | { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 4320 | struct hdd_station_ctx *sta_ctx = &adapter->session.station; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4321 | struct hdd_context *hdd_ctx; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4322 | QDF_STATUS status; |
| 4323 | int ret_val; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4324 | mac_handle_t mac_handle; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4325 | bool bval = false; |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4326 | |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4327 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 4328 | mac_handle = hdd_ctx->mac_handle; |
| 4329 | sme_set_curr_device_mode(mac_handle, adapter->device_mode); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4330 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4331 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4332 | hdd_err("unable to get vht_enable2x2"); |
| 4333 | sme_set_pdev_ht_vht_ies(mac_handle, bval); |
| 4334 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4335 | sme_set_vdev_ies_per_band(mac_handle, adapter->vdev_id); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4336 | |
Jeff Johnson | 7f2c591 | 2018-03-23 11:42:28 -0700 | [diff] [blame] | 4337 | hdd_roam_profile_init(adapter); |
| 4338 | hdd_register_wext(adapter->dev); |
| 4339 | |
Varun Reddy Yeturu | 9e0032c | 2017-07-12 18:39:59 -0700 | [diff] [blame] | 4340 | hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4341 | |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 4342 | qdf_mem_set(sta_ctx->conn_info.sta_id, |
| 4343 | sizeof(sta_ctx->conn_info.sta_id), |
| 4344 | HDD_WLAN_INVALID_STA_ID); |
Hanumanth Reddy Pothula | b2d729c | 2017-05-30 11:49:53 +0530 | [diff] [blame] | 4345 | |
Deepak Dhamdhere | a278582 | 2016-11-17 01:17:45 -0800 | [diff] [blame] | 4346 | /* set fast roaming capability in sme session */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4347 | status = sme_config_fast_roaming(mac_handle, adapter->vdev_id, |
Abhishek Singh | 1f217ec | 2017-12-22 11:48:27 +0530 | [diff] [blame] | 4348 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4349 | /* Set the default operation channel */ |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 4350 | sta_ctx->conn_info.channel = |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 4351 | hdd_ctx->config->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4352 | |
| 4353 | /* Make the default Auth Type as OPEN */ |
Jeff Johnson | 96e3351 | 2019-02-27 15:10:21 -0800 | [diff] [blame] | 4354 | sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4355 | |
| 4356 | status = hdd_init_tx_rx(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4357 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4358 | hdd_err("hdd_init_tx_rx() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4359 | status, status); |
| 4360 | goto error_init_txrx; |
| 4361 | } |
| 4362 | |
| 4363 | set_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4364 | |
| 4365 | status = hdd_wmm_adapter_init(adapter); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4366 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4367 | hdd_err("hdd_wmm_adapter_init() failed, status code %08d [x%08x]", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4368 | status, status); |
| 4369 | goto error_wmm_init; |
| 4370 | } |
| 4371 | |
| 4372 | set_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4373 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4374 | ret_val = sme_cli_set_command(adapter->vdev_id, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4375 | WMI_PDEV_PARAM_BURST_ENABLE, |
Dundi Raviteja | 3aa01be | 2018-05-21 18:58:59 +0530 | [diff] [blame] | 4376 | HDD_ENABLE_SIFS_BURST_DEFAULT, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4377 | PDEV_CMD); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4378 | if (ret_val) |
| 4379 | hdd_err("WMI_PDEV_PARAM_BURST_ENABLE set failed %d", ret_val); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4380 | |
Poddar, Siddarth | 4b3f731 | 2017-11-02 17:00:20 +0530 | [diff] [blame] | 4381 | /* |
| 4382 | * In case of USB tethering, LRO is disabled. If SSR happened |
| 4383 | * during that time, then as part of SSR init, do not enable |
| 4384 | * the LRO again. Keep the LRO state same as before SSR. |
| 4385 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 4386 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4387 | cfg_dp_lro_enable) && |
| 4388 | !(qdf_atomic_read(&hdd_ctx->vendor_disable_lro_flag))) |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 4389 | adapter->dev->features |= NETIF_F_LRO; |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4390 | |
Rakshith Suresh Patkar | 9f5c586 | 2019-02-04 16:23:02 +0530 | [diff] [blame] | 4391 | if (cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 4392 | cfg_dp_enable_ip_tcp_udp_checksum_offload)) |
| 4393 | adapter->dev->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; |
| 4394 | adapter->dev->features |= NETIF_F_RXCSUM; |
| 4395 | |
| 4396 | hdd_set_tso_flags(hdd_ctx, adapter->dev); |
| 4397 | |
Rajeev Kumar Sirasanagandla | 996e529 | 2016-11-22 21:20:33 +0530 | [diff] [blame] | 4398 | /* rcpi info initialization */ |
| 4399 | qdf_mem_zero(&adapter->rcpi, sizeof(adapter->rcpi)); |
| 4400 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4401 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4402 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4403 | error_wmm_init: |
| 4404 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4405 | hdd_deinit_tx_rx(adapter); |
| 4406 | error_init_txrx: |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4407 | hdd_unregister_wext(adapter->dev); |
Dustin Brown | d28772b | 2017-03-17 14:16:07 -0700 | [diff] [blame] | 4408 | QDF_BUG(!hdd_vdev_destroy(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4409 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4410 | return status; |
| 4411 | } |
| 4412 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4413 | /** |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4414 | * hdd_deinit_station_mode() - De-initialize the station adapter |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4415 | * @hdd_ctx: global hdd context |
| 4416 | * @adapter: HDD adapter |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4417 | * @rtnl_held: Used to indicate whether or not the caller is holding |
| 4418 | * the kernel rtnl_mutex |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4419 | * |
| 4420 | * This function De-initializes the STA/P2P/OCB adapter. |
| 4421 | * |
| 4422 | * Return: None. |
| 4423 | */ |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4424 | static void hdd_deinit_station_mode(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4425 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4426 | bool rtnl_held) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4427 | { |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4428 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4429 | |
Hanumanth Reddy Pothula | 7a65740 | 2016-09-07 20:59:18 +0530 | [diff] [blame] | 4430 | if (adapter->dev) { |
| 4431 | if (rtnl_held) |
| 4432 | adapter->dev->wireless_handlers = NULL; |
| 4433 | else { |
| 4434 | rtnl_lock(); |
| 4435 | adapter->dev->wireless_handlers = NULL; |
| 4436 | rtnl_unlock(); |
| 4437 | } |
| 4438 | } |
| 4439 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4440 | if (test_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags)) { |
| 4441 | hdd_deinit_tx_rx(adapter); |
| 4442 | clear_bit(INIT_TX_RX_SUCCESS, &adapter->event_flags); |
| 4443 | } |
| 4444 | |
| 4445 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 4446 | hdd_wmm_adapter_close(adapter); |
| 4447 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 4448 | } |
| 4449 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4450 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4451 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4452 | } |
| 4453 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4454 | void hdd_deinit_adapter(struct hdd_context *hdd_ctx, |
| 4455 | struct hdd_adapter *adapter, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4456 | bool rtnl_held) |
| 4457 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 4458 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 4459 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4460 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4461 | case QDF_STA_MODE: |
| 4462 | case QDF_P2P_CLIENT_MODE: |
| 4463 | case QDF_P2P_DEVICE_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 4464 | case QDF_IBSS_MODE: |
| 4465 | case QDF_NDI_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4466 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4467 | hdd_deinit_station_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4468 | break; |
| 4469 | } |
| 4470 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 4471 | case QDF_SAP_MODE: |
| 4472 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4473 | { |
Krunal Soni | 4a020c7 | 2017-10-30 20:58:40 -0700 | [diff] [blame] | 4474 | hdd_deinit_ap_mode(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4475 | break; |
| 4476 | } |
| 4477 | |
| 4478 | default: |
| 4479 | break; |
| 4480 | } |
| 4481 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4482 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4483 | } |
| 4484 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4485 | static void hdd_cleanup_adapter(struct hdd_context *hdd_ctx, |
| 4486 | struct hdd_adapter *adapter, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 4487 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4488 | { |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4489 | struct net_device *dev = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4490 | |
| 4491 | if (adapter) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4492 | dev = adapter->dev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4493 | else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 4494 | hdd_err("adapter is Null"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4495 | return; |
| 4496 | } |
| 4497 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4498 | hdd_nud_deinit_tracking(adapter); |
| 4499 | qdf_mutex_destroy(&adapter->disconnection_status_lock); |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 4500 | hdd_apf_context_destroy(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 4501 | qdf_spinlock_destroy(&adapter->vdev_lock); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 4502 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4503 | wlan_hdd_debugfs_csr_deinit(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 4504 | if (adapter->device_mode == QDF_STA_MODE) |
| 4505 | hdd_sysfs_destroy_adapter_root_obj(adapter); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 4506 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 4507 | hdd_debugfs_exit(adapter); |
Selvaraj, Sridhar | 4ea106e | 2016-08-05 20:34:46 +0530 | [diff] [blame] | 4508 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4509 | /* |
| 4510 | * The adapter is marked as closed. When hdd_wlan_exit() call returns, |
| 4511 | * the driver is almost closed and cannot handle either control |
| 4512 | * messages or data. However, unregister_netdevice() call above will |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4513 | * eventually invoke hdd_stop(ndo_close) driver callback, which attempts |
| 4514 | * to close the active connections(basically excites control path) which |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4515 | * is not right. Setting this flag helps hdd_stop() to recognize that |
| 4516 | * the interface is closed and restricts any operations on that |
| 4517 | */ |
| 4518 | clear_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); |
| 4519 | |
| 4520 | if (test_bit(NET_DEVICE_REGISTERED, &adapter->event_flags)) { |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4521 | if (rtnl_held) |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4522 | unregister_netdevice(dev); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4523 | else |
Jeff Johnson | 5505db8 | 2017-11-02 21:19:23 -0700 | [diff] [blame] | 4524 | unregister_netdev(dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4525 | /* |
| 4526 | * Note that the adapter is no longer valid at this point |
| 4527 | * since the memory has been reclaimed |
| 4528 | */ |
| 4529 | } |
| 4530 | } |
| 4531 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4532 | static QDF_STATUS hdd_check_for_existing_macaddr(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4533 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4534 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4535 | struct hdd_adapter *adapter; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 4536 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4537 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 4538 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 4539 | mac_addr, sizeof(tSirMacAddr))) { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4540 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4541 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4542 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 4543 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 4544 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4545 | } |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4546 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4547 | #ifdef CONFIG_FW_LOGS_BASED_ON_INI |
| 4548 | /** |
| 4549 | * hdd_set_fw_log_params() - Set log parameters to FW |
| 4550 | * @hdd_ctx: HDD Context |
| 4551 | * @adapter: HDD Adapter |
| 4552 | * |
| 4553 | * This function set the FW Debug log level based on the INI. |
| 4554 | * |
| 4555 | * Return: None |
| 4556 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4557 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4558 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4559 | { |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4560 | QDF_STATUS status; |
| 4561 | uint16_t enable_fw_log_level, enable_fw_log_type; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4562 | int ret; |
| 4563 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4564 | if (QDF_GLOBAL_FTM_MODE == cds_get_conparam() || |
| 4565 | (!hdd_ctx->config->enable_fw_log)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 4566 | 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] | 4567 | return; |
| 4568 | } |
| 4569 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4570 | /* Enable FW logs based on INI configuration */ |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4571 | status = ucfg_fwol_get_enable_fw_log_type(hdd_ctx->psoc, |
| 4572 | &enable_fw_log_type); |
| 4573 | if (QDF_IS_STATUS_ERROR(status)) |
| 4574 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4575 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4576 | WMI_DBGLOG_TYPE, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4577 | enable_fw_log_type, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4578 | DBG_CMD); |
| 4579 | if (ret != 0) |
| 4580 | hdd_err("Failed to enable FW log type ret %d", |
| 4581 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4582 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4583 | status = ucfg_fwol_get_enable_fw_log_level(hdd_ctx->psoc, |
| 4584 | &enable_fw_log_level); |
| 4585 | if (QDF_IS_STATUS_ERROR(status)) |
| 4586 | return; |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4587 | ret = sme_cli_set_command(adapter->vdev_id, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4588 | WMI_DBGLOG_LOG_LEVEL, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4589 | enable_fw_log_level, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4590 | DBG_CMD); |
| 4591 | if (ret != 0) |
| 4592 | hdd_err("Failed to enable FW log level ret %d", |
| 4593 | ret); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4594 | |
lifeng | faa83cb | 2018-11-24 01:53:56 +0800 | [diff] [blame] | 4595 | sme_enable_fw_module_log_level(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4596 | adapter->vdev_id); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4597 | } |
| 4598 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4599 | static void hdd_set_fw_log_params(struct hdd_context *hdd_ctx, |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4600 | struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4601 | { |
| 4602 | } |
| 4603 | |
| 4604 | #endif |
| 4605 | |
| 4606 | /** |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4607 | * hdd_configure_chain_mask() - programs chain mask to firmware |
| 4608 | * @adapter: HDD adapter |
| 4609 | * |
| 4610 | * Return: 0 on success or errno on failure |
| 4611 | */ |
| 4612 | static int hdd_configure_chain_mask(struct hdd_adapter *adapter) |
| 4613 | { |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4614 | QDF_STATUS status; |
| 4615 | struct wma_caps_per_phy non_dbs_phy_cap; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4616 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4617 | bool enable2x2 = false, enable_bt_chain_sep = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4618 | uint8_t dual_mac_feature = DISABLE_DBS_CXN_AND_SCAN; |
| 4619 | |
| 4620 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 4621 | &dual_mac_feature); |
| 4622 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4623 | hdd_err("unable to get dual mac feature"); |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4624 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4625 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &enable2x2); |
| 4626 | if (QDF_IS_STATUS_ERROR(status)) |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4627 | hdd_err("unable to get vht_enable2x2"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4628 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4629 | status = ucfg_mlme_get_bt_chain_separation_flag(hdd_ctx->psoc, |
| 4630 | &enable_bt_chain_sep); |
| 4631 | if (QDF_IS_STATUS_ERROR(status)) |
| 4632 | hdd_debug("unable to get BT chain separation. using default"); |
| 4633 | |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4634 | hdd_debug("enable2x2: %d, lte_coex: %d, disable_DBS: %d", |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4635 | enable2x2, hdd_ctx->lte_coex_ant_share, |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4636 | dual_mac_feature); |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4637 | hdd_debug("enable_bt_chain_separation %d", enable_bt_chain_sep); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4638 | |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4639 | status = wma_get_caps_for_phyidx_hwmode(&non_dbs_phy_cap, |
| 4640 | HW_MODE_DBS_NONE, |
| 4641 | CDS_BAND_ALL); |
| 4642 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4643 | hdd_err("couldn't get phy caps. skip chain mask programming"); |
| 4644 | return qdf_status_to_os_return(status); |
| 4645 | } |
| 4646 | |
| 4647 | if (non_dbs_phy_cap.tx_chain_mask_2G < 3 || |
| 4648 | non_dbs_phy_cap.rx_chain_mask_2G < 3 || |
| 4649 | non_dbs_phy_cap.tx_chain_mask_5G < 3 || |
| 4650 | non_dbs_phy_cap.rx_chain_mask_5G < 3) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4651 | hdd_debug("firmware not capable. skip chain mask programming"); |
Naveen Rawat | 9832247 | 2018-03-06 10:29:42 -0800 | [diff] [blame] | 4652 | return 0; |
| 4653 | } |
| 4654 | |
Pragaspathi Thilagaraj | 4b5c060 | 2018-11-14 22:35:23 +0530 | [diff] [blame] | 4655 | if (enable2x2 && !enable_bt_chain_sep) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4656 | hdd_debug("2x2 enabled. skip chain mask programming"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4657 | return 0; |
| 4658 | } |
| 4659 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4660 | if (dual_mac_feature != DISABLE_DBS_CXN_AND_SCAN) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4661 | hdd_debug("DBS enabled(%d). skip chain mask programming", |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 4662 | dual_mac_feature); |
Naveen Rawat | b54c72b | 2018-02-05 10:39:06 -0800 | [diff] [blame] | 4663 | return 0; |
| 4664 | } |
| 4665 | |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4666 | if (hdd_ctx->lte_coex_ant_share) { |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 4667 | hdd_debug("lte ant sharing enabled. skip chainmask programming"); |
Naveen Rawat | dacb503 | 2018-02-08 15:23:24 -0800 | [diff] [blame] | 4668 | return 0; |
| 4669 | } |
| 4670 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 4671 | status = ucfg_mlme_configure_chain_mask(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4672 | adapter->vdev_id); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4673 | if (status != QDF_STATUS_SUCCESS) |
| 4674 | goto error; |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4675 | |
| 4676 | return 0; |
| 4677 | |
| 4678 | error: |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 4679 | hdd_err("WMI PDEV set param failed"); |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4680 | return -EINVAL; |
| 4681 | } |
| 4682 | |
| 4683 | /** |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4684 | * hdd_send_coex_config_params() - Send coex config params to FW |
| 4685 | * @hdd_ctx: HDD context |
| 4686 | * @adapter: Primary adapter context |
| 4687 | * |
| 4688 | * This function is used to send all coex config related params to FW |
| 4689 | * |
| 4690 | * Return: 0 on success and -EINVAL on failure |
| 4691 | */ |
| 4692 | static int hdd_send_coex_config_params(struct hdd_context *hdd_ctx, |
| 4693 | struct hdd_adapter *adapter) |
| 4694 | { |
| 4695 | struct coex_config_params coex_cfg_params = {0}; |
| 4696 | struct wlan_fwol_coex_config config = {0}; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 4697 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4698 | QDF_STATUS status; |
| 4699 | |
| 4700 | if (!hdd_ctx) { |
| 4701 | hdd_err("hdd_ctx is invalid"); |
| 4702 | goto err; |
| 4703 | } |
| 4704 | |
| 4705 | if (!adapter) { |
| 4706 | hdd_err("adapter is invalid"); |
| 4707 | goto err; |
| 4708 | } |
| 4709 | |
| 4710 | if (!psoc) { |
| 4711 | hdd_err("HDD psoc is invalid"); |
| 4712 | goto err; |
| 4713 | } |
| 4714 | |
| 4715 | status = ucfg_fwol_get_coex_config_params(psoc, &config); |
| 4716 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4717 | hdd_err("Unable to get coex config params"); |
| 4718 | goto err; |
| 4719 | } |
| 4720 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4721 | coex_cfg_params.vdev_id = adapter->vdev_id; |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4722 | coex_cfg_params.config_type = WMI_COEX_CONFIG_TX_POWER; |
| 4723 | coex_cfg_params.config_arg1 = config.max_tx_power_for_btc; |
| 4724 | |
| 4725 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4726 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4727 | hdd_err("Failed to send coex Tx power"); |
| 4728 | goto err; |
| 4729 | } |
| 4730 | |
| 4731 | coex_cfg_params.config_type = WMI_COEX_CONFIG_HANDOVER_RSSI; |
| 4732 | coex_cfg_params.config_arg1 = config.wlan_low_rssi_threshold; |
| 4733 | |
| 4734 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4735 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4736 | hdd_err("Failed to send coex handover RSSI"); |
| 4737 | goto err; |
| 4738 | } |
| 4739 | |
| 4740 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BTC_MODE; |
| 4741 | coex_cfg_params.config_arg1 = config.btc_mode; |
| 4742 | |
| 4743 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4744 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4745 | hdd_err("Failed to send coex BTC mode"); |
| 4746 | goto err; |
| 4747 | } |
| 4748 | |
| 4749 | coex_cfg_params.config_type = WMI_COEX_CONFIG_ANTENNA_ISOLATION; |
| 4750 | coex_cfg_params.config_arg1 = config.antenna_isolation; |
| 4751 | |
| 4752 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4753 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4754 | hdd_err("Failed to send coex antenna isolation"); |
| 4755 | goto err; |
| 4756 | } |
| 4757 | |
| 4758 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_LOW_RSSI_THRESHOLD; |
| 4759 | coex_cfg_params.config_arg1 = config.bt_low_rssi_threshold; |
| 4760 | |
| 4761 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4762 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4763 | hdd_err("Failed to send coex BT low RSSI threshold"); |
| 4764 | goto err; |
| 4765 | } |
| 4766 | |
| 4767 | coex_cfg_params.config_type = WMI_COEX_CONFIG_BT_INTERFERENCE_LEVEL; |
| 4768 | coex_cfg_params.config_arg1 = config.bt_interference_low_ll; |
| 4769 | coex_cfg_params.config_arg2 = config.bt_interference_low_ul; |
| 4770 | coex_cfg_params.config_arg3 = config.bt_interference_medium_ll; |
| 4771 | coex_cfg_params.config_arg4 = config.bt_interference_medium_ul; |
| 4772 | coex_cfg_params.config_arg5 = config.bt_interference_high_ll; |
| 4773 | coex_cfg_params.config_arg6 = config.bt_interference_high_ul; |
| 4774 | |
| 4775 | status = sme_send_coex_config_cmd(&coex_cfg_params); |
| 4776 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4777 | hdd_err("Failed to send coex BT interference level"); |
| 4778 | goto err; |
| 4779 | } |
stonez | c9936cb | 2019-03-11 16:41:22 +0800 | [diff] [blame] | 4780 | |
| 4781 | if (wlan_hdd_mpta_helper_enable(&coex_cfg_params, &config)) |
| 4782 | goto err; |
| 4783 | |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4784 | return 0; |
| 4785 | err: |
| 4786 | return -EINVAL; |
| 4787 | } |
| 4788 | |
| 4789 | /** |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4790 | * hdd_set_fw_params() - Set parameters to firmware |
| 4791 | * @adapter: HDD adapter |
| 4792 | * |
| 4793 | * This function Sets various parameters to fw once the |
| 4794 | * adapter is started. |
| 4795 | * |
| 4796 | * Return: 0 on success or errno on failure |
| 4797 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 4798 | int hdd_set_fw_params(struct hdd_adapter *adapter) |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4799 | { |
| 4800 | int ret; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4801 | uint16_t upper_brssi_thresh, lower_brssi_thresh, rts_profile; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4802 | bool enable_dtim_1chrx; |
| 4803 | QDF_STATUS status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 4804 | struct hdd_context *hdd_ctx; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4805 | bool bval = false; |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4806 | uint8_t max_amsdu_len, enable_tx_sch_delay; |
| 4807 | uint32_t dtim_sel_diversity, enable_secondary_rate; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4808 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 4809 | hdd_enter_dev(adapter->dev); |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4810 | |
| 4811 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 4812 | if (!hdd_ctx) |
| 4813 | return -EINVAL; |
| 4814 | |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4815 | if (cds_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
| 4816 | hdd_debug("FTM Mode is active; nothing to do"); |
| 4817 | return 0; |
| 4818 | } |
| 4819 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4820 | ret = -1; |
| 4821 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_lprx_enable(hdd_ctx->psoc, |
| 4822 | &bval))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4823 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4824 | WMI_PDEV_PARAM_DTIM_SYNTH, |
| 4825 | bval, PDEV_CMD); |
| 4826 | } |
Ashish Kumar Dhanotiya | b8630ab | 2017-07-21 14:18:14 +0530 | [diff] [blame] | 4827 | if (ret) { |
| 4828 | hdd_err("Failed to set LPRx"); |
| 4829 | goto error; |
| 4830 | } |
| 4831 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4832 | ucfg_mlme_get_dtim_selection_diversity(hdd_ctx->psoc, |
| 4833 | &dtim_sel_diversity); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4834 | |
| 4835 | ret = sme_cli_set_command( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4836 | adapter->vdev_id, |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4837 | WMI_PDEV_PARAM_1CH_DTIM_OPTIMIZED_CHAIN_SELECTION, |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 4838 | dtim_sel_diversity, PDEV_CMD); |
Ashish Kumar Dhanotiya | 191d164 | 2018-02-08 17:43:09 +0530 | [diff] [blame] | 4839 | if (ret) { |
| 4840 | hdd_err("Failed to set DTIM_OPTIMIZED_CHAIN_SELECTION"); |
| 4841 | goto error; |
| 4842 | } |
| 4843 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4844 | ret = -1; |
| 4845 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_tx_sch_delay( |
| 4846 | hdd_ctx->psoc, &enable_tx_sch_delay))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4847 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4848 | WMI_PDEV_PARAM_TX_SCH_DELAY, |
| 4849 | enable_tx_sch_delay, PDEV_CMD); |
| 4850 | } |
Ashish Kumar Dhanotiya | 48dac7d | 2018-03-28 14:59:50 +0530 | [diff] [blame] | 4851 | if (ret) { |
| 4852 | hdd_err("Failed to set WMI_PDEV_PARAM_TX_SCH_DELAY"); |
| 4853 | goto error; |
| 4854 | } |
| 4855 | |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4856 | ret = -1; |
| 4857 | if (QDF_IS_STATUS_SUCCESS(ucfg_fwol_get_enable_secondary_rate( |
| 4858 | hdd_ctx->psoc, &enable_secondary_rate))) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4859 | ret = sme_cli_set_command(adapter->vdev_id, |
Manikandan Mohan | d350c19 | 2018-11-29 14:01:12 -0800 | [diff] [blame] | 4860 | WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE, |
| 4861 | enable_secondary_rate, PDEV_CMD); |
| 4862 | } |
Ashish Kumar Dhanotiya | 959b38c | 2018-04-06 21:07:57 +0530 | [diff] [blame] | 4863 | if (ret) { |
| 4864 | hdd_err("Failed to set WMI_PDEV_PARAM_SECONDARY_RETRY_ENABLE"); |
| 4865 | goto error; |
| 4866 | } |
| 4867 | |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4868 | if (adapter->device_mode == QDF_STA_MODE) { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4869 | status = ucfg_get_upper_brssi_thresh(hdd_ctx->psoc, |
| 4870 | &upper_brssi_thresh); |
| 4871 | if (QDF_IS_STATUS_ERROR(status)) |
| 4872 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4873 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4874 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4875 | HDD_STA_SMPS_PARAM_UPPER_BRSSI_THRESH, |
| 4876 | upper_brssi_thresh); |
| 4877 | |
| 4878 | status = ucfg_get_lower_brssi_thresh(hdd_ctx->psoc, |
| 4879 | &lower_brssi_thresh); |
| 4880 | if (QDF_IS_STATUS_ERROR(status)) |
| 4881 | return -EINVAL; |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4882 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4883 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4884 | HDD_STA_SMPS_PARAM_LOWER_BRSSI_THRESH, |
| 4885 | lower_brssi_thresh); |
| 4886 | |
| 4887 | status = ucfg_get_enable_dtim_1chrx(hdd_ctx->psoc, |
| 4888 | &enable_dtim_1chrx); |
| 4889 | if (QDF_IS_STATUS_ERROR(status)) |
| 4890 | return -EINVAL; |
| 4891 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4892 | sme_set_smps_cfg(adapter->vdev_id, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 4893 | HDD_STA_SMPS_PARAM_DTIM_1CHRX_ENABLE, |
| 4894 | enable_dtim_1chrx); |
Ashish Kumar Dhanotiya | b28338c | 2017-07-21 20:12:34 +0530 | [diff] [blame] | 4895 | } |
| 4896 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 4897 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 4898 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 4899 | hdd_err("unable to get vht_enable2x2"); |
| 4900 | |
| 4901 | if (bval) { |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4902 | hdd_debug("configuring 2x2 mode fw params"); |
| 4903 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4904 | ret = sme_set_cck_tx_fir_override(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4905 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4906 | if (ret) { |
| 4907 | hdd_err("WMI_PDEV_PARAM_ENABLE_CCK_TXFIR_OVERRIDE set failed %d", |
| 4908 | ret); |
| 4909 | goto error; |
| 4910 | } |
Liangwei Dong | 22810e8 | 2018-03-15 03:42:12 -0400 | [diff] [blame] | 4911 | |
| 4912 | if (hdd_configure_chain_mask(adapter)) |
| 4913 | goto error; |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4914 | } else { |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4915 | #define HDD_DTIM_1CHAIN_RX_ID 0x5 |
| 4916 | #define HDD_SMPS_PARAM_VALUE_S 29 |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4917 | hdd_debug("configuring 1x1 mode fw params"); |
| 4918 | |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4919 | /* |
| 4920 | * Disable DTIM 1 chain Rx when in 1x1, |
| 4921 | * we are passing two value |
| 4922 | * as param_id << 29 | param_value. |
| 4923 | * Below param_value = 0(disable) |
| 4924 | */ |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4925 | ret = sme_cli_set_command(adapter->vdev_id, |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4926 | WMI_STA_SMPS_PARAM_CMDID, |
| 4927 | HDD_DTIM_1CHAIN_RX_ID << |
| 4928 | HDD_SMPS_PARAM_VALUE_S, |
| 4929 | VDEV_CMD); |
| 4930 | if (ret) { |
| 4931 | hdd_err("DTIM 1 chain set failed %d", ret); |
| 4932 | goto error; |
| 4933 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4934 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4935 | #undef HDD_DTIM_1CHAIN_RX_ID |
| 4936 | #undef HDD_SMPS_PARAM_VALUE_S |
Naveen Rawat | 269b4ed | 2017-12-07 06:47:32 -0800 | [diff] [blame] | 4937 | |
| 4938 | if (hdd_configure_chain_mask(adapter)) |
| 4939 | goto error; |
Krishna Kumaar Natarajan | aa93872 | 2016-08-21 23:18:53 -0700 | [diff] [blame] | 4940 | } |
| 4941 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 4942 | ret = sme_set_enable_mem_deep_sleep(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4943 | adapter->vdev_id); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4944 | if (ret) { |
| 4945 | hdd_err("WMI_PDEV_PARAM_HYST_EN set failed %d", ret); |
| 4946 | goto error; |
| 4947 | } |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4948 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4949 | status = ucfg_fwol_get_rts_profile(hdd_ctx->psoc, &rts_profile); |
| 4950 | if (QDF_IS_STATUS_ERROR(status)) |
| 4951 | return -EINVAL; |
| 4952 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4953 | ret = sme_cli_set_command(adapter->vdev_id, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4954 | WMI_VDEV_PARAM_ENABLE_RTSCTS, |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 4955 | rts_profile, |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4956 | VDEV_CMD); |
| 4957 | if (ret) { |
| 4958 | hdd_err("FAILED TO SET RTSCTS Profile ret:%d", ret); |
| 4959 | goto error; |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4960 | } |
| 4961 | |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4962 | status = ucfg_mlme_get_max_amsdu_num(hdd_ctx->psoc, &max_amsdu_len); |
| 4963 | if (QDF_IS_STATUS_ERROR(status)) { |
| 4964 | hdd_err("Failed to get Max AMSDU Num"); |
| 4965 | goto error; |
| 4966 | } |
| 4967 | |
| 4968 | hdd_debug("SET AMSDU num %d", max_amsdu_len); |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4969 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 4970 | ret = wma_cli_set_command(adapter->vdev_id, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4971 | GEN_VDEV_PARAM_AMSDU, |
Vignesh Viswanathan | ddc89e5 | 2018-11-02 18:43:42 +0530 | [diff] [blame] | 4972 | max_amsdu_len, |
Deepak Dhamdhere | 612392c | 2016-08-28 02:56:51 -0700 | [diff] [blame] | 4973 | GEN_CMD); |
| 4974 | if (ret != 0) { |
| 4975 | hdd_err("GEN_VDEV_PARAM_AMSDU set failed %d", ret); |
| 4976 | goto error; |
| 4977 | } |
| 4978 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4979 | hdd_set_fw_log_params(hdd_ctx, adapter); |
Dundi Raviteja | 3b63709 | 2018-09-12 13:42:50 +0530 | [diff] [blame] | 4980 | |
| 4981 | ret = hdd_send_coex_config_params(hdd_ctx, adapter); |
| 4982 | if (ret) { |
| 4983 | hdd_warn("Error initializing coex config params"); |
| 4984 | goto error; |
| 4985 | } |
| 4986 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 4987 | hdd_exit(); |
Dustin Brown | 732ab9c | 2017-06-15 13:24:09 -0700 | [diff] [blame] | 4988 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4989 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 4990 | |
Arun Khandavalli | 2358d52 | 2016-05-16 18:05:37 +0530 | [diff] [blame] | 4991 | error: |
| 4992 | return -EINVAL; |
| 4993 | } |
| 4994 | |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 4995 | /** |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 4996 | * hdd_init_completion() - Initialize Completion Variables |
| 4997 | * @adapter: HDD adapter |
| 4998 | * |
| 4999 | * This function Initialize the completion variables for |
| 5000 | * a particular adapter |
| 5001 | * |
| 5002 | * Return: None |
| 5003 | */ |
| 5004 | static void hdd_init_completion(struct hdd_adapter *adapter) |
| 5005 | { |
| 5006 | init_completion(&adapter->disconnect_comp_var); |
| 5007 | init_completion(&adapter->roaming_comp_var); |
| 5008 | init_completion(&adapter->linkup_event_var); |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5009 | init_completion(&adapter->sta_authorized_event); |
| 5010 | init_completion(&adapter->offchannel_tx_event); |
| 5011 | init_completion(&adapter->tx_action_cnf_event); |
| 5012 | init_completion(&adapter->ibss_peer_info_comp); |
| 5013 | init_completion(&adapter->lfr_fw_status.disable_lfr_event); |
| 5014 | } |
| 5015 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5016 | static void hdd_reset_locally_admin_bit(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5017 | tSirMacAddr mac_addr) |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5018 | { |
| 5019 | int i; |
| 5020 | /* |
| 5021 | * Reset locally administered bit for dynamic_mac_list |
| 5022 | * also as while releasing the MAC address for any |
| 5023 | * interface mac will be compared with dynamic mac list |
| 5024 | */ |
| 5025 | for (i = 0; i < QDF_MAX_CONCURRENCY_PERSONA; i++) { |
| 5026 | if (!qdf_mem_cmp( |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5027 | mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5028 | &hdd_ctx-> |
| 5029 | dynamic_mac_list[i].dynamic_mac.bytes[0], |
| 5030 | sizeof(struct qdf_mac_addr))) { |
| 5031 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT( |
| 5032 | hdd_ctx-> |
| 5033 | dynamic_mac_list[i].dynamic_mac.bytes); |
| 5034 | break; |
| 5035 | } |
| 5036 | } |
| 5037 | /* |
| 5038 | * Reset locally administered bit if the device mode is |
| 5039 | * STA |
| 5040 | */ |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5041 | WLAN_HDD_RESET_LOCALLY_ADMINISTERED_BIT(mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5042 | hdd_debug("locally administered bit reset in sta mode: " |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5043 | MAC_ADDRESS_STR, QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 5044 | } |
| 5045 | |
Dustin Brown | 96b98dd | 2019-03-06 12:39:37 -0800 | [diff] [blame] | 5046 | static void wlan_hdd_cfg80211_scan_block_cb(struct work_struct *work) |
| 5047 | { |
| 5048 | struct hdd_adapter *adapter = |
| 5049 | container_of(work, struct hdd_adapter, scan_block_work); |
| 5050 | struct osif_vdev_sync *vdev_sync; |
| 5051 | |
| 5052 | if (osif_vdev_sync_op_start(adapter->dev, &vdev_sync)) |
| 5053 | return; |
| 5054 | |
| 5055 | wlan_hdd_cfg80211_scan_block(adapter); |
| 5056 | |
| 5057 | osif_vdev_sync_op_stop(vdev_sync); |
| 5058 | } |
| 5059 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5060 | /** |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5061 | * hdd_open_adapter() - open and setup the hdd adatper |
| 5062 | * @hdd_ctx: global hdd context |
| 5063 | * @session_type: type of the interface to be created |
| 5064 | * @iface_name: User-visible name of the interface |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5065 | * @mac_addr: MAC address to assign to the interface |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5066 | * @name_assign_type: the name of assign type of the netdev |
| 5067 | * @rtnl_held: the rtnl lock hold flag |
| 5068 | * |
| 5069 | * This function open and setup the hdd adpater according to the device |
| 5070 | * type request, assign the name, the mac address assigned, and then prepared |
| 5071 | * the hdd related parameters, queue, lock and ready to start. |
| 5072 | * |
| 5073 | * Return: the pointer of hdd adapter, otherwise NULL. |
| 5074 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5075 | struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t session_type, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5076 | const char *iface_name, tSirMacAddr mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5077 | unsigned char name_assign_type, |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 5078 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5079 | { |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5080 | struct net_device *ndev = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5081 | struct hdd_adapter *adapter = NULL; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5082 | QDF_STATUS status = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5083 | |
| 5084 | if (hdd_ctx->current_intf_count >= hdd_ctx->max_intf_count) { |
| 5085 | /* |
| 5086 | * Max limit reached on the number of vdevs configured by the |
| 5087 | * host. Return error |
| 5088 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5089 | hdd_err("Unable to add virtual intf: currentVdevCnt=%d,hostConfiguredVdevCnt=%d", |
| 5090 | hdd_ctx->current_intf_count, hdd_ctx->max_intf_count); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5091 | return NULL; |
| 5092 | } |
| 5093 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5094 | status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)mac_addr); |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5095 | if (QDF_IS_STATUS_ERROR(status)) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5096 | /* Not received valid mac_addr */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5097 | 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] | 5098 | return NULL; |
| 5099 | } |
Pragaspathi Thilagaraj | 84b7284 | 2018-09-19 22:06:57 +0530 | [diff] [blame] | 5100 | |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5101 | status = hdd_check_for_existing_macaddr(hdd_ctx, mac_addr); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5102 | if (QDF_STATUS_E_FAILURE == status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5103 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5104 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5105 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5106 | return NULL; |
| 5107 | } |
| 5108 | |
| 5109 | switch (session_type) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5110 | case QDF_STA_MODE: |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5111 | if (!hdd_ctx->config->mac_provision) { |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5112 | hdd_reset_locally_admin_bit(hdd_ctx, mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5113 | /* |
| 5114 | * After resetting locally administered bit |
| 5115 | * again check if the new mac address is already |
| 5116 | * exists. |
| 5117 | */ |
| 5118 | status = hdd_check_for_existing_macaddr(hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5119 | mac_addr); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5120 | if (QDF_STATUS_E_FAILURE == status) { |
| 5121 | hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR |
| 5122 | " already exists", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 5123 | QDF_MAC_ADDR_ARRAY(mac_addr)); |
Ashish Kumar Dhanotiya | 0148519 | 2018-12-24 12:44:06 +0530 | [diff] [blame] | 5124 | return NULL; |
| 5125 | } |
| 5126 | } |
Ashish Kumar Dhanotiya | 6784b50 | 2018-10-17 12:51:10 +0530 | [diff] [blame] | 5127 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5128 | /* fall through */ |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5129 | case QDF_P2P_CLIENT_MODE: |
| 5130 | case QDF_P2P_DEVICE_MODE: |
| 5131 | case QDF_OCB_MODE: |
Deepak Dhamdhere | 5cdce84 | 2016-05-31 10:39:12 -0700 | [diff] [blame] | 5132 | case QDF_NDI_MODE: |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5133 | case QDF_MONITOR_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5134 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5135 | name_assign_type, |
| 5136 | iface_name); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5137 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5138 | if (!adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5139 | hdd_err("failed to allocate adapter for session %d", |
| 5140 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5141 | return NULL; |
| 5142 | } |
| 5143 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5144 | ndev = adapter->dev; |
| 5145 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5146 | if (QDF_P2P_CLIENT_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5147 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_CLIENT; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5148 | else if (QDF_P2P_DEVICE_MODE == session_type) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5149 | adapter->wdev.iftype = NL80211_IFTYPE_P2P_DEVICE; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5150 | else if (QDF_MONITOR_MODE == session_type) |
| 5151 | adapter->wdev.iftype = NL80211_IFTYPE_MONITOR; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5152 | else |
| 5153 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5154 | |
| 5155 | adapter->device_mode = session_type; |
| 5156 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5157 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5158 | /* |
| 5159 | * Workqueue which gets scheduled in IPv4 notification |
| 5160 | * callback |
| 5161 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5162 | INIT_WORK(&adapter->ipv4_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5163 | hdd_ipv4_notifier_work_queue); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5164 | |
| 5165 | #ifdef WLAN_NS_OFFLOAD |
| 5166 | /* |
| 5167 | * Workqueue which gets scheduled in IPv6 |
| 5168 | * notification callback. |
| 5169 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5170 | INIT_WORK(&adapter->ipv6_notifier_work, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5171 | hdd_ipv6_notifier_work_queue); |
| 5172 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5173 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5174 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5175 | goto err_free_netdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5176 | |
| 5177 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5178 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5179 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5180 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5181 | WLAN_CONTROL_PATH); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5182 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5183 | hdd_nud_init_tracking(adapter); |
Arunk Khandavalli | ca56d4b | 2018-11-29 15:46:00 +0530 | [diff] [blame] | 5184 | if (adapter->device_mode == QDF_STA_MODE || |
| 5185 | adapter->device_mode == QDF_P2P_DEVICE_MODE) |
| 5186 | hdd_sysfs_create_adapter_root_obj(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5187 | qdf_mutex_create(&adapter->disconnection_status_lock); |
| 5188 | |
Ravi Joshi | 1a29256 | 2017-05-18 16:28:54 -0700 | [diff] [blame] | 5189 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5190 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5191 | case QDF_P2P_GO_MODE: |
| 5192 | case QDF_SAP_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5193 | adapter = hdd_wlan_create_ap_dev(hdd_ctx, mac_addr, |
Ryan Hsu | 07495ea | 2016-01-21 15:25:39 -0800 | [diff] [blame] | 5194 | name_assign_type, |
| 5195 | (uint8_t *) iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5196 | if (!adapter) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5197 | hdd_err("failed to allocate adapter for session %d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5198 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5199 | return NULL; |
| 5200 | } |
| 5201 | |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5202 | ndev = adapter->dev; |
| 5203 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5204 | adapter->wdev.iftype = |
| 5205 | (session_type == |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5206 | QDF_SAP_MODE) ? NL80211_IFTYPE_AP : |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5207 | NL80211_IFTYPE_P2P_GO; |
| 5208 | adapter->device_mode = session_type; |
| 5209 | |
Mahesh Kumar Kalikot Veetil | aff9486 | 2017-07-28 11:06:19 -0700 | [diff] [blame] | 5210 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5211 | if (QDF_STATUS_SUCCESS != status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5212 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5213 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5214 | hdd_debug("Disabling queues"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5215 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5216 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5217 | WLAN_CONTROL_PATH); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5218 | |
| 5219 | /* |
| 5220 | * Workqueue which gets scheduled in IPv4 notification |
| 5221 | * callback |
| 5222 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5223 | INIT_WORK(&adapter->ipv4_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5224 | hdd_ipv4_notifier_work_queue); |
| 5225 | |
| 5226 | #ifdef WLAN_NS_OFFLOAD |
| 5227 | /* |
| 5228 | * Workqueue which gets scheduled in IPv6 |
| 5229 | * notification callback. |
| 5230 | */ |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5231 | INIT_WORK(&adapter->ipv6_notifier_work, |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5232 | hdd_ipv6_notifier_work_queue); |
| 5233 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5234 | break; |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5235 | case QDF_FTM_MODE: |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 5236 | adapter = hdd_alloc_station_adapter(hdd_ctx, mac_addr, |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5237 | name_assign_type, |
Lin Bai | 1c67848 | 2017-12-18 18:29:11 +0800 | [diff] [blame] | 5238 | iface_name); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5239 | if (!adapter) { |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5240 | hdd_err("Failed to allocate adapter for FTM mode"); |
| 5241 | return NULL; |
| 5242 | } |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5243 | |
| 5244 | ndev = adapter->dev; |
| 5245 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5246 | adapter->wdev.iftype = NL80211_IFTYPE_STATION; |
| 5247 | adapter->device_mode = session_type; |
| 5248 | status = hdd_register_interface(adapter, rtnl_held); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5249 | if (QDF_STATUS_SUCCESS != status) |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 5250 | goto err_free_netdev; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5251 | |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5252 | /* Stop the Interface TX queue. */ |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5253 | hdd_debug("Disabling queues"); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5254 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5255 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5256 | WLAN_CONTROL_PATH); |
Arun Khandavalli | 16fd1ee | 2016-10-08 17:47:07 +0530 | [diff] [blame] | 5257 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5258 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5259 | hdd_err("Invalid session type %d", session_type); |
Anurag Chouhan | b2dc16f | 2016-02-25 11:47:37 +0530 | [diff] [blame] | 5260 | QDF_ASSERT(0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5261 | return NULL; |
| 5262 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5263 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5264 | qdf_spinlock_create(&adapter->vdev_lock); |
| 5265 | |
Abhinav Kumar | cc959f1 | 2018-08-09 13:58:30 +0530 | [diff] [blame] | 5266 | hdd_init_completion(adapter); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5267 | INIT_WORK(&adapter->scan_block_work, wlan_hdd_cfg80211_scan_block_cb); |
Min Liu | 9be5d4a | 2018-05-17 11:51:53 +0800 | [diff] [blame] | 5268 | qdf_list_create(&adapter->blocked_scan_request_q, WLAN_MAX_SCAN_COUNT); |
| 5269 | qdf_mutex_create(&adapter->blocked_scan_request_q_lock); |
hqu | eaa33ee | 2017-05-04 17:56:35 +0800 | [diff] [blame] | 5270 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5271 | if (QDF_STATUS_SUCCESS == status) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5272 | /* Add it to the hdd's session list. */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5273 | status = hdd_add_adapter_back(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5274 | } |
| 5275 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5276 | if (QDF_STATUS_SUCCESS != status) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 5277 | if (adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5278 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5279 | adapter = NULL; |
| 5280 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5281 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5282 | return NULL; |
| 5283 | } |
Nachiket Kukade | 5f0ce4f | 2018-06-15 19:47:37 +0530 | [diff] [blame] | 5284 | hdd_apf_context_init(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5285 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5286 | if (QDF_STATUS_SUCCESS == status) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5287 | policy_mgr_set_concurrency_mode(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5288 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5289 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5290 | /* Adapter successfully added. Increment the vdev count */ |
| 5291 | hdd_ctx->current_intf_count++; |
| 5292 | |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5293 | hdd_debug("current_intf_count=%d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5294 | hdd_ctx->current_intf_count); |
| 5295 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 5296 | hdd_check_and_restart_sap_with_non_dfs_acs(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5297 | } |
| 5298 | |
Rajeev Kumar | dca5f81 | 2016-02-04 17:28:06 -0800 | [diff] [blame] | 5299 | if (QDF_STATUS_SUCCESS != hdd_debugfs_init(adapter)) |
Mahesh Kumar Kalikot Veetil | 80dda9a | 2017-07-17 11:38:03 -0700 | [diff] [blame] | 5300 | hdd_err("Interface %s wow debug_fs init failed", |
| 5301 | netdev_name(adapter->dev)); |
| 5302 | |
| 5303 | hdd_info("%s interface created. iftype: %d", netdev_name(adapter->dev), |
| 5304 | session_type); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5305 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 5306 | if (adapter->device_mode == QDF_STA_MODE) |
| 5307 | wlan_hdd_debugfs_csr_init(adapter); |
| 5308 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5309 | return adapter; |
| 5310 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5311 | err_free_netdev: |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5312 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
Madhvapathi Sriram | 8b05665 | 2019-03-27 17:38:12 +0530 | [diff] [blame] | 5313 | |
| 5314 | if (ndev) |
| 5315 | free_netdev(ndev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5316 | |
| 5317 | return NULL; |
| 5318 | } |
| 5319 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5320 | static void __hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5321 | struct hdd_adapter *adapter, |
| 5322 | bool rtnl_held) |
| 5323 | { |
| 5324 | qdf_list_destroy(&adapter->blocked_scan_request_q); |
| 5325 | qdf_mutex_destroy(&adapter->blocked_scan_request_q_lock); |
| 5326 | policy_mgr_clear_concurrency_mode(hdd_ctx->psoc, adapter->device_mode); |
| 5327 | |
| 5328 | hdd_cleanup_adapter(hdd_ctx, adapter, rtnl_held); |
| 5329 | |
| 5330 | if (hdd_ctx->current_intf_count != 0) |
| 5331 | hdd_ctx->current_intf_count--; |
| 5332 | } |
| 5333 | |
| 5334 | void hdd_close_adapter(struct hdd_context *hdd_ctx, |
| 5335 | struct hdd_adapter *adapter, |
| 5336 | bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5337 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5338 | /* |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5339 | * Stop the global bus bandwidth timer while touching the adapter list |
| 5340 | * to avoid bad memory access by the timer handler. |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5341 | */ |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5342 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5343 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5344 | hdd_remove_adapter(hdd_ctx, adapter); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5345 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5346 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5347 | /* conditionally restart the bw timer */ |
| 5348 | hdd_bus_bw_compute_timer_try_start(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5349 | } |
| 5350 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5351 | void hdd_close_all_adapters(struct hdd_context *hdd_ctx, bool rtnl_held) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5352 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5353 | struct hdd_adapter *adapter; |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5354 | struct osif_vdev_sync *vdev_sync; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5355 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5356 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5357 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5358 | while (QDF_IS_STATUS_SUCCESS(hdd_remove_front_adapter(hdd_ctx, |
| 5359 | &adapter))) { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5360 | vdev_sync = osif_vdev_sync_unregister(adapter->dev); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5361 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5362 | osif_vdev_sync_wait_for_ops(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5363 | |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5364 | wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); |
| 5365 | __hdd_close_adapter(hdd_ctx, adapter, rtnl_held); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 5366 | |
| 5367 | if (vdev_sync) |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 5368 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 728d65a | 2018-10-02 16:27:52 -0700 | [diff] [blame] | 5369 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5370 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5371 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5372 | } |
| 5373 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5374 | void wlan_hdd_reset_prob_rspies(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5375 | { |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 5376 | struct qdf_mac_addr *bssid = NULL; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5377 | tSirUpdateIE update_ie; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5378 | mac_handle_t mac_handle; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5379 | |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5380 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5381 | case QDF_STA_MODE: |
| 5382 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5383 | { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5384 | struct hdd_station_ctx *sta_ctx = |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5385 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5386 | bssid = &sta_ctx->conn_info.bssid; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5387 | break; |
| 5388 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5389 | case QDF_SAP_MODE: |
| 5390 | case QDF_P2P_GO_MODE: |
| 5391 | case QDF_IBSS_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5392 | { |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5393 | bssid = &adapter->mac_addr; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5394 | break; |
| 5395 | } |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5396 | case QDF_FTM_MODE: |
| 5397 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5398 | default: |
| 5399 | /* |
| 5400 | * wlan_hdd_reset_prob_rspies should not have been called |
| 5401 | * for these kind of devices |
| 5402 | */ |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5403 | hdd_err("Unexpected request for the current device type %d", |
Jeff Johnson | 9c4f93d | 2017-10-04 08:56:22 -0700 | [diff] [blame] | 5404 | adapter->device_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5405 | return; |
| 5406 | } |
| 5407 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5408 | qdf_copy_macaddr(&update_ie.bssid, bssid); |
| 5409 | update_ie.smeSessionId = adapter->vdev_id; |
| 5410 | update_ie.ieBufferlength = 0; |
| 5411 | update_ie.pAdditionIEBuffer = NULL; |
| 5412 | update_ie.append = true; |
| 5413 | update_ie.notify = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5414 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 5415 | if (sme_update_add_ie(mac_handle, |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5416 | &update_ie, |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5417 | eUPDATE_IE_PROBE_RESP) == QDF_STATUS_E_FAILURE) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5418 | hdd_err("Could not pass on PROBE_RSP_BCN data to PE"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5419 | } |
| 5420 | } |
| 5421 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5422 | QDF_STATUS hdd_stop_adapter(struct hdd_context *hdd_ctx, |
| 5423 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5424 | { |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5425 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 5426 | struct hdd_station_ctx *sta_ctx; |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5427 | struct sap_context *sap_ctx; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5428 | struct csr_roam_profile *roam_profile; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5429 | union iwreq_data wrqu; |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5430 | tSirUpdateIE update_ie; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5431 | unsigned long rc; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 5432 | struct sap_config *sap_config; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5433 | mac_handle_t mac_handle; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5434 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5435 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5436 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5437 | |
Jeff Johnson | 912b1bb | 2019-03-06 10:12:36 -0800 | [diff] [blame] | 5438 | if (adapter->vdev_id != WLAN_UMAC_VDEV_ID_MAX) |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 5439 | wlan_hdd_cfg80211_deregister_frames(adapter); |
| 5440 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5441 | hdd_nud_ignore_tracking(adapter, true); |
| 5442 | hdd_nud_reset_tracking(adapter); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5443 | hdd_nud_flush_work(adapter); |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5444 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5445 | |
Varun Reddy Yeturu | 8a5d3d4 | 2017-08-02 13:03:27 -0700 | [diff] [blame] | 5446 | hdd_debug("Disabling queues"); |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5447 | wlan_hdd_netif_queue_control(adapter, |
| 5448 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
| 5449 | WLAN_CONTROL_PATH); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5450 | |
| 5451 | mac_handle = hdd_ctx->mac_handle; |
| 5452 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5453 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5454 | case QDF_STA_MODE: |
| 5455 | case QDF_P2P_CLIENT_MODE: |
| 5456 | case QDF_IBSS_MODE: |
| 5457 | case QDF_P2P_DEVICE_MODE: |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5458 | case QDF_NDI_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5459 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 5460 | |
| 5461 | if (adapter->device_mode == QDF_NDI_MODE || |
| 5462 | hdd_conn_is_connected(sta_ctx) || |
| 5463 | hdd_is_connecting(sta_ctx)) { |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5464 | INIT_COMPLETION(adapter->disconnect_comp_var); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5465 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5466 | roam_profile = hdd_roam_profile(adapter); |
| 5467 | /* For NDI do not use roam_profile */ |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5468 | if (adapter->device_mode == QDF_NDI_MODE) |
| 5469 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5470 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5471 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5472 | eCSR_DISCONNECT_REASON_NDI_DELETE); |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 5473 | else if (roam_profile->BSSType == |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5474 | eCSR_BSS_TYPE_START_IBSS) |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5475 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5476 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5477 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5478 | eCSR_DISCONNECT_REASON_IBSS_LEAVE); |
Abhinav Kumar | 19a7a40 | 2018-07-12 17:36:57 +0530 | [diff] [blame] | 5479 | else if (adapter->device_mode == QDF_STA_MODE) |
| 5480 | wlan_hdd_disconnect(adapter, |
| 5481 | eCSR_DISCONNECT_REASON_DEAUTH); |
| 5482 | else |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5483 | status = sme_roam_disconnect( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 5484 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5485 | adapter->vdev_id, |
Deepak Dhamdhere | 13983f2 | 2016-05-31 19:06:09 -0700 | [diff] [blame] | 5486 | eCSR_DISCONNECT_REASON_UNSPECIFIED); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5487 | /* success implies disconnect is queued */ |
| 5488 | if (QDF_IS_STATUS_SUCCESS(status) && |
| 5489 | adapter->device_mode != QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5490 | rc = wait_for_completion_timeout( |
| 5491 | &adapter->disconnect_comp_var, |
| 5492 | msecs_to_jiffies |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5493 | (SME_DISCONNECT_TIMEOUT)); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 5494 | if (!rc) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5495 | hdd_warn("disconn_comp_var wait fail"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5496 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5497 | if (QDF_IS_STATUS_ERROR(status)) |
Varun Reddy Yeturu | 96dced7 | 2017-03-29 18:03:54 -0700 | [diff] [blame] | 5498 | hdd_warn("failed to post disconnect"); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5499 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5500 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 5501 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 5502 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 5503 | wireless_send_event(adapter->dev, SIOCGIWAP, &wrqu, |
| 5504 | NULL); |
Sachin Ahuja | 988fd10 | 2016-09-15 17:16:25 +0530 | [diff] [blame] | 5505 | } |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 5506 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5507 | wlan_hdd_scan_abort(adapter); |
Wu Gao | 4a1ec8c | 2018-07-23 19:18:40 +0800 | [diff] [blame] | 5508 | wlan_hdd_cleanup_actionframe(adapter); |
Abhishek Singh | 1e94d7a | 2015-11-30 17:26:54 +0530 | [diff] [blame] | 5509 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Sridhar Selvaraj | 8c6f5e8 | 2017-08-21 14:53:46 +0530 | [diff] [blame] | 5510 | hdd_clear_fils_connection_info(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5511 | |
Liangwei Dong | a44d55b | 2019-03-20 03:22:08 -0400 | [diff] [blame] | 5512 | status = wlan_hdd_flush_pmksa_cache(adapter); |
Ashish Kumar Dhanotiya | 3651083 | 2019-02-20 22:13:25 +0530 | [diff] [blame] | 5513 | if (QDF_IS_STATUS_ERROR(status)) |
| 5514 | hdd_err("Cannot flush PMKIDCache"); |
| 5515 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5516 | hdd_deregister_hl_netdev_fc_timer(adapter); |
| 5517 | |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5518 | hdd_deregister_tx_flow_control(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5519 | |
| 5520 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5521 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5522 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5523 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5524 | #endif |
| 5525 | #endif |
| 5526 | |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5527 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5528 | struct wlan_objmgr_vdev *vdev; |
| 5529 | |
| 5530 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5531 | if (vdev) { |
| 5532 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5533 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5534 | } |
| 5535 | } |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5536 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5537 | /* |
| 5538 | * During vdev destroy, if any STA is in connecting state the |
| 5539 | * roam command will be in active queue and thus vdev destroy is |
| 5540 | * queued in pending queue. In case STA tries to connect to |
| 5541 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5542 | * timeouts it may take more than vdev destroy time to get |
| 5543 | * completed. On vdev destroy timeout vdev is moved to logically |
| 5544 | * deleted state. Once connection is completed, vdev destroy is |
| 5545 | * activated and to release the self-peer ref count it try to |
| 5546 | * get the ref of the vdev, which fails as vdev is logically |
| 5547 | * deleted and this leads to peer ref leak. So before vdev |
| 5548 | * destroy is queued abort any STA ongoing connection to avoid |
| 5549 | * vdev destroy timeout. |
| 5550 | */ |
| 5551 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5552 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5553 | |
Himanshu Agarwal | b229a14 | 2017-12-21 10:16:45 +0530 | [diff] [blame] | 5554 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5555 | break; |
| 5556 | |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5557 | case QDF_MONITOR_MODE: |
| 5558 | wlan_hdd_scan_abort(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5559 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Rajeev Kumar | 3b90620 | 2018-02-01 10:55:14 -0800 | [diff] [blame] | 5560 | hdd_deregister_tx_flow_control(adapter); |
| 5561 | hdd_vdev_destroy(adapter); |
| 5562 | break; |
| 5563 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5564 | case QDF_SAP_MODE: |
Will Huang | 7049bae | 2018-08-13 17:25:02 +0800 | [diff] [blame] | 5565 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5566 | cds_flush_delayed_work(&adapter->acs_pending_work); |
| 5567 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5568 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5569 | |
wadesong | f9b15ed | 2017-12-14 14:12:32 +0800 | [diff] [blame] | 5570 | wlan_hdd_scan_abort(adapter); |
gaurank kathpalia | b7a9f70 | 2019-02-15 18:09:58 +0530 | [diff] [blame] | 5571 | /* Diassociate with all the peers before stop ap post */ |
| 5572 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) |
| 5573 | wlan_hdd_del_station(adapter); |
Arunk Khandavalli | 96c122f | 2017-10-17 11:49:36 +0530 | [diff] [blame] | 5574 | sap_config = &adapter->session.ap.sap_config; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5575 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
| 5576 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 5577 | ucfg_ipa_flush(hdd_ctx->pdev); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5578 | |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5579 | /* don't flush pre-cac destroy if we are destroying pre-cac */ |
| 5580 | sap_ctx = WLAN_HDD_GET_SAP_CTX_PTR(adapter); |
| 5581 | if (!wlan_sap_is_pre_cac_context(sap_ctx)) |
Liangwei Dong | ad89c76 | 2018-06-01 01:56:23 -0400 | [diff] [blame] | 5582 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
Dustin Brown | b4260d5 | 2019-01-24 11:53:08 -0800 | [diff] [blame] | 5583 | |
Jeff Johnson | 46807cd | 2018-04-29 21:32:22 -0700 | [diff] [blame] | 5584 | /* fallthrough */ |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5585 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5586 | case QDF_P2P_GO_MODE: |
Krunal Soni | 2220839 | 2017-09-29 18:10:34 -0700 | [diff] [blame] | 5587 | cds_flush_work(&adapter->sap_stop_bss_work); |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5588 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Dustin Brown | a5cf8e0 | 2017-10-19 16:04:19 -0700 | [diff] [blame] | 5589 | wlan_hdd_undo_acs(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5590 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5591 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5592 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5593 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5594 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5595 | hdd_deregister_tx_flow_control(adapter); |
Kapil Gupta | c1224bf | 2017-06-22 21:22:40 +0530 | [diff] [blame] | 5596 | hdd_destroy_acs_timer(adapter); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5597 | |
Pragaspathi Thilagaraj | e6f37e0 | 2019-01-04 12:24:33 +0530 | [diff] [blame] | 5598 | /** |
| 5599 | * During vdev destroy, If any STA is in connecting state the |
| 5600 | * roam command will be in active queue and thus vdev destroy is |
| 5601 | * queued in pending queue. In case STA is tries to connected to |
| 5602 | * multiple BSSID and fails to connect, due to auth/assoc |
| 5603 | * timeouts it may take more than vdev destroy time to get |
| 5604 | * completes. If vdev destroy timeout vdev is moved to logically |
| 5605 | * deleted state. Once connection is completed, vdev destroy is |
| 5606 | * activated and to release the self-peer ref count it try to |
| 5607 | * get the ref of the vdev, which fails as vdev is logically |
| 5608 | * deleted and this leads to peer ref leak. So before vdev |
| 5609 | * destroy is queued abort any STA ongoing connection to avoid |
| 5610 | * vdev destroy timeout. |
| 5611 | */ |
| 5612 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5613 | hdd_abort_ongoing_sta_connection(hdd_ctx); |
| 5614 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5615 | mutex_lock(&hdd_ctx->sap_lock); |
| 5616 | if (test_bit(SOFTAP_BSS_STARTED, &adapter->event_flags)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5617 | status = wlansap_stop_bss( |
| 5618 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5619 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5620 | if (QDF_IS_STATUS_SUCCESS(status)) { |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 5621 | struct hdd_hostapd_state *hostapd_state = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5622 | WLAN_HDD_GET_HOSTAP_STATE_PTR(adapter); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 5623 | qdf_event_reset(&hostapd_state-> |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 5624 | qdf_stop_bss_event); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5625 | status = qdf_wait_for_event_completion( |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 5626 | &hostapd_state->qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 5627 | SME_CMD_STOP_BSS_TIMEOUT); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5628 | if (QDF_IS_STATUS_ERROR(status)) |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5629 | hdd_err("failure waiting for wlansap_stop_bss %d", |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5630 | status); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5631 | } else { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 5632 | hdd_err("failure in wlansap_stop_bss"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5633 | } |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5634 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5635 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5636 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 5637 | adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5638 | adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5639 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5640 | adapter->device_mode, |
| 5641 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5642 | |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5643 | qdf_copy_macaddr(&update_ie.bssid, |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 5644 | &adapter->mac_addr); |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5645 | update_ie.smeSessionId = adapter->vdev_id; |
| 5646 | update_ie.ieBufferlength = 0; |
| 5647 | update_ie.pAdditionIEBuffer = NULL; |
| 5648 | update_ie.append = false; |
| 5649 | update_ie.notify = false; |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5650 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5651 | /* Probe bcn reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5652 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5653 | eUPDATE_IE_PROBE_BCN); |
| 5654 | if (status == QDF_STATUS_E_FAILURE) |
| 5655 | hdd_err("Could not pass PROBE_RSP_BCN to PE"); |
| 5656 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5657 | /* Assoc resp reset */ |
Jeff Johnson | c565af1 | 2019-03-10 21:09:47 -0700 | [diff] [blame] | 5658 | status = sme_update_add_ie(mac_handle, &update_ie, |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5659 | eUPDATE_IE_ASSOC_RESP); |
| 5660 | if (status == QDF_STATUS_E_FAILURE) |
| 5661 | hdd_err("Could not pass ASSOC_RSP to PE"); |
| 5662 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5663 | /* Reset WNI_CFG_PROBE_RSP Flags */ |
| 5664 | wlan_hdd_reset_prob_rspies(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5665 | } |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5666 | clear_bit(SOFTAP_INIT_DONE, &adapter->event_flags); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 5667 | qdf_mem_free(adapter->session.ap.beacon); |
| 5668 | adapter->session.ap.beacon = NULL; |
Jiachao Wu | b1e1ddd | 2018-05-21 12:04:15 +0800 | [diff] [blame] | 5669 | |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5670 | /* |
| 5671 | * If Do_Not_Break_Stream was enabled clear avoid channel list. |
| 5672 | */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5673 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5674 | if (vdev) { |
| 5675 | if (policy_mgr_is_dnsc_set(vdev)) |
| 5676 | wlan_hdd_send_avoid_freq_for_dnbs(hdd_ctx, 0); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5677 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5678 | } |
Ajit Pal Singh | 747b680 | 2017-05-24 15:42:03 +0530 | [diff] [blame] | 5679 | |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5680 | #ifdef WLAN_OPEN_SOURCE |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5681 | cancel_work_sync(&adapter->ipv4_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5682 | #ifdef WLAN_NS_OFFLOAD |
Jeff Johnson | b527ebe | 2017-10-28 13:14:03 -0700 | [diff] [blame] | 5683 | cancel_work_sync(&adapter->ipv6_notifier_work); |
Hanumanth Reddy Pothula | aaa3f88 | 2017-10-05 17:45:00 +0530 | [diff] [blame] | 5684 | #endif |
| 5685 | #endif |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5686 | |
| 5687 | hdd_vdev_destroy(adapter); |
| 5688 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 5689 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5690 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 5691 | case QDF_OCB_MODE: |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5692 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Krishna Kumaar Natarajan | e58b409 | 2017-01-25 15:47:35 -0800 | [diff] [blame] | 5693 | cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC), |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5694 | cds_get_context(QDF_MODULE_ID_TXRX), |
Jeff Johnson | 0a082d9 | 2019-03-04 12:25:49 -0800 | [diff] [blame] | 5695 | sta_ctx->conn_info.sta_id[0]); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5696 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Zhang Qian | 79d0d13 | 2018-02-05 13:40:16 +0800 | [diff] [blame] | 5697 | hdd_deregister_tx_flow_control(adapter); |
| 5698 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5699 | break; |
| 5700 | default: |
| 5701 | break; |
| 5702 | } |
| 5703 | |
Dustin Brown | 0434837 | 2017-12-14 16:13:39 -0800 | [diff] [blame] | 5704 | if (adapter->scan_info.default_scan_ies) { |
| 5705 | qdf_mem_free(adapter->scan_info.default_scan_ies); |
| 5706 | adapter->scan_info.default_scan_ies = NULL; |
| 5707 | } |
| 5708 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5709 | hdd_exit(); |
Dustin Brown | d747ecd | 2018-10-26 16:32:22 -0700 | [diff] [blame] | 5710 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5711 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5712 | } |
| 5713 | |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5714 | /** |
| 5715 | * hdd_deinit_all_adapters - deinit all adapters |
| 5716 | * @hdd_ctx: HDD context |
| 5717 | * @rtnl_held: True if RTNL lock held |
| 5718 | * |
| 5719 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5720 | 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] | 5721 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5722 | struct hdd_adapter *adapter; |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5723 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5724 | hdd_enter(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5725 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5726 | hdd_for_each_adapter(hdd_ctx, adapter) |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5727 | hdd_deinit_adapter(hdd_ctx, adapter, rtnl_held); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5728 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5729 | hdd_exit(); |
Hanumanth Reddy Pothula | 9f4048f | 2016-09-30 15:06:57 +0530 | [diff] [blame] | 5730 | } |
| 5731 | |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5732 | QDF_STATUS hdd_stop_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5733 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5734 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5735 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5736 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5737 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5738 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5739 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5740 | hdd_for_each_adapter(hdd_ctx, adapter) |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 5741 | hdd_stop_adapter(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5742 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5743 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5744 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5745 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5746 | } |
| 5747 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5748 | static void hdd_reset_scan_operation(struct hdd_context *hdd_ctx, |
| 5749 | struct hdd_adapter *adapter) |
| 5750 | { |
| 5751 | switch (adapter->device_mode) { |
| 5752 | case QDF_STA_MODE: |
| 5753 | case QDF_P2P_CLIENT_MODE: |
| 5754 | case QDF_IBSS_MODE: |
| 5755 | case QDF_P2P_DEVICE_MODE: |
| 5756 | case QDF_NDI_MODE: |
| 5757 | wlan_hdd_scan_abort(adapter); |
| 5758 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5759 | if (adapter->device_mode == QDF_STA_MODE) { |
| 5760 | struct wlan_objmgr_vdev *vdev; |
| 5761 | |
| 5762 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5763 | if (vdev) { |
| 5764 | wlan_cfg80211_sched_scan_stop(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5765 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5766 | } |
| 5767 | } |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5768 | break; |
| 5769 | case QDF_P2P_GO_MODE: |
| 5770 | wlan_hdd_cleanup_remain_on_channel_ctx(adapter); |
| 5771 | break; |
| 5772 | case QDF_SAP_MODE: |
Abhinav Kumar | b638b5d | 2018-03-26 12:25:41 +0530 | [diff] [blame] | 5773 | qdf_atomic_set(&adapter->session.ap.acs_in_progress, 0); |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5774 | wlan_hdd_undo_acs(adapter); |
| 5775 | break; |
| 5776 | default: |
| 5777 | break; |
| 5778 | } |
| 5779 | } |
| 5780 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5781 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5782 | /** |
| 5783 | * hdd_adapter_abort_tx_flow() - Abort the tx flow control |
| 5784 | * @pAdapter: pointer to hdd_adapter_t |
| 5785 | * |
| 5786 | * Resume tx and stop the tx flow control timer if the tx is paused |
| 5787 | * and the flow control timer is running. This function is called by |
| 5788 | * SSR to avoid the inconsistency of tx status before and after SSR. |
| 5789 | * |
| 5790 | * Return: void |
| 5791 | */ |
| 5792 | static void hdd_adapter_abort_tx_flow(struct hdd_adapter *adapter) |
| 5793 | { |
| 5794 | if (adapter->hdd_stats.tx_rx_stats.is_txflow_paused && |
| 5795 | QDF_TIMER_STATE_RUNNING == |
| 5796 | qdf_mc_timer_get_current_state( |
| 5797 | &adapter->tx_flow_control_timer)) { |
| 5798 | hdd_tx_resume_timer_expired_handler(adapter); |
| 5799 | qdf_mc_timer_stop(&adapter->tx_flow_control_timer); |
| 5800 | } |
| 5801 | } |
| 5802 | #endif |
| 5803 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 5804 | QDF_STATUS hdd_reset_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5805 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 5806 | struct hdd_adapter *adapter; |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5807 | struct hdd_station_ctx *sta_ctx; |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5808 | struct qdf_mac_addr peer_macaddr; |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5809 | int sta_id; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5810 | bool value; |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5811 | struct wlan_objmgr_vdev *vdev; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5812 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 5813 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5814 | |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 5815 | cds_flush_work(&hdd_ctx->sap_pre_cac_work); |
| 5816 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5817 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5818 | hdd_info("[SSR] reset adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 5819 | qdf_opmode_str(adapter->device_mode), |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 5820 | adapter->device_mode); |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5821 | |
Ke Huang | c067b8d | 2018-05-21 15:50:13 +0800 | [diff] [blame] | 5822 | #ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL |
| 5823 | hdd_adapter_abort_tx_flow(adapter); |
| 5824 | #endif |
| 5825 | |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5826 | if ((adapter->device_mode == QDF_STA_MODE) || |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5827 | (adapter->device_mode == QDF_P2P_CLIENT_MODE)) { |
Ganesh Kondabattini | 9e4fbbb | 2017-05-24 16:53:02 +0530 | [diff] [blame] | 5828 | /* Stop tdls timers */ |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5829 | vdev = hdd_objmgr_get_vdev(adapter); |
| 5830 | if (vdev) { |
| 5831 | hdd_notify_tdls_reset_adapter(vdev); |
Rajeev Kumar Sirasanagandla | 25bdfad | 2019-02-15 19:15:49 +0530 | [diff] [blame] | 5832 | hdd_objmgr_put_vdev(vdev); |
Min Liu | 8c5d99e | 2018-09-10 17:18:44 +0800 | [diff] [blame] | 5833 | } |
Paul Zhang | 679025e | 2018-03-08 22:39:44 +0800 | [diff] [blame] | 5834 | adapter->session.station.hdd_reassoc_scenario = false; |
| 5835 | } |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 5836 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 5837 | if (value && |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5838 | adapter->device_mode == QDF_SAP_MODE) { |
| 5839 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5840 | WLAN_STOP_ALL_NETIF_QUEUE, |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5841 | WLAN_CONTROL_PATH); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5842 | if (test_bit(ACS_PENDING, &adapter->event_flags)) { |
| 5843 | cds_flush_delayed_work( |
| 5844 | &adapter->acs_pending_work); |
| 5845 | clear_bit(ACS_PENDING, &adapter->event_flags); |
| 5846 | } |
| 5847 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5848 | if (test_bit(SOFTAP_BSS_STARTED, |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5849 | &adapter->event_flags)) { |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5850 | hdd_sap_indicate_disconnect_for_sta(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5851 | clear_bit(SOFTAP_BSS_STARTED, |
| 5852 | &adapter->event_flags); |
| 5853 | } |
| 5854 | |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5855 | } else { |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 5856 | wlan_hdd_netif_queue_control(adapter, |
Himanshu Agarwal | 865201d | 2017-04-12 15:45:31 +0530 | [diff] [blame] | 5857 | WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5858 | WLAN_CONTROL_PATH); |
Manikandan Mohan | 0a44ec8 | 2017-02-17 15:06:11 -0800 | [diff] [blame] | 5859 | } |
Nijun Gong | 104ccc7 | 2018-08-07 10:43:56 +0800 | [diff] [blame] | 5860 | /* |
| 5861 | * Clear fc flag if it was set before SSR to avoid TX queues |
| 5862 | * permanently stopped after SSR. |
| 5863 | * Here WLAN_START_ALL_NETIF_QUEUE will actually not start any |
| 5864 | * queue since it's blocked by reason WLAN_CONTROL_PATH. |
| 5865 | */ |
| 5866 | if (adapter->pause_map & (1 << WLAN_DATA_FLOW_CONTROL)) |
| 5867 | wlan_hdd_netif_queue_control(adapter, |
| 5868 | WLAN_START_ALL_NETIF_QUEUE, |
| 5869 | WLAN_DATA_FLOW_CONTROL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5870 | |
Paul Zhang | 84fa938 | 2017-11-10 21:18:21 +0800 | [diff] [blame] | 5871 | hdd_reset_scan_operation(hdd_ctx, adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5872 | |
| 5873 | hdd_deinit_tx_rx(adapter); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 5874 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 5875 | adapter->device_mode, adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 5876 | hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 5877 | false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5878 | if (test_bit(WMM_INIT_DONE, &adapter->event_flags)) { |
| 5879 | hdd_wmm_adapter_close(adapter); |
| 5880 | clear_bit(WMM_INIT_DONE, &adapter->event_flags); |
| 5881 | } |
| 5882 | |
Vignesh Viswanathan | 2eb1874 | 2017-09-08 11:18:59 +0530 | [diff] [blame] | 5883 | if (adapter->device_mode == QDF_STA_MODE) |
| 5884 | hdd_clear_fils_connection_info(adapter); |
| 5885 | |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5886 | if (adapter->device_mode == QDF_SAP_MODE) { |
Jingxiang Ge | ec11359 | 2018-08-09 15:40:39 +0800 | [diff] [blame] | 5887 | wlansap_cleanup_cac_timer( |
| 5888 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5889 | /* |
| 5890 | * If adapter is SAP, set session ID to invalid |
| 5891 | * since SAP session will be cleanup during SSR. |
| 5892 | */ |
Wu Gao | 3671743 | 2016-11-21 15:09:48 +0800 | [diff] [blame] | 5893 | wlansap_set_invalid_session( |
| 5894 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
Wu Gao | 3545e64 | 2017-07-14 19:24:41 +0800 | [diff] [blame] | 5895 | } |
| 5896 | |
Abhishek Singh | 8f4aa18 | 2019-03-06 10:29:24 +0530 | [diff] [blame] | 5897 | /* Release vdev ref count to avoid vdev object leak */ |
| 5898 | if (adapter->device_mode == QDF_P2P_GO_MODE || |
| 5899 | adapter->device_mode == QDF_SAP_MODE) |
| 5900 | wlansap_release_vdev_ref( |
| 5901 | WLAN_HDD_GET_SAP_CTX_PTR(adapter)); |
| 5902 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5903 | /* Delete connection peers if any to avoid peer object leaks */ |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5904 | if (adapter->device_mode == QDF_STA_MODE || |
| 5905 | adapter->device_mode == QDF_P2P_CLIENT_MODE) { |
Jeff Johnson | d377dce | 2017-10-04 10:32:42 -0700 | [diff] [blame] | 5906 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
Jeff Johnson | 2d04461 | 2019-02-26 20:08:43 -0800 | [diff] [blame] | 5907 | qdf_copy_macaddr(&peer_macaddr, |
Jeff Johnson | e04b699 | 2019-02-27 14:06:55 -0800 | [diff] [blame] | 5908 | &sta_ctx->conn_info.bssid); |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5909 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5910 | } else if (adapter->device_mode == QDF_P2P_GO_MODE) { |
Wu Gao | 6b81fc5 | 2018-05-24 19:27:27 +0800 | [diff] [blame] | 5911 | clear_bit(SOFTAP_BSS_STARTED, &adapter->event_flags); |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 5912 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; sta_id++) { |
| 5913 | if (adapter->sta_info[sta_id].in_use) { |
| 5914 | hdd_debug("[SSR] deregister STA with ID %d", |
| 5915 | sta_id); |
| 5916 | hdd_softap_deregister_sta(adapter, |
| 5917 | sta_id); |
| 5918 | adapter->sta_info[sta_id].in_use = 0; |
| 5919 | } |
| 5920 | } |
Yue Ma | d5b4b9f | 2017-05-26 16:23:40 -0700 | [diff] [blame] | 5921 | } |
| 5922 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5923 | hdd_nud_ignore_tracking(adapter, true); |
Alok Kumar | 016a1ac | 2018-09-16 09:55:50 +0530 | [diff] [blame] | 5924 | hdd_nud_reset_tracking(adapter); |
| 5925 | hdd_nud_flush_work(adapter); |
Ashish Kumar Dhanotiya | dc3900f | 2019-01-11 20:42:04 +0530 | [diff] [blame] | 5926 | |
| 5927 | if (adapter->device_mode != QDF_SAP_MODE && |
| 5928 | adapter->device_mode != QDF_P2P_GO_MODE && |
| 5929 | adapter->device_mode != QDF_FTM_MODE) |
| 5930 | hdd_set_disconnect_status(adapter, false); |
| 5931 | |
hangtian | 9c47aaf | 2018-11-26 17:59:39 +0800 | [diff] [blame] | 5932 | hdd_stop_tsf_sync(adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 5933 | |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5934 | hdd_softap_deinit_tx_rx(adapter); |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 5935 | hdd_deregister_hl_netdev_fc_timer(adapter); |
Tiger Yu | 8c38770 | 2018-07-06 16:56:42 +0800 | [diff] [blame] | 5936 | hdd_deregister_tx_flow_control(adapter); |
Tiger Yu | 94a5a5c | 2018-03-09 21:22:26 +0800 | [diff] [blame] | 5937 | |
Yue Ma | f978284 | 2017-05-08 12:49:49 -0700 | [diff] [blame] | 5938 | /* Destroy vdev which will be recreated during reinit. */ |
| 5939 | hdd_vdev_destroy(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5940 | } |
| 5941 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 5942 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5943 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 5944 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 5945 | } |
| 5946 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5947 | bool hdd_is_any_interface_open(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5948 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5949 | struct hdd_adapter *adapter; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5950 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5951 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE) { |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5952 | hdd_info("FTM mode, don't close the module"); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5953 | return true; |
Arun Khandavalli | ba479c4 | 2017-07-26 21:29:40 +0530 | [diff] [blame] | 5954 | } |
| 5955 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 5956 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 5957 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags) || |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5958 | test_bit(SME_SESSION_OPENED, &adapter->event_flags)) |
| 5959 | return true; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5960 | } |
| 5961 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 5962 | return false; |
Ashish Kumar Dhanotiya | 486c13a | 2017-03-03 12:57:56 +0530 | [diff] [blame] | 5963 | } |
| 5964 | |
yeshwanth sriram guntuka | ea63f63 | 2017-08-30 19:31:56 +0530 | [diff] [blame] | 5965 | bool hdd_is_interface_up(struct hdd_adapter *adapter) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 5966 | { |
| 5967 | if (test_bit(DEVICE_IFACE_OPENED, &adapter->event_flags)) |
| 5968 | return true; |
| 5969 | else |
| 5970 | return false; |
| 5971 | } |
| 5972 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5973 | #if defined CFG80211_CONNECT_BSS || \ |
| 5974 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5975 | #if defined CFG80211_CONNECT_TIMEOUT_REASON_CODE || \ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 5976 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 5977 | /** |
| 5978 | * hdd_convert_timeout_reason() - Convert to kernel specific enum |
| 5979 | * @timeout_reason: reason for connect timeout |
| 5980 | * |
| 5981 | * This function is used to convert host timeout |
| 5982 | * reason enum to kernel specific enum. |
| 5983 | * |
| 5984 | * Return: nl timeout enum |
| 5985 | */ |
| 5986 | static enum nl80211_timeout_reason hdd_convert_timeout_reason( |
| 5987 | tSirResultCodes timeout_reason) |
| 5988 | { |
| 5989 | switch (timeout_reason) { |
| 5990 | case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE: |
| 5991 | return NL80211_TIMEOUT_SCAN; |
| 5992 | case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE: |
| 5993 | return NL80211_TIMEOUT_AUTH; |
| 5994 | case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE: |
| 5995 | return NL80211_TIMEOUT_ASSOC; |
| 5996 | default: |
| 5997 | return NL80211_TIMEOUT_UNSPECIFIED; |
| 5998 | } |
| 5999 | } |
| 6000 | |
| 6001 | /** |
| 6002 | * hdd_cfg80211_connect_timeout() - API to send connection timeout reason |
| 6003 | * @dev: network device |
| 6004 | * @bssid: bssid to which we want to associate |
| 6005 | * @timeout_reason: reason for connect timeout |
| 6006 | * |
| 6007 | * This API is used to send connection timeout reason to supplicant |
| 6008 | * |
| 6009 | * Return: void |
| 6010 | */ |
| 6011 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6012 | const u8 *bssid, |
| 6013 | tSirResultCodes timeout_reason) |
| 6014 | { |
| 6015 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6016 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6017 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6018 | |
| 6019 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL, |
| 6020 | nl_timeout_reason); |
| 6021 | } |
| 6022 | |
| 6023 | /** |
| 6024 | * __hdd_connect_bss() - API to send connection status to supplicant |
| 6025 | * @dev: network device |
| 6026 | * @bssid: bssid to which we want to associate |
| 6027 | * @req_ie: Request Information Element |
| 6028 | * @req_ie_len: len of the req IE |
| 6029 | * @resp_ie: Response IE |
| 6030 | * @resp_ie_len: len of ht response IE |
| 6031 | * @status: status |
| 6032 | * @gfp: Kernel Flag |
| 6033 | * @timeout_reason: reason for connect timeout |
| 6034 | * |
| 6035 | * Return: void |
| 6036 | */ |
| 6037 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6038 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6039 | size_t req_ie_len, const u8 *resp_ie, |
| 6040 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6041 | tSirResultCodes timeout_reason) |
| 6042 | { |
| 6043 | enum nl80211_timeout_reason nl_timeout_reason; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6044 | |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6045 | nl_timeout_reason = hdd_convert_timeout_reason(timeout_reason); |
| 6046 | |
| 6047 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6048 | resp_ie, resp_ie_len, status, gfp, |
| 6049 | nl_timeout_reason); |
| 6050 | } |
| 6051 | #else |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6052 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6053 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6054 | static void hdd_cfg80211_connect_timeout(struct net_device *dev, |
| 6055 | const u8 *bssid, |
| 6056 | tSirResultCodes timeout_reason) |
| 6057 | { |
| 6058 | cfg80211_connect_timeout(dev, bssid, NULL, 0, GFP_KERNEL); |
| 6059 | } |
| 6060 | #endif |
| 6061 | |
| 6062 | static void __hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6063 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6064 | size_t req_ie_len, const u8 *resp_ie, |
| 6065 | size_t resp_ie_len, int status, gfp_t gfp, |
| 6066 | tSirResultCodes timeout_reason) |
| 6067 | { |
| 6068 | cfg80211_connect_bss(dev, bssid, bss, req_ie, req_ie_len, |
| 6069 | resp_ie, resp_ie_len, status, gfp); |
| 6070 | } |
| 6071 | #endif |
| 6072 | |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6073 | /** |
| 6074 | * hdd_connect_bss() - API to send connection status to supplicant |
| 6075 | * @dev: network device |
| 6076 | * @bssid: bssid to which we want to associate |
| 6077 | * @req_ie: Request Information Element |
| 6078 | * @req_ie_len: len of the req IE |
| 6079 | * @resp_ie: Response IE |
| 6080 | * @resp_ie_len: len of ht response IE |
| 6081 | * @status: status |
| 6082 | * @gfp: Kernel Flag |
| 6083 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6084 | * @timeout_reason: reason for connect timeout |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6085 | * |
| 6086 | * The API is a wrapper to send connection status to supplicant |
| 6087 | * |
| 6088 | * Return: Void |
| 6089 | */ |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6090 | #if defined CFG80211_CONNECT_TIMEOUT || \ |
| 6091 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6092 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6093 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6094 | size_t req_ie_len, const u8 *resp_ie, |
| 6095 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6096 | bool connect_timeout, |
| 6097 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6098 | { |
| 6099 | if (connect_timeout) |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6100 | hdd_cfg80211_connect_timeout(dev, bssid, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6101 | else |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6102 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6103 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6104 | } |
| 6105 | #else |
| 6106 | static void hdd_connect_bss(struct net_device *dev, const u8 *bssid, |
| 6107 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 6108 | size_t req_ie_len, const u8 *resp_ie, |
| 6109 | size_t resp_ie_len, int status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6110 | bool connect_timeout, |
| 6111 | tSirResultCodes timeout_reason) |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6112 | { |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6113 | __hdd_connect_bss(dev, bssid, bss, req_ie, req_ie_len, resp_ie, |
| 6114 | resp_ie_len, status, gfp, timeout_reason); |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6115 | } |
| 6116 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6117 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6118 | #if defined(WLAN_FEATURE_FILS_SK) |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6119 | #if (defined(CFG80211_CONNECT_DONE) || \ |
| 6120 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))) && \ |
| 6121 | (LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0)) |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6122 | #if defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \ |
| 6123 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6124 | /** |
| 6125 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6126 | * @fils_params: connect response to supplicant |
| 6127 | * @fils_kek: FILS kek |
| 6128 | * @fils_kek_len: FILS kek length |
| 6129 | * @pmk: FILS PMK |
| 6130 | * @pmk_len: FILS PMK length |
| 6131 | * @pmkid: PMKID |
| 6132 | * @fils_seq_num: FILS Seq number |
| 6133 | * |
| 6134 | * Return: None |
| 6135 | */ |
| 6136 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6137 | *fils_params, const uint8_t *fils_kek, |
| 6138 | size_t fils_kek_len, const uint8_t *pmk, |
| 6139 | size_t pmk_len, const uint8_t *pmkid, |
| 6140 | uint16_t fils_seq_num) |
| 6141 | { |
| 6142 | /* Increament seq number to be used for next FILS */ |
| 6143 | fils_params->fils_erp_next_seq_num = fils_seq_num + 1; |
| 6144 | fils_params->update_erp_next_seq_num = true; |
| 6145 | fils_params->fils_kek = fils_kek; |
| 6146 | fils_params->fils_kek_len = fils_kek_len; |
| 6147 | fils_params->pmk = pmk; |
| 6148 | fils_params->pmk_len = pmk_len; |
| 6149 | fils_params->pmkid = pmkid; |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6150 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6151 | fils_params->fils_erp_next_seq_num); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6152 | } |
| 6153 | #else |
| 6154 | static inline void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6155 | *fils_params, const uint8_t |
| 6156 | *fils_kek, size_t fils_kek_len, |
| 6157 | const uint8_t *pmk, size_t pmk_len, |
| 6158 | const uint8_t *pmkid, |
| 6159 | uint16_t fils_seq_num) |
| 6160 | { } |
| 6161 | #endif |
| 6162 | |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6163 | #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) |
| 6164 | /** |
| 6165 | * hdd_populate_fils_params() - Populate FILS keys to connect response |
| 6166 | * @fils_params: connect response to supplicant |
| 6167 | * @fils_kek: FILS kek |
| 6168 | * @fils_kek_len: FILS kek length |
| 6169 | * @pmk: FILS PMK |
| 6170 | * @pmk_len: FILS PMK length |
| 6171 | * @pmkid: PMKID |
| 6172 | * @fils_seq_num: FILS Seq number |
| 6173 | * |
| 6174 | * Return: None |
| 6175 | */ |
| 6176 | static void hdd_populate_fils_params(struct cfg80211_connect_resp_params |
| 6177 | *fils_params, const uint8_t *fils_kek, |
| 6178 | size_t fils_kek_len, const uint8_t *pmk, |
| 6179 | size_t pmk_len, const uint8_t *pmkid, |
| 6180 | uint16_t fils_seq_num) |
| 6181 | { |
| 6182 | /* Increament seq number to be used for next FILS */ |
| 6183 | fils_params->fils.erp_next_seq_num = fils_seq_num + 1; |
| 6184 | fils_params->fils.update_erp_next_seq_num = true; |
| 6185 | fils_params->fils.kek = fils_kek; |
| 6186 | fils_params->fils.kek_len = fils_kek_len; |
| 6187 | fils_params->fils.pmk = pmk; |
| 6188 | fils_params->fils.pmk_len = pmk_len; |
| 6189 | fils_params->fils.pmkid = pmkid; |
| 6190 | hdd_debug("FILS erp_next_seq_num:%d", |
| 6191 | fils_params->fils.erp_next_seq_num); |
| 6192 | } |
| 6193 | #endif /* CFG80211_CONNECT_DONE */ |
| 6194 | |
| 6195 | #if defined(CFG80211_CONNECT_DONE) || \ |
| 6196 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)) |
| 6197 | |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6198 | void hdd_update_hlp_info(struct net_device *dev, |
| 6199 | struct csr_roam_info *roam_info) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6200 | { |
| 6201 | struct sk_buff *skb; |
| 6202 | uint16_t skb_len; |
| 6203 | struct llc_snap_hdr_t *llc_hdr; |
| 6204 | QDF_STATUS status; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6205 | uint8_t *hlp_data; |
| 6206 | uint16_t hlp_data_len; |
| 6207 | struct fils_join_rsp_params *roam_fils_params |
| 6208 | = roam_info->fils_join_rsp; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6209 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6210 | |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6211 | if (!roam_fils_params) { |
| 6212 | hdd_err("FILS Roam Param NULL"); |
| 6213 | return; |
| 6214 | } |
| 6215 | |
Srinivas Girigowda | 3cc8e91 | 2017-11-28 18:11:57 -0800 | [diff] [blame] | 6216 | if (!roam_fils_params->hlp_data_len) { |
Jianmin Zhu | cc6b3d0 | 2019-03-07 14:19:34 +0800 | [diff] [blame] | 6217 | hdd_debug("FILS HLP Data NULL, len %d", |
| 6218 | roam_fils_params->hlp_data_len); |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6219 | return; |
| 6220 | } |
| 6221 | |
| 6222 | hlp_data = roam_fils_params->hlp_data; |
| 6223 | hlp_data_len = roam_fils_params->hlp_data_len; |
| 6224 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6225 | /* Calculate skb length */ |
| 6226 | skb_len = (2 * ETH_ALEN) + hlp_data_len; |
| 6227 | skb = qdf_nbuf_alloc(NULL, skb_len, 0, 4, false); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 6228 | if (!skb) { |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6229 | hdd_err("HLP packet nbuf alloc fails"); |
| 6230 | return; |
| 6231 | } |
| 6232 | |
| 6233 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->dst_mac.bytes, |
| 6234 | QDF_MAC_ADDR_SIZE); |
| 6235 | qdf_mem_copy(skb_put(skb, ETH_ALEN), roam_fils_params->src_mac.bytes, |
| 6236 | QDF_MAC_ADDR_SIZE); |
| 6237 | |
| 6238 | llc_hdr = (struct llc_snap_hdr_t *) hlp_data; |
| 6239 | if (IS_SNAP(llc_hdr)) { |
| 6240 | hlp_data += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6241 | hlp_data_len += LLC_SNAP_HDR_OFFSET_ETHERTYPE; |
| 6242 | } |
| 6243 | |
| 6244 | qdf_mem_copy(skb_put(skb, hlp_data_len), hlp_data, hlp_data_len); |
| 6245 | |
| 6246 | /* |
| 6247 | * This HLP packet is formed from HLP info encapsulated |
| 6248 | * in assoc response frame which is AEAD encrypted. |
| 6249 | * Hence, this checksum validation can be set unnecessary. |
| 6250 | * i.e. network layer need not worry about checksum. |
| 6251 | */ |
| 6252 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 6253 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6254 | status = hdd_rx_packet_cbk(adapter, skb); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6255 | if (QDF_IS_STATUS_ERROR(status)) { |
| 6256 | hdd_err("Sending HLP packet fails"); |
| 6257 | return; |
| 6258 | } |
| 6259 | hdd_debug("send HLP packet to netif successfully"); |
| 6260 | } |
| 6261 | |
| 6262 | /** |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6263 | * hdd_connect_done() - Wrapper API to call cfg80211_connect_done |
| 6264 | * @dev: network device |
| 6265 | * @bssid: bssid to which we want to associate |
| 6266 | * @bss: cfg80211 bss info |
| 6267 | * @roam_info: information about connected bss |
| 6268 | * @req_ie: Request Information Element |
| 6269 | * @req_ie_len: len of the req IE |
| 6270 | * @resp_ie: Response IE |
| 6271 | * @resp_ie_len: len of ht response IE |
| 6272 | * @status: status |
| 6273 | * @gfp: allocation flags |
| 6274 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6275 | * @timeout_reason: reason for connect timeout |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6276 | * |
| 6277 | * This API is used as wrapper to send FILS key/sequence number |
| 6278 | * params etc. to supplicant in case of FILS connection |
| 6279 | * |
| 6280 | * Return: None |
| 6281 | */ |
| 6282 | static void hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6283 | struct cfg80211_bss *bss, |
| 6284 | struct csr_roam_info *roam_info, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6285 | const u8 *req_ie, size_t req_ie_len, |
| 6286 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6287 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6288 | tSirResultCodes timeout_reason) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6289 | { |
| 6290 | struct cfg80211_connect_resp_params fils_params; |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6291 | struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); |
| 6292 | struct fils_join_rsp_params *roam_fils_params = |
| 6293 | roam_info->fils_join_rsp; |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6294 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6295 | qdf_mem_zero(&fils_params, sizeof(fils_params)); |
| 6296 | |
| 6297 | if (!roam_fils_params) { |
| 6298 | fils_params.status = WLAN_STATUS_UNSPECIFIED_FAILURE; |
| 6299 | } else { |
| 6300 | fils_params.status = status; |
| 6301 | fils_params.bssid = bssid; |
Srinivas Girigowda | e975f53 | 2018-01-05 14:03:05 -0800 | [diff] [blame] | 6302 | fils_params.timeout_reason = |
| 6303 | hdd_convert_timeout_reason(timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6304 | fils_params.req_ie = req_ie; |
| 6305 | fils_params.req_ie_len = req_ie_len; |
| 6306 | fils_params.resp_ie = resp_ie; |
| 6307 | fils_params.resp_ie_len = resp_ie_len; |
| 6308 | fils_params.bss = bss; |
| 6309 | hdd_populate_fils_params(&fils_params, roam_fils_params->kek, |
| 6310 | roam_fils_params->kek_len, |
| 6311 | roam_fils_params->fils_pmk, |
| 6312 | roam_fils_params->fils_pmk_len, |
| 6313 | roam_fils_params->fils_pmkid, |
| 6314 | roam_info->fils_seq_num); |
Sridhar Selvaraj | e526044 | 2017-08-19 10:12:03 +0530 | [diff] [blame] | 6315 | hdd_save_gtk_params(adapter, roam_info, false); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6316 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6317 | hdd_debug("FILS indicate connect status %d", fils_params.status); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6318 | |
| 6319 | cfg80211_connect_done(dev, &fils_params, gfp); |
| 6320 | |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6321 | if (roam_fils_params && roam_fils_params->hlp_data_len) |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6322 | hdd_update_hlp_info(dev, roam_info); |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6323 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6324 | /* Clear all the FILS key info */ |
| 6325 | if (roam_fils_params && roam_fils_params->fils_pmk) |
| 6326 | qdf_mem_free(roam_fils_params->fils_pmk); |
| 6327 | if (roam_fils_params) |
| 6328 | qdf_mem_free(roam_fils_params); |
| 6329 | roam_info->fils_join_rsp = NULL; |
| 6330 | } |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6331 | #else /* CFG80211_CONNECT_DONE */ |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6332 | static inline void |
| 6333 | hdd_connect_done(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6334 | struct cfg80211_bss *bss, struct csr_roam_info *roam_info, |
Jeff Johnson | 4f7f7c6 | 2017-10-05 08:53:41 -0700 | [diff] [blame] | 6335 | const u8 *req_ie, size_t req_ie_len, |
| 6336 | const u8 *resp_ie, size_t resp_ie_len, u16 status, |
| 6337 | gfp_t gfp, bool connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6338 | tSirResultCodes timeout_reason) |
Vignesh Viswanathan | a1bb092 | 2017-09-15 12:58:48 +0530 | [diff] [blame] | 6339 | { } |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6340 | #endif |
Pragaspathi Thilagaraj | 9e61908 | 2019-01-24 15:15:45 +0530 | [diff] [blame] | 6341 | #endif /* WLAN_FEATURE_FILS_SK */ |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6342 | |
Vignesh Viswanathan | 3fa1d38 | 2017-08-02 19:36:43 +0530 | [diff] [blame] | 6343 | #if defined(WLAN_FEATURE_FILS_SK) && \ |
| 6344 | (defined(CFG80211_CONNECT_DONE) || \ |
| 6345 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0))) |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6346 | /** |
| 6347 | * hdd_fils_update_connect_results() - API to send fils connection status to |
| 6348 | * supplicant. |
| 6349 | * @dev: network device |
| 6350 | * @bssid: bssid to which we want to associate |
| 6351 | * @bss: cfg80211 bss info |
| 6352 | * @roam_info: information about connected bss |
| 6353 | * @req_ie: Request Information Element |
| 6354 | * @req_ie_len: len of the req IE |
| 6355 | * @resp_ie: Response IE |
| 6356 | * @resp_ie_len: len of ht response IE |
| 6357 | * @status: status |
| 6358 | * @gfp: allocation flags |
| 6359 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
| 6360 | * @timeout_reason: reason for connect timeout |
| 6361 | * |
| 6362 | * The API is a wrapper to send connection status to supplicant |
| 6363 | * |
| 6364 | * Return: 0 if success else failure |
| 6365 | */ |
| 6366 | static int hdd_fils_update_connect_results(struct net_device *dev, |
| 6367 | const u8 *bssid, |
| 6368 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6369 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6370 | size_t req_ie_len, const u8 *resp_ie, |
| 6371 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6372 | bool connect_timeout, |
| 6373 | tSirResultCodes timeout_reason) |
| 6374 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6375 | hdd_enter(); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6376 | if (!roam_info || !roam_info->is_fils_connection) |
| 6377 | return -EINVAL; |
| 6378 | |
| 6379 | hdd_connect_done(dev, bssid, bss, roam_info, req_ie, req_ie_len, |
| 6380 | resp_ie, resp_ie_len, status, gfp, connect_timeout, |
Vignesh Viswanathan | c6d1e1c | 2017-09-18 12:32:49 +0530 | [diff] [blame] | 6381 | timeout_reason); |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6382 | return 0; |
| 6383 | } |
| 6384 | #else |
| 6385 | static inline int hdd_fils_update_connect_results(struct net_device *dev, |
| 6386 | const u8 *bssid, |
| 6387 | struct cfg80211_bss *bss, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6388 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6389 | size_t req_ie_len, const u8 *resp_ie, |
| 6390 | size_t resp_ie_len, u16 status, gfp_t gfp, |
| 6391 | bool connect_timeout, |
| 6392 | tSirResultCodes timeout_reason) |
| 6393 | { |
| 6394 | return -EINVAL; |
| 6395 | } |
| 6396 | #endif |
| 6397 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6398 | /** |
| 6399 | * hdd_connect_result() - API to send connection status to supplicant |
| 6400 | * @dev: network device |
| 6401 | * @bssid: bssid to which we want to associate |
| 6402 | * @roam_info: information about connected bss |
| 6403 | * @req_ie: Request Information Element |
| 6404 | * @req_ie_len: len of the req IE |
| 6405 | * @resp_ie: Response IE |
| 6406 | * @resp_ie_len: len of ht response IE |
| 6407 | * @status: status |
| 6408 | * @gfp: Kernel Flag |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6409 | * @connect_timeout: If timed out waiting for Auth/Assoc/Probe resp |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6410 | * @timeout_reason: reason for connect timeout |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6411 | * |
| 6412 | * The API is a wrapper to send connection status to supplicant |
| 6413 | * and allow runtime suspend |
| 6414 | * |
| 6415 | * Return: Void |
| 6416 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6417 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6418 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6419 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6420 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6421 | bool connect_timeout, |
| 6422 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6423 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6424 | struct hdd_adapter *adapter = netdev_priv(dev); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6425 | struct cfg80211_bss *bss = NULL; |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6426 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6427 | |
| 6428 | if (WLAN_STATUS_SUCCESS == status) { |
| 6429 | struct ieee80211_channel *chan; |
| 6430 | int freq; |
| 6431 | int chan_no = roam_info->pBssDesc->channelId; |
| 6432 | |
| 6433 | if (chan_no <= 14) |
| 6434 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6435 | HDD_NL80211_BAND_2GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6436 | else |
| 6437 | freq = ieee80211_channel_to_frequency(chan_no, |
Srinivas Girigowda | 38f1ded | 2017-06-12 23:00:38 -0700 | [diff] [blame] | 6438 | HDD_NL80211_BAND_5GHZ); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6439 | |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6440 | chan = ieee80211_get_channel(adapter->wdev.wiphy, freq); |
| 6441 | bss = wlan_cfg80211_get_bss(adapter->wdev.wiphy, chan, bssid, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6442 | roam_info->u.pConnectedProfile->SSID.ssId, |
| 6443 | roam_info->u.pConnectedProfile->SSID.length); |
| 6444 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6445 | |
Sridhar Selvaraj | 0d5d2c7 | 2017-08-17 17:30:01 +0530 | [diff] [blame] | 6446 | if (hdd_fils_update_connect_results(dev, bssid, bss, |
| 6447 | roam_info, req_ie, req_ie_len, resp_ie, |
| 6448 | resp_ie_len, status, gfp, connect_timeout, |
| 6449 | timeout_reason) != 0) { |
| 6450 | hdd_connect_bss(dev, bssid, bss, req_ie, |
| 6451 | req_ie_len, resp_ie, resp_ie_len, |
| 6452 | status, gfp, connect_timeout, timeout_reason); |
| 6453 | } |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6454 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6455 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6456 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6457 | } |
| 6458 | #else |
| 6459 | void hdd_connect_result(struct net_device *dev, const u8 *bssid, |
Jeff Johnson | 172237b | 2017-11-07 15:32:59 -0800 | [diff] [blame] | 6460 | struct csr_roam_info *roam_info, const u8 *req_ie, |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6461 | size_t req_ie_len, const u8 *resp_ie, |
Abhishek Singh | a84d395 | 2016-09-13 13:45:05 +0530 | [diff] [blame] | 6462 | size_t resp_ie_len, u16 status, gfp_t gfp, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6463 | bool connect_timeout, |
| 6464 | tSirResultCodes timeout_reason) |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6465 | { |
Jeff Johnson | a138238 | 2019-03-31 11:08:27 -0700 | [diff] [blame] | 6466 | struct hdd_adapter *adapter = netdev_priv(dev); |
| 6467 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Komal Seelam | a89be8d | 2016-09-29 11:09:26 +0530 | [diff] [blame] | 6468 | |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6469 | cfg80211_connect_result(dev, bssid, req_ie, req_ie_len, |
| 6470 | resp_ie, resp_ie_len, status, gfp); |
Prashanth Bhatta | 87b6dc0 | 2017-01-19 15:17:58 -0800 | [diff] [blame] | 6471 | |
Jingxiang Ge | b49aa30 | 2018-01-17 20:54:15 +0800 | [diff] [blame] | 6472 | qdf_runtime_pm_allow_suspend(&hdd_ctx->runtime_context.connect); |
Dustin Brown | ceed67e | 2017-05-26 11:57:31 -0700 | [diff] [blame] | 6473 | hdd_allow_suspend(WIFI_POWER_EVENT_WAKELOCK_CONNECT); |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6474 | } |
| 6475 | #endif |
| 6476 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6477 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6478 | int wlan_hdd_set_mon_chan(struct hdd_adapter *adapter, uint32_t chan, |
| 6479 | uint32_t bandwidth) |
| 6480 | { |
| 6481 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 6482 | struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 6483 | struct hdd_mon_set_ch_info *ch_info = &sta_ctx->ch_info; |
| 6484 | QDF_STATUS status; |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6485 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6486 | struct qdf_mac_addr bssid; |
| 6487 | struct csr_roam_profile roam_profile; |
| 6488 | struct ch_params ch_params; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6489 | eConnectionState connstate; |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6490 | |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6491 | if (hdd_get_conparam() != QDF_GLOBAL_MONITOR_MODE && |
| 6492 | adapter->device_mode != QDF_STA_MODE) { |
| 6493 | hdd_err("Not supported, device is not in monitor mode or sta mission mode"); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6494 | return -EINVAL; |
| 6495 | } |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6496 | if (adapter->device_mode == QDF_STA_MODE && |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6497 | ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc)) { |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6498 | connstate = sta_ctx->conn_info.conn_state; |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6499 | if (eConnectionState_Associated == connstate || |
| 6500 | eConnectionState_Connecting == connstate) { |
| 6501 | return -EINVAL; |
| 6502 | } |
| 6503 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6504 | |
Visweswara Tanuku | 006313a | 2018-04-12 12:26:34 +0530 | [diff] [blame] | 6505 | /* Validate Channel */ |
| 6506 | if (!WLAN_REG_IS_24GHZ_CH(chan) && !WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6507 | hdd_err("Channel %d Not supported", chan); |
| 6508 | return -EINVAL; |
| 6509 | } |
| 6510 | |
| 6511 | if (WLAN_REG_IS_24GHZ_CH(chan)) { |
| 6512 | if (bandwidth == CH_WIDTH_80MHZ) { |
| 6513 | hdd_err("BW80 not possible in 2.4GHz band"); |
| 6514 | return -EINVAL; |
| 6515 | } |
| 6516 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 14) && |
| 6517 | (bandwidth != CH_WIDTH_MAX)) { |
| 6518 | hdd_err("Only BW20 possible on channel 14"); |
| 6519 | return -EINVAL; |
| 6520 | } |
| 6521 | } |
| 6522 | |
| 6523 | if (WLAN_REG_IS_5GHZ_CH(chan)) { |
| 6524 | if ((bandwidth != CH_WIDTH_20MHZ) && (chan == 165) && |
| 6525 | (bandwidth != CH_WIDTH_MAX)) { |
| 6526 | hdd_err("Only BW20 possible on channel 165"); |
| 6527 | return -EINVAL; |
| 6528 | } |
| 6529 | } |
| 6530 | |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6531 | hdd_debug("Set monitor mode Channel %d", chan); |
| 6532 | qdf_mem_zero(&roam_profile, sizeof(roam_profile)); |
| 6533 | roam_profile.ChannelInfo.ChannelList = &ch_info->channel; |
| 6534 | roam_profile.ChannelInfo.numOfChannels = 1; |
| 6535 | roam_profile.phyMode = ch_info->phy_mode; |
| 6536 | roam_profile.ch_params.ch_width = bandwidth; |
| 6537 | hdd_select_cbmode(adapter, chan, &roam_profile.ch_params); |
Pragaspathi Thilagaraj | a889375 | 2019-02-06 19:58:59 +0530 | [diff] [blame] | 6538 | if (ucfg_mlme_is_change_channel_bandwidth_enabled(hdd_ctx->psoc) && |
Jeff Johnson | 43837af | 2018-10-17 12:44:05 -0700 | [diff] [blame] | 6539 | (!sme_find_session_by_bssid(mac_handle, adapter->mac_addr.bytes))) { |
| 6540 | status = sme_create_mon_session(mac_handle, |
Rajeev Kumar Sirasanagandla | e3b5991 | 2018-08-24 15:53:31 +0530 | [diff] [blame] | 6541 | adapter->mac_addr.bytes, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6542 | adapter->vdev_id); |
Chaoli Zhou | 75b062f | 2018-06-11 12:36:54 +0800 | [diff] [blame] | 6543 | if (status != QDF_STATUS_SUCCESS) { |
| 6544 | hdd_err("Status: %d Failed to create session.", |
| 6545 | status); |
| 6546 | return qdf_status_to_os_return(status); |
| 6547 | } |
| 6548 | } |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6549 | qdf_mem_copy(bssid.bytes, adapter->mac_addr.bytes, |
| 6550 | QDF_MAC_ADDR_SIZE); |
| 6551 | |
| 6552 | ch_params.ch_width = bandwidth; |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 6553 | wlan_reg_set_channel_params(hdd_ctx->pdev, chan, 0, &ch_params); |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6554 | if (ch_params.ch_width == CH_WIDTH_INVALID) { |
| 6555 | hdd_err("Invalid capture channel or bandwidth for a country"); |
| 6556 | return -EINVAL; |
| 6557 | } |
| 6558 | if (wlan_hdd_change_hw_mode_for_given_chnl(adapter, chan, |
| 6559 | POLICY_MGR_UPDATE_REASON_SET_OPER_CHAN)) { |
| 6560 | hdd_err("Failed to change hw mode"); |
| 6561 | return -EINVAL; |
| 6562 | } |
| 6563 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 6564 | status = sme_roam_channel_change_req(hdd_ctx->mac_handle, |
| 6565 | bssid, &ch_params, |
Jeff Johnson | d995275 | 2018-04-18 12:15:35 -0700 | [diff] [blame] | 6566 | &roam_profile); |
| 6567 | if (status) { |
| 6568 | hdd_err("Status: %d Failed to set sme_roam Channel for monitor mode", |
| 6569 | status); |
| 6570 | } |
| 6571 | |
| 6572 | adapter->mon_chan = chan; |
| 6573 | adapter->mon_bandwidth = bandwidth; |
| 6574 | return qdf_status_to_os_return(status); |
| 6575 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 6576 | #endif |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6577 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6578 | #ifdef MSM_PLATFORM |
| 6579 | /** |
| 6580 | * hdd_stop_p2p_go() - call cfg80211 API to stop P2P GO |
| 6581 | * @adapter: pointer to adapter |
| 6582 | * |
| 6583 | * This function calls cfg80211 API to stop P2P GO |
| 6584 | * |
| 6585 | * Return: None |
| 6586 | */ |
| 6587 | static void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6588 | { |
| 6589 | hdd_debug("[SSR] send stop ap to supplicant"); |
| 6590 | cfg80211_ap_stopped(adapter->dev, GFP_KERNEL); |
| 6591 | } |
| 6592 | |
| 6593 | static inline void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6594 | { |
| 6595 | } |
| 6596 | #else |
| 6597 | static inline void hdd_stop_p2p_go(struct hdd_adapter *adapter) |
| 6598 | { |
| 6599 | } |
| 6600 | |
| 6601 | /** |
| 6602 | * hdd_delete_sta() - call cfg80211 API to delete STA |
| 6603 | * @adapter: pointer to adapter |
| 6604 | * |
| 6605 | * This function calls cfg80211 API to delete STA |
| 6606 | * |
| 6607 | * Return: None |
| 6608 | */ |
| 6609 | static void hdd_delete_sta(struct hdd_adapter *adapter) |
| 6610 | { |
| 6611 | struct qdf_mac_addr bcast_mac = QDF_MAC_ADDR_BCAST_INIT; |
| 6612 | |
| 6613 | hdd_debug("[SSR] send restart supplicant"); |
| 6614 | /* event supplicant to restart */ |
| 6615 | cfg80211_del_sta(adapter->dev, |
| 6616 | (const u8 *)&bcast_mac.bytes[0], |
| 6617 | GFP_KERNEL); |
| 6618 | } |
| 6619 | #endif |
| 6620 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6621 | QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6622 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6623 | struct hdd_adapter *adapter; |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6624 | eConnectionState conn_state; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6625 | bool value; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6626 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6627 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6628 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6629 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6630 | if (!hdd_is_interface_up(adapter)) |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6631 | continue; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 6632 | |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6633 | hdd_debug("[SSR] start adapter with device mode %s(%d)", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 6634 | qdf_opmode_str(adapter->device_mode), |
Yue Ma | 4265468 | 2018-01-11 16:55:24 -0800 | [diff] [blame] | 6635 | adapter->device_mode); |
| 6636 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6637 | hdd_wmm_init(adapter); |
| 6638 | |
| 6639 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6640 | case QDF_STA_MODE: |
| 6641 | case QDF_P2P_CLIENT_MODE: |
| 6642 | case QDF_P2P_DEVICE_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6643 | |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6644 | conn_state = (WLAN_HDD_GET_STATION_CTX_PTR(adapter)) |
| 6645 | ->conn_info.conn_state; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6646 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6647 | hdd_start_station_adapter(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6648 | /* Open the gates for HDD to receive Wext commands */ |
Jeff Johnson | c72c573 | 2017-10-28 12:49:37 -0700 | [diff] [blame] | 6649 | adapter->is_link_up_service_needed = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6650 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6651 | /* Indicate disconnect event to supplicant |
| 6652 | * if associated previously |
| 6653 | */ |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6654 | if (eConnectionState_Associated == conn_state || |
| 6655 | eConnectionState_IbssConnected == conn_state || |
| 6656 | eConnectionState_NotConnected == conn_state || |
| 6657 | eConnectionState_IbssDisconnected == conn_state || |
| 6658 | eConnectionState_Disconnecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6659 | union iwreq_data wrqu; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6660 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6661 | memset(&wrqu, '\0', sizeof(wrqu)); |
| 6662 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 6663 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); |
| 6664 | wireless_send_event(adapter->dev, SIOCGIWAP, |
| 6665 | &wrqu, NULL); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 6666 | adapter->session.station. |
Jeff Johnson | 690fe95 | 2017-10-25 11:48:39 -0700 | [diff] [blame] | 6667 | hdd_reassoc_scenario = false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6668 | |
| 6669 | /* indicate disconnected event to nl80211 */ |
Mahesh A Saptasagar | c35e8bf | 2016-06-17 20:03:46 +0530 | [diff] [blame] | 6670 | wlan_hdd_cfg80211_indicate_disconnect( |
| 6671 | adapter->dev, false, |
| 6672 | WLAN_REASON_UNSPECIFIED); |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 6673 | } else if (eConnectionState_Connecting == conn_state) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6674 | /* |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6675 | * Indicate connect failure to supplicant if we |
| 6676 | * were in the process of connecting |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6677 | */ |
Anurag Chouhan | c409292 | 2016-09-08 15:56:11 +0530 | [diff] [blame] | 6678 | hdd_connect_result(adapter->dev, NULL, NULL, |
yeshwanth sriram guntuka | af7b73f | 2017-02-22 17:35:32 +0530 | [diff] [blame] | 6679 | NULL, 0, NULL, 0, |
| 6680 | WLAN_STATUS_ASSOC_DENIED_UNSPEC, |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6681 | GFP_KERNEL, false, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6682 | } |
| 6683 | |
| 6684 | hdd_register_tx_flow_control(adapter, |
| 6685 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 6686 | hdd_tx_resume_cb, |
| 6687 | hdd_tx_flow_control_is_pause); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6688 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 6689 | hdd_register_hl_netdev_fc_timer( |
| 6690 | adapter, |
| 6691 | hdd_tx_resume_timer_expired_handler); |
| 6692 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 6693 | hdd_lpass_notify_start(hdd_ctx, adapter); |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 6694 | hdd_nud_ignore_tracking(adapter, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6695 | break; |
| 6696 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6697 | case QDF_SAP_MODE: |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 6698 | ucfg_mlme_get_sap_internal_restart(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 6699 | &value); |
| 6700 | if (value) |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6701 | hdd_start_ap_adapter(adapter); |
Arun Khandavalli | cc544b3 | 2017-01-30 19:52:16 +0530 | [diff] [blame] | 6702 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6703 | break; |
| 6704 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6705 | case QDF_P2P_GO_MODE: |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6706 | hdd_delete_sta(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6707 | break; |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6708 | case QDF_MONITOR_MODE: |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 6709 | hdd_start_station_adapter(adapter); |
Arunk Khandavalli | 062fb03 | 2017-10-04 12:18:15 +0530 | [diff] [blame] | 6710 | hdd_set_mon_rx_cb(adapter->dev); |
| 6711 | wlan_hdd_set_mon_chan(adapter, adapter->mon_chan, |
| 6712 | adapter->mon_bandwidth); |
| 6713 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6714 | default: |
| 6715 | break; |
| 6716 | } |
Krunal Soni | 9c2ee03 | 2017-07-18 13:49:54 -0700 | [diff] [blame] | 6717 | /* |
| 6718 | * Action frame registered in one adapter which will |
| 6719 | * applicable to all interfaces |
| 6720 | */ |
| 6721 | wlan_hdd_cfg80211_register_frames(adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6722 | } |
| 6723 | |
Wu Gao | df929f1 | 2018-05-25 18:12:25 +0800 | [diff] [blame] | 6724 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6725 | if (!hdd_is_interface_up(adapter)) |
| 6726 | continue; |
| 6727 | |
| 6728 | if (adapter->device_mode == QDF_P2P_GO_MODE) |
| 6729 | hdd_stop_p2p_go(adapter); |
| 6730 | } |
| 6731 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 6732 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6733 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6734 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6735 | } |
| 6736 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6737 | QDF_STATUS hdd_get_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6738 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6739 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6740 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6741 | qdf_list_node_t *node; |
| 6742 | |
| 6743 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6744 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6745 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6746 | status = qdf_list_peek_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6747 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6748 | |
| 6749 | if (QDF_IS_STATUS_ERROR(status)) |
| 6750 | return status; |
| 6751 | |
| 6752 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6753 | |
| 6754 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6755 | } |
| 6756 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6757 | QDF_STATUS hdd_get_next_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6758 | struct hdd_adapter *current_adapter, |
| 6759 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6760 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6761 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6762 | qdf_list_node_t *node; |
| 6763 | |
| 6764 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6765 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6766 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 6767 | status = qdf_list_peek_next(&hdd_ctx->hdd_adapters, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6768 | ¤t_adapter->node, |
| 6769 | &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6770 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6771 | |
| 6772 | if (QDF_IS_STATUS_ERROR(status)) |
| 6773 | return status; |
| 6774 | |
| 6775 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6776 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6777 | return status; |
| 6778 | } |
| 6779 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6780 | QDF_STATUS hdd_remove_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6781 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6782 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6783 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6784 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6785 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6786 | status = qdf_list_remove_node(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6787 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6788 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6789 | return status; |
| 6790 | } |
| 6791 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6792 | QDF_STATUS hdd_remove_front_adapter(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6793 | struct hdd_adapter **out_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6794 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6795 | QDF_STATUS status; |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6796 | qdf_list_node_t *node; |
| 6797 | |
| 6798 | *out_adapter = NULL; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6799 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6800 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6801 | status = qdf_list_remove_front(&hdd_ctx->hdd_adapters, &node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6802 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6803 | |
| 6804 | if (QDF_IS_STATUS_ERROR(status)) |
| 6805 | return status; |
| 6806 | |
| 6807 | *out_adapter = qdf_container_of(node, struct hdd_adapter, node); |
| 6808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6809 | return status; |
| 6810 | } |
| 6811 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6812 | QDF_STATUS hdd_add_adapter_back(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6813 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6814 | { |
Anurag Chouhan | ffb2154 | 2016-02-17 14:33:03 +0530 | [diff] [blame] | 6815 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6816 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6817 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6818 | status = qdf_list_insert_back(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6819 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6820 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6821 | return status; |
| 6822 | } |
| 6823 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6824 | QDF_STATUS hdd_add_adapter_front(struct hdd_context *hdd_ctx, |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6825 | struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6826 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 6827 | QDF_STATUS status; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6828 | |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6829 | qdf_spin_lock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6830 | status = qdf_list_insert_front(&hdd_ctx->hdd_adapters, &adapter->node); |
Rajeev Kumar | dd4dd08 | 2016-02-25 12:24:32 -0800 | [diff] [blame] | 6831 | qdf_spin_unlock_bh(&hdd_ctx->hdd_adapter_lock); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6832 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6833 | return status; |
| 6834 | } |
| 6835 | |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6836 | struct hdd_adapter *hdd_get_adapter_by_rand_macaddr( |
| 6837 | struct hdd_context *hdd_ctx, tSirMacAddr mac_addr) |
| 6838 | { |
| 6839 | struct hdd_adapter *adapter; |
| 6840 | |
| 6841 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6842 | if ((adapter->device_mode == QDF_STA_MODE || |
| 6843 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 6844 | adapter->device_mode == QDF_P2P_DEVICE_MODE) && |
| 6845 | ucfg_p2p_check_random_mac(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6846 | adapter->vdev_id, mac_addr)) |
Liangwei Dong | 3abfe8f | 2018-09-20 02:25:44 -0400 | [diff] [blame] | 6847 | return adapter; |
| 6848 | } |
| 6849 | |
| 6850 | return NULL; |
| 6851 | } |
| 6852 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6853 | struct hdd_adapter *hdd_get_adapter_by_macaddr(struct hdd_context *hdd_ctx, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 6854 | tSirMacAddr mac_addr) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6855 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6856 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6857 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6858 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6859 | if (!qdf_mem_cmp(adapter->mac_addr.bytes, |
Jeff Johnson | aa6cbb8 | 2019-03-10 19:31:35 -0700 | [diff] [blame] | 6860 | mac_addr, sizeof(tSirMacAddr))) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6861 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6862 | } |
| 6863 | |
| 6864 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6865 | } |
| 6866 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6867 | struct hdd_adapter *hdd_get_adapter_by_vdev(struct hdd_context *hdd_ctx, |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6868 | uint32_t vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6869 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6870 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6871 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6872 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 6873 | if (adapter->vdev_id == vdev_id) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6874 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6875 | } |
| 6876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6877 | return NULL; |
| 6878 | } |
| 6879 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6880 | 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] | 6881 | const char *iface_name) |
| 6882 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6883 | struct hdd_adapter *adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6884 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6885 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6886 | if (!qdf_str_cmp(adapter->dev->name, iface_name)) |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6887 | return adapter; |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6888 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6889 | |
Naveen Rawat | 4edb682 | 2017-04-12 10:09:17 -0700 | [diff] [blame] | 6890 | return NULL; |
| 6891 | } |
| 6892 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6893 | /** |
| 6894 | * hdd_get_adapter() - to get adapter matching the mode |
| 6895 | * @hdd_ctx: hdd context |
| 6896 | * @mode: adapter mode |
| 6897 | * |
| 6898 | * This routine will return the pointer to adapter matching |
| 6899 | * with the passed mode. |
| 6900 | * |
| 6901 | * Return: pointer to adapter or null |
| 6902 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6903 | struct hdd_adapter *hdd_get_adapter(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6904 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6905 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6906 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6907 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6908 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 6909 | if (adapter->device_mode == mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6910 | return adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6911 | } |
| 6912 | |
| 6913 | return NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6914 | } |
| 6915 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6916 | enum QDF_OPMODE hdd_get_device_mode(uint32_t vdev_id) |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6917 | { |
| 6918 | struct hdd_context *hdd_ctx; |
| 6919 | struct hdd_adapter *adapter; |
| 6920 | |
| 6921 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 6922 | if (!hdd_ctx) { |
| 6923 | hdd_err("Invalid HDD context"); |
| 6924 | return QDF_MAX_NO_OF_MODE; |
| 6925 | } |
| 6926 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 6927 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Yeshwanth Sriram Guntuka | 469f957 | 2018-02-12 13:28:22 +0530 | [diff] [blame] | 6928 | if (!adapter) { |
| 6929 | hdd_err("Invalid HDD adapter"); |
| 6930 | return QDF_MAX_NO_OF_MODE; |
| 6931 | } |
| 6932 | |
| 6933 | return adapter->device_mode; |
| 6934 | } |
| 6935 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6936 | /** |
| 6937 | * hdd_get_operating_channel() - return operating channel of the device mode |
| 6938 | * @hdd_ctx: Pointer to the HDD context. |
| 6939 | * @mode: Device mode for which operating channel is required. |
Jeff Johnson | 77f89bb | 2018-05-06 16:21:36 -0700 | [diff] [blame] | 6940 | * Supported modes: |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6941 | * QDF_STA_MODE, |
| 6942 | * QDF_P2P_CLIENT_MODE, |
| 6943 | * QDF_SAP_MODE, |
| 6944 | * QDF_P2P_GO_MODE. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6945 | * |
| 6946 | * This API returns the operating channel of the requested device mode |
| 6947 | * |
| 6948 | * Return: channel number. "0" id the requested device is not found OR it is |
| 6949 | * not connected. |
| 6950 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6951 | uint8_t hdd_get_operating_channel(struct hdd_context *hdd_ctx, |
Jeff Johnson | c1e6278 | 2017-11-09 09:50:17 -0800 | [diff] [blame] | 6952 | enum QDF_OPMODE mode) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6953 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6954 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6955 | uint8_t operatingChannel = 0; |
| 6956 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6957 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6958 | if (mode == adapter->device_mode) { |
| 6959 | switch (adapter->device_mode) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6960 | case QDF_STA_MODE: |
| 6961 | case QDF_P2P_CLIENT_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6962 | if (hdd_conn_is_connected |
| 6963 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6964 | (adapter))) { |
| 6965 | operatingChannel = |
| 6966 | (WLAN_HDD_GET_STATION_CTX_PTR |
| 6967 | (adapter))->conn_info. |
Jeff Johnson | 8626e93 | 2019-02-27 18:35:22 -0800 | [diff] [blame] | 6968 | channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6969 | } |
| 6970 | break; |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 6971 | case QDF_SAP_MODE: |
| 6972 | case QDF_P2P_GO_MODE: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6973 | /* softap connection info */ |
| 6974 | if (test_bit |
| 6975 | (SOFTAP_BSS_STARTED, |
| 6976 | &adapter->event_flags)) |
| 6977 | operatingChannel = |
| 6978 | (WLAN_HDD_GET_AP_CTX_PTR |
Jeff Johnson | 0120686 | 2017-10-27 20:55:59 -0700 | [diff] [blame] | 6979 | (adapter))->operating_channel; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6980 | break; |
| 6981 | default: |
| 6982 | break; |
| 6983 | } |
| 6984 | |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 6985 | /* Found the device of interest. break the loop */ |
| 6986 | break; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6987 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6988 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 6989 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6990 | return operatingChannel; |
| 6991 | } |
| 6992 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 6993 | static inline QDF_STATUS hdd_unregister_wext_all_adapters(struct hdd_context * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6994 | hdd_ctx) |
| 6995 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 6996 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6997 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 6998 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 6999 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7000 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7001 | if (adapter->device_mode == QDF_STA_MODE || |
| 7002 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7003 | adapter->device_mode == QDF_IBSS_MODE || |
| 7004 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7005 | adapter->device_mode == QDF_SAP_MODE || |
| 7006 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7007 | hdd_unregister_wext(adapter->dev); |
| 7008 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7009 | } |
| 7010 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7011 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7012 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7013 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7014 | } |
| 7015 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7016 | 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] | 7017 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7018 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7019 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7020 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7021 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7022 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7023 | if (adapter->device_mode == QDF_STA_MODE || |
| 7024 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7025 | adapter->device_mode == QDF_IBSS_MODE || |
| 7026 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7027 | adapter->device_mode == QDF_SAP_MODE || |
| 7028 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7029 | wlan_abort_scan(hdd_ctx->pdev, INVAL_PDEV_ID, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7030 | adapter->vdev_id, INVALID_SCAN_ID, |
Vignesh Viswanathan | 19611c8 | 2018-01-16 16:20:40 +0530 | [diff] [blame] | 7031 | true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7032 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7033 | } |
| 7034 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7035 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7036 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7037 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7038 | } |
| 7039 | |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7040 | /** |
| 7041 | * hdd_abort_sched_scan_all_adapters() - stops scheduled (PNO) scans for all |
| 7042 | * adapters |
| 7043 | * @hdd_ctx: The HDD context containing the adapters to operate on |
| 7044 | * |
| 7045 | * return: QDF_STATUS_SUCCESS |
| 7046 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7047 | 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] | 7048 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 7049 | struct hdd_adapter *adapter; |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7050 | int err; |
| 7051 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7052 | hdd_enter(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7053 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7054 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7055 | if (adapter->device_mode == QDF_STA_MODE || |
| 7056 | adapter->device_mode == QDF_P2P_CLIENT_MODE || |
| 7057 | adapter->device_mode == QDF_IBSS_MODE || |
| 7058 | adapter->device_mode == QDF_P2P_DEVICE_MODE || |
| 7059 | adapter->device_mode == QDF_SAP_MODE || |
| 7060 | adapter->device_mode == QDF_P2P_GO_MODE) { |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7061 | err = wlan_hdd_sched_scan_stop(adapter->dev); |
| 7062 | if (err) |
| 7063 | hdd_err("Unable to stop scheduled scan"); |
| 7064 | } |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7065 | } |
| 7066 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 7067 | hdd_exit(); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7068 | |
| 7069 | return QDF_STATUS_SUCCESS; |
| 7070 | } |
| 7071 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7072 | #ifdef WLAN_NS_OFFLOAD |
| 7073 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7074 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7075 | * @hdd_ctx: Pointer to hdd context |
| 7076 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7077 | * Unregister for IPv6 address change notifications. |
| 7078 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7079 | * Return: None |
| 7080 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7081 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7082 | { |
| 7083 | unregister_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7084 | } |
| 7085 | |
| 7086 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7087 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7088 | * @hdd_ctx: Pointer to hdd context |
| 7089 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7090 | * Register for IPv6 address change notifications. |
| 7091 | * |
| 7092 | * Return: 0 on success and errno on failure. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7093 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7094 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7095 | { |
| 7096 | int ret; |
| 7097 | |
| 7098 | hdd_ctx->ipv6_notifier.notifier_call = wlan_hdd_ipv6_changed; |
| 7099 | ret = register_inet6addr_notifier(&hdd_ctx->ipv6_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7100 | if (ret) { |
| 7101 | hdd_err("Failed to register IPv6 notifier: %d", ret); |
| 7102 | goto out; |
| 7103 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7104 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7105 | hdd_debug("Registered IPv6 notifier"); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7106 | out: |
| 7107 | return ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7108 | } |
| 7109 | #else |
| 7110 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7111 | * hdd_wlan_unregister_ip6_notifier() - unregister IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7112 | * @hdd_ctx: Pointer to hdd context |
| 7113 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7114 | * Unregister for IPv6 address change notifications. |
| 7115 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7116 | * Return: None |
| 7117 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7118 | static void hdd_wlan_unregister_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7119 | { |
| 7120 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7121 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7122 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7123 | * hdd_wlan_register_ip6_notifier() - register IPv6 change notifier |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7124 | * @hdd_ctx: Pointer to hdd context |
| 7125 | * |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7126 | * Register for IPv6 address change notifications. |
| 7127 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7128 | * Return: None |
| 7129 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7130 | static int hdd_wlan_register_ip6_notifier(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7131 | { |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7132 | return 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7133 | } |
| 7134 | #endif |
| 7135 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7136 | void hdd_set_disconnect_status(struct hdd_adapter *adapter, bool status) |
| 7137 | { |
| 7138 | qdf_mutex_acquire(&adapter->disconnection_status_lock); |
| 7139 | adapter->disconnection_in_progress = status; |
| 7140 | qdf_mutex_release(&adapter->disconnection_status_lock); |
| 7141 | hdd_debug("setting disconnection status: %d", status); |
| 7142 | } |
| 7143 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7144 | /** |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7145 | * hdd_register_notifiers - Register netdev notifiers. |
| 7146 | * @hdd_ctx: HDD context |
| 7147 | * |
| 7148 | * Register netdev notifiers like IPv4 and IPv6. |
| 7149 | * |
| 7150 | * Return: 0 on success and errno on failure |
| 7151 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7152 | static int hdd_register_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7153 | { |
| 7154 | int ret; |
| 7155 | |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7156 | ret = hdd_wlan_register_ip6_notifier(hdd_ctx); |
| 7157 | if (ret) |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7158 | goto out; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7159 | |
| 7160 | hdd_ctx->ipv4_notifier.notifier_call = wlan_hdd_ipv4_changed; |
| 7161 | ret = register_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
| 7162 | if (ret) { |
| 7163 | hdd_err("Failed to register IPv4 notifier: %d", ret); |
| 7164 | goto unregister_ip6_notifier; |
| 7165 | } |
| 7166 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7167 | ret = hdd_nud_register_netevent_notifier(hdd_ctx); |
| 7168 | if (ret) { |
| 7169 | hdd_err("Failed to register netevent notifier: %d", |
| 7170 | ret); |
| 7171 | goto unregister_inetaddr_notifier; |
| 7172 | } |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7173 | return 0; |
| 7174 | |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7175 | unregister_inetaddr_notifier: |
| 7176 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7177 | unregister_ip6_notifier: |
| 7178 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7179 | out: |
| 7180 | return ret; |
| 7181 | |
| 7182 | } |
| 7183 | |
| 7184 | /** |
| 7185 | * hdd_unregister_notifiers - Unregister netdev notifiers. |
| 7186 | * @hdd_ctx: HDD context |
| 7187 | * |
| 7188 | * Unregister netdev notifiers like IPv4 and IPv6. |
| 7189 | * |
| 7190 | * Return: None. |
| 7191 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7192 | void hdd_unregister_notifiers(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7193 | { |
Alok Kumar | b64650c | 2018-03-23 17:05:11 +0530 | [diff] [blame] | 7194 | hdd_nud_unregister_netevent_notifier(hdd_ctx); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7195 | hdd_wlan_unregister_ip6_notifier(hdd_ctx); |
| 7196 | |
| 7197 | unregister_inetaddr_notifier(&hdd_ctx->ipv4_notifier); |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 7198 | } |
| 7199 | |
| 7200 | /** |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7201 | * hdd_exit_netlink_services - Exit netlink services |
| 7202 | * @hdd_ctx: HDD context |
| 7203 | * |
| 7204 | * Exit netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7205 | * nl service. |
| 7206 | * |
| 7207 | * Return: None. |
| 7208 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7209 | static void hdd_exit_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7210 | { |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7211 | spectral_scan_deactivate_service(); |
| 7212 | cnss_diag_deactivate_service(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7213 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7214 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7215 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7216 | |
| 7217 | nl_srv_exit(); |
| 7218 | } |
| 7219 | |
| 7220 | /** |
| 7221 | * hdd_init_netlink_services- Init netlink services |
| 7222 | * @hdd_ctx: HDD context |
| 7223 | * |
| 7224 | * Init netlink services like cnss_diag, cesium netlink socket, ptt socket and |
| 7225 | * nl service. |
| 7226 | * |
| 7227 | * Return: 0 on success and errno on failure. |
| 7228 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7229 | static int hdd_init_netlink_services(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7230 | { |
| 7231 | int ret; |
| 7232 | |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7233 | ret = wlan_hdd_nl_init(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7234 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7235 | hdd_err("nl_srv_init failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7236 | goto out; |
| 7237 | } |
Ryan Hsu | ceddceb | 2016-04-28 10:20:14 -0700 | [diff] [blame] | 7238 | cds_set_radio_index(hdd_ctx->radio_index); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7239 | |
Naveen Rawat | 910726a | 2017-03-06 11:42:51 -0800 | [diff] [blame] | 7240 | ret = hdd_activate_wifi_pos(hdd_ctx); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7241 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7242 | hdd_err("hdd_activate_wifi_pos failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7243 | goto err_nl_srv; |
| 7244 | } |
| 7245 | |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7246 | ptt_sock_activate_svc(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7247 | |
| 7248 | ret = hdd_open_cesium_nl_sock(); |
Ryan Hsu | 5e2e205 | 2016-04-28 10:19:38 -0700 | [diff] [blame] | 7249 | if (ret) |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7250 | hdd_err("hdd_open_cesium_nl_sock failed ret: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7251 | |
| 7252 | ret = cnss_diag_activate_service(); |
| 7253 | if (ret) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7254 | hdd_err("cnss_diag_activate_service failed: %d", ret); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7255 | goto err_close_cesium; |
| 7256 | } |
| 7257 | |
Dustin Brown | 0152085 | 2019-02-27 12:14:16 -0800 | [diff] [blame] | 7258 | spectral_scan_activate_service(hdd_ctx); |
Sandeep Puligilla | 019a1bd | 2018-02-04 22:57:44 -0800 | [diff] [blame] | 7259 | |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7260 | return 0; |
| 7261 | |
| 7262 | err_close_cesium: |
| 7263 | hdd_close_cesium_nl_sock(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7264 | ptt_sock_deactivate_svc(); |
Vignesh Viswanathan | a1cb4b4 | 2018-05-17 21:19:27 +0530 | [diff] [blame] | 7265 | hdd_deactivate_wifi_pos(); |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7266 | err_nl_srv: |
| 7267 | nl_srv_exit(); |
| 7268 | out: |
| 7269 | return ret; |
| 7270 | } |
| 7271 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7272 | /** |
| 7273 | * hdd_rx_wake_lock_destroy() - Destroy RX wakelock |
| 7274 | * @hdd_ctx: HDD context. |
| 7275 | * |
| 7276 | * Destroy RX wakelock. |
| 7277 | * |
| 7278 | * Return: None. |
| 7279 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7280 | static void hdd_rx_wake_lock_destroy(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7281 | { |
| 7282 | qdf_wake_lock_destroy(&hdd_ctx->rx_wake_lock); |
| 7283 | } |
Prashanth Bhatta | 6a6a555 | 2016-02-01 13:49:29 -0800 | [diff] [blame] | 7284 | |
| 7285 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7286 | * hdd_rx_wake_lock_create() - Create RX wakelock |
| 7287 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7288 | * |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7289 | * Create RX wakelock. |
| 7290 | * |
| 7291 | * Return: None. |
| 7292 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7293 | static void hdd_rx_wake_lock_create(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7294 | { |
| 7295 | qdf_wake_lock_create(&hdd_ctx->rx_wake_lock, "qcom_rx_wakelock"); |
| 7296 | } |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7297 | |
| 7298 | /** |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7299 | * hdd_context_deinit() - Deinitialize HDD context |
| 7300 | * @hdd_ctx: HDD context. |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7301 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7302 | * Deinitialize HDD context along with all the feature specific contexts but |
| 7303 | * do not free hdd context itself. Caller of this API is supposed to free |
| 7304 | * HDD context. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7305 | * |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7306 | * return: 0 on success and errno on failure. |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7307 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7308 | static int hdd_context_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7309 | { |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7310 | qdf_wake_lock_destroy(&hdd_ctx->monitor_mode_wakelock); |
| 7311 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7312 | wlan_hdd_cfg80211_deinit(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7313 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7314 | hdd_sap_context_destroy(hdd_ctx); |
| 7315 | |
| 7316 | hdd_rx_wake_lock_destroy(hdd_ctx); |
| 7317 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7318 | hdd_scan_context_destroy(hdd_ctx); |
| 7319 | |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 7320 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 7321 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7322 | return 0; |
| 7323 | } |
| 7324 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7325 | void hdd_context_destroy(struct hdd_context *hdd_ctx) |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7326 | { |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 7327 | cds_set_context(QDF_MODULE_ID_HDD, NULL); |
Arunk Khandavalli | 3d267b4 | 2017-05-02 18:58:59 +0530 | [diff] [blame] | 7328 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 7329 | hdd_exit_netlink_services(hdd_ctx); |
Hanumantha Reddy Pothula | 00c74f6 | 2016-11-24 20:13:32 +0530 | [diff] [blame] | 7330 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 7331 | |
Houston Hoffman | 160db39 | 2016-10-10 17:37:51 -0700 | [diff] [blame] | 7332 | hdd_context_deinit(hdd_ctx); |
| 7333 | |
Dustin Brown | db2df2e | 2018-10-31 15:29:24 -0700 | [diff] [blame] | 7334 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 7335 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 7336 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7337 | hdd_ctx->config = NULL; |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 7338 | cfg_release(); |
| 7339 | |
Min Liu | 4710404 | 2019-04-09 17:49:21 +0800 | [diff] [blame] | 7340 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 7341 | wiphy_free(hdd_ctx->wiphy); |
| 7342 | } |
| 7343 | |
| 7344 | /** |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7345 | * wlan_destroy_bug_report_lock() - Destroy bug report lock |
| 7346 | * |
| 7347 | * This function is used to destroy bug report lock |
| 7348 | * |
| 7349 | * Return: None |
| 7350 | */ |
| 7351 | static void wlan_destroy_bug_report_lock(void) |
| 7352 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 7353 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 7354 | |
| 7355 | p_cds_context = cds_get_global_context(); |
| 7356 | if (!p_cds_context) { |
| 7357 | hdd_err("cds context is NULL"); |
| 7358 | return; |
| 7359 | } |
| 7360 | |
| 7361 | qdf_spinlock_destroy(&p_cds_context->bug_report_lock); |
| 7362 | } |
| 7363 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7364 | #ifdef DISABLE_CHANNEL_LIST |
| 7365 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7366 | { |
| 7367 | qdf_mutex_destroy(&hdd_ctx->cache_channel_lock); |
| 7368 | } |
| 7369 | #else |
| 7370 | static void wlan_hdd_cache_chann_mutex_destroy(struct hdd_context *hdd_ctx) |
| 7371 | { |
| 7372 | } |
| 7373 | #endif |
| 7374 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 7375 | void hdd_wlan_exit(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7376 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7377 | struct wiphy *wiphy = hdd_ctx->wiphy; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7378 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 7379 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7380 | |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 7381 | hdd_debugfs_mws_coex_info_deinit(hdd_ctx); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 7382 | hdd_psoc_idle_timer_stop(hdd_ctx); |
Dustin Brown | 6470aba | 2018-09-05 09:49:58 -0700 | [diff] [blame] | 7383 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7384 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7385 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7386 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7387 | if (QDF_TIMER_STATE_RUNNING == |
| 7388 | qdf_mc_timer_get_current_state(&hdd_ctx->skip_acs_scan_timer)) { |
| 7389 | qdf_mc_timer_stop(&hdd_ctx->skip_acs_scan_timer); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7390 | } |
| 7391 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7392 | if (!QDF_IS_STATUS_SUCCESS |
Anurag Chouhan | 210db07 | 2016-02-22 18:42:15 +0530 | [diff] [blame] | 7393 | (qdf_mc_timer_destroy(&hdd_ctx->skip_acs_scan_timer))) { |
Jeff Johnson | 5880d79 | 2016-08-15 13:32:30 -0700 | [diff] [blame] | 7394 | hdd_err("Cannot deallocate ACS Skip timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7395 | } |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7396 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7397 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7398 | hdd_ctx->last_acs_channel_list = NULL; |
| 7399 | hdd_ctx->num_of_channels = 0; |
| 7400 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7401 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7402 | |
| 7403 | /* |
| 7404 | * Powersave Offload Case |
| 7405 | * Disable Idle Power Save Mode |
| 7406 | */ |
| 7407 | hdd_set_idle_ps_config(hdd_ctx, false); |
Sandeep Puligilla | 8fa28fd | 2017-11-02 12:19:33 -0700 | [diff] [blame] | 7408 | /* clear the scan queue in all the scenarios */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 7409 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7410 | |
Dustin Brown | f688ea1 | 2019-03-19 17:02:32 -0700 | [diff] [blame] | 7411 | if (hdd_ctx->driver_status != DRIVER_MODULES_CLOSED) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7412 | hdd_unregister_wext_all_adapters(hdd_ctx); |
| 7413 | /* |
| 7414 | * Cancel any outstanding scan requests. We are about to close |
| 7415 | * all of our adapters, but an adapter structure is what SME |
| 7416 | * passes back to our callback function. Hence if there |
| 7417 | * are any outstanding scan requests then there is a |
| 7418 | * race condition between when the adapter is closed and |
| 7419 | * when the callback is invoked. We try to resolve that |
| 7420 | * race condition here by canceling any outstanding scans |
| 7421 | * before we close the adapters. |
| 7422 | * Note that the scans may be cancelled in an asynchronous |
| 7423 | * manner, so ideally there needs to be some kind of |
| 7424 | * synchronization. Rather than introduce a new |
| 7425 | * synchronization here, we will utilize the fact that we are |
| 7426 | * about to Request Full Power, and since that is synchronized, |
| 7427 | * the expectation is that by the time Request Full Power has |
| 7428 | * completed, all scans will be cancelled |
| 7429 | */ |
| 7430 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
Dustin Brown | f27bce8 | 2016-11-03 12:52:27 -0700 | [diff] [blame] | 7431 | hdd_abort_sched_scan_all_adapters(hdd_ctx); |
Dustin Brown | db2a8be | 2017-12-20 11:49:56 -0800 | [diff] [blame] | 7432 | hdd_stop_all_adapters(hdd_ctx); |
bings | 29c9986 | 2017-11-01 13:54:13 +0800 | [diff] [blame] | 7433 | hdd_deinit_all_adapters(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7434 | } |
| 7435 | |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 7436 | unregister_reboot_notifier(&system_reboot_notifier); |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 7437 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 7438 | |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 7439 | qdf_dp_trace_deinit(); |
| 7440 | |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 7441 | hdd_wlan_stop_modules(hdd_ctx, false); |
Hanumanth Reddy Pothula | 709a636 | 2016-10-18 18:19:44 +0530 | [diff] [blame] | 7442 | |
Visweswara Tanuku | c029a20 | 2018-11-27 10:42:10 +0530 | [diff] [blame] | 7443 | hdd_bus_bw_compute_timer_stop(hdd_ctx); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 7444 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 7445 | hdd_driver_memdump_deinit(); |
| 7446 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 7447 | qdf_nbuf_deinit_replenish_timer(); |
| 7448 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 7449 | if (QDF_GLOBAL_MONITOR_MODE == hdd_get_conparam()) { |
| 7450 | hdd_info("Release wakelock for monitor mode!"); |
| 7451 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 7452 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 7453 | } |
| 7454 | |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7455 | qdf_spinlock_destroy(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7456 | qdf_spinlock_destroy(&hdd_ctx->connection_status_lock); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 7457 | wlan_hdd_cache_chann_mutex_destroy(hdd_ctx); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 7458 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 7459 | osif_request_manager_deinit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7460 | |
Dustin Brown | d005ad8 | 2018-01-19 10:32:13 -0800 | [diff] [blame] | 7461 | hdd_close_all_adapters(hdd_ctx, false); |
| 7462 | |
Manishekar Chandrasekaran | f7a1dad | 2016-06-23 06:43:47 +0530 | [diff] [blame] | 7463 | wlansap_global_deinit(); |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7464 | /* |
| 7465 | * If there is re_init failure wiphy would have already de-registered |
| 7466 | * check the wiphy status before un-registering again |
| 7467 | */ |
Ashish Kumar Dhanotiya | e16feb7 | 2017-03-31 19:39:37 +0530 | [diff] [blame] | 7468 | if (wiphy && wiphy->registered) { |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 7469 | wiphy_unregister(wiphy); |
| 7470 | wlan_hdd_cfg80211_deinit(wiphy); |
| 7471 | hdd_lpass_notify_stop(hdd_ctx); |
| 7472 | } |
Yuanyuan Liu | 3e918e5 | 2016-08-17 15:41:35 -0700 | [diff] [blame] | 7473 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 7474 | hdd_exit_netlink_services(hdd_ctx); |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 7475 | #ifdef FEATURE_WLAN_CH_AVOID |
| 7476 | mutex_destroy(&hdd_ctx->avoid_freq_lock); |
| 7477 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7478 | } |
| 7479 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7480 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7481 | /** |
| 7482 | * hdd_skip_acs_scan_timer_handler() - skip ACS scan timer timeout handler |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7483 | * @data: pointer to struct hdd_context |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7484 | * |
| 7485 | * This function will reset acs_scan_status to eSAP_DO_NEW_ACS_SCAN. |
| 7486 | * Then new ACS request will do a fresh scan without reusing the cached |
| 7487 | * scan information. |
| 7488 | * |
| 7489 | * Return: void |
| 7490 | */ |
Tang Yingying | 523322d | 2017-01-17 23:28:43 +0800 | [diff] [blame] | 7491 | static void hdd_skip_acs_scan_timer_handler(void *data) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7492 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7493 | struct hdd_context *hdd_ctx = (struct hdd_context *) data; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7494 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7495 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7496 | hdd_debug("ACS Scan result expired. Reset ACS scan skip"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7497 | hdd_ctx->skip_acs_scan_status = eSAP_DO_NEW_ACS_SCAN; |
Liangwei Dong | aef8434 | 2016-10-21 05:28:00 -0400 | [diff] [blame] | 7498 | qdf_spin_lock(&hdd_ctx->acs_skip_lock); |
| 7499 | qdf_mem_free(hdd_ctx->last_acs_channel_list); |
| 7500 | hdd_ctx->last_acs_channel_list = NULL; |
| 7501 | hdd_ctx->num_of_channels = 0; |
| 7502 | qdf_spin_unlock(&hdd_ctx->acs_skip_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7503 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7504 | mac_handle = hdd_ctx->mac_handle; |
| 7505 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7506 | return; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7507 | sme_scan_flush_result(mac_handle); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7508 | } |
| 7509 | #endif |
| 7510 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7511 | /** |
| 7512 | * hdd_wlan_notify_modem_power_state() - notify FW with modem power status |
| 7513 | * @state: state |
| 7514 | * |
| 7515 | * This function notifies FW with modem power status |
| 7516 | * |
| 7517 | * Return: 0 if successful, error number otherwise |
| 7518 | */ |
| 7519 | int hdd_wlan_notify_modem_power_state(int state) |
| 7520 | { |
| 7521 | int status; |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7522 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7523 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7524 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7525 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 7526 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7527 | status = wlan_hdd_validate_context(hdd_ctx); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7528 | if (status) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7529 | return status; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 7530 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7531 | mac_handle = hdd_ctx->mac_handle; |
| 7532 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7533 | return -EINVAL; |
| 7534 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7535 | qdf_status = sme_notify_modem_power_state(mac_handle, state); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7536 | if (QDF_STATUS_SUCCESS != qdf_status) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7537 | hdd_err("Fail to send notification with modem power state %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7538 | state); |
| 7539 | return -EINVAL; |
| 7540 | } |
| 7541 | return 0; |
| 7542 | } |
| 7543 | |
| 7544 | /** |
| 7545 | * |
| 7546 | * hdd_post_cds_enable_config() - HDD post cds start config helper |
| 7547 | * @adapter - Pointer to the HDD |
| 7548 | * |
| 7549 | * Return: None |
| 7550 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7551 | QDF_STATUS hdd_post_cds_enable_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7552 | { |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7553 | QDF_STATUS qdf_ret_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7554 | |
| 7555 | /* |
| 7556 | * Send ready indication to the HDD. This will kick off the MAC |
| 7557 | * into a 'running' state and should kick off an initial scan. |
| 7558 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7559 | qdf_ret_status = sme_hdd_ready_ind(hdd_ctx->mac_handle); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 7560 | if (!QDF_IS_STATUS_SUCCESS(qdf_ret_status)) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 7561 | hdd_err("sme_hdd_ready_ind() failed with status code %08d [x%08x]", |
| 7562 | qdf_ret_status, qdf_ret_status); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7563 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7564 | } |
| 7565 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 7566 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7567 | } |
| 7568 | |
Sourav Mohapatra | 92ea8d6 | 2018-02-05 10:03:10 +0530 | [diff] [blame] | 7569 | struct hdd_adapter *hdd_get_first_valid_adapter(struct hdd_context *hdd_ctx) |
| 7570 | { |
| 7571 | struct hdd_adapter *adapter; |
| 7572 | |
| 7573 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 7574 | if (adapter && adapter->magic == WLAN_HDD_ADAPTER_MAGIC) |
| 7575 | return adapter; |
| 7576 | } |
| 7577 | |
| 7578 | return NULL; |
| 7579 | } |
| 7580 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7581 | /* wake lock APIs for HDD */ |
| 7582 | void hdd_prevent_suspend(uint32_t reason) |
| 7583 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7584 | qdf_wake_lock_acquire(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7585 | } |
| 7586 | |
| 7587 | void hdd_allow_suspend(uint32_t reason) |
| 7588 | { |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 7589 | qdf_wake_lock_release(&wlan_wake_lock, reason); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7590 | } |
| 7591 | |
| 7592 | void hdd_prevent_suspend_timeout(uint32_t timeout, uint32_t reason) |
| 7593 | { |
Anurag Chouhan | 01cfa4e | 2016-09-04 15:10:49 +0530 | [diff] [blame] | 7594 | cds_host_diag_log_work(&wlan_wake_lock, timeout, reason); |
| 7595 | qdf_wake_lock_timeout_acquire(&wlan_wake_lock, timeout); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7596 | } |
| 7597 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7598 | /* Initialize channel list in sme based on the country code */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7599 | QDF_STATUS hdd_set_sme_chan_list(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7600 | { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 7601 | return sme_init_chan_list(hdd_ctx->mac_handle, |
Amar Singhal | 6f8592b | 2017-04-26 14:31:58 -0700 | [diff] [blame] | 7602 | hdd_ctx->reg.alpha2, |
| 7603 | hdd_ctx->reg.cc_src); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7604 | } |
| 7605 | |
| 7606 | /** |
| 7607 | * hdd_is_5g_supported() - check if hardware supports 5GHz |
| 7608 | * @hdd_ctx: Pointer to the hdd context |
| 7609 | * |
| 7610 | * HDD function to know if hardware supports 5GHz |
| 7611 | * |
| 7612 | * Return: true if hardware supports 5GHz |
| 7613 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7614 | bool hdd_is_5g_supported(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7615 | { |
Amar Singhal | 58b45ef | 2017-08-01 13:43:54 -0700 | [diff] [blame] | 7616 | if (!hdd_ctx) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7617 | return true; |
| 7618 | |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 7619 | if (hdd_ctx->curr_band != BAND_2G) |
zding | f54169a | 2016-10-12 17:08:45 +0800 | [diff] [blame] | 7620 | return true; |
| 7621 | else |
| 7622 | return false; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7623 | } |
| 7624 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7625 | static int hdd_wiphy_init(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7626 | { |
| 7627 | struct wiphy *wiphy; |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7628 | int ret_val; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7629 | uint32_t channel_bonding_mode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7630 | |
| 7631 | wiphy = hdd_ctx->wiphy; |
| 7632 | |
| 7633 | /* |
| 7634 | * The channel information in |
| 7635 | * wiphy needs to be initialized before wiphy registration |
| 7636 | */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7637 | ret_val = hdd_regulatory_init(hdd_ctx, wiphy); |
| 7638 | if (ret_val) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 7639 | hdd_err("regulatory init failed"); |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7640 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7641 | } |
| 7642 | |
| 7643 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) |
| 7644 | wiphy->wowlan = &wowlan_support_reg_init; |
| 7645 | #else |
| 7646 | wiphy->wowlan.flags = WIPHY_WOWLAN_ANY | |
| 7647 | WIPHY_WOWLAN_MAGIC_PKT | |
| 7648 | WIPHY_WOWLAN_DISCONNECT | |
| 7649 | WIPHY_WOWLAN_SUPPORTS_GTK_REKEY | |
| 7650 | WIPHY_WOWLAN_GTK_REKEY_FAILURE | |
| 7651 | WIPHY_WOWLAN_EAP_IDENTITY_REQ | |
| 7652 | WIPHY_WOWLAN_4WAY_HANDSHAKE | |
| 7653 | WIPHY_WOWLAN_RFKILL_RELEASE; |
| 7654 | |
| 7655 | wiphy->wowlan.n_patterns = (WOW_MAX_FILTER_LISTS * |
| 7656 | WOW_MAX_FILTERS_PER_LIST); |
| 7657 | wiphy->wowlan.pattern_min_len = WOW_MIN_PATTERN_SIZE; |
| 7658 | wiphy->wowlan.pattern_max_len = WOW_MAX_PATTERN_SIZE; |
| 7659 | #endif |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7660 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 7661 | &channel_bonding_mode); |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7662 | if (hdd_ctx->obss_scan_offload) { |
| 7663 | hdd_debug("wmi_service_obss_scan supported"); |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 7664 | } else if (channel_bonding_mode) { |
Liangwei Dong | 0da1426 | 2018-07-03 03:30:23 -0400 | [diff] [blame] | 7665 | hdd_debug("enable wpa_supp obss_scan"); |
| 7666 | wiphy->features |= NL80211_FEATURE_NEED_OBSS_SCAN; |
| 7667 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7668 | |
| 7669 | /* registration of wiphy dev with cfg80211 */ |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7670 | ret_val = wlan_hdd_cfg80211_register(wiphy); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7671 | if (0 > ret_val) { |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7672 | hdd_err("wiphy registration failed"); |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7673 | return ret_val; |
| 7674 | } |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7675 | |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7676 | /* Check the kernel version for upstream commit aced43ce780dc5 that |
| 7677 | * has support for processing user cell_base hints when wiphy is |
| 7678 | * self managed or check the backport flag for the same. |
| 7679 | */ |
Amar Singhal | ac26de2 | 2018-06-22 12:53:06 -0700 | [diff] [blame] | 7680 | #if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \ |
| 7681 | (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)) |
Kiran Kumar Lokere | 0508af9 | 2018-04-23 18:38:32 -0700 | [diff] [blame] | 7682 | hdd_send_wiphy_regd_sync_event(hdd_ctx); |
| 7683 | #endif |
Ashish Kumar Dhanotiya | 4da3792 | 2017-04-05 14:17:56 +0530 | [diff] [blame] | 7684 | |
Amar Singhal | 2d81201 | 2018-02-03 15:06:47 +0800 | [diff] [blame] | 7685 | pld_increment_driver_load_cnt(hdd_ctx->parent_dev); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7686 | |
Amar Singhal | e4f28ee | 2015-10-21 14:36:56 -0700 | [diff] [blame] | 7687 | return ret_val; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7688 | } |
| 7689 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 7690 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7691 | /** |
| 7692 | * hdd_display_periodic_stats() - Function to display periodic stats |
| 7693 | * @hdd_ctx - handle to hdd context |
| 7694 | * @bool data_in_interval - true, if data detected in bw time interval |
| 7695 | * |
| 7696 | * The periodicity is determined by hdd_ctx->config->periodic_stats_disp_time. |
| 7697 | * Stats show up in wlan driver logs. |
| 7698 | * |
| 7699 | * Returns: None |
| 7700 | */ |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7701 | static void hdd_display_periodic_stats(struct hdd_context *hdd_ctx, |
| 7702 | bool data_in_interval) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7703 | { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7704 | static uint32_t counter; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7705 | static bool data_in_time_period; |
| 7706 | ol_txrx_pdev_handle pdev; |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7707 | ol_txrx_soc_handle soc; |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7708 | uint32_t periodic_stats_disp_time = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7709 | |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7710 | ucfg_mlme_stats_get_periodic_display_time(hdd_ctx->psoc, |
| 7711 | &periodic_stats_disp_time); |
| 7712 | if (!periodic_stats_disp_time) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7713 | return; |
| 7714 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7715 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 7716 | if (!soc) { |
| 7717 | hdd_err("soc is NULL"); |
| 7718 | return; |
| 7719 | } |
| 7720 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7721 | pdev = cds_get_context(QDF_MODULE_ID_TXRX); |
| 7722 | if (!pdev) { |
| 7723 | hdd_err("pdev is NULL"); |
| 7724 | return; |
| 7725 | } |
| 7726 | |
| 7727 | counter++; |
| 7728 | if (data_in_interval) |
| 7729 | data_in_time_period = data_in_interval; |
| 7730 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7731 | if (counter * hdd_ctx->config->bus_bw_compute_interval >= |
Arif Hussain | cca6043 | 2018-12-03 19:45:12 -0800 | [diff] [blame] | 7732 | periodic_stats_disp_time * 1000) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7733 | if (data_in_time_period) { |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7734 | wlan_hdd_display_txrx_stats(hdd_ctx); |
Mohit Khanna | c964965 | 2018-11-28 18:10:28 -0800 | [diff] [blame] | 7735 | dp_txrx_ext_dump_stats(soc, CDP_DP_RX_THREAD_STATS); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7736 | cdp_display_stats(soc, |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 7737 | CDP_RX_RING_STATS, |
| 7738 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 7739 | cdp_display_stats(soc, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7740 | CDP_TXRX_PATH_STATS, |
| 7741 | QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7742 | wlan_hdd_display_netif_queue_history |
| 7743 | (hdd_ctx, QDF_STATS_VERBOSITY_LEVEL_LOW); |
| 7744 | qdf_dp_trace_dump_stats(); |
| 7745 | } |
| 7746 | counter = 0; |
| 7747 | data_in_time_period = false; |
| 7748 | } |
| 7749 | } |
| 7750 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7751 | /** |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7752 | * hdd_clear_rps_cpu_mask - clear RPS CPU mask for interfaces |
| 7753 | * @hdd_ctx: pointer to struct hdd_context |
| 7754 | * |
| 7755 | * Return: none |
| 7756 | */ |
| 7757 | static void hdd_clear_rps_cpu_mask(struct hdd_context *hdd_ctx) |
| 7758 | { |
| 7759 | struct hdd_adapter *adapter; |
| 7760 | |
| 7761 | hdd_for_each_adapter(hdd_ctx, adapter) |
| 7762 | hdd_send_rps_disable_ind(adapter); |
| 7763 | } |
| 7764 | |
| 7765 | /** |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7766 | * hdd_pld_request_bus_bandwidth() - Function to control bus bandwidth |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7767 | * @hdd_ctx - handle to hdd context |
| 7768 | * @tx_packets - transmit packet count |
| 7769 | * @rx_packets - receive packet count |
| 7770 | * |
| 7771 | * The function controls the bus bandwidth and dynamic control of |
| 7772 | * tcp delayed ack configuration |
| 7773 | * |
| 7774 | * Returns: None |
| 7775 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7776 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 7777 | static void hdd_pld_request_bus_bandwidth(struct hdd_context *hdd_ctx, |
Jeff Johnson | 590e201 | 2016-10-05 16:16:24 -0700 | [diff] [blame] | 7778 | const uint64_t tx_packets, |
| 7779 | const uint64_t rx_packets) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7780 | { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7781 | u64 total_pkts = tx_packets + rx_packets; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7782 | uint64_t temp_tx = 0, avg_rx = 0; |
| 7783 | uint64_t no_rx_offload_pkts = 0, avg_no_rx_offload_pkts = 0; |
| 7784 | uint64_t rx_offload_pkts = 0, avg_rx_offload_pkts = 0; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7785 | enum pld_bus_width_type next_vote_level = PLD_BUS_WIDTH_NONE; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7786 | static enum wlan_tp_level next_rx_level = WLAN_SVC_TP_NONE; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7787 | enum wlan_tp_level next_tx_level = WLAN_SVC_TP_NONE; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7788 | uint32_t delack_timer_cnt = hdd_ctx->config->tcp_delack_timer_count; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7789 | uint16_t index = 0; |
| 7790 | bool vote_level_change = false; |
| 7791 | bool rx_level_change = false; |
| 7792 | bool tx_level_change = false; |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7793 | bool rxthread_high_tput_req = false; |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7794 | bool dptrace_high_tput_req; |
Srinivas Girigowda | 5033534 | 2018-09-07 15:21:01 -0700 | [diff] [blame] | 7795 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7796 | if (total_pkts > hdd_ctx->config->bus_bw_high_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7797 | next_vote_level = PLD_BUS_WIDTH_HIGH; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7798 | else if (total_pkts > hdd_ctx->config->bus_bw_medium_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7799 | next_vote_level = PLD_BUS_WIDTH_MEDIUM; |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7800 | else if (total_pkts > hdd_ctx->config->bus_bw_low_threshold) |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7801 | next_vote_level = PLD_BUS_WIDTH_LOW; |
Yue Ma | d6478e4 | 2015-10-20 18:49:24 -0700 | [diff] [blame] | 7802 | else |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7803 | next_vote_level = PLD_BUS_WIDTH_NONE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7804 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7805 | dptrace_high_tput_req = |
| 7806 | next_vote_level > PLD_BUS_WIDTH_NONE ? true : false; |
| 7807 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7808 | if (hdd_ctx->cur_vote_level != next_vote_level) { |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7809 | hdd_debug("trigger level %d, tx_packets: %lld, rx_packets: %lld", |
| 7810 | next_vote_level, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7811 | hdd_ctx->cur_vote_level = next_vote_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7812 | vote_level_change = true; |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 7813 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, next_vote_level); |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7814 | if ((next_vote_level == PLD_BUS_WIDTH_LOW) || |
| 7815 | (next_vote_level == PLD_BUS_WIDTH_NONE)) { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7816 | if (hdd_ctx->hbw_requested) { |
| 7817 | pld_remove_pm_qos(hdd_ctx->parent_dev); |
| 7818 | hdd_ctx->hbw_requested = false; |
| 7819 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7820 | if (hdd_ctx->dynamic_rps) |
| 7821 | hdd_clear_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7822 | } else { |
Nirav Shah | ffc6a09 | 2016-06-09 16:09:08 +0530 | [diff] [blame] | 7823 | if (!hdd_ctx->hbw_requested) { |
| 7824 | pld_request_pm_qos(hdd_ctx->parent_dev, 1); |
| 7825 | hdd_ctx->hbw_requested = true; |
| 7826 | } |
Tang Yingying | 5a4ccf2 | 2018-03-30 15:58:27 +0800 | [diff] [blame] | 7827 | if (hdd_ctx->dynamic_rps) |
| 7828 | hdd_set_rps_cpu_mask(hdd_ctx); |
Jeff Johnson | 59eb5fd | 2017-10-05 09:42:39 -0700 | [diff] [blame] | 7829 | } |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7830 | |
Manjunathappa Prakash | cb6df76 | 2018-05-29 18:54:58 -0700 | [diff] [blame] | 7831 | if (hdd_ctx->config->napi_cpu_affinity_mask) |
| 7832 | hdd_napi_apply_throughput_policy(hdd_ctx, |
| 7833 | tx_packets, |
| 7834 | rx_packets); |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7835 | |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7836 | if (rx_packets < hdd_ctx->config->bus_bw_low_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7837 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, true); |
| 7838 | else |
| 7839 | hdd_disable_rx_ol_for_low_tput(hdd_ctx, false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7840 | } |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7841 | |
Mohit Khanna | f7562c3 | 2018-07-05 17:42:36 -0700 | [diff] [blame] | 7842 | qdf_dp_trace_apply_tput_policy(dptrace_high_tput_req); |
| 7843 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7844 | /* |
| 7845 | * Includes tcp+udp, if perf core is required for tcp, then |
| 7846 | * perf core is also required for udp. |
| 7847 | */ |
| 7848 | no_rx_offload_pkts = hdd_ctx->no_rx_offload_pkt_cnt; |
| 7849 | hdd_ctx->no_rx_offload_pkt_cnt = 0; |
| 7850 | rx_offload_pkts = rx_packets - no_rx_offload_pkts; |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7851 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7852 | avg_no_rx_offload_pkts = (no_rx_offload_pkts + |
| 7853 | hdd_ctx->prev_no_rx_offload_pkts) / 2; |
| 7854 | hdd_ctx->prev_no_rx_offload_pkts = no_rx_offload_pkts; |
Mohit Khanna | b1dd1e8 | 2017-02-04 15:14:38 -0800 | [diff] [blame] | 7855 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7856 | avg_rx_offload_pkts = (rx_offload_pkts + |
| 7857 | hdd_ctx->prev_rx_offload_pkts) / 2; |
| 7858 | hdd_ctx->prev_rx_offload_pkts = rx_offload_pkts; |
| 7859 | |
| 7860 | avg_rx = avg_no_rx_offload_pkts + avg_rx_offload_pkts; |
| 7861 | /* |
| 7862 | * Takes care to set Rx_thread affinity for below case |
| 7863 | * 1)LRO/GRO not supported ROME case |
| 7864 | * 2)when rx_ol is disabled in cases like concurrency etc |
| 7865 | * 3)For UDP cases |
| 7866 | */ |
| 7867 | if (avg_no_rx_offload_pkts > |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7868 | hdd_ctx->config->bus_bw_high_threshold) |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7869 | rxthread_high_tput_req = true; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7870 | else |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7871 | rxthread_high_tput_req = false; |
Poddar, Siddarth | 47c2340 | 2017-10-25 12:17:39 +0530 | [diff] [blame] | 7872 | |
Manjunathappa Prakash | 3a21bea | 2018-05-29 20:41:12 -0700 | [diff] [blame] | 7873 | if (cds_sched_handle_throughput_req(rxthread_high_tput_req)) |
| 7874 | hdd_warn("Rx thread high_tput(%d) affinity request failed", |
| 7875 | rxthread_high_tput_req); |
| 7876 | |
| 7877 | /* fine-tuning parameters for RX Flows */ |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 7878 | if (avg_rx > hdd_ctx->config->tcp_delack_thres_high) { |
Ravi Joshi | fed8357 | 2016-10-07 16:20:37 -0700 | [diff] [blame] | 7879 | if ((hdd_ctx->cur_rx_level != WLAN_SVC_TP_HIGH) && |
| 7880 | (++hdd_ctx->rx_high_ind_cnt == delack_timer_cnt)) { |
| 7881 | next_rx_level = WLAN_SVC_TP_HIGH; |
| 7882 | } |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7883 | } else { |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7884 | hdd_ctx->rx_high_ind_cnt = 0; |
Mohit Khanna | c3da706 | 2017-02-08 21:08:56 -0800 | [diff] [blame] | 7885 | next_rx_level = WLAN_SVC_TP_LOW; |
Ravi Joshi | b89e7f7 | 2016-09-07 13:43:15 -0700 | [diff] [blame] | 7886 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7887 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7888 | if (hdd_ctx->cur_rx_level != next_rx_level) { |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7889 | struct wlan_rx_tp_data rx_tp_data = {0}; |
| 7890 | |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7891 | hdd_debug("TCP DELACK trigger level %d, average_rx: %llu", |
Jeff Johnson | b9feee4 | 2018-07-08 10:34:48 -0700 | [diff] [blame] | 7892 | next_rx_level, avg_rx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7893 | hdd_ctx->cur_rx_level = next_rx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7894 | rx_level_change = true; |
Ravi Joshi | e2331e8 | 2015-07-01 18:18:54 -0700 | [diff] [blame] | 7895 | /* Send throughput indication only if it is enabled. |
| 7896 | * Disabling tcp_del_ack will revert the tcp stack behavior |
| 7897 | * to default delayed ack. Note that this will disable the |
| 7898 | * dynamic delayed ack mechanism across the system |
| 7899 | */ |
Manjunathappa Prakash | bfd1276 | 2018-04-29 22:44:52 -0700 | [diff] [blame] | 7900 | if (hdd_ctx->en_tcp_delack_no_lro) |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7901 | rx_tp_data.rx_tp_flags |= TCP_DEL_ACK_IND; |
| 7902 | |
Mohit Khanna | 6272fb68 | 2017-04-13 09:34:36 -0700 | [diff] [blame] | 7903 | if (hdd_ctx->config->enable_tcp_adv_win_scale) |
| 7904 | rx_tp_data.rx_tp_flags |= TCP_ADV_WIN_SCL; |
| 7905 | |
Manjunathappa Prakash | c13cb5b | 2017-10-09 01:47:07 -0700 | [diff] [blame] | 7906 | rx_tp_data.level = next_rx_level; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7907 | wlan_hdd_update_tcp_rx_param(hdd_ctx, &rx_tp_data); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7908 | } |
| 7909 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7910 | /* fine-tuning parameters for TX Flows */ |
| 7911 | temp_tx = (tx_packets + hdd_ctx->prev_tx) / 2; |
| 7912 | hdd_ctx->prev_tx = tx_packets; |
| 7913 | if (temp_tx > hdd_ctx->config->tcp_tx_high_tput_thres) |
| 7914 | next_tx_level = WLAN_SVC_TP_HIGH; |
| 7915 | else |
| 7916 | next_tx_level = WLAN_SVC_TP_LOW; |
| 7917 | |
Prakash Manjunathappa | e73e3b5 | 2018-02-27 18:56:22 -0800 | [diff] [blame] | 7918 | if ((hdd_ctx->config->enable_tcp_limit_output) && |
| 7919 | (hdd_ctx->cur_tx_level != next_tx_level)) { |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7920 | struct wlan_tx_tp_data tx_tp_data = {0}; |
| 7921 | |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7922 | hdd_debug("change TCP TX trigger level %d, average_tx: %llu", |
| 7923 | next_tx_level, temp_tx); |
| 7924 | hdd_ctx->cur_tx_level = next_tx_level; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7925 | tx_level_change = true; |
Alok Kumar | 2fad644 | 2018-11-08 19:19:28 +0530 | [diff] [blame] | 7926 | tx_tp_data.level = next_tx_level; |
| 7927 | tx_tp_data.tcp_limit_output = true; |
| 7928 | wlan_hdd_update_tcp_tx_param(hdd_ctx, &tx_tp_data); |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 7929 | } |
| 7930 | |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7931 | index = hdd_ctx->hdd_txrx_hist_idx; |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 7932 | if (vote_level_change || tx_level_change || rx_level_change) { |
| 7933 | hdd_ctx->hdd_txrx_hist[index].next_tx_level = next_tx_level; |
| 7934 | hdd_ctx->hdd_txrx_hist[index].next_rx_level = next_rx_level; |
| 7935 | hdd_ctx->hdd_txrx_hist[index].next_vote_level = next_vote_level; |
| 7936 | hdd_ctx->hdd_txrx_hist[index].interval_rx = rx_packets; |
| 7937 | hdd_ctx->hdd_txrx_hist[index].interval_tx = tx_packets; |
| 7938 | hdd_ctx->hdd_txrx_hist[index].qtime = qdf_get_log_timestamp(); |
| 7939 | hdd_ctx->hdd_txrx_hist_idx++; |
| 7940 | hdd_ctx->hdd_txrx_hist_idx &= NUM_TX_RX_HISTOGRAM_MASK; |
| 7941 | } |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 7942 | |
| 7943 | hdd_display_periodic_stats(hdd_ctx, (total_pkts > 0) ? true : false); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7944 | } |
| 7945 | |
| 7946 | #define HDD_BW_GET_DIFF(_x, _y) (unsigned long)((ULONG_MAX - (_y)) + (_x) + 1) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7947 | static void __hdd_bus_bw_work_handler(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7948 | { |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 7949 | struct hdd_adapter *adapter = NULL, *con_sap_adapter = NULL; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7950 | uint64_t tx_packets = 0, rx_packets = 0; |
Himanshu Agarwal | a6cedee | 2016-06-08 14:50:00 +0530 | [diff] [blame] | 7951 | uint64_t fwd_tx_packets = 0, fwd_rx_packets = 0; |
| 7952 | uint64_t fwd_tx_packets_diff = 0, fwd_rx_packets_diff = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7953 | uint64_t total_tx = 0, total_rx = 0; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7954 | A_STATUS ret; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7955 | bool connected = false; |
| 7956 | uint32_t ipa_tx_packets = 0, ipa_rx_packets = 0; |
| 7957 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7958 | if (wlan_hdd_validate_context(hdd_ctx)) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7959 | goto stop_work; |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 7960 | |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 7961 | if (hdd_ctx->is_wiphy_suspended) |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 7962 | return; |
Jingxiang Ge | c64e193 | 2017-08-22 14:38:59 +0800 | [diff] [blame] | 7963 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 7964 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Manjeet Singh | 01327cc | 2016-09-03 12:14:25 +0530 | [diff] [blame] | 7965 | /* |
| 7966 | * Validate magic so we don't end up accessing |
| 7967 | * an invalid adapter. |
| 7968 | */ |
| 7969 | if (adapter->magic != WLAN_HDD_ADAPTER_MAGIC) |
| 7970 | continue; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7971 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7972 | if ((adapter->device_mode == QDF_STA_MODE || |
| 7973 | adapter->device_mode == QDF_P2P_CLIENT_MODE) && |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 7974 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)->conn_info.conn_state |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7975 | != eConnectionState_Associated) { |
| 7976 | |
| 7977 | continue; |
| 7978 | } |
| 7979 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 7980 | if ((adapter->device_mode == QDF_SAP_MODE || |
| 7981 | adapter->device_mode == QDF_P2P_GO_MODE) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 7982 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active == false) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 7983 | |
| 7984 | continue; |
| 7985 | } |
| 7986 | |
| 7987 | tx_packets += HDD_BW_GET_DIFF(adapter->stats.tx_packets, |
| 7988 | adapter->prev_tx_packets); |
| 7989 | rx_packets += HDD_BW_GET_DIFF(adapter->stats.rx_packets, |
| 7990 | adapter->prev_rx_packets); |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7991 | |
| 7992 | if (adapter->device_mode == QDF_SAP_MODE || |
| 7993 | adapter->device_mode == QDF_P2P_GO_MODE || |
| 7994 | adapter->device_mode == QDF_IBSS_MODE) { |
| 7995 | |
Dhanashri Atre | a8f82f2 | 2017-01-23 12:58:24 -0800 | [diff] [blame] | 7996 | ret = cdp_get_intra_bss_fwd_pkts_count( |
| 7997 | cds_get_context(QDF_MODULE_ID_SOC), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 7998 | adapter->vdev_id, |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 7999 | &fwd_tx_packets, &fwd_rx_packets); |
| 8000 | if (ret == A_OK) { |
| 8001 | fwd_tx_packets_diff += HDD_BW_GET_DIFF( |
| 8002 | fwd_tx_packets, |
| 8003 | adapter->prev_fwd_tx_packets); |
| 8004 | fwd_rx_packets_diff += HDD_BW_GET_DIFF( |
| 8005 | fwd_tx_packets, |
| 8006 | adapter->prev_fwd_rx_packets); |
| 8007 | } |
| 8008 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8009 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8010 | if (adapter->device_mode == QDF_SAP_MODE) |
| 8011 | con_sap_adapter = adapter; |
| 8012 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8013 | total_rx += adapter->stats.rx_packets; |
| 8014 | total_tx += adapter->stats.tx_packets; |
| 8015 | |
| 8016 | spin_lock_bh(&hdd_ctx->bus_bw_lock); |
| 8017 | adapter->prev_tx_packets = adapter->stats.tx_packets; |
| 8018 | adapter->prev_rx_packets = adapter->stats.rx_packets; |
Himanshu Agarwal | 5ac2f7b | 2016-05-06 20:08:10 +0530 | [diff] [blame] | 8019 | adapter->prev_fwd_tx_packets = fwd_tx_packets; |
| 8020 | adapter->prev_fwd_rx_packets = fwd_rx_packets; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8021 | spin_unlock_bh(&hdd_ctx->bus_bw_lock); |
| 8022 | connected = true; |
| 8023 | } |
| 8024 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8025 | if (!connected) { |
Jeff Johnson | 760350b | 2016-08-15 14:01:52 -0700 | [diff] [blame] | 8026 | hdd_err("bus bandwidth timer running in disconnected state"); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8027 | goto stop_work; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8028 | } |
| 8029 | |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8030 | /* add intra bss forwarded tx and rx packets */ |
| 8031 | tx_packets += fwd_tx_packets_diff; |
| 8032 | rx_packets += fwd_rx_packets_diff; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8033 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8034 | if (ucfg_ipa_is_fw_wdi_activated(hdd_ctx->pdev)) { |
| 8035 | ucfg_ipa_uc_stat_query(hdd_ctx->pdev, &ipa_tx_packets, |
| 8036 | &ipa_rx_packets); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8037 | tx_packets += (uint64_t)ipa_tx_packets; |
| 8038 | rx_packets += (uint64_t)ipa_rx_packets; |
| 8039 | |
Sravan Kumar Kairam | 86fce77 | 2018-04-26 14:15:30 +0530 | [diff] [blame] | 8040 | if (con_sap_adapter) { |
| 8041 | con_sap_adapter->stats.tx_packets += ipa_tx_packets; |
| 8042 | con_sap_adapter->stats.rx_packets += ipa_rx_packets; |
| 8043 | } |
| 8044 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8045 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, tx_packets, rx_packets); |
| 8046 | ucfg_ipa_uc_stat_request(hdd_ctx->pdev, 2); |
Yun Park | a29974a | 2018-04-09 12:05:49 -0700 | [diff] [blame] | 8047 | } |
| 8048 | |
| 8049 | hdd_pld_request_bus_bandwidth(hdd_ctx, tx_packets, rx_packets); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8050 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8051 | return; |
| 8052 | |
| 8053 | stop_work: |
| 8054 | qdf_periodic_work_stop_async(&hdd_ctx->bus_bw_work); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8055 | } |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8056 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8057 | static void hdd_bus_bw_work_handler(void *context) |
Rajeev Kumar | b2b5e69 | 2018-08-31 15:12:40 -0700 | [diff] [blame] | 8058 | { |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8059 | struct hdd_context *hdd_ctx = context; |
| 8060 | struct qdf_op_sync *op_sync; |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8061 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8062 | if (qdf_op_protect(&op_sync)) |
| 8063 | return; |
| 8064 | |
| 8065 | __hdd_bus_bw_work_handler(hdd_ctx); |
| 8066 | |
| 8067 | qdf_op_unprotect(op_sync); |
Poddar, Siddarth | 2333acb | 2017-01-09 16:45:39 +0530 | [diff] [blame] | 8068 | } |
| 8069 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8070 | int hdd_bus_bandwidth_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8071 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8072 | QDF_STATUS status; |
| 8073 | |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8074 | hdd_enter(); |
| 8075 | |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8076 | spin_lock_init(&hdd_ctx->bus_bw_lock); |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8077 | status = qdf_periodic_work_create(&hdd_ctx->bus_bw_work, |
| 8078 | hdd_bus_bw_work_handler, |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 8079 | hdd_ctx); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8080 | |
| 8081 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8082 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8083 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8084 | } |
| 8085 | |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 8086 | void hdd_bus_bandwidth_deinit(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8087 | { |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8088 | hdd_enter(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8089 | |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 8090 | QDF_BUG(!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)); |
| 8091 | qdf_periodic_work_destroy(&hdd_ctx->bus_bw_work); |
Dustin Brown | 35008ba | 2018-08-23 14:34:21 -0700 | [diff] [blame] | 8092 | |
| 8093 | hdd_exit(); |
Prashanth Bhatta | ab00438 | 2016-10-11 16:08:11 -0700 | [diff] [blame] | 8094 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 8095 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8096 | |
| 8097 | /** |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8098 | * wlan_hdd_init_tx_rx_histogram() - init tx/rx histogram stats |
| 8099 | * @hdd_ctx: hdd context |
| 8100 | * |
| 8101 | * Return: 0 for success or error code |
| 8102 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8103 | 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] | 8104 | { |
| 8105 | hdd_ctx->hdd_txrx_hist = qdf_mem_malloc( |
| 8106 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8107 | if (!hdd_ctx->hdd_txrx_hist) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8108 | return -ENOMEM; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8109 | return 0; |
| 8110 | } |
| 8111 | |
| 8112 | /** |
| 8113 | * wlan_hdd_deinit_tx_rx_histogram() - deinit tx/rx histogram stats |
| 8114 | * @hdd_ctx: hdd context |
| 8115 | * |
| 8116 | * Return: none |
| 8117 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8118 | void wlan_hdd_deinit_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8119 | { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 8120 | if (!hdd_ctx || !hdd_ctx->hdd_txrx_hist) |
Ashish Kumar Dhanotiya | aa2b17c | 2017-03-29 00:41:32 +0530 | [diff] [blame] | 8121 | return; |
| 8122 | |
| 8123 | qdf_mem_free(hdd_ctx->hdd_txrx_hist); |
| 8124 | hdd_ctx->hdd_txrx_hist = NULL; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8125 | } |
| 8126 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8127 | static uint8_t *convert_level_to_string(uint32_t level) |
| 8128 | { |
| 8129 | switch (level) { |
| 8130 | /* initialize the wlan sub system */ |
| 8131 | case WLAN_SVC_TP_NONE: |
| 8132 | return "NONE"; |
| 8133 | case WLAN_SVC_TP_LOW: |
| 8134 | return "LOW"; |
| 8135 | case WLAN_SVC_TP_MEDIUM: |
| 8136 | return "MED"; |
| 8137 | case WLAN_SVC_TP_HIGH: |
| 8138 | return "HIGH"; |
| 8139 | default: |
| 8140 | return "INVAL"; |
| 8141 | } |
| 8142 | } |
| 8143 | |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8144 | |
| 8145 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8146 | * wlan_hdd_display_tx_rx_histogram() - display tx rx histogram |
| 8147 | * @hdd_ctx: hdd context |
| 8148 | * |
| 8149 | * Return: none |
| 8150 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8151 | void wlan_hdd_display_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8152 | { |
| 8153 | int i; |
| 8154 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 8155 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8156 | hdd_nofl_info("BW compute Interval: %dms", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8157 | hdd_ctx->config->bus_bw_compute_interval); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8158 | hdd_nofl_info("BW High TH: %d BW Med TH: %d BW Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8159 | hdd_ctx->config->bus_bw_high_threshold, |
| 8160 | hdd_ctx->config->bus_bw_medium_threshold, |
| 8161 | hdd_ctx->config->bus_bw_low_threshold); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8162 | hdd_nofl_info("Enable TCP DEL ACK: %d", |
| 8163 | hdd_ctx->en_tcp_delack_no_lro); |
| 8164 | hdd_nofl_info("TCP DEL High TH: %d TCP DEL Low TH: %d", |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 8165 | hdd_ctx->config->tcp_delack_thres_high, |
| 8166 | hdd_ctx->config->tcp_delack_thres_low); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8167 | hdd_nofl_info("TCP TX HIGH TP TH: %d (Use to set tcp_output_bytes_limit)", |
| 8168 | hdd_ctx->config->tcp_tx_high_tput_thres); |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 8169 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8170 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8171 | hdd_nofl_info("Total entries: %d Current index: %d", |
| 8172 | NUM_TX_RX_HISTOGRAM, hdd_ctx->hdd_txrx_hist_idx); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8173 | |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8174 | hdd_nofl_info("[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] | 8175 | |
| 8176 | for (i = 0; i < NUM_TX_RX_HISTOGRAM; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8177 | /* using hdd_log to avoid printing function name */ |
Mohit Khanna | afff9fb | 2016-11-16 20:22:03 -0800 | [diff] [blame] | 8178 | if (hdd_ctx->hdd_txrx_hist[i].qtime > 0) |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8179 | hdd_nofl_info("[%3d][%15llu]: %6llu, %6llu, %s, %s, %s", |
| 8180 | i, hdd_ctx->hdd_txrx_hist[i].qtime, |
| 8181 | hdd_ctx->hdd_txrx_hist[i].interval_rx, |
| 8182 | hdd_ctx->hdd_txrx_hist[i].interval_tx, |
| 8183 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8184 | hdd_ctx->hdd_txrx_hist[i]. |
| 8185 | next_vote_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8186 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8187 | hdd_ctx->hdd_txrx_hist[i]. |
| 8188 | next_rx_level), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8189 | convert_level_to_string( |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8190 | hdd_ctx->hdd_txrx_hist[i]. |
| 8191 | next_tx_level)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8192 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8193 | } |
| 8194 | |
| 8195 | /** |
| 8196 | * wlan_hdd_clear_tx_rx_histogram() - clear tx rx histogram |
| 8197 | * @hdd_ctx: hdd context |
| 8198 | * |
| 8199 | * Return: none |
| 8200 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8201 | void wlan_hdd_clear_tx_rx_histogram(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8202 | { |
| 8203 | hdd_ctx->hdd_txrx_hist_idx = 0; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 8204 | qdf_mem_zero(hdd_ctx->hdd_txrx_hist, |
| 8205 | (sizeof(struct hdd_tx_rx_histogram) * NUM_TX_RX_HISTOGRAM)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8206 | } |
| 8207 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8208 | /* length of the netif queue log needed per adapter */ |
| 8209 | #define ADAP_NETIFQ_LOG_LEN ((20 * WLAN_REASON_TYPE_MAX) + 50) |
| 8210 | |
| 8211 | /** |
| 8212 | * |
| 8213 | * hdd_display_netif_queue_history_compact() - display compact netifq history |
| 8214 | * @hdd_ctx: hdd context |
| 8215 | * |
| 8216 | * Return: none |
| 8217 | */ |
| 8218 | static void |
| 8219 | hdd_display_netif_queue_history_compact(struct hdd_context *hdd_ctx) |
| 8220 | { |
| 8221 | int adapter_num = 0; |
| 8222 | int i; |
| 8223 | int bytes_written; |
| 8224 | u32 tbytes; |
| 8225 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8226 | char temp_str[20 * WLAN_REASON_TYPE_MAX]; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8227 | char *comb_log_str; |
| 8228 | uint32_t comb_log_str_size; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8229 | struct hdd_adapter *adapter = NULL; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8230 | |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 8231 | comb_log_str_size = (ADAP_NETIFQ_LOG_LEN * WLAN_MAX_VDEVS) + 1; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8232 | comb_log_str = qdf_mem_malloc(comb_log_str_size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8233 | if (!comb_log_str) |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8234 | return; |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8235 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8236 | bytes_written = 0; |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8237 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8238 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8239 | curr_time = qdf_system_ticks(); |
| 8240 | total = curr_time - adapter->start_time; |
| 8241 | delta = curr_time - adapter->last_time; |
| 8242 | |
| 8243 | if (adapter->pause_map) { |
| 8244 | pause = adapter->total_pause_time + delta; |
| 8245 | unpause = adapter->total_unpause_time; |
| 8246 | } else { |
| 8247 | unpause = adapter->total_unpause_time + delta; |
| 8248 | pause = adapter->total_pause_time; |
| 8249 | } |
| 8250 | |
| 8251 | tbytes = 0; |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 8252 | qdf_mem_zero(temp_str, sizeof(temp_str)); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8253 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8254 | if (adapter->queue_oper_stats[i].pause_count == 0) |
| 8255 | continue; |
| 8256 | tbytes += |
| 8257 | snprintf( |
| 8258 | &temp_str[tbytes], |
| 8259 | (tbytes >= sizeof(temp_str) ? |
| 8260 | 0 : sizeof(temp_str) - tbytes), |
| 8261 | "%d(%d,%d) ", |
| 8262 | i, |
| 8263 | adapter->queue_oper_stats[i]. |
| 8264 | pause_count, |
| 8265 | adapter->queue_oper_stats[i]. |
| 8266 | unpause_count); |
| 8267 | } |
| 8268 | if (tbytes >= sizeof(temp_str)) |
| 8269 | hdd_warn("log truncated"); |
| 8270 | |
| 8271 | bytes_written += snprintf(&comb_log_str[bytes_written], |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8272 | bytes_written >= comb_log_str_size ? 0 : |
| 8273 | comb_log_str_size - bytes_written, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8274 | "[%d %d] (%d) %u/%ums %s|", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8275 | adapter->vdev_id, adapter->device_mode, |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8276 | adapter->pause_map, |
| 8277 | qdf_system_ticks_to_msecs(pause), |
| 8278 | qdf_system_ticks_to_msecs(total), |
| 8279 | temp_str); |
| 8280 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8281 | adapter_num++; |
| 8282 | } |
| 8283 | |
| 8284 | /* using QDF_TRACE to avoid printing function name */ |
| 8285 | QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_INFO_LOW, |
| 8286 | "STATS |%s", comb_log_str); |
| 8287 | |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8288 | if (bytes_written >= comb_log_str_size) |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8289 | hdd_warn("log string truncated"); |
jiad | bdefb25 | 2018-01-03 14:27:06 +0800 | [diff] [blame] | 8290 | |
| 8291 | qdf_mem_free(comb_log_str); |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8292 | } |
| 8293 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8294 | /* Max size of a single netdev tx queue state string. e.g. "1: 0x1" */ |
| 8295 | #define HDD_NETDEV_TX_Q_STATE_STRLEN 15 |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8296 | /** |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 8297 | * wlan_hdd_display_netif_queue_history() - display netif queue history |
Jeff Johnson | 58adbcf | 2017-09-03 08:53:31 -0700 | [diff] [blame] | 8298 | * @hdd_ctx: hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8299 | * |
| 8300 | * Return: none |
| 8301 | */ |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8302 | void |
| 8303 | wlan_hdd_display_netif_queue_history(struct hdd_context *hdd_ctx, |
| 8304 | enum qdf_stats_verbosity_level verb_lvl) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8305 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8306 | int i; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8307 | struct hdd_adapter *adapter = NULL; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8308 | qdf_time_t total, pause, unpause, curr_time, delta; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8309 | struct hdd_netif_queue_history *q_hist_ptr; |
| 8310 | char q_status_buf[NUM_TX_QUEUES * HDD_NETDEV_TX_Q_STATE_STRLEN] = {0}; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8311 | |
Mohit Khanna | ca4173b | 2017-09-12 21:52:19 -0700 | [diff] [blame] | 8312 | if (verb_lvl == QDF_STATS_VERBOSITY_LEVEL_LOW) { |
| 8313 | hdd_display_netif_queue_history_compact(hdd_ctx); |
| 8314 | return; |
| 8315 | } |
| 8316 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8317 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8318 | if (adapter->vdev_id == CDP_INVALID_VDEV_ID) |
| 8319 | continue; |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8320 | hdd_nofl_info("Netif queue operation statistics:"); |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 8321 | hdd_nofl_info("vdev_id %d device mode %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8322 | adapter->vdev_id, adapter->device_mode); |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8323 | hdd_nofl_info("Current pause_map value %x", adapter->pause_map); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8324 | curr_time = qdf_system_ticks(); |
| 8325 | total = curr_time - adapter->start_time; |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8326 | delta = curr_time - adapter->last_time; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8327 | if (adapter->pause_map) { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8328 | pause = adapter->total_pause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8329 | unpause = adapter->total_unpause_time; |
| 8330 | } else { |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8331 | unpause = adapter->total_unpause_time + delta; |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8332 | pause = adapter->total_pause_time; |
| 8333 | } |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8334 | hdd_nofl_info("Total: %ums Pause: %ums Unpause: %ums", |
| 8335 | qdf_system_ticks_to_msecs(total), |
| 8336 | qdf_system_ticks_to_msecs(pause), |
| 8337 | qdf_system_ticks_to_msecs(unpause)); |
| 8338 | hdd_nofl_info("reason_type: pause_cnt: unpause_cnt: pause_time"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8339 | |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8340 | for (i = WLAN_CONTROL_PATH; i < WLAN_REASON_TYPE_MAX; i++) { |
| 8341 | qdf_time_t pause_delta = 0; |
| 8342 | |
| 8343 | if (adapter->pause_map & (1 << i)) |
| 8344 | pause_delta = delta; |
| 8345 | |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8346 | /* using hdd_log to avoid printing function name */ |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8347 | hdd_nofl_info("%s: %d: %d: %ums", |
| 8348 | hdd_reason_type_to_string(i), |
| 8349 | adapter->queue_oper_stats[i].pause_count, |
| 8350 | adapter->queue_oper_stats[i]. |
| 8351 | unpause_count, |
| 8352 | qdf_system_ticks_to_msecs( |
| 8353 | adapter->queue_oper_stats[i]. |
| 8354 | total_pause_time + pause_delta)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8355 | } |
| 8356 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8357 | hdd_nofl_info("Netif queue operation history: Total entries: %d current index %d(-1) time %u", |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8358 | WLAN_HDD_MAX_HISTORY_ENTRY, |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8359 | adapter->history_index, |
| 8360 | qdf_system_ticks_to_msecs(qdf_system_ticks())); |
Nirav Shah | da00834 | 2016-05-17 18:50:40 +0530 | [diff] [blame] | 8361 | |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8362 | hdd_nofl_info("%2s%20s%50s%30s%10s %s", |
| 8363 | "#", "time(ms)", "action_type", "reason_type", |
| 8364 | "pause_map", "netdev-queue-status"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8365 | |
| 8366 | for (i = 0; i < WLAN_HDD_MAX_HISTORY_ENTRY; i++) { |
Mohit Khanna | 3e2115b | 2016-10-11 13:18:29 -0700 | [diff] [blame] | 8367 | /* using hdd_log to avoid printing function name */ |
| 8368 | if (adapter->queue_oper_history[i].time == 0) |
| 8369 | continue; |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8370 | q_hist_ptr = &adapter->queue_oper_history[i]; |
| 8371 | wlan_hdd_dump_queue_history_state(q_hist_ptr, |
| 8372 | q_status_buf, |
| 8373 | sizeof(q_status_buf)); |
| 8374 | hdd_nofl_info("%2d%20u%50s%30s%10x %s", |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8375 | i, qdf_system_ticks_to_msecs( |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8376 | adapter->queue_oper_history[i].time), |
Nirav Shah | e6194ac | 2018-07-13 11:04:41 +0530 | [diff] [blame] | 8377 | hdd_action_type_to_string( |
| 8378 | adapter->queue_oper_history[i]. |
| 8379 | netif_action), |
| 8380 | hdd_reason_type_to_string( |
| 8381 | adapter->queue_oper_history[i]. |
| 8382 | netif_reason), |
Mohit Khanna | f7e7b34 | 2019-04-08 11:54:21 -0700 | [diff] [blame] | 8383 | adapter->queue_oper_history[i].pause_map, |
| 8384 | q_status_buf); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8385 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8386 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8387 | } |
| 8388 | |
| 8389 | /** |
| 8390 | * wlan_hdd_clear_netif_queue_history() - clear netif queue operation history |
| 8391 | * @hdd_ctx: hdd context |
| 8392 | * |
| 8393 | * Return: none |
| 8394 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8395 | void wlan_hdd_clear_netif_queue_history(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8396 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8397 | struct hdd_adapter *adapter = NULL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8398 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8399 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8400 | qdf_mem_zero(adapter->queue_oper_stats, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8401 | sizeof(adapter->queue_oper_stats)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 8402 | qdf_mem_zero(adapter->queue_oper_history, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8403 | sizeof(adapter->queue_oper_history)); |
Nirav Shah | 617cff9 | 2016-04-25 10:24:24 +0530 | [diff] [blame] | 8404 | adapter->history_index = 0; |
| 8405 | adapter->start_time = adapter->last_time = qdf_system_ticks(); |
| 8406 | adapter->total_pause_time = 0; |
| 8407 | adapter->total_unpause_time = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8408 | } |
| 8409 | } |
| 8410 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8411 | #ifdef WLAN_FEATURE_OFFLOAD_PACKETS |
| 8412 | /** |
| 8413 | * hdd_init_offloaded_packets_ctx() - Initialize offload packets context |
| 8414 | * @hdd_ctx: hdd global context |
| 8415 | * |
| 8416 | * Return: none |
| 8417 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8418 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8419 | { |
| 8420 | uint8_t i; |
| 8421 | |
| 8422 | mutex_init(&hdd_ctx->op_ctx.op_lock); |
| 8423 | for (i = 0; i < MAXNUM_PERIODIC_TX_PTRNS; i++) { |
| 8424 | hdd_ctx->op_ctx.op_table[i].request_id = MAX_REQUEST_ID; |
| 8425 | hdd_ctx->op_ctx.op_table[i].pattern_id = i; |
| 8426 | } |
| 8427 | } |
| 8428 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8429 | static void hdd_init_offloaded_packets_ctx(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8430 | { |
| 8431 | } |
| 8432 | #endif |
| 8433 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8434 | #ifdef WLAN_FEATURE_WOW_PULSE |
| 8435 | /** |
| 8436 | * wlan_hdd_set_wow_pulse() - call SME to send wmi cmd of wow pulse |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8437 | * @hdd_ctx: struct hdd_context structure pointer |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8438 | * @enable: enable or disable this behaviour |
| 8439 | * |
| 8440 | * Return: int |
| 8441 | */ |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8442 | static int wlan_hdd_set_wow_pulse(struct hdd_context *hdd_ctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8443 | { |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8444 | struct wow_pulse_mode wow_pulse_set_info; |
| 8445 | QDF_STATUS status; |
| 8446 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8447 | hdd_debug("wow pulse enable flag is %d", enable); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8448 | |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8449 | if (!ucfg_pmo_is_wow_pulse_enabled(hdd_ctx->psoc)) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8450 | return 0; |
| 8451 | |
| 8452 | /* prepare the request to send to SME */ |
| 8453 | if (enable == true) { |
| 8454 | wow_pulse_set_info.wow_pulse_enable = true; |
| 8455 | wow_pulse_set_info.wow_pulse_pin = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8456 | ucfg_pmo_get_wow_pulse_pin(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8457 | |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8458 | wow_pulse_set_info.wow_pulse_interval_high = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8459 | ucfg_pmo_get_wow_pulse_interval_high(hdd_ctx->psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 8460 | |
| 8461 | wow_pulse_set_info.wow_pulse_interval_low = |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8462 | ucfg_pmo_get_wow_pulse_interval_low(hdd_ctx->psoc); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8463 | } else { |
| 8464 | wow_pulse_set_info.wow_pulse_enable = false; |
| 8465 | wow_pulse_set_info.wow_pulse_pin = 0; |
| 8466 | wow_pulse_set_info.wow_pulse_interval_low = 0; |
| 8467 | wow_pulse_set_info.wow_pulse_interval_high = 0; |
| 8468 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8469 | hdd_debug("enable %d pin %d low %d high %d", |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8470 | wow_pulse_set_info.wow_pulse_enable, |
| 8471 | wow_pulse_set_info.wow_pulse_pin, |
| 8472 | wow_pulse_set_info.wow_pulse_interval_low, |
| 8473 | wow_pulse_set_info.wow_pulse_interval_high); |
| 8474 | |
| 8475 | status = sme_set_wow_pulse(&wow_pulse_set_info); |
| 8476 | if (QDF_STATUS_E_FAILURE == status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8477 | hdd_debug("sme_set_wow_pulse failure!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8478 | return -EIO; |
| 8479 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8480 | hdd_debug("sme_set_wow_pulse success!"); |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8481 | return 0; |
| 8482 | } |
| 8483 | #else |
Jeff Johnson | fd7d1ef | 2019-03-31 10:41:37 -0700 | [diff] [blame] | 8484 | static inline int wlan_hdd_set_wow_pulse(struct hdd_context *hdd_ctx, bool enable) |
Yingying Tang | 9540997 | 2016-10-20 15:16:15 +0800 | [diff] [blame] | 8485 | { |
| 8486 | return 0; |
| 8487 | } |
| 8488 | #endif |
| 8489 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8490 | #ifdef WLAN_FEATURE_FASTPATH |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8491 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8492 | /** |
| 8493 | * hdd_enable_fastpath() - Enable fastpath if enabled in config INI |
| 8494 | * @hdd_cfg: hdd config |
| 8495 | * @context: lower layer context |
| 8496 | * |
| 8497 | * Return: none |
| 8498 | */ |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8499 | void hdd_enable_fastpath(struct hdd_context *hdd_ctx, |
| 8500 | void *context) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8501 | { |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 8502 | if (cfg_get(hdd_ctx->psoc, CFG_DP_ENABLE_FASTPATH)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8503 | hif_enable_fastpath(context); |
| 8504 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8505 | #endif |
| 8506 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8507 | #if defined(FEATURE_WLAN_CH_AVOID) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8508 | /** |
| 8509 | * hdd_set_thermal_level_cb() - set thermal level callback function |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8510 | * @hdd_handle: opaque handle for the hdd context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8511 | * @level: thermal level |
| 8512 | * |
| 8513 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8514 | * than 0, and restore the original data path when throttle level is 0 |
| 8515 | * |
| 8516 | * Return: none |
| 8517 | */ |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8518 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8519 | { |
Jeff Johnson | 0e96308 | 2018-07-04 19:39:20 -0700 | [diff] [blame] | 8520 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 8521 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8522 | /* Change IPA to SW path when throttle level greater than 0 */ |
| 8523 | if (level > THROTTLE_LEVEL_0) |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8524 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, true); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8525 | else |
| 8526 | /* restore original concurrency mode */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 8527 | ucfg_ipa_send_mcc_scc_msg(hdd_ctx->pdev, hdd_ctx->mcc_mode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8528 | } |
| 8529 | |
| 8530 | /** |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8531 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8532 | * @hdd_ctx: pointer to hdd context |
| 8533 | * @adapter: pointer to softap adapter |
| 8534 | * |
| 8535 | * This function is used to get safe channel from current regulatory valid |
| 8536 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8537 | * |
| 8538 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8539 | * failure, the channel number returned is zero. |
| 8540 | */ |
| 8541 | static uint8_t |
| 8542 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8543 | struct hdd_adapter *adapter) |
| 8544 | { |
| 8545 | struct sir_pcl_list pcl = {0}; |
| 8546 | uint32_t i, j; |
| 8547 | bool found = false; |
| 8548 | int ret; |
| 8549 | |
| 8550 | /* Try for safe channel from all valid channel */ |
| 8551 | pcl.pcl_len = MAX_NUM_CHAN; |
| 8552 | ret = hdd_get_valid_chan(hdd_ctx, pcl.pcl_list, |
| 8553 | &pcl.pcl_len); |
| 8554 | if (ret) { |
| 8555 | hdd_err("error %d in getting valid channel list", ret); |
| 8556 | return INVALID_CHANNEL_ID; |
| 8557 | } |
| 8558 | |
| 8559 | for (i = 0; i < pcl.pcl_len; i++) { |
| 8560 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
| 8561 | found = false; |
| 8562 | for (j = 0; j < hdd_ctx->unsafe_channel_count; j++) { |
| 8563 | if (pcl.pcl_list[i] == |
| 8564 | hdd_ctx->unsafe_channel_list[j]) { |
| 8565 | hdd_debug("unsafe chan:%d", pcl.pcl_list[i]); |
| 8566 | found = true; |
| 8567 | break; |
| 8568 | } |
| 8569 | } |
| 8570 | |
| 8571 | if (found) |
| 8572 | continue; |
| 8573 | |
| 8574 | if ((pcl.pcl_list[i] >= |
| 8575 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
| 8576 | (pcl.pcl_list[i] <= |
| 8577 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
| 8578 | hdd_debug("found safe chan:%d", pcl.pcl_list[i]); |
| 8579 | return pcl.pcl_list[i]; |
| 8580 | } |
| 8581 | } |
| 8582 | |
| 8583 | return INVALID_CHANNEL_ID; |
| 8584 | } |
| 8585 | |
| 8586 | #else |
| 8587 | /** |
| 8588 | * hdd_set_thermal_level_cb() - set thermal level callback function |
| 8589 | * @hdd_handle: opaque handle for the hdd context |
| 8590 | * @level: thermal level |
| 8591 | * |
| 8592 | * Change IPA data path to SW path when the thermal throttle level greater |
| 8593 | * than 0, and restore the original data path when throttle level is 0 |
| 8594 | * |
| 8595 | * Return: none |
| 8596 | */ |
| 8597 | static void hdd_set_thermal_level_cb(hdd_handle_t hdd_handle, u_int8_t level) |
| 8598 | { |
| 8599 | } |
| 8600 | |
| 8601 | /** |
| 8602 | * hdd_get_safe_channel() - Get safe channel from current regulatory |
| 8603 | * @hdd_ctx: pointer to hdd context |
| 8604 | * @adapter: pointer to softap adapter |
| 8605 | * |
| 8606 | * This function is used to get safe channel from current regulatory valid |
| 8607 | * channels to restart SAP if failed to get safe channel from PCL. |
| 8608 | * |
| 8609 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8610 | * failure, the channel number returned is zero. |
| 8611 | */ |
| 8612 | static uint8_t |
| 8613 | hdd_get_safe_channel(struct hdd_context *hdd_ctx, |
| 8614 | struct hdd_adapter *adapter) |
| 8615 | { |
| 8616 | return 0; |
| 8617 | } |
| 8618 | #endif |
| 8619 | |
| 8620 | /** |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8621 | * hdd_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP |
| 8622 | * restart |
Manishekar Chandrasekaran | db9b867 | 2016-06-10 23:31:19 +0530 | [diff] [blame] | 8623 | * @adapter: AP adapter, which should be checked for NULL |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8624 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8625 | * Get a safe channel to restart SAP. PCL already takes into account the |
| 8626 | * unsafe channels. So, the PCL is validated with the ACS range to provide |
| 8627 | * a safe channel for the SAP to restart. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8628 | * |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8629 | * Return: Channel number to restart SAP in case of success. In case of any |
| 8630 | * failure, the channel number returned is zero. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8631 | */ |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8632 | static uint8_t |
| 8633 | hdd_get_safe_channel_from_pcl_and_acs_range(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8634 | { |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8635 | struct sir_pcl_list pcl; |
| 8636 | QDF_STATUS status; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8637 | uint32_t i; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8638 | mac_handle_t mac_handle; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8639 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8640 | |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8641 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8642 | if (!hdd_ctx) { |
| 8643 | hdd_err("invalid HDD context"); |
| 8644 | return INVALID_CHANNEL_ID; |
| 8645 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8646 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8647 | mac_handle = hdd_ctx->mac_handle; |
| 8648 | if (!mac_handle) { |
| 8649 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | 79746ac | 2016-06-24 04:45:33 +0530 | [diff] [blame] | 8650 | return INVALID_CHANNEL_ID; |
| 8651 | } |
| 8652 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8653 | status = policy_mgr_get_pcl_for_existing_conn(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8654 | PM_SAP_MODE, pcl.pcl_list, &pcl.pcl_len, |
bings | 37bd58f | 2017-07-20 16:49:26 +0800 | [diff] [blame] | 8655 | pcl.weight_list, QDF_ARRAY_SIZE(pcl.weight_list), |
| 8656 | false); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8657 | if (QDF_IS_STATUS_ERROR(status)) { |
| 8658 | hdd_err("Get PCL failed"); |
| 8659 | return INVALID_CHANNEL_ID; |
| 8660 | } |
| 8661 | |
Frank Liu | dc2cefb | 2017-06-21 15:38:18 +0800 | [diff] [blame] | 8662 | /* |
| 8663 | * In some scenarios, like hw dbs disabled, sap+sap case, if operating |
| 8664 | * channel is unsafe channel, the pcl may be empty, instead of return, |
| 8665 | * try to choose a safe channel from acs range. |
| 8666 | */ |
| 8667 | if (!pcl.pcl_len) |
| 8668 | hdd_debug("pcl length is zero!"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8669 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8670 | hdd_debug("start:%d end:%d", |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8671 | adapter->session.ap.sap_config.acs_cfg.start_ch, |
| 8672 | adapter->session.ap.sap_config.acs_cfg.end_ch); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8673 | |
| 8674 | /* PCL already takes unsafe channel into account */ |
| 8675 | for (i = 0; i < pcl.pcl_len; i++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8676 | hdd_debug("chan[%d]:%d", i, pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8677 | if ((pcl.pcl_list[i] >= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8678 | adapter->session.ap.sap_config.acs_cfg.start_ch) && |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8679 | (pcl.pcl_list[i] <= |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8680 | adapter->session.ap.sap_config.acs_cfg.end_ch)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8681 | hdd_debug("found PCL safe chan:%d", pcl.pcl_list[i]); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8682 | return pcl.pcl_list[i]; |
| 8683 | } |
| 8684 | } |
| 8685 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8686 | hdd_debug("no safe channel from PCL found in ACS range"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8687 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 8688 | return hdd_get_safe_channel(hdd_ctx, adapter); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8689 | } |
| 8690 | |
| 8691 | /** |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8692 | * hdd_switch_sap_channel() - Move SAP to the given channel |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8693 | * @adapter: AP adapter |
| 8694 | * @channel: Channel |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8695 | * @forced: Force to switch channel, ignore SCC/MCC check |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8696 | * |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 8697 | * Moves the SAP interface by invoking the function which |
| 8698 | * executes the callback to perform channel switch using (E)CSA. |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8699 | * |
| 8700 | * Return: None |
| 8701 | */ |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8702 | void hdd_switch_sap_channel(struct hdd_adapter *adapter, uint8_t channel, |
| 8703 | bool forced) |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8704 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 8705 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8706 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8707 | mac_handle_t mac_handle; |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8708 | |
| 8709 | if (!adapter) { |
| 8710 | hdd_err("invalid adapter"); |
| 8711 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8712 | } |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8713 | |
| 8714 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(adapter); |
| 8715 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 8716 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 8717 | if (!mac_handle) { |
| 8718 | hdd_err("invalid MAC handle"); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8719 | return; |
| 8720 | } |
| 8721 | |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 8722 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 8723 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8724 | hdd_debug("chan:%d width:%d", |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 8725 | channel, hdd_ap_ctx->sap_config.ch_width_orig); |
Manishekar Chandrasekaran | c67b2bb | 2016-05-25 18:44:01 +0530 | [diff] [blame] | 8726 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 8727 | policy_mgr_change_sap_channel_with_csa(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 8728 | adapter->vdev_id, channel, |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8729 | hdd_ap_ctx->sap_config.ch_width_orig, forced); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8730 | } |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8731 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8732 | 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] | 8733 | { |
| 8734 | struct hdd_external_acs_timer_context *timer_context; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8735 | int status; |
| 8736 | QDF_STATUS qdf_status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8737 | |
| 8738 | set_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 8739 | |
| 8740 | if (QDF_TIMER_STATE_RUNNING == |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8741 | qdf_mc_timer_get_current_state(&adapter->session. |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8742 | ap.vendor_acs_timer)) { |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8743 | qdf_mc_timer_stop(&adapter->session.ap.vendor_acs_timer); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8744 | } |
| 8745 | timer_context = (struct hdd_external_acs_timer_context *) |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8746 | adapter->session.ap.vendor_acs_timer.user_data; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8747 | timer_context->reason = reason; |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8748 | qdf_status = |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 8749 | qdf_mc_timer_start(&adapter->session.ap.vendor_acs_timer, |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8750 | WLAN_VENDOR_ACS_WAIT_TIME); |
| 8751 | if (qdf_status != QDF_STATUS_SUCCESS) { |
| 8752 | hdd_err("failed to start external acs timer"); |
| 8753 | return -ENOSPC; |
| 8754 | } |
| 8755 | /* Update config to application */ |
| 8756 | status = hdd_cfg80211_update_acs_config(adapter, reason); |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 8757 | hdd_info("Updated ACS config to nl with reason %d", reason); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8758 | |
Himanshu Agarwal | dfc4dca | 2017-08-29 19:49:05 +0530 | [diff] [blame] | 8759 | return status; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8760 | } |
| 8761 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 8762 | #if defined(FEATURE_WLAN_CH_AVOID) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8763 | /** |
| 8764 | * hdd_unsafe_channel_restart_sap() - restart sap if sap is on unsafe channel |
| 8765 | * @hdd_ctx: hdd context pointer |
| 8766 | * |
| 8767 | * hdd_unsafe_channel_restart_sap check all unsafe channel list |
| 8768 | * and if ACS is enabled, driver will ask userspace to restart the |
| 8769 | * sap. User space on LTE coex indication restart driver. |
| 8770 | * |
| 8771 | * Return - none |
| 8772 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8773 | void hdd_unsafe_channel_restart_sap(struct hdd_context *hdd_ctxt) |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8774 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8775 | struct hdd_adapter *adapter; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8776 | uint32_t i; |
| 8777 | bool found = false; |
| 8778 | uint8_t restart_chan; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8779 | uint8_t scc_on_lte_coex = 0; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8780 | bool value; |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8781 | QDF_STATUS status; |
| 8782 | bool is_acs_support_for_dfs_ltecoex = cfg_default(CFG_USER_ACS_DFS_LTE); |
| 8783 | bool is_vendor_acs_support = |
| 8784 | cfg_default(CFG_USER_AUTO_CHANNEL_SELECTION); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8785 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8786 | hdd_for_each_adapter(hdd_ctxt, adapter) { |
| 8787 | if (!(adapter->device_mode == QDF_SAP_MODE && |
| 8788 | adapter->session.ap.sap_config.acs_cfg.acs_mode)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8789 | hdd_debug("skip device mode:%d acs:%d", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8790 | adapter->device_mode, |
| 8791 | adapter->session.ap.sap_config. |
| 8792 | acs_cfg.acs_mode); |
| 8793 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8794 | } |
| 8795 | |
| 8796 | found = false; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 8797 | status = |
| 8798 | ucfg_policy_mgr_get_sta_sap_scc_lte_coex_chnl(hdd_ctxt->psoc, |
| 8799 | &scc_on_lte_coex); |
| 8800 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8801 | hdd_err("can't get scc on lte coex chnl, use def"); |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8802 | /* |
| 8803 | * If STA+SAP is doing SCC & g_sta_sap_scc_on_lte_coex_chan |
| 8804 | * is set, no need to move SAP. |
| 8805 | */ |
Manikandan Mohan | 956b69e | 2019-02-14 13:08:14 -0800 | [diff] [blame] | 8806 | if ((policy_mgr_is_sta_sap_scc( |
| 8807 | hdd_ctxt->psoc, |
| 8808 | adapter->session.ap.operating_channel) && |
| 8809 | scc_on_lte_coex) || |
| 8810 | policy_mgr_nan_sap_scc_on_unsafe_ch_chk( |
| 8811 | hdd_ctxt->psoc, |
| 8812 | adapter->session.ap.operating_channel)) { |
| 8813 | hdd_debug("SAP allowed in unsafe SCC channel"); |
| 8814 | } else { |
Tushnim Bhattacharyya | d2e085d | 2018-06-18 11:58:50 -0700 | [diff] [blame] | 8815 | for (i = 0; i < hdd_ctxt->unsafe_channel_count; i++) { |
| 8816 | if (adapter->session.ap.operating_channel == |
| 8817 | hdd_ctxt->unsafe_channel_list[i]) { |
| 8818 | found = true; |
| 8819 | hdd_debug("operating ch:%d is unsafe", |
| 8820 | adapter->session.ap.operating_channel); |
| 8821 | break; |
| 8822 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8823 | } |
| 8824 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8825 | if (!found) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8826 | hdd_debug("ch:%d is safe. no need to change channel", |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8827 | adapter->session.ap.operating_channel); |
| 8828 | continue; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8829 | } |
| 8830 | |
Harprit Chhabada | 1eeeb8d | 2018-09-14 15:16:56 -0700 | [diff] [blame] | 8831 | status = ucfg_mlme_get_acs_support_for_dfs_ltecoex( |
| 8832 | hdd_ctxt->psoc, |
| 8833 | &is_acs_support_for_dfs_ltecoex); |
| 8834 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8835 | hdd_err("get_acs_support_for_dfs_ltecoex failed,set def"); |
| 8836 | |
| 8837 | status = ucfg_mlme_get_vendor_acs_support( |
| 8838 | hdd_ctxt->psoc, |
| 8839 | &is_vendor_acs_support); |
| 8840 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 8841 | hdd_err("get_vendor_acs_support failed, set default"); |
| 8842 | |
| 8843 | if (is_vendor_acs_support && is_acs_support_for_dfs_ltecoex) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8844 | hdd_update_acs_timer_reason(adapter, |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8845 | QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX); |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8846 | continue; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 8847 | } else |
| 8848 | restart_chan = |
| 8849 | hdd_get_safe_channel_from_pcl_and_acs_range( |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 8850 | adapter); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8851 | if (!restart_chan) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8852 | hdd_err("fail to restart SAP"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8853 | } else { |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8854 | /* |
| 8855 | * SAP restart due to unsafe channel. While |
| 8856 | * restarting the SAP, make sure to clear |
| 8857 | * acs_channel, channel to reset to |
| 8858 | * 0. Otherwise these settings will override |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8859 | * the ACS while restart. |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 8860 | */ |
Kondabattini, Ganesh | 2836c5a | 2016-09-20 17:10:19 +0530 | [diff] [blame] | 8861 | hdd_ctxt->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8862 | hdd_debug("sending coex indication"); |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8863 | wlan_hdd_send_svc_nlink_msg(hdd_ctxt->radio_index, |
| 8864 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 8865 | ucfg_mlme_get_sap_internal_restart(hdd_ctxt->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 8866 | &value); |
| 8867 | hdd_debug("driver to start sap: %d", value); |
| 8868 | if (value) |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8869 | hdd_switch_sap_channel(adapter, restart_chan, |
| 8870 | true); |
Liangwei Dong | 6663d16 | 2017-07-10 03:29:36 -0400 | [diff] [blame] | 8871 | else |
| 8872 | return; |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8873 | } |
Agrawal Ashish | 467dde4 | 2016-09-08 18:44:22 +0530 | [diff] [blame] | 8874 | } |
| 8875 | } |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 8876 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8877 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8878 | * hdd_init_channel_avoidance() - Initialize channel avoidance |
| 8879 | * @hdd_ctx: HDD global context |
| 8880 | * |
| 8881 | * Initialize the channel avoidance logic by retrieving the unsafe |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8882 | * channel list from the platform driver and plumbing the data |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8883 | * down to the lower layers. Then subscribe to subsequent channel |
| 8884 | * avoidance events. |
| 8885 | * |
| 8886 | * Return: None |
| 8887 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8888 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8889 | { |
| 8890 | uint16_t unsafe_channel_count; |
| 8891 | int index; |
| 8892 | |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8893 | pld_get_wlan_unsafe_channel(hdd_ctx->parent_dev, |
| 8894 | hdd_ctx->unsafe_channel_list, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8895 | &(hdd_ctx->unsafe_channel_count), |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8896 | sizeof(uint16_t) * NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8897 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8898 | hdd_debug("num of unsafe channels is %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8899 | hdd_ctx->unsafe_channel_count); |
| 8900 | |
Anurag Chouhan | 6d76066 | 2016-02-20 16:05:43 +0530 | [diff] [blame] | 8901 | unsafe_channel_count = QDF_MIN((uint16_t)hdd_ctx->unsafe_channel_count, |
Amar Singhal | b8d4f15 | 2016-02-10 10:21:43 -0800 | [diff] [blame] | 8902 | (uint16_t)NUM_CHANNELS); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8903 | |
| 8904 | for (index = 0; index < unsafe_channel_count; index++) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 8905 | hdd_debug("channel %d is not safe", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8906 | hdd_ctx->unsafe_channel_list[index]); |
| 8907 | |
| 8908 | } |
| 8909 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8910 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8911 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8912 | static void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8913 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8914 | { |
| 8915 | uint8_t restart_chan; |
| 8916 | |
| 8917 | restart_chan = hdd_get_safe_channel_from_pcl_and_acs_range(adapter); |
| 8918 | if (!restart_chan) { |
| 8919 | hdd_alert("fail to restart SAP"); |
| 8920 | return; |
| 8921 | } |
| 8922 | |
| 8923 | /* SAP restart due to unsafe channel. While restarting |
| 8924 | * the SAP, make sure to clear acs_channel, channel to |
| 8925 | * reset to 0. Otherwise these settings will override |
| 8926 | * the ACS while restart. |
| 8927 | */ |
| 8928 | hdd_ctx->acs_policy.acs_channel = AUTO_CHANNEL_SELECT; |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8929 | |
| 8930 | hdd_debug("sending coex indication"); |
| 8931 | |
| 8932 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 8933 | WLAN_SVC_LTE_COEX_IND, NULL, 0); |
Min Liu | 2fef579 | 2018-01-19 17:59:42 +0800 | [diff] [blame] | 8934 | hdd_switch_sap_channel(adapter, restart_chan, true); |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8935 | } |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8936 | |
| 8937 | int hdd_clone_local_unsafe_chan(struct hdd_context *hdd_ctx, |
| 8938 | uint16_t **local_unsafe_list, uint16_t *local_unsafe_list_count) |
| 8939 | { |
| 8940 | uint32_t size; |
| 8941 | uint16_t *unsafe_list; |
| 8942 | uint16_t chan_count; |
| 8943 | |
| 8944 | if (!hdd_ctx || !local_unsafe_list_count || !local_unsafe_list_count) |
| 8945 | return -EINVAL; |
| 8946 | |
| 8947 | chan_count = QDF_MIN(hdd_ctx->unsafe_channel_count, |
| 8948 | NUM_CHANNELS); |
| 8949 | if (chan_count) { |
| 8950 | size = chan_count * sizeof(hdd_ctx->unsafe_channel_list[0]); |
| 8951 | unsafe_list = qdf_mem_malloc(size); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 8952 | if (!unsafe_list) |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8953 | return -ENOMEM; |
Liangwei Dong | 6e1a209 | 2017-08-30 16:29:06 +0800 | [diff] [blame] | 8954 | qdf_mem_copy(unsafe_list, hdd_ctx->unsafe_channel_list, size); |
| 8955 | } else { |
| 8956 | unsafe_list = NULL; |
| 8957 | } |
| 8958 | |
| 8959 | *local_unsafe_list = unsafe_list; |
| 8960 | *local_unsafe_list_count = chan_count; |
| 8961 | |
| 8962 | return 0; |
| 8963 | } |
| 8964 | |
| 8965 | bool hdd_local_unsafe_channel_updated(struct hdd_context *hdd_ctx, |
| 8966 | uint16_t *local_unsafe_list, uint16_t local_unsafe_list_count) |
| 8967 | { |
| 8968 | int i, j; |
| 8969 | |
| 8970 | if (local_unsafe_list_count != hdd_ctx->unsafe_channel_count) |
| 8971 | return true; |
| 8972 | if (local_unsafe_list_count == 0) |
| 8973 | return false; |
| 8974 | for (i = 0; i < local_unsafe_list_count; i++) { |
| 8975 | for (j = 0; j < local_unsafe_list_count; j++) |
| 8976 | if (local_unsafe_list[i] == |
| 8977 | hdd_ctx->unsafe_channel_list[j]) |
| 8978 | break; |
| 8979 | if (j >= local_unsafe_list_count) |
| 8980 | break; |
| 8981 | } |
| 8982 | if (i >= local_unsafe_list_count) { |
| 8983 | hdd_info("unsafe chan list same"); |
| 8984 | return false; |
| 8985 | } |
| 8986 | |
| 8987 | return true; |
| 8988 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8989 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8990 | static void hdd_init_channel_avoidance(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 8991 | { |
| 8992 | } |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8993 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 8994 | static inline void hdd_lte_coex_restart_sap(struct hdd_adapter *adapter, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 8995 | struct hdd_context *hdd_ctx) |
Dustin Brown | 676a232 | 2017-08-15 13:16:13 -0700 | [diff] [blame] | 8996 | { |
| 8997 | hdd_debug("Channel avoidance is not enabled; Abort SAP restart"); |
| 8998 | } |
Yuanyuan Liu | 1373850 | 2016-04-06 17:41:37 -0700 | [diff] [blame] | 8999 | #endif /* defined(FEATURE_WLAN_CH_AVOID) */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9000 | |
| 9001 | /** |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9002 | * hdd_indicate_mgmt_frame() - Wrapper to indicate management frame to |
| 9003 | * user space |
| 9004 | * @frame_ind: Management frame data to be informed. |
| 9005 | * |
| 9006 | * This function is used to indicate management frame to |
| 9007 | * user space |
| 9008 | * |
| 9009 | * Return: None |
| 9010 | * |
| 9011 | */ |
| 9012 | void hdd_indicate_mgmt_frame(tSirSmeMgmtFrameInd *frame_ind) |
| 9013 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9014 | struct hdd_context *hdd_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9015 | struct hdd_adapter *adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9016 | int i; |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 9017 | struct ieee80211_mgmt *mgmt = |
| 9018 | (struct ieee80211_mgmt *)frame_ind->frameBuf; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9019 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 9020 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 9021 | if (wlan_hdd_validate_context(hdd_ctx)) |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9022 | return; |
| 9023 | |
Pragaspathi Thilagaraj | 28ffc04 | 2018-07-18 15:19:36 +0530 | [diff] [blame] | 9024 | if (frame_ind->frame_len < ieee80211_hdrlen(mgmt->frame_control)) { |
| 9025 | hdd_err(" Invalid frame length"); |
| 9026 | return; |
| 9027 | } |
| 9028 | |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9029 | if (SME_SESSION_ID_ANY == frame_ind->sessionId) { |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 9030 | for (i = 0; i < WLAN_MAX_VDEVS; i++) { |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9031 | adapter = |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 9032 | hdd_get_adapter_by_vdev(hdd_ctx, i); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9033 | if (adapter) |
| 9034 | break; |
| 9035 | } |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 9036 | } else if (SME_SESSION_ID_BROADCAST == frame_ind->sessionId) { |
| 9037 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 9038 | if ((adapter) && |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 9039 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) { |
| 9040 | __hdd_indicate_mgmt_frame(adapter, |
| 9041 | frame_ind->frame_len, |
| 9042 | frame_ind->frameBuf, |
| 9043 | frame_ind->frameType, |
| 9044 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 9045 | frame_ind->rxRssi, |
| 9046 | frame_ind->rx_flags); |
Wu Gao | a0230a6 | 2018-01-04 20:56:57 +0800 | [diff] [blame] | 9047 | } |
| 9048 | } |
| 9049 | adapter = NULL; |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9050 | } else { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 9051 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, |
| 9052 | frame_ind->sessionId); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9053 | } |
| 9054 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 9055 | if ((adapter) && |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9056 | (WLAN_HDD_ADAPTER_MAGIC == adapter->magic)) |
| 9057 | __hdd_indicate_mgmt_frame(adapter, |
| 9058 | frame_ind->frame_len, |
| 9059 | frame_ind->frameBuf, |
| 9060 | frame_ind->frameType, |
| 9061 | frame_ind->rxChan, |
Srinivas Dasari | ea1c133 | 2019-02-18 12:43:23 +0530 | [diff] [blame] | 9062 | frame_ind->rxRssi, |
| 9063 | frame_ind->rx_flags); |
Rajeev Kumar | d004abc | 2016-02-17 12:09:56 -0800 | [diff] [blame] | 9064 | } |
| 9065 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9066 | void hdd_acs_response_timeout_handler(void *context) |
| 9067 | { |
| 9068 | struct hdd_external_acs_timer_context *timer_context = |
| 9069 | (struct hdd_external_acs_timer_context *)context; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9070 | struct hdd_adapter *adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9071 | struct hdd_context *hdd_ctx; |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9072 | uint8_t reason; |
| 9073 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9074 | hdd_enter(); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9075 | if (!timer_context) { |
| 9076 | hdd_err("invlaid timer context"); |
| 9077 | return; |
| 9078 | } |
| 9079 | adapter = timer_context->adapter; |
| 9080 | reason = timer_context->reason; |
| 9081 | |
| 9082 | |
| 9083 | if ((!adapter) || |
| 9084 | (adapter->magic != WLAN_HDD_ADAPTER_MAGIC)) { |
| 9085 | hdd_err("invalid adapter or adapter has invalid magic"); |
| 9086 | return; |
| 9087 | } |
| 9088 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 9089 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9090 | return; |
| 9091 | |
| 9092 | if (test_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags)) |
| 9093 | clear_bit(VENDOR_ACS_RESPONSE_PENDING, &adapter->event_flags); |
| 9094 | else |
| 9095 | return; |
| 9096 | |
| 9097 | hdd_err("ACS timeout happened for %s reason %d", |
| 9098 | adapter->dev->name, reason); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9099 | |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9100 | switch (reason) { |
| 9101 | /* SAP init case */ |
| 9102 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_INIT: |
| 9103 | wlan_sap_set_vendor_acs(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
| 9104 | false); |
| 9105 | wlan_hdd_cfg80211_start_acs(adapter); |
| 9106 | break; |
| 9107 | /* DFS detected on current channel */ |
| 9108 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_DFS: |
| 9109 | wlan_sap_update_next_channel( |
| 9110 | WLAN_HDD_GET_SAP_CTX_PTR(adapter), 0, 0); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9111 | sme_update_new_channel_event(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9112 | adapter->vdev_id); |
Kapil Gupta | 8878ad9 | 2017-02-13 11:56:04 +0530 | [diff] [blame] | 9113 | break; |
| 9114 | /* LTE coex event on current channel */ |
| 9115 | case QCA_WLAN_VENDOR_ACS_SELECT_REASON_LTE_COEX: |
| 9116 | hdd_lte_coex_restart_sap(adapter, hdd_ctx); |
| 9117 | break; |
| 9118 | default: |
| 9119 | hdd_info("invalid reason for timer invoke"); |
| 9120 | |
| 9121 | } |
| 9122 | } |
| 9123 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9124 | /** |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9125 | * hdd_override_ini_config - Override INI config |
| 9126 | * @hdd_ctx: HDD context |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9127 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9128 | * Override INI config based on module parameter. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9129 | * |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9130 | * Return: None |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9131 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9132 | static void hdd_override_ini_config(struct hdd_context *hdd_ctx) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9133 | { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9134 | QDF_STATUS status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9135 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9136 | if (0 == enable_dfs_chan_scan || 1 == enable_dfs_chan_scan) { |
gaurank kathpalia | 97c070b | 2019-01-07 17:23:06 +0530 | [diff] [blame] | 9137 | ucfg_scan_cfg_set_dfs_chan_scan_allowed(hdd_ctx->psoc, |
| 9138 | enable_dfs_chan_scan); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 9139 | hdd_debug("Module enable_dfs_chan_scan set to %d", |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9140 | enable_dfs_chan_scan); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9141 | } |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9142 | if (0 == enable_11d || 1 == enable_11d) { |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9143 | status = ucfg_mlme_set_11d_enabled(hdd_ctx->psoc, enable_11d); |
| 9144 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9145 | hdd_err("Failed to set 11d_enable flag"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9146 | } |
Leo Chang | 11545d6 | 2016-10-17 14:53:50 -0700 | [diff] [blame] | 9147 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9148 | if (hdd_ctx->config->action_oui_enable && !ucfg_action_oui_enabled()) { |
| 9149 | hdd_ctx->config->action_oui_enable = 0; |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9150 | hdd_err("Ignore action oui ini, since no action_oui component"); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 9151 | } |
Will Huang | 14b120f | 2019-01-14 17:26:14 +0800 | [diff] [blame] | 9152 | |
| 9153 | if (QDF_GLOBAL_MONITOR_MODE == cds_get_conparam()) |
| 9154 | hdd_override_all_ps(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9155 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 9156 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9157 | #ifdef ENABLE_MTRACE_LOG |
| 9158 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9159 | { |
| 9160 | uint8_t module_id = 0; |
| 9161 | int qdf_print_idx = -1; |
| 9162 | |
| 9163 | qdf_print_idx = qdf_get_pidx(); |
| 9164 | for (module_id = 0; module_id < QDF_MODULE_ID_MAX; module_id++) |
| 9165 | qdf_print_set_category_verbose( |
| 9166 | qdf_print_idx, |
| 9167 | module_id, QDF_TRACE_LEVEL_TRACE, |
| 9168 | hdd_ctx->config->enable_mtrace); |
| 9169 | } |
| 9170 | #else |
| 9171 | static void hdd_set_mtrace_for_each(struct hdd_context *hdd_ctx) |
| 9172 | { |
| 9173 | } |
| 9174 | |
| 9175 | #endif |
| 9176 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9177 | /** |
| 9178 | * hdd_set_trace_level_for_each - Set trace level for each INI config |
| 9179 | * @hdd_ctx - HDD context |
| 9180 | * |
| 9181 | * Set trace level for each module based on INI config. |
| 9182 | * |
| 9183 | * Return: None |
| 9184 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9185 | 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] | 9186 | { |
Wu Gao | bc6eaa1 | 2018-11-30 14:17:45 +0800 | [diff] [blame] | 9187 | hdd_qdf_trace_enable(QDF_MODULE_ID_DP, 0x7f); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 9188 | hdd_qdf_trace_enable(QDF_MODULE_ID_MLME, 0xffff); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 9189 | hdd_qdf_trace_enable(QDF_MODULE_ID_FWOL, 0xffff); |
Kiran Kumar Lokere | 4ce4048 | 2018-08-30 16:31:00 -0700 | [diff] [blame] | 9190 | hdd_qdf_trace_enable(QDF_MODULE_ID_CRYPTO, 0xffff); |
Kiran Kumar Lokere | 798de7e | 2017-03-30 14:01:12 -0700 | [diff] [blame] | 9191 | |
Ashish Kumar Dhanotiya | 12f6821 | 2018-09-04 22:00:14 +0530 | [diff] [blame] | 9192 | hdd_set_mtrace_for_each(hdd_ctx); |
| 9193 | |
Nirav Shah | 5c083da | 2018-08-03 13:46:02 +0530 | [diff] [blame] | 9194 | hdd_cfg_print_global_config(hdd_ctx); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9195 | } |
| 9196 | |
| 9197 | /** |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9198 | * hdd_context_init() - Initialize HDD context |
| 9199 | * @hdd_ctx: HDD context. |
| 9200 | * |
| 9201 | * Initialize HDD context along with all the feature specific contexts. |
| 9202 | * |
| 9203 | * return: 0 on success and errno on failure. |
| 9204 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9205 | static int hdd_context_init(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9206 | { |
| 9207 | int ret; |
| 9208 | |
| 9209 | hdd_ctx->ioctl_scan_mode = eSIR_ACTIVE_SCAN; |
Dustin Brown | ad06be6 | 2019-02-04 14:52:56 -0800 | [diff] [blame] | 9210 | hdd_ctx->max_intf_count = WLAN_MAX_VDEVS; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9211 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9212 | init_completion(&hdd_ctx->mc_sus_event_var); |
| 9213 | init_completion(&hdd_ctx->ready_to_suspend); |
| 9214 | |
| 9215 | qdf_spinlock_create(&hdd_ctx->connection_status_lock); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9216 | qdf_spinlock_create(&hdd_ctx->hdd_adapter_lock); |
Manishekar Chandrasekaran | 7f63d05 | 2016-05-07 09:54:00 +0530 | [diff] [blame] | 9217 | |
Dustin Brown | bee8283 | 2018-07-23 10:10:51 -0700 | [diff] [blame] | 9218 | qdf_list_create(&hdd_ctx->hdd_adapters, 0); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9219 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9220 | ret = hdd_scan_context_init(hdd_ctx); |
| 9221 | if (ret) |
| 9222 | goto list_destroy; |
| 9223 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9224 | hdd_rx_wake_lock_create(hdd_ctx); |
| 9225 | |
| 9226 | ret = hdd_sap_context_init(hdd_ctx); |
| 9227 | if (ret) |
| 9228 | goto scan_destroy; |
| 9229 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9230 | wlan_hdd_cfg80211_extscan_init(hdd_ctx); |
| 9231 | |
| 9232 | hdd_init_offloaded_packets_ctx(hdd_ctx); |
| 9233 | |
| 9234 | ret = wlan_hdd_cfg80211_init(hdd_ctx->parent_dev, hdd_ctx->wiphy, |
| 9235 | hdd_ctx->config); |
| 9236 | if (ret) |
Wu Gao | 02bd75b | 2017-10-13 18:34:02 +0800 | [diff] [blame] | 9237 | goto sap_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9238 | |
Arunk Khandavalli | ebd1e37 | 2017-11-06 15:00:24 +0530 | [diff] [blame] | 9239 | qdf_wake_lock_create(&hdd_ctx->monitor_mode_wakelock, |
| 9240 | "monitor_mode_wakelock"); |
| 9241 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9242 | return 0; |
| 9243 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9244 | sap_destroy: |
| 9245 | hdd_sap_context_destroy(hdd_ctx); |
| 9246 | |
| 9247 | scan_destroy: |
| 9248 | hdd_scan_context_destroy(hdd_ctx); |
| 9249 | hdd_rx_wake_lock_destroy(hdd_ctx); |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9250 | list_destroy: |
Jeff Johnson | 19fc8e4 | 2017-10-30 19:53:49 -0700 | [diff] [blame] | 9251 | qdf_list_destroy(&hdd_ctx->hdd_adapters); |
Sandeep Puligilla | d000421 | 2017-02-26 18:34:56 -0800 | [diff] [blame] | 9252 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9253 | return ret; |
| 9254 | } |
| 9255 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9256 | void hdd_psoc_idle_timer_start(struct hdd_context *hdd_ctx) |
| 9257 | { |
| 9258 | uint32_t timeout_ms = hdd_ctx->config->iface_change_wait_time; |
| 9259 | enum wake_lock_reason reason = |
| 9260 | WIFI_POWER_EVENT_WAKELOCK_IFACE_CHANGE_TIMER; |
| 9261 | |
Rajeev Kumar | 7b7bb3f | 2018-12-20 12:09:54 -0800 | [diff] [blame] | 9262 | if (!timeout_ms) { |
| 9263 | hdd_info("psoc idle timer is disabled"); |
| 9264 | return; |
| 9265 | } |
| 9266 | |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9267 | hdd_debug("Starting psoc idle timer"); |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9268 | qdf_delayed_work_start(&hdd_ctx->psoc_idle_timeout_work, timeout_ms); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9269 | hdd_prevent_suspend_timeout(timeout_ms, reason); |
| 9270 | } |
| 9271 | |
| 9272 | void hdd_psoc_idle_timer_stop(struct hdd_context *hdd_ctx) |
| 9273 | { |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9274 | qdf_delayed_work_stop_sync(&hdd_ctx->psoc_idle_timeout_work); |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 9275 | hdd_debug("Stopped psoc idle timer"); |
| 9276 | } |
| 9277 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9278 | /* |
| 9279 | * enum hdd_block_shutdown - Control if driver allows modem shutdown |
| 9280 | * @HDD_UNBLOCK_MODEM_SHUTDOWN: Unblock shutdown |
| 9281 | * @HDD_BLOCK_MODEM_SHUTDOWN: Block shutdown |
| 9282 | * |
| 9283 | * On calling pld_block_shutdown API with the given values, modem |
| 9284 | * graceful shutdown is blocked/unblocked. |
| 9285 | */ |
| 9286 | enum hdd_block_shutdown { |
| 9287 | HDD_UNBLOCK_MODEM_SHUTDOWN, |
| 9288 | HDD_BLOCK_MODEM_SHUTDOWN, |
| 9289 | }; |
| 9290 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9291 | /** |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9292 | * hdd_psoc_idle_shutdown() - perform an idle shutdown on the given psoc |
| 9293 | * @hdd_ctx: the hdd context which should be shutdown |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9294 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9295 | * When no interfaces are "up" on a psoc, an idle shutdown timer is started. |
| 9296 | * If no interfaces are brought up before the timer expires, we do an |
| 9297 | * "idle shutdown," cutting power to the physical SoC to save power. This is |
| 9298 | * done completely transparently from the perspective of userspace. |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9299 | * |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9300 | * Return: None |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9301 | */ |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9302 | static void hdd_psoc_idle_shutdown(struct hdd_context *hdd_ctx) |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9303 | { |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9304 | struct osif_psoc_sync *psoc_sync; |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9305 | int errno; |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9306 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9307 | hdd_enter(); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9308 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9309 | errno = osif_psoc_sync_trans_start(hdd_ctx->parent_dev, &psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9310 | if (errno) { |
| 9311 | hdd_info("psoc busy, abort idle shutdown; errno:%d", errno); |
| 9312 | goto exit; |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9313 | } |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9314 | /* Block the modem graceful shutdown till stop modules is completed */ |
| 9315 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_BLOCK_MODEM_SHUTDOWN); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9316 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9317 | osif_psoc_sync_wait_for_ops(psoc_sync); |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9318 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9319 | QDF_BUG(!hdd_wlan_stop_modules(hdd_ctx, false)); |
| 9320 | |
Dustin Brown | 363b479 | 2019-02-05 16:11:55 -0800 | [diff] [blame] | 9321 | osif_psoc_sync_trans_stop(psoc_sync); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9322 | |
Sourav Mohapatra | 698d6f6 | 2019-01-29 14:49:52 +0530 | [diff] [blame] | 9323 | pld_block_shutdown(hdd_ctx->parent_dev, HDD_UNBLOCK_MODEM_SHUTDOWN); |
| 9324 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9325 | exit: |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9326 | hdd_exit(); |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9327 | } |
| 9328 | |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9329 | int hdd_psoc_idle_restart(struct hdd_context *hdd_ctx) |
| 9330 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 9331 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9332 | |
Dustin Brown | cfcb576 | 2019-01-31 15:43:45 -0800 | [diff] [blame] | 9333 | return hdd_wlan_start_modules(hdd_ctx, false); |
Dustin Brown | 3ecc878 | 2018-09-19 16:37:13 -0700 | [diff] [blame] | 9334 | } |
| 9335 | |
| 9336 | /** |
| 9337 | * hdd_psoc_idle_timeout_callback() - Handler for psoc idle timeout |
| 9338 | * @priv: pointer to hdd context |
| 9339 | * |
| 9340 | * Return: None |
| 9341 | */ |
| 9342 | static void hdd_psoc_idle_timeout_callback(void *priv) |
| 9343 | { |
| 9344 | struct hdd_context *hdd_ctx = priv; |
| 9345 | |
| 9346 | if (wlan_hdd_validate_context(hdd_ctx)) |
| 9347 | return; |
| 9348 | |
| 9349 | hdd_debug("Psoc idle timeout elapsed; starting psoc shutdown"); |
| 9350 | hdd_psoc_idle_shutdown(hdd_ctx); |
| 9351 | } |
| 9352 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9353 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9354 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9355 | { |
| 9356 | wlan_logging_set_log_to_console(hdd_ctx->config-> |
| 9357 | wlan_logging_to_console); |
| 9358 | wlan_logging_set_active(hdd_ctx->config->wlan_logging_enable); |
| 9359 | } |
| 9360 | #else |
| 9361 | static void hdd_set_wlan_logging(struct hdd_context *hdd_ctx) |
| 9362 | { } |
| 9363 | #endif |
| 9364 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9365 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 9366 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9367 | struct wlan_objmgr_psoc *psoc) |
| 9368 | { |
| 9369 | config->wlan_logging_enable = cfg_get(psoc, CFG_WLAN_LOGGING_SUPPORT); |
| 9370 | |
| 9371 | config->wlan_logging_to_console = |
| 9372 | cfg_get(psoc, CFG_WLAN_LOGGING_CONSOLE_SUPPORT); |
| 9373 | } |
| 9374 | #else |
| 9375 | static void hdd_init_wlan_logging_params(struct hdd_config *config, |
| 9376 | struct wlan_objmgr_psoc *psoc) |
| 9377 | { |
| 9378 | } |
| 9379 | #endif |
| 9380 | |
| 9381 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 9382 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9383 | struct wlan_objmgr_psoc *psoc) |
| 9384 | { |
| 9385 | config->wlan_auto_shutdown = cfg_get(psoc, CFG_WLAN_AUTO_SHUTDOWN); |
| 9386 | } |
| 9387 | #else |
| 9388 | static void hdd_init_wlan_auto_shutdown(struct hdd_config *config, |
| 9389 | struct wlan_objmgr_psoc *psoc) |
| 9390 | { |
| 9391 | } |
| 9392 | #endif |
| 9393 | |
| 9394 | #ifndef REMOVE_PKT_LOG |
| 9395 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9396 | struct wlan_objmgr_psoc *psoc) |
| 9397 | { |
| 9398 | config->enable_packet_log = cfg_get(psoc, CFG_ENABLE_PACKET_LOG); |
| 9399 | } |
| 9400 | #else |
| 9401 | static void hdd_init_packet_log(struct hdd_config *config, |
| 9402 | struct wlan_objmgr_psoc *psoc) |
| 9403 | { |
| 9404 | } |
| 9405 | #endif |
| 9406 | |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9407 | #ifdef ENABLE_MTRACE_LOG |
| 9408 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9409 | struct wlan_objmgr_psoc *psoc) |
| 9410 | { |
| 9411 | config->enable_mtrace = cfg_get(psoc, CFG_ENABLE_MTRACE); |
| 9412 | } |
| 9413 | #else |
| 9414 | static void hdd_init_mtrace_log(struct hdd_config *config, |
| 9415 | struct wlan_objmgr_psoc *psoc) |
| 9416 | { |
| 9417 | } |
| 9418 | #endif |
| 9419 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9420 | #ifdef FEATURE_RUNTIME_PM |
| 9421 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9422 | struct wlan_objmgr_psoc *psoc) |
| 9423 | { |
| 9424 | config->runtime_pm = cfg_get(psoc, CFG_ENABLE_RUNTIME_PM); |
| 9425 | } |
| 9426 | #else |
| 9427 | static void hdd_init_runtime_pm(struct hdd_config *config, |
| 9428 | struct wlan_objmgr_psoc *psoc) |
| 9429 | |
| 9430 | { |
| 9431 | } |
| 9432 | #endif |
| 9433 | |
| 9434 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 9435 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9436 | struct wlan_objmgr_psoc *psoc) |
| 9437 | { |
| 9438 | config->vc_mode_cfg_bitmap = cfg_get(psoc, CFG_VC_MODE_BITMAP); |
| 9439 | } |
| 9440 | #else |
| 9441 | static void hdd_init_vc_mode_cfg_bitmap(struct hdd_config *config, |
| 9442 | struct wlan_objmgr_psoc *psoc) |
| 9443 | { |
| 9444 | } |
| 9445 | #endif |
| 9446 | |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9447 | #ifdef DHCP_SERVER_OFFLOAD |
| 9448 | static void |
| 9449 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9450 | { |
| 9451 | uint8_t num_entries; |
| 9452 | |
| 9453 | hdd_ctx->config->dhcp_server_ip.is_dhcp_server_ip_valid = true; |
| 9454 | hdd_string_to_u8_array(cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME), |
| 9455 | hdd_ctx->config->dhcp_server_ip.dhcp_server_ip, |
| 9456 | &num_entries, IPADDR_NUM_ENTRIES); |
| 9457 | |
| 9458 | if (num_entries != IPADDR_NUM_ENTRIES) { |
| 9459 | hdd_err("Incorrect IP address (%s) assigned for DHCP server!", |
| 9460 | cfg_get(hdd_ctx->psoc, CFG_DHCP_SERVER_IP_NAME)); |
| 9461 | hdd_config->dhcp_server_ip.is_dhcp_server_ip_valid = false; |
| 9462 | } |
| 9463 | } |
| 9464 | #else |
| 9465 | static void |
| 9466 | hdd_init_dhcp_server_ip(struct hdd_context *hdd_ctx) |
| 9467 | { |
| 9468 | } |
| 9469 | #endif |
| 9470 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9471 | /** |
| 9472 | * hdd_cfg_params_init() - Initialize hdd params in hdd_config strucuture |
| 9473 | * @hdd_ctx - Pointer to HDD context |
| 9474 | * |
| 9475 | * Return: None |
| 9476 | */ |
| 9477 | static void hdd_cfg_params_init(struct hdd_context *hdd_ctx) |
| 9478 | { |
| 9479 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
| 9480 | struct hdd_config *config = hdd_ctx->config; |
| 9481 | |
| 9482 | if (!psoc) { |
| 9483 | hdd_err("Invalid psoc"); |
| 9484 | return; |
| 9485 | } |
| 9486 | |
| 9487 | if (!config) { |
| 9488 | hdd_err("Invalid hdd config"); |
| 9489 | return; |
| 9490 | } |
| 9491 | |
gaurank kathpalia | 43c5262 | 2019-02-11 12:30:05 +0530 | [diff] [blame] | 9492 | config->dot11Mode = cfg_get(psoc, CFG_HDD_DOT11_MODE); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9493 | config->bug_on_reinit_failure = cfg_get(psoc, |
| 9494 | CFG_BUG_ON_REINIT_FAILURE); |
| 9495 | |
| 9496 | config->is_ramdump_enabled = cfg_get(psoc, |
| 9497 | CFG_ENABLE_RAMDUMP_COLLECTION); |
| 9498 | |
| 9499 | config->iface_change_wait_time = cfg_get(psoc, |
| 9500 | CFG_INTERFACE_CHANGE_WAIT); |
| 9501 | |
| 9502 | config->multicast_host_fw_msgs = cfg_get(psoc, |
| 9503 | CFG_MULTICAST_HOST_FW_MSGS); |
| 9504 | |
| 9505 | config->private_wext_control = cfg_get(psoc, CFG_PRIVATE_WEXT_CONTROL); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9506 | config->enablefwprint = cfg_get(psoc, CFG_ENABLE_FW_UART_PRINT); |
| 9507 | config->enable_fw_log = cfg_get(psoc, CFG_ENABLE_FW_LOG); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9508 | config->operating_channel = cfg_get(psoc, CFG_OPERATING_CHANNEL); |
| 9509 | config->num_vdevs = cfg_get(psoc, CFG_NUM_VDEV_ENABLE); |
Vignesh Viswanathan | a0358ff | 2018-11-27 09:53:07 +0530 | [diff] [blame] | 9510 | qdf_str_lcopy(config->enable_concurrent_sta, |
| 9511 | cfg_get(psoc, CFG_ENABLE_CONCURRENT_STA), |
| 9512 | CFG_CONCURRENT_IFACE_MAX_LEN); |
| 9513 | qdf_str_lcopy(config->dbs_scan_selection, |
| 9514 | cfg_get(psoc, CFG_DBS_SCAN_SELECTION), |
| 9515 | CFG_DBS_SCAN_PARAM_LENGTH); |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9516 | config->inform_bss_rssi_raw = cfg_get(psoc, CFG_INFORM_BSS_RSSI_RAW); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 9517 | config->mac_provision = cfg_get(psoc, CFG_ENABLE_MAC_PROVISION); |
| 9518 | config->provisioned_intf_pool = |
| 9519 | cfg_get(psoc, CFG_PROVISION_INTERFACE_POOL); |
| 9520 | config->derived_intf_pool = cfg_get(psoc, CFG_DERIVED_INTERFACE_POOL); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9521 | config->action_oui_enable = cfg_get(psoc, CFG_ENABLE_ACTION_OUI); |
Jeff Johnson | 15a88ac | 2019-03-11 14:35:25 -0700 | [diff] [blame] | 9522 | config->advertise_concurrent_operation = |
Sandeep Puligilla | dc6d68a | 2019-01-04 16:57:12 -0800 | [diff] [blame] | 9523 | cfg_get(psoc, |
| 9524 | CFG_ADVERTISE_CONCURRENT_OPERATION); |
Sourav Mohapatra | 5884106 | 2018-11-19 16:33:27 +0530 | [diff] [blame] | 9525 | qdf_str_lcopy(config->action_oui_str[0], |
| 9526 | cfg_get(psoc, CFG_ACTION_OUI_CONNECT_1X1), |
| 9527 | ACTION_OUI_MAX_STR_LEN); |
| 9528 | qdf_str_lcopy(config->action_oui_str[1], |
| 9529 | cfg_get(psoc, CFG_ACTION_OUI_ITO_EXTENSION), |
| 9530 | ACTION_OUI_MAX_STR_LEN); |
| 9531 | qdf_str_lcopy(config->action_oui_str[2], |
| 9532 | cfg_get(psoc, CFG_ACTION_OUI_CCKM_1X1), |
| 9533 | ACTION_OUI_MAX_STR_LEN); |
| 9534 | qdf_str_lcopy(config->action_oui_str[3], |
| 9535 | cfg_get(psoc, CFG_ACTION_OUI_ITO_ALTERNATE), |
| 9536 | ACTION_OUI_MAX_STR_LEN); |
| 9537 | qdf_str_lcopy(config->action_oui_str[4], |
| 9538 | cfg_get(psoc, CFG_ACTION_OUI_SWITCH_TO_11N_MODE), |
| 9539 | ACTION_OUI_MAX_STR_LEN); |
| 9540 | qdf_str_lcopy(config->action_oui_str[5], |
| 9541 | cfg_get(psoc, |
| 9542 | CFG_ACTION_OUI_CONNECT_1X1_WITH_1_CHAIN), |
| 9543 | ACTION_OUI_MAX_STR_LEN); |
Rajeev Kumar Sirasanagandla | d7987f1 | 2018-12-08 23:24:04 +0530 | [diff] [blame] | 9544 | qdf_str_lcopy(config->action_oui_str[6], |
| 9545 | cfg_get(psoc, |
| 9546 | CFG_ACTION_OUI_DISABLE_AGGRESSIVE_TX), |
| 9547 | ACTION_OUI_MAX_STR_LEN); |
Sourav Mohapatra | 9e014cf | 2018-12-11 09:39:33 +0530 | [diff] [blame] | 9548 | config->enable_rtt_support = cfg_get(psoc, CFG_ENABLE_RTT_SUPPORT); |
Sandeep Puligilla | efeb4a9 | 2019-01-08 00:06:51 -0800 | [diff] [blame] | 9549 | config->is_unit_test_framework_enabled = |
| 9550 | cfg_get(psoc, CFG_ENABLE_UNIT_TEST_FRAMEWORK); |
Ashish Kumar Dhanotiya | d63d686 | 2019-03-14 18:54:10 +0530 | [diff] [blame] | 9551 | config->disable_channel = cfg_get(psoc, CFG_ENABLE_DISABLE_CHANNEL); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9552 | |
Sourav Mohapatra | 0dfe555 | 2018-11-16 11:29:54 +0530 | [diff] [blame] | 9553 | hdd_init_vc_mode_cfg_bitmap(config, psoc); |
| 9554 | hdd_init_runtime_pm(config, psoc); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9555 | hdd_init_wlan_auto_shutdown(config, psoc); |
| 9556 | hdd_init_wlan_logging_params(config, psoc); |
| 9557 | hdd_init_packet_log(config, psoc); |
Sandeep Puligilla | 43b6d1a | 2018-12-03 09:16:13 -0800 | [diff] [blame] | 9558 | hdd_init_mtrace_log(config, psoc); |
gaurank kathpalia | 566c81b | 2019-02-20 14:31:45 +0530 | [diff] [blame] | 9559 | hdd_init_dhcp_server_ip(hdd_ctx); |
jitiphil | 869b9f7 | 2018-09-25 17:14:01 +0530 | [diff] [blame] | 9560 | hdd_dp_cfg_update(psoc, hdd_ctx); |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9561 | } |
| 9562 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 9563 | struct hdd_context *hdd_context_create(struct device *dev) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9564 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9565 | QDF_STATUS status; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9566 | int ret = 0; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9567 | struct hdd_context *hdd_ctx; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9568 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9569 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9570 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 9571 | hdd_ctx = hdd_cfg80211_wiphy_alloc(); |
| 9572 | if (!hdd_ctx) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9573 | ret = -ENOMEM; |
| 9574 | goto err_out; |
| 9575 | } |
| 9576 | |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9577 | status = qdf_delayed_work_create(&hdd_ctx->psoc_idle_timeout_work, |
| 9578 | hdd_psoc_idle_timeout_callback, |
| 9579 | hdd_ctx); |
| 9580 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9581 | ret = qdf_status_to_os_return(status); |
| 9582 | goto wiphy_dealloc; |
| 9583 | } |
Sourav Mohapatra | fed6aa9 | 2017-11-14 18:05:11 +0530 | [diff] [blame] | 9584 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9585 | hdd_ctx->parent_dev = dev; |
Jeff Johnson | 995fd51 | 2019-03-06 08:45:10 -0800 | [diff] [blame] | 9586 | hdd_ctx->last_scan_reject_vdev_id = WLAN_UMAC_VDEV_ID_MAX; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9587 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9588 | hdd_ctx->config = qdf_mem_malloc(sizeof(struct hdd_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9589 | if (!hdd_ctx->config) { |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9590 | ret = -ENOMEM; |
| 9591 | goto err_free_hdd_context; |
| 9592 | } |
| 9593 | |
| 9594 | /* Read and parse the qcom_cfg.ini file */ |
| 9595 | status = hdd_parse_config_ini(hdd_ctx); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9596 | if (QDF_STATUS_SUCCESS != status) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9597 | hdd_err("Error (status: %d) parsing INI file: %s", status, |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9598 | WLAN_INI_FILE); |
| 9599 | ret = -EINVAL; |
| 9600 | goto err_free_config; |
| 9601 | } |
| 9602 | |
Dustin Brown | 84f46ea | 2018-02-15 11:57:36 -0800 | [diff] [blame] | 9603 | status = cfg_parse(WLAN_INI_FILE); |
| 9604 | if (QDF_IS_STATUS_ERROR(status)) |
| 9605 | hdd_err("Failed to parse cfg %s; status:%d\n", |
| 9606 | WLAN_INI_FILE, status); |
| 9607 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9608 | ret = hdd_objmgr_create_and_store_psoc(hdd_ctx, DEFAULT_PSOC_ID); |
| 9609 | if (ret) { |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9610 | QDF_DEBUG_PANIC("Psoc creation fails!"); |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9611 | goto err_free_config; |
| 9612 | } |
| 9613 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 9614 | hdd_cfg_params_init(hdd_ctx); |
| 9615 | |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 9616 | /* apply multiplier config, if not already set via module parameter */ |
| 9617 | if (qdf_timer_get_multiplier() == 1) |
| 9618 | qdf_timer_set_multiplier(cfg_get(hdd_ctx->psoc, |
| 9619 | CFG_TIMER_MULTIPLIER)); |
Dustin Brown | a9a8452 | 2019-02-04 12:25:40 -0800 | [diff] [blame] | 9620 | hdd_debug("set timer multiplier: %u", qdf_timer_get_multiplier()); |
Dustin Brown | 7f93993 | 2017-05-18 15:02:17 -0700 | [diff] [blame] | 9621 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9622 | cds_set_fatal_event(cfg_get(hdd_ctx->psoc, |
| 9623 | CFG_ENABLE_FATAL_EVENT_TRIGGER)); |
Abhishek Singh | 5ea8653 | 2016-04-27 14:10:53 +0530 | [diff] [blame] | 9624 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9625 | hdd_override_ini_config(hdd_ctx); |
| 9626 | |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9627 | ret = hdd_context_init(hdd_ctx); |
| 9628 | |
| 9629 | if (ret) |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9630 | goto err_hdd_objmgr_destroy; |
Prashanth Bhatta | 527fd75 | 2016-04-28 12:35:23 -0700 | [diff] [blame] | 9631 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 9632 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 9633 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9634 | goto skip_multicast_logging; |
| 9635 | |
| 9636 | cds_set_multicast_logging(hdd_ctx->config->multicast_host_fw_msgs); |
| 9637 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9638 | ret = wlan_hdd_init_tx_rx_histogram(hdd_ctx); |
| 9639 | if (ret) |
| 9640 | goto err_deinit_hdd_context; |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9641 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9642 | ret = hdd_init_netlink_services(hdd_ctx); |
| 9643 | if (ret) |
| 9644 | goto err_deinit_txrx_histogram; |
| 9645 | |
Nirav Shah | eb017be | 2018-02-15 11:20:58 +0530 | [diff] [blame] | 9646 | hdd_set_wlan_logging(hdd_ctx); |
Nirav Shah | ed34b21 | 2016-04-25 10:59:16 +0530 | [diff] [blame] | 9647 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9648 | skip_multicast_logging: |
| 9649 | hdd_set_trace_level_for_each(hdd_ctx); |
| 9650 | |
Rajeev Kumar | 493a31b | 2017-09-29 14:01:24 -0700 | [diff] [blame] | 9651 | cds_set_context(QDF_MODULE_ID_HDD, hdd_ctx); |
| 9652 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9653 | hdd_exit(); |
Mahesh Kumar Kalikot Veetil | b85cefd | 2017-08-14 14:03:32 -0700 | [diff] [blame] | 9654 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9655 | return hdd_ctx; |
| 9656 | |
Houston Hoffman | b18dc6e | 2017-08-11 17:43:07 -0700 | [diff] [blame] | 9657 | err_deinit_txrx_histogram: |
| 9658 | wlan_hdd_deinit_tx_rx_histogram(hdd_ctx); |
| 9659 | |
Rajeev Kumar | fb02a5e | 2016-09-20 16:16:17 -0700 | [diff] [blame] | 9660 | err_deinit_hdd_context: |
| 9661 | hdd_context_deinit(hdd_ctx); |
| 9662 | |
Dundi Raviteja | fb9357a | 2018-09-25 12:16:03 +0530 | [diff] [blame] | 9663 | err_hdd_objmgr_destroy: |
| 9664 | hdd_objmgr_release_and_destroy_psoc(hdd_ctx); |
| 9665 | |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9666 | err_free_config: |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 9667 | qdf_mem_free(hdd_ctx->config); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9668 | |
| 9669 | err_free_hdd_context: |
Dustin Brown | 8d8ab30 | 2019-03-05 16:19:36 -0800 | [diff] [blame] | 9670 | qdf_delayed_work_destroy(&hdd_ctx->psoc_idle_timeout_work); |
| 9671 | |
| 9672 | wiphy_dealloc: |
Rajeev Kumar | fa55a69 | 2018-01-09 14:12:41 -0800 | [diff] [blame] | 9673 | wiphy_free(hdd_ctx->wiphy); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 9674 | |
| 9675 | err_out: |
| 9676 | return ERR_PTR(ret); |
| 9677 | } |
| 9678 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9679 | /** |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9680 | * hdd_start_station_adapter()- Start the Station Adapter |
| 9681 | * @adapter: HDD adapter |
| 9682 | * |
| 9683 | * This function initializes the adapter for the station mode. |
| 9684 | * |
| 9685 | * Return: 0 on success or errno on failure. |
| 9686 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9687 | int hdd_start_station_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9688 | { |
| 9689 | QDF_STATUS status; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9690 | int ret; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9691 | |
Dustin Brown | fdf17c1 | 2018-03-14 12:55:34 -0700 | [diff] [blame] | 9692 | hdd_enter_dev(adapter->dev); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9693 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9694 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9695 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9696 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9697 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9698 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9699 | ret = hdd_vdev_create(adapter, hdd_sme_roam_callback, adapter); |
| 9700 | if (ret) { |
| 9701 | hdd_err("failed to create vdev: %d", ret); |
| 9702 | return ret; |
| 9703 | } |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9704 | status = hdd_init_station_mode(adapter); |
| 9705 | |
| 9706 | if (QDF_STATUS_SUCCESS != status) { |
| 9707 | hdd_err("Error Initializing station mode: %d", status); |
| 9708 | return qdf_status_to_os_return(status); |
| 9709 | } |
| 9710 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9711 | hdd_register_tx_flow_control(adapter, |
| 9712 | hdd_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9713 | hdd_tx_resume_cb, |
| 9714 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9715 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9716 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9717 | hdd_tx_resume_timer_expired_handler); |
| 9718 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9719 | hdd_exit(); |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 9720 | |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9721 | return 0; |
| 9722 | } |
| 9723 | |
| 9724 | /** |
| 9725 | * hdd_start_ap_adapter()- Start AP Adapter |
| 9726 | * @adapter: HDD adapter |
| 9727 | * |
| 9728 | * This function initializes the adapter for the AP mode. |
| 9729 | * |
| 9730 | * Return: 0 on success errno on failure. |
| 9731 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 9732 | int hdd_start_ap_adapter(struct hdd_adapter *adapter) |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9733 | { |
| 9734 | QDF_STATUS status; |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9735 | bool is_ssr = false; |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9736 | int ret; |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9737 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9738 | uint32_t fine_time_meas_cap = 0; |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9739 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 9740 | hdd_enter(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9741 | |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9742 | if (test_bit(SME_SESSION_OPENED, &adapter->event_flags)) { |
| 9743 | hdd_err("session is already opened, %d", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9744 | adapter->vdev_id); |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9745 | return qdf_status_to_os_return(QDF_STATUS_SUCCESS); |
| 9746 | } |
| 9747 | /* |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9748 | * In SSR case no need to create new sap context. |
| 9749 | * Otherwise create sap context first and then create |
| 9750 | * vdev as while creating the vdev, driver needs to |
| 9751 | * register SAP callback and that callback uses sap context |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9752 | */ |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9753 | if (adapter->session.ap.sap_context) { |
| 9754 | is_ssr = true; |
| 9755 | } else if (!hdd_sap_create_ctx(adapter)) { |
Krunal Soni | b51eec7 | 2017-11-20 21:53:01 -0800 | [diff] [blame] | 9756 | hdd_err("sap creation failed"); |
| 9757 | return qdf_status_to_os_return(QDF_STATUS_E_FAILURE); |
| 9758 | } |
| 9759 | |
| 9760 | ret = hdd_vdev_create(adapter, wlansap_roam_callback, |
| 9761 | adapter->session.ap.sap_context); |
| 9762 | if (ret) { |
| 9763 | hdd_err("failed to create vdev, status:%d", ret); |
| 9764 | hdd_sap_destroy_ctx(adapter); |
| 9765 | return ret; |
| 9766 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9767 | |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9768 | if (adapter->device_mode == QDF_SAP_MODE) { |
| 9769 | ucfg_mlme_get_fine_time_meas_cap(hdd_ctx->psoc, |
| 9770 | &fine_time_meas_cap); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 9771 | sme_cli_set_command(adapter->vdev_id, |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9772 | WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE, |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9773 | (bool)(fine_time_meas_cap & WMI_FW_AP_RTT_RESPR), |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9774 | VDEV_CMD); |
Arif Hussain | bd5194c | 2018-11-27 19:01:15 -0800 | [diff] [blame] | 9775 | } |
Naveen Rawat | 1af0939 | 2018-01-03 17:28:21 -0800 | [diff] [blame] | 9776 | |
Tushnim Bhattacharyya | 18b0eaa | 2017-11-27 18:33:50 -0800 | [diff] [blame] | 9777 | status = hdd_init_ap_mode(adapter, is_ssr); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9778 | |
| 9779 | if (QDF_STATUS_SUCCESS != status) { |
| 9780 | hdd_err("Error Initializing the AP mode: %d", status); |
| 9781 | return qdf_status_to_os_return(status); |
| 9782 | } |
| 9783 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9784 | hdd_register_tx_flow_control(adapter, |
| 9785 | hdd_softap_tx_resume_timer_expired_handler, |
bings | 284f8be | 2017-08-11 10:41:30 +0800 | [diff] [blame] | 9786 | hdd_softap_tx_resume_cb, |
| 9787 | hdd_tx_flow_control_is_pause); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 9788 | |
Visweswara Tanuku | b5a6124 | 2019-03-26 12:24:13 +0530 | [diff] [blame] | 9789 | hdd_register_hl_netdev_fc_timer(adapter, |
| 9790 | hdd_tx_resume_timer_expired_handler); |
| 9791 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 9792 | hdd_exit(); |
Arun Khandavalli | 7e857c3 | 2016-06-26 12:07:16 +0530 | [diff] [blame] | 9793 | return 0; |
| 9794 | } |
| 9795 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9796 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 9797 | /** |
| 9798 | * hdd_txrx_populate_cds_config() - Populate txrx cds configuration |
| 9799 | * @cds_cfg: CDS Configuration |
| 9800 | * @hdd_ctx: Pointer to hdd context |
| 9801 | * |
| 9802 | * Return: none |
| 9803 | */ |
| 9804 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9805 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9806 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9807 | { |
| 9808 | cds_cfg->tx_flow_stop_queue_th = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9809 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9810 | cds_cfg->tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9811 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame] | 9812 | /* configuration for DP RX Threads */ |
| 9813 | cds_cfg->enable_dp_rx_threads = hdd_ctx->enable_dp_rx_threads; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9814 | } |
| 9815 | #else |
| 9816 | static inline void hdd_txrx_populate_cds_config(struct cds_config_info |
| 9817 | *cds_cfg, |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9818 | struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9819 | { |
| 9820 | } |
| 9821 | #endif |
| 9822 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9823 | /** |
| 9824 | * hdd_update_cds_config() - API to update cds configuration parameters |
| 9825 | * @hdd_ctx: HDD Context |
| 9826 | * |
| 9827 | * Return: 0 for Success, errno on failure |
| 9828 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9829 | static int hdd_update_cds_config(struct hdd_context *hdd_ctx) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9830 | { |
| 9831 | struct cds_config_info *cds_cfg; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9832 | int value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9833 | uint8_t band_capability; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9834 | uint8_t ito_repeat_count; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9835 | bool crash_inject; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9836 | bool self_recovery; |
| 9837 | bool fw_timeout_crash; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9838 | QDF_STATUS status; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9839 | |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9840 | cds_cfg = qdf_mem_malloc(sizeof(*cds_cfg)); |
| 9841 | if (!cds_cfg) |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9842 | return -ENOMEM; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9843 | |
Srinivas Girigowda | 35b0031 | 2017-06-27 21:52:03 -0700 | [diff] [blame] | 9844 | cds_cfg->driver_type = QDF_DRIVER_TYPE_PRODUCTION; |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 9845 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 9846 | &cds_cfg->sta_maxlimod_dtim); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9847 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9848 | status = ucfg_mlme_get_crash_inject(hdd_ctx->psoc, &crash_inject); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9849 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9850 | hdd_err("Failed to get crash inject ini config"); |
| 9851 | goto exit; |
| 9852 | } |
| 9853 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9854 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 9855 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9856 | hdd_err("Failed to get self recovery ini config"); |
| 9857 | goto exit; |
| 9858 | } |
| 9859 | |
| 9860 | status = ucfg_mlme_get_fw_timeout_crash(hdd_ctx->psoc, |
| 9861 | &fw_timeout_crash); |
| 9862 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9863 | hdd_err("Failed to get fw timeout crash ini config"); |
| 9864 | goto exit; |
| 9865 | } |
| 9866 | |
| 9867 | status = ucfg_mlme_get_ito_repeat_count(hdd_ctx->psoc, |
| 9868 | &ito_repeat_count); |
| 9869 | if (QDF_IS_STATUS_ERROR(status)) { |
| 9870 | hdd_err("Failed to get ITO repeat count ini config"); |
| 9871 | goto exit; |
| 9872 | } |
| 9873 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 9874 | cds_cfg->force_target_assert_enabled = crash_inject; |
SaidiReddy Yenuga | cc733af | 2016-11-09 17:45:42 +0530 | [diff] [blame] | 9875 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9876 | ucfg_mlme_get_sap_max_offload_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9877 | cds_cfg->ap_maxoffload_peers = value; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9878 | ucfg_mlme_get_sap_max_offload_reorder_buffs(hdd_ctx->psoc, |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9879 | &value); |
| 9880 | cds_cfg->ap_maxoffload_reorderbuffs = value; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9881 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9882 | cds_cfg->reorder_offload = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 9883 | cfg_get(hdd_ctx->psoc, CFG_DP_REORDER_OFFLOAD_SUPPORT); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9884 | |
| 9885 | /* IPA micro controller data path offload resource config item */ |
Sravan Kumar Kairam | 5214f65 | 2018-03-13 09:52:31 +0530 | [diff] [blame] | 9886 | cds_cfg->uc_offload_enabled = ucfg_ipa_uc_is_enabled(); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9887 | |
Jeff Johnson | e2ba3cd | 2017-10-30 20:02:09 -0700 | [diff] [blame] | 9888 | cds_cfg->enable_rxthread = hdd_ctx->enable_rxthread; |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 9889 | ucfg_mlme_get_sap_max_peers(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 9890 | cds_cfg->max_station = value; |
Naveen Rawat | 64e477e | 2016-05-20 10:34:56 -0700 | [diff] [blame] | 9891 | cds_cfg->sub_20_channel_width = WLAN_SUB_20_CH_WIDTH_NONE; |
Orhan K AKYILDIZ | 30e8cbc | 2017-08-11 18:00:28 -0700 | [diff] [blame] | 9892 | cds_cfg->max_msdus_per_rxinorderind = |
jitiphil | 8e15ea6 | 2018-11-16 18:05:34 +0530 | [diff] [blame] | 9893 | cfg_get(hdd_ctx->psoc, CFG_DP_MAX_MSDUS_PER_RXIND); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9894 | cds_cfg->self_recovery_enabled = self_recovery; |
| 9895 | cds_cfg->fw_timeout_crash = fw_timeout_crash; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9896 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 9897 | cds_cfg->ito_repeat_count = ito_repeat_count; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9898 | |
| 9899 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9900 | if (QDF_IS_STATUS_ERROR(status)) |
| 9901 | goto exit; |
| 9902 | |
| 9903 | cds_cfg->bandcapability = band_capability; |
Rachit Kankane | 0106e38 | 2018-05-16 18:59:28 +0530 | [diff] [blame] | 9904 | cds_cfg->num_vdevs = hdd_ctx->config->num_vdevs; |
Ashish Kumar Dhanotiya | 9335d81 | 2017-06-30 16:57:20 +0530 | [diff] [blame] | 9905 | |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9906 | hdd_txrx_populate_cds_config(cds_cfg, hdd_ctx); |
Jeff Johnson | 9078bdc | 2016-09-23 17:18:11 -0700 | [diff] [blame] | 9907 | hdd_lpass_populate_cds_config(cds_cfg, hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9908 | cds_init_ini_config(cds_cfg); |
| 9909 | return 0; |
SaidiReddy Yenuga | 466b3ce | 2017-05-02 18:50:25 +0530 | [diff] [blame] | 9910 | |
| 9911 | exit: |
| 9912 | qdf_mem_free(cds_cfg); |
| 9913 | return -EINVAL; |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 9914 | } |
| 9915 | |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9916 | /** |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9917 | * hdd_update_user_config() - API to update user configuration |
| 9918 | * parameters to obj mgr which are used by multiple components |
| 9919 | * @hdd_ctx: HDD Context |
| 9920 | * |
| 9921 | * Return: 0 for Success, errno on failure |
| 9922 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9923 | static int hdd_update_user_config(struct hdd_context *hdd_ctx) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9924 | { |
| 9925 | struct wlan_objmgr_psoc_user_config *user_config; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9926 | uint8_t band_capability; |
| 9927 | QDF_STATUS status; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9928 | bool value = false; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9929 | |
| 9930 | status = ucfg_mlme_get_band_capability(hdd_ctx->psoc, &band_capability); |
| 9931 | if (QDF_IS_STATUS_ERROR(status)) |
| 9932 | return -EIO; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9933 | |
| 9934 | user_config = qdf_mem_malloc(sizeof(*user_config)); |
Min Liu | 74a1a50 | 2018-10-10 19:59:07 +0800 | [diff] [blame] | 9935 | if (!user_config) |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9936 | return -ENOMEM; |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9937 | |
| 9938 | user_config->dot11_mode = hdd_ctx->config->dot11Mode; |
Abhinav Kumar | d4d6eb7 | 2018-12-04 20:30:37 +0530 | [diff] [blame] | 9939 | status = ucfg_mlme_is_11d_enabled(hdd_ctx->psoc, &value); |
| 9940 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9941 | hdd_err("Invalid 11d_enable flag"); |
| 9942 | user_config->is_11d_support_enabled = value; |
| 9943 | |
| 9944 | value = false; |
| 9945 | status = ucfg_mlme_is_11h_enabled(hdd_ctx->psoc, &value); |
| 9946 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 9947 | hdd_err("Invalid 11h_enable flag"); |
| 9948 | user_config->is_11h_support_enabled = value; |
Vignesh Viswanathan | f97cc11 | 2018-10-03 19:17:07 +0530 | [diff] [blame] | 9949 | user_config->band_capability = band_capability; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 9950 | wlan_objmgr_psoc_set_user_config(hdd_ctx->psoc, user_config); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 9951 | |
| 9952 | qdf_mem_free(user_config); |
| 9953 | return 0; |
| 9954 | } |
| 9955 | |
| 9956 | /** |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9957 | * hdd_init_thermal_info - Initialize thermal level |
| 9958 | * @hdd_ctx: HDD context |
| 9959 | * |
| 9960 | * Initialize thermal level at SME layer and set the thermal level callback |
| 9961 | * which would be called when a configured thermal threshold is hit. |
| 9962 | * |
| 9963 | * Return: 0 on success and errno on failure |
| 9964 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 9965 | static int hdd_init_thermal_info(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9966 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9967 | QDF_STATUS status; |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9968 | mac_handle_t mac_handle = hdd_ctx->mac_handle; |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9969 | |
Manikandan Mohan | 9045e2e | 2018-11-26 16:44:19 -0800 | [diff] [blame] | 9970 | status = sme_init_thermal_info(mac_handle); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9971 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 9972 | if (!QDF_IS_STATUS_SUCCESS(status)) |
Anurag Chouhan | c554842 | 2016-02-24 18:33:27 +0530 | [diff] [blame] | 9973 | return qdf_status_to_os_return(status); |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9974 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 9975 | sme_add_set_thermal_level_callback(mac_handle, |
Prashanth Bhatta | 5f7c9b8 | 2016-01-09 13:15:21 -0800 | [diff] [blame] | 9976 | hdd_set_thermal_level_cb); |
| 9977 | |
| 9978 | return 0; |
| 9979 | |
| 9980 | } |
| 9981 | |
Prashanth Bhatta | 98f04d2 | 2016-01-08 16:46:21 -0800 | [diff] [blame] | 9982 | #if defined(CONFIG_HDD_INIT_WITH_RTNL_LOCK) |
| 9983 | /** |
| 9984 | * hdd_hold_rtnl_lock - Hold RTNL lock |
| 9985 | * |
| 9986 | * Hold RTNL lock |
| 9987 | * |
| 9988 | * Return: True if held and false otherwise |
| 9989 | */ |
| 9990 | static inline bool hdd_hold_rtnl_lock(void) |
| 9991 | { |
| 9992 | rtnl_lock(); |
| 9993 | return true; |
| 9994 | } |
| 9995 | |
| 9996 | /** |
| 9997 | * hdd_release_rtnl_lock - Release RTNL lock |
| 9998 | * |
| 9999 | * Release RTNL lock |
| 10000 | * |
| 10001 | * Return: None |
| 10002 | */ |
| 10003 | static inline void hdd_release_rtnl_lock(void) |
| 10004 | { |
| 10005 | rtnl_unlock(); |
| 10006 | } |
| 10007 | #else |
| 10008 | static inline bool hdd_hold_rtnl_lock(void) { return false; } |
| 10009 | static inline void hdd_release_rtnl_lock(void) { } |
| 10010 | #endif |
| 10011 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10012 | #if !defined(REMOVE_PKT_LOG) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10013 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10014 | /* MAX iwpriv command support */ |
| 10015 | #define PKTLOG_SET_BUFF_SIZE 3 |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10016 | #define PKTLOG_CLEAR_BUFF 4 |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10017 | /* Set Maximum pktlog file size to 64MB */ |
| 10018 | #define MAX_PKTLOG_SIZE 64 |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10019 | |
| 10020 | /** |
| 10021 | * hdd_pktlog_set_buff_size() - set pktlog buffer size |
| 10022 | * @hdd_ctx: hdd context |
| 10023 | * @set_value2: pktlog buffer size value |
| 10024 | * |
| 10025 | * |
| 10026 | * Return: 0 for success or error. |
| 10027 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10028 | 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] | 10029 | { |
| 10030 | struct sir_wifi_start_log start_log = { 0 }; |
| 10031 | QDF_STATUS status; |
| 10032 | |
| 10033 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10034 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10035 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10036 | start_log.user_triggered = 1; |
| 10037 | start_log.size = set_value2; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10038 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10039 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10040 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10041 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10042 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10043 | hdd_exit(); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10044 | return -EINVAL; |
| 10045 | } |
| 10046 | |
| 10047 | return 0; |
| 10048 | } |
| 10049 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10050 | /** |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10051 | * hdd_pktlog_clear_buff() - clear pktlog buffer |
| 10052 | * @hdd_ctx: hdd context |
| 10053 | * |
| 10054 | * Return: 0 for success or error. |
| 10055 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10056 | static int hdd_pktlog_clear_buff(struct hdd_context *hdd_ctx) |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10057 | { |
| 10058 | struct sir_wifi_start_log start_log; |
| 10059 | QDF_STATUS status; |
| 10060 | |
| 10061 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10062 | start_log.verbose_level = WLAN_LOG_LEVEL_OFF; |
| 10063 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10064 | start_log.user_triggered = 1; |
| 10065 | start_log.size = 0; |
| 10066 | start_log.is_pktlog_buff_clear = true; |
| 10067 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10068 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10069 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10070 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10071 | hdd_exit(); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10072 | return -EINVAL; |
| 10073 | } |
| 10074 | |
| 10075 | return 0; |
| 10076 | } |
| 10077 | |
| 10078 | |
| 10079 | /** |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10080 | * hdd_process_pktlog_command() - process pktlog command |
| 10081 | * @hdd_ctx: hdd context |
| 10082 | * @set_value: value set by user |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10083 | * @set_value2: pktlog buffer size value |
| 10084 | * |
| 10085 | * This function process pktlog command. |
| 10086 | * set_value2 only matters when set_value is 3 (set buff size) |
| 10087 | * otherwise we ignore it. |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10088 | * |
| 10089 | * Return: 0 for success or error. |
| 10090 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10091 | 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] | 10092 | int set_value2) |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10093 | { |
| 10094 | int ret; |
| 10095 | bool enable; |
| 10096 | uint8_t user_triggered = 0; |
| 10097 | |
| 10098 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 10099 | if (0 != ret) |
| 10100 | return ret; |
| 10101 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10102 | hdd_debug("set pktlog %d, set size %d", set_value, set_value2); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10103 | |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10104 | if (set_value > PKTLOG_CLEAR_BUFF) { |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10105 | hdd_err("invalid pktlog value %d", set_value); |
| 10106 | return -EINVAL; |
| 10107 | } |
| 10108 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10109 | if (set_value == PKTLOG_SET_BUFF_SIZE) { |
| 10110 | if (set_value2 <= 0) { |
| 10111 | hdd_err("invalid pktlog size %d", set_value2); |
| 10112 | return -EINVAL; |
| 10113 | } else if (set_value2 > MAX_PKTLOG_SIZE) { |
Venkata Sharath Chandra Manchala | 27e4490 | 2019-01-28 11:29:18 -0800 | [diff] [blame] | 10114 | hdd_err_rl("Pktlog size is large. max value is %uMB.", |
| 10115 | MAX_PKTLOG_SIZE); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10116 | return -EINVAL; |
| 10117 | } |
| 10118 | return hdd_pktlog_set_buff_size(hdd_ctx, set_value2); |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10119 | } else if (set_value == PKTLOG_CLEAR_BUFF) { |
| 10120 | return hdd_pktlog_clear_buff(hdd_ctx); |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10121 | } |
| 10122 | |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10123 | /* |
| 10124 | * set_value = 0 then disable packetlog |
| 10125 | * set_value = 1 enable packetlog forcefully |
| 10126 | * set_vlaue = 2 then disable packetlog if disabled through ini or |
| 10127 | * enable packetlog with AUTO type. |
| 10128 | */ |
| 10129 | enable = ((set_value > 0) && cds_is_packet_log_enabled()) ? |
| 10130 | true : false; |
| 10131 | |
| 10132 | if (1 == set_value) { |
| 10133 | enable = true; |
| 10134 | user_triggered = 1; |
| 10135 | } |
| 10136 | |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10137 | return hdd_pktlog_enable_disable(hdd_ctx, enable, user_triggered, 0); |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10138 | } |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 10139 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10140 | /** |
| 10141 | * hdd_pktlog_enable_disable() - Enable/Disable packet logging |
| 10142 | * @hdd_ctx: HDD context |
| 10143 | * @enable: Flag to enable/disable |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10144 | * @user_triggered: triggered through iwpriv |
| 10145 | * @size: buffer size to be used for packetlog |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10146 | * |
| 10147 | * Return: 0 on success; error number otherwise |
| 10148 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10149 | int hdd_pktlog_enable_disable(struct hdd_context *hdd_ctx, bool enable, |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10150 | uint8_t user_triggered, int size) |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10151 | { |
| 10152 | struct sir_wifi_start_log start_log; |
| 10153 | QDF_STATUS status; |
| 10154 | |
| 10155 | start_log.ring_id = RING_ID_PER_PACKET_STATS; |
| 10156 | start_log.verbose_level = |
| 10157 | enable ? WLAN_LOG_LEVEL_ACTIVE : WLAN_LOG_LEVEL_OFF; |
Srinivas Girigowda | c34f11d | 2016-02-25 16:02:42 -0800 | [diff] [blame] | 10158 | start_log.ini_triggered = cds_is_packet_log_enabled(); |
| 10159 | start_log.user_triggered = user_triggered; |
Poddar, Siddarth | 176c436 | 2016-10-03 12:25:00 +0530 | [diff] [blame] | 10160 | start_log.size = size; |
Poddar, Siddarth | ab99a27 | 2017-04-10 12:53:26 +0530 | [diff] [blame] | 10161 | start_log.is_pktlog_buff_clear = false; |
Poddar, Siddarth | eefe348 | 2016-09-21 18:12:59 +0530 | [diff] [blame] | 10162 | /* |
| 10163 | * Use "is_iwpriv_command" flag to distinguish iwpriv command from other |
| 10164 | * commands. Host uses this flag to decide whether to send pktlog |
| 10165 | * disable command to fw without sending pktlog enable command |
| 10166 | * previously. For eg, If vendor sends pktlog disable command without |
| 10167 | * sending pktlog enable command, then host discards the packet |
| 10168 | * but for iwpriv command, host will send it to fw. |
| 10169 | */ |
| 10170 | start_log.is_iwpriv_command = 1; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10171 | status = sme_wifi_start_logger(hdd_ctx->mac_handle, start_log); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10172 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10173 | hdd_err("sme_wifi_start_logger failed(err=%d)", status); |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10174 | hdd_exit(); |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10175 | return -EINVAL; |
| 10176 | } |
| 10177 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10178 | if (enable == true) |
| 10179 | hdd_ctx->is_pktlog_enabled = 1; |
| 10180 | else |
| 10181 | hdd_ctx->is_pktlog_enabled = 0; |
| 10182 | |
Srinivas Girigowda | d9e6f7b | 2016-02-01 19:37:52 -0800 | [diff] [blame] | 10183 | return 0; |
| 10184 | } |
| 10185 | #endif /* REMOVE_PKT_LOG */ |
| 10186 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10187 | void hdd_free_mac_address_lists(struct hdd_context *hdd_ctx) |
| 10188 | { |
| 10189 | hdd_debug("Resetting MAC address lists"); |
hangtian | 127c953 | 2019-01-12 13:29:07 +0800 | [diff] [blame] | 10190 | qdf_mem_zero(hdd_ctx->provisioned_mac_addr, |
| 10191 | sizeof(hdd_ctx->provisioned_mac_addr)); |
| 10192 | qdf_mem_zero(hdd_ctx->derived_mac_addr, |
| 10193 | sizeof(hdd_ctx->derived_mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10194 | hdd_ctx->num_provisioned_addr = 0; |
| 10195 | hdd_ctx->num_derived_addr = 0; |
| 10196 | hdd_ctx->provisioned_intf_addr_mask = 0; |
| 10197 | hdd_ctx->derived_intf_addr_mask = 0; |
| 10198 | } |
| 10199 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10200 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10201 | * hdd_get_platform_wlan_mac_buff() - API to query platform driver |
| 10202 | * for MAC address |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10203 | * @dev: Device Pointer |
| 10204 | * @num: Number of Valid Mac address |
| 10205 | * |
| 10206 | * Return: Pointer to MAC address buffer |
| 10207 | */ |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10208 | static uint8_t *hdd_get_platform_wlan_mac_buff(struct device *dev, |
| 10209 | uint32_t *num) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10210 | { |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10211 | return pld_get_wlan_mac_address(dev, num); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10212 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10213 | |
| 10214 | /** |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10215 | * hdd_get_platform_wlan_derived_mac_buff() - API to query platform driver |
| 10216 | * for derived MAC address |
| 10217 | * @dev: Device Pointer |
| 10218 | * @num: Number of Valid Mac address |
| 10219 | * |
| 10220 | * Return: Pointer to MAC address buffer |
| 10221 | */ |
| 10222 | static uint8_t *hdd_get_platform_wlan_derived_mac_buff(struct device *dev, |
| 10223 | uint32_t *num) |
| 10224 | { |
| 10225 | return pld_get_wlan_derived_mac_address(dev, num); |
| 10226 | } |
| 10227 | |
| 10228 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10229 | * hdd_populate_random_mac_addr() - API to populate random mac addresses |
| 10230 | * @hdd_ctx: HDD Context |
| 10231 | * @num: Number of random mac addresses needed |
| 10232 | * |
| 10233 | * Generate random addresses using bit manipulation on the base mac address |
| 10234 | * |
| 10235 | * Return: None |
| 10236 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10237 | 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] | 10238 | { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10239 | uint32_t idx = hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10240 | uint32_t iter; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10241 | uint8_t *buf = NULL; |
| 10242 | uint8_t macaddr_b3, tmp_br3; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10243 | /* |
| 10244 | * Consider first provisioned mac address as source address to derive |
| 10245 | * remaining addresses |
| 10246 | */ |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10247 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10248 | uint8_t *src = hdd_ctx->provisioned_mac_addr[0].bytes; |
| 10249 | |
| 10250 | for (iter = 0; iter < num; ++iter, ++idx) { |
| 10251 | buf = hdd_ctx->derived_mac_addr[idx].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10252 | qdf_mem_copy(buf, src, QDF_MAC_ADDR_SIZE); |
| 10253 | macaddr_b3 = buf[3]; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10254 | tmp_br3 = ((macaddr_b3 >> 4 & INTF_MACADDR_MASK) + idx) & |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10255 | INTF_MACADDR_MASK; |
| 10256 | macaddr_b3 += tmp_br3; |
| 10257 | macaddr_b3 ^= (1 << INTF_MACADDR_MASK); |
| 10258 | buf[0] |= 0x02; |
| 10259 | buf[3] = macaddr_b3; |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10260 | hdd_debug(MAC_ADDRESS_STR, QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10261 | hdd_ctx->num_derived_addr++; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10262 | } |
| 10263 | } |
| 10264 | |
| 10265 | /** |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10266 | * hdd_platform_wlan_mac() - API to get mac addresses from platform driver |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10267 | * @hdd_ctx: HDD Context |
| 10268 | * |
| 10269 | * API to get mac addresses from platform driver and update the driver |
| 10270 | * structures and configure FW with the base mac address. |
| 10271 | * Return: int |
| 10272 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10273 | static int hdd_platform_wlan_mac(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10274 | { |
| 10275 | uint32_t no_of_mac_addr, iter; |
| 10276 | uint32_t max_mac_addr = QDF_MAX_CONCURRENCY_PERSONA; |
| 10277 | uint32_t mac_addr_size = QDF_MAC_ADDR_SIZE; |
| 10278 | uint8_t *addr, *buf; |
| 10279 | struct device *dev = hdd_ctx->parent_dev; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10280 | tSirMacAddr mac_addr; |
| 10281 | QDF_STATUS status; |
| 10282 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10283 | addr = hdd_get_platform_wlan_mac_buff(dev, &no_of_mac_addr); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10284 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10285 | if (no_of_mac_addr == 0 || !addr) { |
| 10286 | hdd_debug("No mac configured from platform driver"); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10287 | return -EINVAL; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10288 | } |
| 10289 | |
| 10290 | hdd_free_mac_address_lists(hdd_ctx); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10291 | |
| 10292 | if (no_of_mac_addr > max_mac_addr) |
| 10293 | no_of_mac_addr = max_mac_addr; |
| 10294 | |
| 10295 | qdf_mem_copy(&mac_addr, addr, mac_addr_size); |
| 10296 | |
| 10297 | for (iter = 0; iter < no_of_mac_addr; ++iter, addr += mac_addr_size) { |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10298 | buf = hdd_ctx->provisioned_mac_addr[iter].bytes; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10299 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10300 | hdd_info("provisioned MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10301 | QDF_MAC_ADDR_ARRAY(buf)); |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10302 | } |
| 10303 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10304 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10305 | hdd_ctx->num_provisioned_addr = no_of_mac_addr; |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 10306 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10307 | if (hdd_ctx->config->mac_provision) { |
| 10308 | addr = hdd_get_platform_wlan_derived_mac_buff(dev, |
| 10309 | &no_of_mac_addr); |
| 10310 | |
| 10311 | if (no_of_mac_addr == 0 || !addr) |
| 10312 | hdd_warn("No derived address from platform driver"); |
| 10313 | else if (no_of_mac_addr > |
| 10314 | (max_mac_addr - hdd_ctx->num_provisioned_addr)) |
| 10315 | no_of_mac_addr = (max_mac_addr - |
| 10316 | hdd_ctx->num_provisioned_addr); |
| 10317 | |
| 10318 | for (iter = 0; iter < no_of_mac_addr; ++iter, |
| 10319 | addr += mac_addr_size) { |
| 10320 | buf = hdd_ctx->derived_mac_addr[iter].bytes; |
| 10321 | qdf_mem_copy(buf, addr, QDF_MAC_ADDR_SIZE); |
| 10322 | hdd_debug("derived MAC Addr [%d]" MAC_ADDRESS_STR, iter, |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 10323 | QDF_MAC_ADDR_ARRAY(buf)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10324 | } |
| 10325 | hdd_ctx->num_derived_addr = no_of_mac_addr; |
| 10326 | } |
| 10327 | |
| 10328 | no_of_mac_addr = hdd_ctx->num_provisioned_addr + |
| 10329 | hdd_ctx->num_derived_addr; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10330 | if (no_of_mac_addr < max_mac_addr) |
| 10331 | hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - |
| 10332 | no_of_mac_addr); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10333 | |
| 10334 | status = sme_set_custom_mac_addr(mac_addr); |
| 10335 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10336 | return -EAGAIN; |
| 10337 | |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10338 | return 0; |
| 10339 | } |
| 10340 | |
| 10341 | /** |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10342 | * hdd_update_mac_addr_to_fw() - API to update wlan mac addresses to FW |
| 10343 | * @hdd_ctx: HDD Context |
| 10344 | * |
| 10345 | * Update MAC address to FW. If MAC address passed by FW is invalid, host |
| 10346 | * will generate its own MAC and update it to FW. |
| 10347 | * |
| 10348 | * Return: 0 for success |
| 10349 | * Non-zero error code for failure |
| 10350 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10351 | 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] | 10352 | { |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10353 | tSirMacAddr custom_mac_addr; |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10354 | QDF_STATUS status; |
| 10355 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10356 | if (hdd_ctx->num_provisioned_addr) |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10357 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10358 | &hdd_ctx->provisioned_mac_addr[0].bytes[0], |
| 10359 | sizeof(tSirMacAddr)); |
| 10360 | else |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10361 | qdf_mem_copy(&custom_mac_addr, |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10362 | &hdd_ctx->derived_mac_addr[0].bytes[0], |
| 10363 | sizeof(tSirMacAddr)); |
Jeff Johnson | 374c085 | 2019-03-10 19:02:07 -0700 | [diff] [blame] | 10364 | status = sme_set_custom_mac_addr(custom_mac_addr); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10365 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10366 | return -EAGAIN; |
| 10367 | return 0; |
| 10368 | } |
| 10369 | |
| 10370 | /** |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10371 | * hdd_initialize_mac_address() - API to get wlan mac addresses |
| 10372 | * @hdd_ctx: HDD Context |
| 10373 | * |
| 10374 | * Get MAC addresses from platform driver or wlan_mac.bin. If platform driver |
| 10375 | * is provisioned with mac addresses, driver uses it, else it will use |
| 10376 | * wlan_mac.bin to update HW MAC addresses. |
| 10377 | * |
| 10378 | * Return: None |
| 10379 | */ |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10380 | static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx) |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10381 | { |
| 10382 | QDF_STATUS status; |
| 10383 | int ret; |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10384 | bool update_mac_addr_to_fw = true; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10385 | |
Yuanyuan Liu | 7145eb2 | 2016-12-01 10:59:29 -0800 | [diff] [blame] | 10386 | ret = hdd_platform_wlan_mac(hdd_ctx); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10387 | if (hdd_ctx->config->mac_provision || !ret) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10388 | hdd_info("using MAC address from platform driver"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10389 | return ret; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10390 | } |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10391 | |
| 10392 | status = hdd_update_mac_config(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10393 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 10394 | hdd_info("using MAC address from wlan_mac.bin"); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10395 | return 0; |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10396 | } |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10397 | |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10398 | hdd_info("using default MAC address"); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10399 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10400 | /* Use fw provided MAC */ |
| 10401 | if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) { |
| 10402 | hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false); |
| 10403 | update_mac_addr_to_fw = false; |
| 10404 | return 0; |
| 10405 | } else if (hdd_generate_macaddr_auto(hdd_ctx) != 0) { |
| 10406 | struct qdf_mac_addr mac_addr; |
| 10407 | |
| 10408 | hdd_err("MAC failure from device serial no."); |
Jeff Johnson | 51a8052 | 2018-12-11 20:19:44 -0800 | [diff] [blame] | 10409 | qdf_get_random_bytes(&mac_addr, sizeof(mac_addr)); |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10410 | /* |
| 10411 | * Reset multicast bit (bit-0) and set |
| 10412 | * locally-administered bit |
| 10413 | */ |
| 10414 | mac_addr.bytes[0] = 0x2; |
| 10415 | hdd_update_macaddr(hdd_ctx, mac_addr, true); |
| 10416 | } |
| 10417 | |
| 10418 | if (update_mac_addr_to_fw) { |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10419 | ret = hdd_update_mac_addr_to_fw(hdd_ctx); |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 10420 | if (ret) |
Yuanyuan Liu | 1c2caa3 | 2016-11-07 17:13:48 -0800 | [diff] [blame] | 10421 | hdd_err("MAC address out-of-sync, ret:%d", ret); |
Yuanyuan Liu | 245a3e4 | 2016-09-14 12:15:16 -0700 | [diff] [blame] | 10422 | } |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 10423 | return ret; |
Komal Seelam | 92fff91 | 2016-03-24 11:51:41 +0530 | [diff] [blame] | 10424 | } |
| 10425 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10426 | static int hdd_set_smart_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10427 | { |
| 10428 | int vdev_id = 0; |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10429 | QDF_STATUS status; |
| 10430 | bool smart_chainmask_enabled; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10431 | int param_id = WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10432 | int vpdev = PDEV_CMD; |
| 10433 | int ret; |
| 10434 | |
Sourav Mohapatra | 0f3b857 | 2018-09-12 10:03:51 +0530 | [diff] [blame] | 10435 | status = ucfg_get_smart_chainmask_enabled(hdd_ctx->psoc, |
| 10436 | &smart_chainmask_enabled); |
| 10437 | if (QDF_IS_STATUS_ERROR(status)) |
| 10438 | return -EINVAL; |
| 10439 | |
| 10440 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10441 | (int)smart_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10442 | if (ret) |
| 10443 | hdd_err("WMI_PDEV_PARAM_SMART_CHAINMASK_SCHEME failed %d", ret); |
| 10444 | |
| 10445 | return ret; |
| 10446 | } |
| 10447 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10448 | static int hdd_set_alternative_chainmask_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10449 | { |
| 10450 | int vdev_id = 0; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10451 | QDF_STATUS status; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10452 | int param_id = WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10453 | bool alternative_chainmask_enabled; |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10454 | int vpdev = PDEV_CMD; |
| 10455 | int ret; |
| 10456 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10457 | status = ucfg_get_alternative_chainmask_enabled( |
| 10458 | hdd_ctx->psoc, |
| 10459 | &alternative_chainmask_enabled); |
| 10460 | if (QDF_IS_STATUS_ERROR(status)) |
| 10461 | return -EINVAL; |
| 10462 | |
| 10463 | ret = sme_cli_set_command(vdev_id, param_id, |
| 10464 | (int)alternative_chainmask_enabled, vpdev); |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10465 | if (ret) |
| 10466 | hdd_err("WMI_PDEV_PARAM_ALTERNATIVE_CHAINMASK_SCHEME failed %d", |
| 10467 | ret); |
| 10468 | |
| 10469 | return ret; |
| 10470 | } |
| 10471 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10472 | static int hdd_set_ani_enabled(struct hdd_context *hdd_ctx) |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10473 | { |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10474 | QDF_STATUS status; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10475 | int vdev_id = 0; |
| 10476 | int param_id = WMI_PDEV_PARAM_ANI_ENABLE; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10477 | bool value; |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10478 | int vpdev = PDEV_CMD; |
| 10479 | int ret; |
| 10480 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10481 | status = ucfg_fwol_get_ani_enabled(hdd_ctx->psoc, &value); |
| 10482 | if (QDF_IS_STATUS_ERROR(status)) |
| 10483 | return -EINVAL; |
| 10484 | |
| 10485 | ret = sme_cli_set_command(vdev_id, param_id, (int)value, vpdev); |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10486 | if (ret) |
| 10487 | hdd_err("WMI_PDEV_PARAM_ANI_ENABLE failed %d", ret); |
| 10488 | |
| 10489 | return ret; |
| 10490 | } |
| 10491 | |
Jeff Johnson | 89c66ff | 2016-04-22 15:21:37 -0700 | [diff] [blame] | 10492 | /** |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10493 | * hdd_pre_enable_configure() - Configurations prior to cds_enable |
| 10494 | * @hdd_ctx: HDD context |
| 10495 | * |
| 10496 | * Pre configurations to be done at lower layer before calling cds enable. |
| 10497 | * |
| 10498 | * Return: 0 on success and errno on failure. |
| 10499 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10500 | static int hdd_pre_enable_configure(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10501 | { |
| 10502 | int ret; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10503 | uint8_t val = 0; |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10504 | QDF_STATUS status; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10505 | uint32_t arp_ac_category; |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10506 | void *soc = cds_get_context(QDF_MODULE_ID_SOC); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10507 | |
Leo Chang | fdb45c3 | 2016-10-28 11:09:23 -0700 | [diff] [blame] | 10508 | cdp_register_pause_cb(soc, wlan_hdd_txrx_pause_cb); |
Ajit Pal Singh | 5d26961 | 2018-04-19 16:29:12 +0530 | [diff] [blame] | 10509 | /* Register HL netdev flow control callback */ |
| 10510 | cdp_hl_fc_register(soc, wlan_hdd_txrx_pause_cb); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10511 | |
| 10512 | /* |
| 10513 | * Note that the cds_pre_enable() sequence triggers the cfg download. |
| 10514 | * The cfg download must occur before we update the SME config |
| 10515 | * since the SME config operation must access the cfg database |
| 10516 | */ |
| 10517 | status = hdd_set_sme_config(hdd_ctx); |
| 10518 | |
| 10519 | if (QDF_STATUS_SUCCESS != status) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10520 | hdd_err("Failed hdd_set_sme_config: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10521 | ret = qdf_status_to_os_return(status); |
| 10522 | goto out; |
| 10523 | } |
| 10524 | |
Tushnim Bhattacharyya | ba8ee93 | 2017-03-23 09:27:40 -0700 | [diff] [blame] | 10525 | status = hdd_set_policy_mgr_user_cfg(hdd_ctx); |
| 10526 | if (QDF_STATUS_SUCCESS != status) { |
| 10527 | hdd_alert("Failed hdd_set_policy_mgr_user_cfg: %d", status); |
| 10528 | ret = qdf_status_to_os_return(status); |
| 10529 | goto out; |
| 10530 | } |
| 10531 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10532 | status = ucfg_mlme_get_tx_chainmask_1ss(hdd_ctx->psoc, &val); |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 10533 | if (QDF_STATUS_SUCCESS != status) { |
| 10534 | hdd_err("Get tx_chainmask_1ss from mlme failed"); |
| 10535 | ret = qdf_status_to_os_return(status); |
| 10536 | goto out; |
| 10537 | } |
| 10538 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS, val, |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10539 | PDEV_CMD); |
| 10540 | if (0 != ret) { |
| 10541 | hdd_err("WMI_PDEV_PARAM_TX_CHAIN_MASK_1SS failed %d", ret); |
| 10542 | goto out; |
| 10543 | } |
| 10544 | |
Jeff Johnson | a89e25d | 2017-02-24 12:25:07 -0800 | [diff] [blame] | 10545 | ret = hdd_set_smart_chainmask_enabled(hdd_ctx); |
| 10546 | if (ret) |
| 10547 | goto out; |
| 10548 | |
| 10549 | ret = hdd_set_alternative_chainmask_enabled(hdd_ctx); |
| 10550 | if (ret) |
| 10551 | goto out; |
| 10552 | |
Jeff Johnson | 12a744b | 2017-04-04 08:19:37 -0700 | [diff] [blame] | 10553 | ret = hdd_set_ani_enabled(hdd_ctx); |
| 10554 | if (ret) |
| 10555 | goto out; |
| 10556 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10557 | status = ucfg_get_arp_ac_category(hdd_ctx->psoc, &arp_ac_category); |
| 10558 | |
| 10559 | if (QDF_IS_STATUS_ERROR(status)) |
| 10560 | return -EINVAL; |
| 10561 | |
Naveen Rawat | 247a868 | 2017-06-05 15:00:31 -0700 | [diff] [blame] | 10562 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_ARP_AC_OVERRIDE, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10563 | arp_ac_category, |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10564 | PDEV_CMD); |
| 10565 | if (0 != ret) { |
| 10566 | hdd_err("WMI_PDEV_PARAM_ARP_AC_OVERRIDE ac: %d ret: %d", |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 10567 | arp_ac_category, ret); |
Srinivas Girigowda | 70e169a | 2017-03-07 23:55:57 -0800 | [diff] [blame] | 10568 | goto out; |
| 10569 | } |
| 10570 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10571 | status = hdd_set_sme_chan_list(hdd_ctx); |
| 10572 | if (status != QDF_STATUS_SUCCESS) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10573 | hdd_err("Failed to init channel list: %d", status); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10574 | ret = qdf_status_to_os_return(status); |
| 10575 | goto out; |
| 10576 | } |
| 10577 | |
| 10578 | /* Apply the cfg.ini to cfg.dat */ |
Krunal Soni | df0f874 | 2016-09-26 14:56:31 -0700 | [diff] [blame] | 10579 | if (!hdd_update_config_cfg(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 10580 | hdd_err("config update failed"); |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10581 | ret = -EINVAL; |
| 10582 | goto out; |
| 10583 | } |
| 10584 | |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10585 | |
| 10586 | hdd_init_channel_avoidance(hdd_ctx); |
| 10587 | |
| 10588 | out: |
| 10589 | return ret; |
| 10590 | } |
| 10591 | |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10592 | #ifdef FEATURE_P2P_LISTEN_OFFLOAD |
Prashanth Bhatta | 0799875 | 2016-04-28 12:35:33 -0700 | [diff] [blame] | 10593 | /** |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10594 | * wlan_hdd_p2p_lo_event_callback - P2P listen offload stop event handler |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10595 | * @context: context registered with sme_register_p2p_lo_event(). HDD |
| 10596 | * always registers a hdd context pointer |
| 10597 | * @evt:event structure pointer |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10598 | * |
| 10599 | * This is the p2p listen offload stop event handler, it sends vendor |
| 10600 | * event back to supplicant to notify the stop reason. |
| 10601 | * |
| 10602 | * Return: None |
| 10603 | */ |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10604 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10605 | struct sir_p2p_lo_event *evt) |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10606 | { |
Jeff Johnson | f7e36d6 | 2018-07-04 21:14:02 -0700 | [diff] [blame] | 10607 | struct hdd_context *hdd_ctx = context; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10608 | struct sk_buff *vendor_event; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 10609 | struct hdd_adapter *adapter; |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10610 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10611 | hdd_enter(); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10612 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 10613 | if (!hdd_ctx) { |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10614 | hdd_err("Invalid HDD context pointer"); |
| 10615 | return; |
| 10616 | } |
| 10617 | |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10618 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, evt->vdev_id); |
| 10619 | if (!adapter) { |
| 10620 | hdd_err("Cannot find adapter by vdev_id = %d", |
| 10621 | evt->vdev_id); |
| 10622 | return; |
| 10623 | } |
| 10624 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10625 | vendor_event = |
| 10626 | cfg80211_vendor_event_alloc(hdd_ctx->wiphy, |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10627 | &(adapter->wdev), sizeof(uint32_t) + NLMSG_HDRLEN, |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10628 | QCA_NL80211_VENDOR_SUBCMD_P2P_LO_EVENT_INDEX, |
| 10629 | GFP_KERNEL); |
| 10630 | |
| 10631 | if (!vendor_event) { |
| 10632 | hdd_err("cfg80211_vendor_event_alloc failed"); |
| 10633 | return; |
| 10634 | } |
| 10635 | |
| 10636 | if (nla_put_u32(vendor_event, |
| 10637 | QCA_WLAN_VENDOR_ATTR_P2P_LISTEN_OFFLOAD_STOP_REASON, |
| 10638 | evt->reason_code)) { |
| 10639 | hdd_err("nla put failed"); |
| 10640 | kfree_skb(vendor_event); |
| 10641 | return; |
| 10642 | } |
| 10643 | |
| 10644 | cfg80211_vendor_event(vendor_event, GFP_KERNEL); |
Peng Xu | 5c68281 | 2017-08-06 07:39:13 -0700 | [diff] [blame] | 10645 | hdd_debug("Sent P2P_LISTEN_OFFLOAD_STOP event for vdev_id = %d", |
| 10646 | evt->vdev_id); |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10647 | } |
Rachit Kankane | 026e77a | 2018-07-31 16:21:09 +0530 | [diff] [blame] | 10648 | #else |
| 10649 | static void wlan_hdd_p2p_lo_event_callback(void *context, |
| 10650 | struct sir_p2p_lo_event *evt) |
| 10651 | { |
| 10652 | } |
| 10653 | #endif |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10654 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10655 | #ifdef FEATURE_WLAN_DYNAMIC_CVM |
| 10656 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10657 | { |
| 10658 | return sme_set_vc_mode_config(hdd_ctx->config->vc_mode_cfg_bitmap); |
| 10659 | } |
| 10660 | #else |
| 10661 | static inline int hdd_set_vc_mode_config(struct hdd_context *hdd_ctx) |
| 10662 | { |
| 10663 | return QDF_STATUS_SUCCESS; |
| 10664 | } |
| 10665 | #endif |
| 10666 | |
Peng Xu | 8fdaa49 | 2016-06-22 10:20:47 -0700 | [diff] [blame] | 10667 | /** |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10668 | * hdd_adaptive_dwelltime_init() - initialization for adaptive dwell time config |
| 10669 | * @hdd_ctx: HDD context |
| 10670 | * |
| 10671 | * This function sends the adaptive dwell time config configuration to the |
| 10672 | * firmware via WMA |
| 10673 | * |
| 10674 | * Return: 0 - success, < 0 - failure |
| 10675 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10676 | static int hdd_adaptive_dwelltime_init(struct hdd_context *hdd_ctx) |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10677 | { |
| 10678 | QDF_STATUS status; |
| 10679 | struct adaptive_dwelltime_params dwelltime_params; |
| 10680 | |
Harprit Chhabada | d59ae76 | 2019-01-08 16:40:43 -0800 | [diff] [blame] | 10681 | status = ucfg_fwol_get_all_adaptive_dwelltime_params(hdd_ctx->psoc, |
| 10682 | &dwelltime_params); |
| 10683 | status = ucfg_fwol_set_adaptive_dwelltime_config(&dwelltime_params); |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10684 | |
| 10685 | hdd_debug("Sending Adaptive Dwelltime Configuration to fw"); |
| 10686 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10687 | hdd_err("Failed to send Adaptive Dwelltime configuration!"); |
| 10688 | return -EAGAIN; |
| 10689 | } |
| 10690 | return 0; |
| 10691 | } |
| 10692 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10693 | int hdd_dbs_scan_selection_init(struct hdd_context *hdd_ctx) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10694 | { |
| 10695 | QDF_STATUS status; |
| 10696 | struct wmi_dbs_scan_sel_params dbs_scan_params; |
| 10697 | uint32_t i = 0; |
| 10698 | uint8_t count = 0, numentries = 0; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10699 | uint8_t dual_mac_feature; |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10700 | uint8_t dbs_scan_config[CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10701 | * CDS_DBS_SCAN_CLIENTS_MAX]; |
| 10702 | |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10703 | status = ucfg_policy_mgr_get_dual_mac_feature(hdd_ctx->psoc, |
| 10704 | &dual_mac_feature); |
| 10705 | |
| 10706 | if (status != QDF_STATUS_SUCCESS) { |
| 10707 | hdd_err("can't get dual mac feature flag"); |
| 10708 | return -EINVAL; |
| 10709 | } |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10710 | /* check if DBS is enabled or supported */ |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 10711 | if ((dual_mac_feature == DISABLE_DBS_CXN_AND_SCAN) || |
| 10712 | (dual_mac_feature == ENABLE_DBS_CXN_AND_DISABLE_DBS_SCAN)) |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10713 | return -EINVAL; |
| 10714 | |
| 10715 | hdd_string_to_u8_array(hdd_ctx->config->dbs_scan_selection, |
| 10716 | dbs_scan_config, &numentries, |
| 10717 | (CDS_DBS_SCAN_PARAM_PER_CLIENT |
| 10718 | * CDS_DBS_SCAN_CLIENTS_MAX)); |
| 10719 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10720 | if (!numentries) { |
Dustin Brown | 6a8d39b | 2018-08-14 15:27:26 -0700 | [diff] [blame] | 10721 | hdd_debug("Do not send scan_selection_config"); |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10722 | return 0; |
| 10723 | } |
| 10724 | |
| 10725 | /* hdd_set_fw_log_params */ |
| 10726 | dbs_scan_params.num_clients = 0; |
| 10727 | while (count < (numentries - 2)) { |
| 10728 | dbs_scan_params.module_id[i] = dbs_scan_config[count]; |
| 10729 | dbs_scan_params.num_dbs_scans[i] = dbs_scan_config[count + 1]; |
| 10730 | dbs_scan_params.num_non_dbs_scans[i] = |
| 10731 | dbs_scan_config[count + 2]; |
| 10732 | dbs_scan_params.num_clients++; |
| 10733 | hdd_debug("module:%d NDS:%d NNDS:%d", |
| 10734 | dbs_scan_params.module_id[i], |
| 10735 | dbs_scan_params.num_dbs_scans[i], |
| 10736 | dbs_scan_params.num_non_dbs_scans[i]); |
| 10737 | count += CDS_DBS_SCAN_PARAM_PER_CLIENT; |
| 10738 | i++; |
| 10739 | } |
| 10740 | |
| 10741 | dbs_scan_params.pdev_id = 0; |
| 10742 | |
| 10743 | hdd_debug("clients:%d pdev:%d", |
| 10744 | dbs_scan_params.num_clients, dbs_scan_params.pdev_id); |
| 10745 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10746 | status = sme_set_dbs_scan_selection_config(hdd_ctx->mac_handle, |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10747 | &dbs_scan_params); |
| 10748 | hdd_debug("Sending DBS Scan Selection Configuration to fw"); |
| 10749 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10750 | hdd_err("Failed to send DBS Scan selection configuration!"); |
| 10751 | return -EAGAIN; |
| 10752 | } |
| 10753 | return 0; |
| 10754 | } |
| 10755 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10756 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 10757 | /** |
| 10758 | * hdd_set_auto_shutdown_cb() - Set auto shutdown callback |
| 10759 | * @hdd_ctx: HDD context |
| 10760 | * |
| 10761 | * Set auto shutdown callback to get indications from firmware to indicate |
| 10762 | * userspace to shutdown WLAN after a configured amount of inactivity. |
| 10763 | * |
| 10764 | * Return: 0 on success and errno on failure. |
| 10765 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10766 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10767 | { |
| 10768 | QDF_STATUS status; |
| 10769 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 10770 | if (!hdd_ctx->config->wlan_auto_shutdown) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10771 | return 0; |
| 10772 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10773 | status = sme_set_auto_shutdown_cb(hdd_ctx->mac_handle, |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10774 | wlan_hdd_auto_shutdown_cb); |
| 10775 | if (status != QDF_STATUS_SUCCESS) |
| 10776 | hdd_err("Auto shutdown feature could not be enabled: %d", |
| 10777 | status); |
| 10778 | |
| 10779 | return qdf_status_to_os_return(status); |
| 10780 | } |
| 10781 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10782 | static int hdd_set_auto_shutdown_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10783 | { |
| 10784 | return 0; |
| 10785 | } |
| 10786 | #endif |
| 10787 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10788 | #ifdef MWS_COEX |
| 10789 | /** |
| 10790 | * hdd_set_mws_coex() - Set MWS coex configurations |
| 10791 | * @hdd_ctx: HDD context |
| 10792 | * |
| 10793 | * This function sends MWS-COEX 4G quick FTDM and |
| 10794 | * MWS-COEX 5G-NR power limit to FW |
| 10795 | * |
| 10796 | * Return: 0 on success and errno on failure. |
| 10797 | */ |
| 10798 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10799 | { |
| 10800 | int ret = 0; |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10801 | uint32_t mws_coex_4g_quick_tdm = 0, mws_coex_5g_nr_pwr_limit = 0; |
| 10802 | |
| 10803 | ucfg_mlme_get_mws_coex_4g_quick_tdm(hdd_ctx->psoc, |
| 10804 | &mws_coex_4g_quick_tdm); |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10805 | |
| 10806 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_4G_ALLOW_QUICK_FTDM, |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10807 | mws_coex_4g_quick_tdm, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10808 | PDEV_CMD); |
| 10809 | if (ret) { |
| 10810 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10811 | return ret; |
| 10812 | } |
| 10813 | |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10814 | ucfg_mlme_get_mws_coex_5g_nr_pwr_limit(hdd_ctx->psoc, |
| 10815 | &mws_coex_5g_nr_pwr_limit); |
| 10816 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10817 | ret = sme_cli_set_command(0, WMI_PDEV_PARAM_MWSCOEX_SET_5GNR_PWR_LIMIT, |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10818 | mws_coex_5g_nr_pwr_limit, |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10819 | PDEV_CMD); |
| 10820 | if (ret) { |
| 10821 | hdd_warn("Unable to send MWS-COEX 4G quick FTDM policy"); |
| 10822 | return ret; |
| 10823 | } |
lifeng | db340e7 | 2018-11-20 00:50:20 +0800 | [diff] [blame] | 10824 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10825 | return ret; |
| 10826 | } |
| 10827 | #else |
| 10828 | static int hdd_init_mws_coex(struct hdd_context *hdd_ctx) |
| 10829 | { |
| 10830 | return 0; |
| 10831 | } |
| 10832 | #endif |
| 10833 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10834 | /** |
| 10835 | * hdd_features_init() - Init features |
| 10836 | * @hdd_ctx: HDD context |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10837 | * |
| 10838 | * Initialize features and their feature context after WLAN firmware is up. |
| 10839 | * |
| 10840 | * Return: 0 on success and errno on failure. |
| 10841 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10842 | static int hdd_features_init(struct hdd_context *hdd_ctx) |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10843 | { |
Jeff Johnson | 19ce8d0 | 2019-02-08 22:56:23 -0800 | [diff] [blame] | 10844 | struct tx_power_limit hddtxlimit; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10845 | QDF_STATUS status; |
| 10846 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10847 | mac_handle_t mac_handle; |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10848 | struct hdd_config *cfg; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10849 | bool b_cts2self, is_imps_enabled; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10850 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 10851 | hdd_enter(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10852 | |
Dustin Brown | ad698ae | 2018-09-05 17:19:30 -0700 | [diff] [blame] | 10853 | ret = hdd_update_country_code(hdd_ctx); |
| 10854 | if (ret) { |
| 10855 | hdd_err("Failed to update country code; errno:%d", ret); |
| 10856 | return -EINVAL; |
| 10857 | } |
| 10858 | |
Dundi Raviteja | eab3b8d | 2018-07-17 18:10:41 +0530 | [diff] [blame] | 10859 | ret = hdd_init_mws_coex(hdd_ctx); |
| 10860 | if (ret) |
| 10861 | hdd_warn("Error initializing mws-coex"); |
| 10862 | |
Kiran Kumar Lokere | 1a43bcf | 2018-05-15 15:51:58 -0700 | [diff] [blame] | 10863 | cfg = hdd_ctx->config; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10864 | /* FW capabilities received, Set the Dot11 mode */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10865 | mac_handle = hdd_ctx->mac_handle; |
| 10866 | sme_setdef_dot11mode(mac_handle); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10867 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 10868 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 10869 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10870 | |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10871 | /* Send Enable/Disable data stall detection cmd to FW */ |
| 10872 | sme_cli_set_command(0, WMI_PDEV_PARAM_DATA_STALL_DETECT_ENABLE, |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 10873 | cdp_cfg_get(cds_get_context(QDF_MODULE_ID_SOC), |
| 10874 | cfg_dp_enable_data_stall), PDEV_CMD); |
Poddar, Siddarth | 3703303 | 2017-10-11 15:47:40 +0530 | [diff] [blame] | 10875 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10876 | ucfg_mlme_get_go_cts2self_for_sta(hdd_ctx->psoc, &b_cts2self); |
Wu Gao | 9381621 | 2018-08-31 16:49:54 +0800 | [diff] [blame] | 10877 | if (b_cts2self) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10878 | sme_set_cts2self_for_p2p_go(mac_handle); |
Agrawal Ashish | 642ec9b | 2017-02-22 14:45:30 +0530 | [diff] [blame] | 10879 | |
Rachit Kankane | f6834c4 | 2018-08-02 18:47:50 +0530 | [diff] [blame] | 10880 | if (hdd_set_vc_mode_config(hdd_ctx)) |
Nachiket Kukade | 8983cf6 | 2017-10-12 18:14:48 +0530 | [diff] [blame] | 10881 | hdd_warn("Error in setting Voltage Corner mode config to FW"); |
| 10882 | |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 10883 | if (hdd_rx_ol_init(hdd_ctx)) |
| 10884 | hdd_err("Unable to initialize Rx LRO/GRO in fw"); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10885 | |
| 10886 | if (hdd_adaptive_dwelltime_init(hdd_ctx)) |
| 10887 | hdd_err("Unable to send adaptive dwelltime setting to FW"); |
| 10888 | |
Nitesh Shah | f9a09ff | 2017-05-22 15:46:25 +0530 | [diff] [blame] | 10889 | if (hdd_dbs_scan_selection_init(hdd_ctx)) |
| 10890 | hdd_err("Unable to send DBS scan selection setting to FW"); |
| 10891 | |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10892 | ret = hdd_init_thermal_info(hdd_ctx); |
| 10893 | if (ret) { |
| 10894 | hdd_err("Error while initializing thermal information"); |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 10895 | return ret; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10896 | } |
| 10897 | |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10898 | /** |
| 10899 | * In case of SSR/PDR, if pktlog was enabled manually before |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10900 | * SSR/PDR, then enable it again automatically after Wlan |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10901 | * device up. |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10902 | * During SSR/PDR, pktlog will be disabled as part of |
| 10903 | * hdd_features_deinit if pktlog is enabled in ini. |
| 10904 | * Re-enable pktlog in SSR case, if pktlog is enabled in ini. |
Poddar, Siddarth | 61fbc93 | 2017-12-19 14:27:55 +0530 | [diff] [blame] | 10905 | */ |
Rakshith Suresh Patkar | 6d95526 | 2019-03-13 16:51:50 +0530 | [diff] [blame] | 10906 | if (cds_is_packet_log_enabled() || |
| 10907 | (cds_is_driver_recovering() && hdd_ctx->is_pktlog_enabled)) |
Alok Kumar | 5a75b9d | 2018-08-31 10:55:43 +0530 | [diff] [blame] | 10908 | hdd_pktlog_enable_disable(hdd_ctx, true, 0, 0); |
Poddar, Siddarth | 66a4659 | 2017-02-22 11:44:44 +0530 | [diff] [blame] | 10909 | |
gaurank kathpalia | 3d2e385 | 2018-10-03 22:03:23 +0530 | [diff] [blame] | 10910 | hddtxlimit.txPower2g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_2G); |
| 10911 | hddtxlimit.txPower5g = ucfg_get_tx_power(hdd_ctx->psoc, BAND_5G); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10912 | status = sme_txpower_limit(mac_handle, &hddtxlimit); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10913 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 10914 | hdd_err("Error setting txlimit in sme: %d", status); |
| 10915 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10916 | wlan_hdd_tsf_init(hdd_ctx); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10917 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 10918 | status = sme_enable_disable_chanavoidind_event(mac_handle, 0); |
| 10919 | if (QDF_IS_STATUS_ERROR(status) && (status != QDF_STATUS_E_NOSUPPORT)) { |
| 10920 | hdd_err("Failed to disable Chan Avoidance Indication"); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10921 | return -EINVAL; |
Selvaraj, Sridhar | 371f55e | 2017-02-21 10:36:15 +0530 | [diff] [blame] | 10922 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10923 | |
| 10924 | /* register P2P Listen Offload event callback */ |
| 10925 | if (wma_is_p2p_lo_capable()) |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 10926 | sme_register_p2p_lo_event(mac_handle, hdd_ctx, |
| 10927 | wlan_hdd_p2p_lo_event_callback); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10928 | |
| 10929 | ret = hdd_set_auto_shutdown_cb(hdd_ctx); |
| 10930 | |
| 10931 | if (ret) |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 10932 | return -EINVAL; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10933 | |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10934 | wlan_hdd_init_chan_info(hdd_ctx); |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10935 | wlan_hdd_twt_init(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10936 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 10937 | hdd_exit(); |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10938 | return 0; |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10939 | } |
| 10940 | |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10941 | /** |
| 10942 | * hdd_features_deinit() - Deinit features |
| 10943 | * @hdd_ctx: HDD context |
| 10944 | * |
| 10945 | * De-Initialize features and their feature context. |
| 10946 | * |
| 10947 | * Return: none. |
| 10948 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10949 | static void hdd_features_deinit(struct hdd_context *hdd_ctx) |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10950 | { |
Varun Reddy Yeturu | 3c9f89c | 2018-04-18 19:10:34 -0700 | [diff] [blame] | 10951 | wlan_hdd_twt_deinit(hdd_ctx); |
Dustin Brown | 11638b7 | 2018-01-25 17:37:25 +0530 | [diff] [blame] | 10952 | wlan_hdd_deinit_chan_info(hdd_ctx); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10953 | wlan_hdd_tsf_deinit(hdd_ctx); |
jitiphil | 4e3bef4 | 2018-11-14 14:31:13 +0530 | [diff] [blame] | 10954 | if (cds_is_packet_log_enabled()) |
| 10955 | hdd_pktlog_enable_disable(hdd_ctx, false, 0, 0); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 10956 | } |
| 10957 | |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10958 | /** |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10959 | * hdd_register_bcn_cb() - register scan beacon callback |
| 10960 | * @hdd_ctx - Pointer to the HDD context |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10961 | * |
Sandeep Puligilla | 0a11f8d | 2017-06-23 15:53:29 -0700 | [diff] [blame] | 10962 | * Return: QDF_STATUS |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10963 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 10964 | 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] | 10965 | { |
| 10966 | QDF_STATUS status; |
| 10967 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 10968 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10969 | wlan_cfg80211_inform_bss_frame, |
| 10970 | SCAN_CB_TYPE_INFORM_BCN); |
| 10971 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Abhishek Singh | 5ffe9de | 2019-03-05 15:42:43 +0530 | [diff] [blame] | 10972 | hdd_err("failed to register SCAN_CB_TYPE_INFORM_BCN with status code %08d [x%08x]", |
| 10973 | status, status); |
| 10974 | return status; |
| 10975 | } |
| 10976 | |
| 10977 | status = ucfg_scan_register_bcn_cb(hdd_ctx->psoc, |
| 10978 | wlan_cfg80211_unlink_bss_list, |
| 10979 | SCAN_CB_TYPE_UNLINK_BSS); |
| 10980 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 10981 | hdd_err("failed to refister SCAN_CB_TYPE_FLUSH_BSS with status code %08d [x%08x]", |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 10982 | status, status); |
| 10983 | return status; |
| 10984 | } |
| 10985 | |
| 10986 | return QDF_STATUS_SUCCESS; |
| 10987 | } |
Arun Khandavalli | d4349a9 | 2016-07-25 11:10:43 +0530 | [diff] [blame] | 10988 | |
Gupta, Kapil | 96c7f2f | 2016-04-25 19:13:41 +0530 | [diff] [blame] | 10989 | /** |
Manjunathappa Prakash | a0cbc92 | 2018-05-08 19:48:34 -0700 | [diff] [blame] | 10990 | * hdd_v2_flow_pool_map() - Flow pool create callback when vdev is active |
| 10991 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 10992 | * |
| 10993 | * Return: none. |
| 10994 | */ |
| 10995 | static void hdd_v2_flow_pool_map(int vdev_id) |
| 10996 | { |
| 10997 | QDF_STATUS status; |
| 10998 | |
| 10999 | status = cdp_flow_pool_map(cds_get_context(QDF_MODULE_ID_SOC), |
| 11000 | cds_get_context(QDF_MODULE_ID_TXRX), |
| 11001 | vdev_id); |
| 11002 | /* |
| 11003 | * For Adrastea flow control v2 is based on FW MAP events, |
| 11004 | * so this above callback is not implemented. |
| 11005 | * Hence this is not actual failure. Dont return failure |
| 11006 | */ |
| 11007 | if ((status != QDF_STATUS_SUCCESS) && |
| 11008 | (status != QDF_STATUS_E_INVAL)) { |
| 11009 | hdd_err("vdev_id: %d, failed to create flow pool status %d", |
| 11010 | vdev_id, status); |
| 11011 | } |
| 11012 | } |
| 11013 | |
| 11014 | /** |
| 11015 | * hdd_v2_flow_pool_unmap() - Flow pool create callback when vdev is not active |
| 11016 | * @vdev_id: vdev_id, corresponds to flow_pool |
| 11017 | * |
| 11018 | * Return: none. |
| 11019 | */ |
| 11020 | static void hdd_v2_flow_pool_unmap(int vdev_id) |
| 11021 | { |
| 11022 | cdp_flow_pool_unmap(cds_get_context(QDF_MODULE_ID_SOC), |
| 11023 | cds_get_context(QDF_MODULE_ID_TXRX), vdev_id); |
| 11024 | } |
| 11025 | |
| 11026 | /** |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11027 | * hdd_action_oui_config() - Configure action_oui strings |
| 11028 | * @hdd_ctx: pointer to hdd context |
| 11029 | * |
| 11030 | * This is a HDD wrapper function which invokes ucfg api |
| 11031 | * of action_oui component to parse action oui strings. |
| 11032 | * |
| 11033 | * Return: None |
| 11034 | */ |
| 11035 | static void hdd_action_oui_config(struct hdd_context *hdd_ctx) |
| 11036 | { |
| 11037 | QDF_STATUS status; |
| 11038 | uint32_t id; |
| 11039 | uint8_t *str; |
| 11040 | |
| 11041 | if (!hdd_ctx->config->action_oui_enable) |
| 11042 | return; |
| 11043 | |
| 11044 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 11045 | str = hdd_ctx->config->action_oui_str[id]; |
| 11046 | if (!qdf_str_len(str)) |
| 11047 | continue; |
| 11048 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11049 | status = ucfg_action_oui_parse(hdd_ctx->psoc, str, id); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11050 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11051 | hdd_err("Failed to parse action_oui str: %u", id); |
| 11052 | } |
| 11053 | } |
| 11054 | |
| 11055 | /** |
| 11056 | * hdd_action_oui_send() - Send action_oui extensions to firmware |
| 11057 | * @hdd_ctx: pointer to hdd context |
| 11058 | * |
| 11059 | * This is a HDD wrapper function which invokes ucfg api |
| 11060 | * of action_oui component to send action oui extensions to firmware. |
| 11061 | * |
| 11062 | * Return: None |
| 11063 | */ |
| 11064 | static void hdd_action_oui_send(struct hdd_context *hdd_ctx) |
| 11065 | { |
| 11066 | QDF_STATUS status; |
| 11067 | |
| 11068 | if (!hdd_ctx->config->action_oui_enable) |
| 11069 | return; |
| 11070 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11071 | status = ucfg_action_oui_send(hdd_ctx->psoc); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11072 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11073 | hdd_err("Failed to send one or all action_ouis"); |
| 11074 | } |
| 11075 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11076 | static void hdd_hastings_bt_war_initialize(struct hdd_context *hdd_ctx) |
| 11077 | { |
| 11078 | if (hdd_ctx->config->iface_change_wait_time) |
| 11079 | hdd_hastings_bt_war_disable_fw(hdd_ctx); |
| 11080 | else |
| 11081 | hdd_hastings_bt_war_enable_fw(hdd_ctx); |
| 11082 | } |
| 11083 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11084 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11085 | * hdd_configure_cds() - Configure cds modules |
| 11086 | * @hdd_ctx: HDD context |
| 11087 | * @adapter: Primary adapter context |
| 11088 | * |
| 11089 | * Enable Cds modules after WLAN firmware is up. |
| 11090 | * |
| 11091 | * Return: 0 on success and errno on failure. |
| 11092 | */ |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11093 | int hdd_configure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11094 | { |
| 11095 | int ret; |
| 11096 | QDF_STATUS status; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11097 | int set_value; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11098 | mac_handle_t mac_handle; |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11099 | bool enable_rts_sifsbursting; |
| 11100 | uint8_t enable_phy_reg_retention; |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11101 | uint8_t max_mpdus_inampdu, is_force_1x1 = 0; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11102 | uint32_t num_abg_tx_chains = 0; |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11103 | uint16_t num_11b_tx_chains = 0; |
| 11104 | uint16_t num_11ag_tx_chains = 0; |
Manjunathappa Prakash | 7b0ad46 | 2018-04-15 00:37:16 -0700 | [diff] [blame] | 11105 | struct policy_mgr_dp_cbacks dp_cbs = {0}; |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11106 | bool value; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11107 | enum pmo_auto_pwr_detect_failure_mode auto_power_fail_mode; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11108 | bool bval = false; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11109 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11110 | mac_handle = hdd_ctx->mac_handle; |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11111 | |
| 11112 | hdd_action_oui_send(hdd_ctx); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11113 | status = ucfg_policy_mgr_get_force_1x1(hdd_ctx->psoc, &is_force_1x1); |
| 11114 | if (status != QDF_STATUS_SUCCESS) { |
| 11115 | hdd_err("Failed to get force 1x1 value"); |
| 11116 | goto out; |
| 11117 | } |
| 11118 | if (is_force_1x1) |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11119 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_SET_IOT_PATTERN, |
| 11120 | 1, PDEV_CMD); |
| 11121 | /* set chip power save failure detected callback */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11122 | sme_set_chip_pwr_save_fail_cb(mac_handle, |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11123 | hdd_chip_pwr_save_fail_detected_cb); |
| 11124 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11125 | status = ucfg_get_max_mpdus_inampdu(hdd_ctx->psoc, |
| 11126 | &max_mpdus_inampdu); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11127 | if (status) { |
| 11128 | hdd_err("Failed to get max mpdus in ampdu value"); |
| 11129 | goto out; |
| 11130 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11131 | |
| 11132 | if (max_mpdus_inampdu) { |
| 11133 | set_value = max_mpdus_inampdu; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11134 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_MAX_MPDUS_IN_AMPDU, |
| 11135 | set_value, PDEV_CMD); |
| 11136 | } |
| 11137 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11138 | status = ucfg_get_enable_rts_sifsbursting(hdd_ctx->psoc, |
| 11139 | &enable_rts_sifsbursting); |
Krunal Soni | df29bc4 | 2018-11-15 13:26:29 -0800 | [diff] [blame] | 11140 | if (status) { |
| 11141 | hdd_err("Failed to get rts sifs bursting value"); |
| 11142 | goto out; |
| 11143 | } |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11144 | |
| 11145 | if (enable_rts_sifsbursting) { |
| 11146 | set_value = enable_rts_sifsbursting; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11147 | sme_cli_set_command(0, |
| 11148 | (int)WMI_PDEV_PARAM_ENABLE_RTS_SIFS_BURSTING, |
| 11149 | set_value, PDEV_CMD); |
| 11150 | } |
| 11151 | |
Dustin Brown | 05d8130 | 2018-09-11 16:49:22 -0700 | [diff] [blame] | 11152 | ucfg_mlme_get_sap_get_peer_info(hdd_ctx->psoc, &value); |
Bala Venkatesh | 2fde2c6 | 2018-09-11 20:33:24 +0530 | [diff] [blame] | 11153 | if (value) { |
| 11154 | set_value = value; |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11155 | sme_cli_set_command(0, |
| 11156 | (int)WMI_PDEV_PARAM_PEER_STATS_INFO_ENABLE, |
| 11157 | set_value, PDEV_CMD); |
| 11158 | } |
| 11159 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11160 | status = ucfg_mlme_get_num_11b_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11161 | &num_11b_tx_chains); |
| 11162 | if (status != QDF_STATUS_SUCCESS) { |
| 11163 | hdd_err("Failed to get num_11b_tx_chains"); |
| 11164 | goto out; |
| 11165 | } |
| 11166 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11167 | status = ucfg_mlme_get_num_11ag_tx_chains(hdd_ctx->psoc, |
Pragaspathi Thilagaraj | 00bd8bc | 2018-08-18 01:23:01 +0530 | [diff] [blame] | 11168 | &num_11ag_tx_chains); |
| 11169 | if (status != QDF_STATUS_SUCCESS) { |
| 11170 | hdd_err("Failed to get num_11ag_tx_chains"); |
| 11171 | goto out; |
| 11172 | } |
| 11173 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 11174 | status = ucfg_mlme_get_vht_enable2x2(hdd_ctx->psoc, &bval); |
| 11175 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 11176 | hdd_err("unable to get vht_enable2x2"); |
| 11177 | |
| 11178 | if (!bval) { |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 11179 | if (num_11b_tx_chains > 1) |
| 11180 | num_11b_tx_chains = 1; |
| 11181 | if (num_11ag_tx_chains > 1) |
| 11182 | num_11ag_tx_chains = 1; |
| 11183 | } |
| 11184 | WMI_PDEV_PARAM_SET_11B_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11185 | num_11b_tx_chains); |
| 11186 | WMI_PDEV_PARAM_SET_11AG_TX_CHAIN_NUM(num_abg_tx_chains, |
| 11187 | num_11ag_tx_chains); |
| 11188 | sme_cli_set_command(0, (int)WMI_PDEV_PARAM_ABG_MODE_TX_CHAIN_NUM, |
| 11189 | num_abg_tx_chains, PDEV_CMD); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11190 | |
Paul Zhang | 02526cd | 2018-09-20 17:47:46 +0800 | [diff] [blame] | 11191 | if (!ucfg_reg_is_regdb_offloaded(hdd_ctx->psoc)) |
| 11192 | ucfg_reg_program_default_cc(hdd_ctx->pdev, |
| 11193 | hdd_ctx->reg.reg_domain); |
| 11194 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11195 | ret = hdd_pre_enable_configure(hdd_ctx); |
| 11196 | if (ret) { |
| 11197 | hdd_err("Failed to pre-configure cds"); |
| 11198 | goto out; |
| 11199 | } |
| 11200 | |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11201 | /* Always get latest IPA resources allocated from cds_open and configure |
| 11202 | * IPA module before configuring them to FW. Sequence required as crash |
| 11203 | * observed otherwise. |
| 11204 | */ |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11205 | if (ucfg_ipa_uc_ol_init(hdd_ctx->pdev, |
| 11206 | cds_get_context(QDF_MODULE_ID_QDF_DEVICE))) { |
Manikandan Mohan | 2e803a0 | 2017-02-14 14:57:53 -0800 | [diff] [blame] | 11207 | hdd_err("Failed to setup pipes"); |
| 11208 | goto out; |
Manikandan Mohan | bb8a7ee | 2017-02-09 11:26:53 -0800 | [diff] [blame] | 11209 | } |
| 11210 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11211 | /* |
| 11212 | * Start CDS which starts up the SME/MAC/HAL modules and everything |
| 11213 | * else |
| 11214 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11215 | status = cds_enable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11216 | |
| 11217 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11218 | hdd_err("cds_enable failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11219 | goto out; |
| 11220 | } |
| 11221 | |
| 11222 | status = hdd_post_cds_enable_config(hdd_ctx); |
| 11223 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11224 | hdd_err("hdd_post_cds_enable_config failed"); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11225 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11226 | } |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11227 | status = hdd_register_bcn_cb(hdd_ctx); |
| 11228 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Paul Zhang | e03cf4c | 2018-01-19 18:33:22 +0800 | [diff] [blame] | 11229 | hdd_err("hdd_register_bcn_cb failed"); |
Abhishek Singh | 6092fbb | 2017-01-25 18:10:31 +0530 | [diff] [blame] | 11230 | goto cds_disable; |
| 11231 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11232 | |
Dustin Brown | e7e71d3 | 2018-05-11 16:00:08 -0700 | [diff] [blame] | 11233 | ret = hdd_features_init(hdd_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11234 | if (ret) |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11235 | goto cds_disable; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11236 | |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 11237 | /* Donot disable rx offload on concurrency for lithium based targets */ |
| 11238 | if (!(hdd_ctx->target_type == TARGET_TYPE_QCA6290 || |
| 11239 | hdd_ctx->target_type == TARGET_TYPE_QCA6390)) |
| 11240 | if (hdd_ctx->ol_enable) |
| 11241 | dp_cbs.hdd_disable_rx_ol_in_concurrency = |
| 11242 | hdd_disable_rx_ol_in_concurrency; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11243 | dp_cbs.hdd_set_rx_mode_rps_cb = hdd_set_rx_mode_rps; |
jiad | bb47e13 | 2018-03-30 16:28:30 +0800 | [diff] [blame] | 11244 | 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] | 11245 | dp_cbs.hdd_v2_flow_pool_map = hdd_v2_flow_pool_map; |
| 11246 | dp_cbs.hdd_v2_flow_pool_unmap = hdd_v2_flow_pool_unmap; |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11247 | status = policy_mgr_register_dp_cb(hdd_ctx->psoc, &dp_cbs); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11248 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 11249 | hdd_debug("Failed to register DP cb with Policy Manager"); |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11250 | goto cds_disable; |
| 11251 | } |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11252 | status = policy_mgr_register_mode_change_cb(hdd_ctx->psoc, |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11253 | wlan_hdd_send_mode_change_event); |
| 11254 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 11255 | hdd_debug("Failed to register mode change cb with Policy Manager"); |
| 11256 | goto cds_disable; |
| 11257 | } |
Manjunathappa Prakash | 7b6cb00 | 2017-10-09 00:40:24 -0700 | [diff] [blame] | 11258 | |
Jeff Johnson | 8bb6111 | 2018-03-31 13:33:54 -0700 | [diff] [blame] | 11259 | if (hdd_green_ap_enable_egap(hdd_ctx)) |
Nachiket Kukade | fbd1afc | 2017-07-12 17:41:54 +0530 | [diff] [blame] | 11260 | hdd_debug("enhance green ap is not enabled"); |
| 11261 | |
Nachiket Kukade | dd30266 | 2017-07-13 17:31:44 +0530 | [diff] [blame] | 11262 | if (0 != wlan_hdd_set_wow_pulse(hdd_ctx, true)) |
| 11263 | hdd_debug("Failed to set wow pulse"); |
| 11264 | |
Ashish Kumar Dhanotiya | cb14b11 | 2018-01-19 19:26:44 +0530 | [diff] [blame] | 11265 | sme_cli_set_command(0, WMI_PDEV_PARAM_GCMP_SUPPORT_ENABLE, |
Manikandan Mohan | 66df7fc | 2019-01-08 17:57:05 -0800 | [diff] [blame] | 11266 | ucfg_fwol_get_gcmp_enable(hdd_ctx->psoc), PDEV_CMD); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11267 | |
| 11268 | auto_power_fail_mode = |
| 11269 | ucfg_pmo_get_auto_power_fail_mode(hdd_ctx->psoc); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11270 | sme_cli_set_command(0, WMI_PDEV_AUTO_DETECT_POWER_FAILURE, |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 11271 | auto_power_fail_mode, PDEV_CMD); |
Hanumanth Reddy Pothula | ab39595 | 2017-09-05 19:12:26 +0530 | [diff] [blame] | 11272 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11273 | status = ucfg_get_enable_phy_reg_retention(hdd_ctx->psoc, |
| 11274 | &enable_phy_reg_retention); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11275 | |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11276 | if (QDF_IS_STATUS_ERROR(status)) |
| 11277 | return -EINVAL; |
| 11278 | |
| 11279 | if (enable_phy_reg_retention) |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11280 | wma_cli_set_command(0, WMI_PDEV_PARAM_FAST_PWR_TRANSITION, |
Sourav Mohapatra | d9387d8 | 2018-09-07 12:28:52 +0530 | [diff] [blame] | 11281 | enable_phy_reg_retention, PDEV_CMD); |
Ravi Kumar Bokka | 990edcc | 2017-01-09 20:02:58 +0530 | [diff] [blame] | 11282 | |
Jeff Johnson | 0187c62 | 2019-01-04 06:39:44 -0800 | [diff] [blame] | 11283 | hdd_hastings_bt_war_initialize(hdd_ctx); |
| 11284 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11285 | return 0; |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11286 | |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11287 | cds_disable: |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11288 | cds_disable(hdd_ctx->psoc); |
Houston Hoffman | 8d1a6f0 | 2016-10-10 17:48:58 -0700 | [diff] [blame] | 11289 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11290 | out: |
| 11291 | return -EINVAL; |
| 11292 | } |
| 11293 | |
| 11294 | /** |
| 11295 | * hdd_deconfigure_cds() -De-Configure cds |
| 11296 | * @hdd_ctx: HDD context |
| 11297 | * |
| 11298 | * Deconfigure Cds modules before WLAN firmware is down. |
| 11299 | * |
| 11300 | * Return: 0 on success and errno on failure. |
| 11301 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11302 | static int hdd_deconfigure_cds(struct hdd_context *hdd_ctx) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11303 | { |
| 11304 | QDF_STATUS qdf_status; |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11305 | int ret = 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11306 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11307 | hdd_enter(); |
Yu Wang | f5d5b5f | 2017-05-25 22:38:32 +0800 | [diff] [blame] | 11308 | |
| 11309 | /* De-init features */ |
| 11310 | hdd_features_deinit(hdd_ctx); |
| 11311 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11312 | qdf_status = policy_mgr_deregister_mode_change_cb(hdd_ctx->psoc); |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 11313 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11314 | hdd_debug("Failed to deregister mode change cb with Policy Manager"); |
Yeshwanth Sriram Guntuka | 2d6204f | 2018-01-23 18:52:14 +0530 | [diff] [blame] | 11315 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11316 | qdf_status = cds_disable(hdd_ctx->psoc); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11317 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11318 | hdd_err("Failed to Disable the CDS Modules! :%d", |
| 11319 | qdf_status); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11320 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11321 | } |
| 11322 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 11323 | if (ucfg_ipa_uc_ol_deinit(hdd_ctx->pdev) != QDF_STATUS_SUCCESS) { |
Sravan Kumar Kairam | 7112171 | 2017-04-15 00:34:42 +0530 | [diff] [blame] | 11324 | hdd_err("Failed to disconnect pipes"); |
| 11325 | ret = -EINVAL; |
| 11326 | } |
| 11327 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11328 | hdd_exit(); |
Houston Hoffman | 6640cf3 | 2016-10-10 16:44:29 -0700 | [diff] [blame] | 11329 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11330 | } |
| 11331 | |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11332 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 11333 | static void hdd_deregister_policy_manager_callback( |
| 11334 | struct wlan_objmgr_psoc *psoc) |
| 11335 | { |
| 11336 | if (QDF_STATUS_SUCCESS != |
| 11337 | policy_mgr_deregister_hdd_cb(psoc)) { |
| 11338 | hdd_err("HDD callback deregister with policy manager failed"); |
| 11339 | } |
| 11340 | } |
| 11341 | #else |
| 11342 | static void hdd_deregister_policy_manager_callback( |
| 11343 | struct wlan_objmgr_psoc *psoc) |
| 11344 | { |
| 11345 | } |
| 11346 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11347 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11348 | 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] | 11349 | { |
| 11350 | void *hif_ctx; |
| 11351 | qdf_device_t qdf_ctx; |
| 11352 | QDF_STATUS qdf_status; |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11353 | bool is_recovery_stop = cds_is_driver_recovering(); |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11354 | int ret = 0; |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11355 | int debugfs_threads; |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11356 | struct target_psoc_info *tgt_hdl; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11357 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11358 | hdd_enter(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11359 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11360 | hdd_deregister_policy_manager_callback(hdd_ctx->psoc); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 11361 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11362 | qdf_ctx = cds_get_context(QDF_MODULE_ID_QDF_DEVICE); |
| 11363 | if (!qdf_ctx) { |
| 11364 | hdd_err("QDF device context NULL"); |
| 11365 | return -EINVAL; |
| 11366 | } |
| 11367 | |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11368 | cds_set_module_stop_in_progress(true); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11369 | |
Rajeev Kumar Sirasanagandla | 197d417 | 2018-02-15 19:03:29 +0530 | [diff] [blame] | 11370 | debugfs_threads = hdd_return_debugfs_threads_count(); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11371 | |
Dustin Brown | 3fdaaf6 | 2019-03-18 14:00:16 -0700 | [diff] [blame] | 11372 | if (debugfs_threads > 0 || hdd_ctx->is_wiphy_suspended) { |
| 11373 | hdd_warn("Debugfs threads %d, wiphy suspend %d", |
| 11374 | debugfs_threads, hdd_ctx->is_wiphy_suspended); |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11375 | |
Sourav Mohapatra | 808e3d4 | 2018-07-04 09:34:23 +0530 | [diff] [blame] | 11376 | if (IS_IDLE_STOP && !ftm_mode) { |
Dustin Brown | 4c66322 | 2018-10-23 14:19:36 -0700 | [diff] [blame] | 11377 | hdd_psoc_idle_timer_start(hdd_ctx); |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11378 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11379 | |
Dustin Brown | 7011182 | 2017-03-30 15:31:40 -0700 | [diff] [blame] | 11380 | return 0; |
| 11381 | } |
Rajeev Kumar | 86177c2 | 2017-03-16 19:44:39 -0700 | [diff] [blame] | 11382 | } |
| 11383 | |
Kabilan Kannan | 6edafeb | 2017-11-16 16:34:34 -0800 | [diff] [blame] | 11384 | /* free user wowl patterns */ |
| 11385 | hdd_free_user_wowl_ptrns(); |
| 11386 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11387 | switch (hdd_ctx->driver_status) { |
| 11388 | case DRIVER_MODULES_UNINITIALIZED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11389 | hdd_debug("Modules not initialized just return"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11390 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11391 | case DRIVER_MODULES_CLOSED: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11392 | hdd_debug("Modules already closed"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11393 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11394 | case DRIVER_MODULES_ENABLED: |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11395 | hdd_info("Wlan transitioning (CLOSED <- ENABLED)"); |
| 11396 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11397 | if (hdd_get_conparam() == QDF_GLOBAL_FTM_MODE || |
| 11398 | hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
Dustin Brown | 1a20b08 | 2018-08-03 17:27:15 -0700 | [diff] [blame] | 11399 | break; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11400 | |
Komal Seelam | f2136bb | 2016-09-28 18:30:44 +0530 | [diff] [blame] | 11401 | hdd_disable_power_management(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11402 | if (hdd_deconfigure_cds(hdd_ctx)) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11403 | hdd_err("Failed to de-configure CDS"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11404 | QDF_ASSERT(0); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11405 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11406 | } |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11407 | hdd_debug("successfully Disabled the CDS modules!"); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11408 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11409 | break; |
| 11410 | default: |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11411 | QDF_DEBUG_PANIC("Unknown driver state:%d", |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11412 | hdd_ctx->driver_status); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11413 | ret = -EINVAL; |
| 11414 | goto done; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11415 | } |
| 11416 | |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11417 | hdd_sysfs_destroy_powerstats_interface(); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11418 | hdd_sysfs_destroy_version_interface(); |
Arunk Khandavalli | 890f6d9 | 2018-10-30 20:18:28 +0530 | [diff] [blame] | 11419 | hdd_sysfs_destroy_driver_root_obj(); |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11420 | hdd_debug("Closing CDS modules!"); |
Amar Singhal | 1808164 | 2018-01-26 16:04:13 -0800 | [diff] [blame] | 11421 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11422 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11423 | qdf_status = cds_post_disable(); |
| 11424 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11425 | hdd_err("Failed to process post CDS disable! :%d", |
| 11426 | qdf_status); |
| 11427 | ret = -EINVAL; |
| 11428 | QDF_ASSERT(0); |
| 11429 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11430 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11431 | /* De-register the SME callbacks */ |
| 11432 | hdd_deregister_cb(hdd_ctx); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 11433 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11434 | hdd_runtime_suspend_context_deinit(hdd_ctx); |
psimha | deea0a1 | 2017-12-18 14:50:02 -0800 | [diff] [blame] | 11435 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11436 | qdf_status = cds_dp_close(hdd_ctx->psoc); |
| 11437 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11438 | hdd_warn("Failed to stop CDS DP: %d", qdf_status); |
| 11439 | ret = -EINVAL; |
| 11440 | QDF_ASSERT(0); |
| 11441 | } |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 11442 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11443 | qdf_status = cds_close(hdd_ctx->psoc); |
| 11444 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
| 11445 | hdd_warn("Failed to stop CDS: %d", qdf_status); |
| 11446 | ret = -EINVAL; |
| 11447 | QDF_ASSERT(0); |
| 11448 | } |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11449 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11450 | qdf_status = wbuff_module_deinit(); |
| 11451 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) |
| 11452 | hdd_err("WBUFF de-init unsuccessful; status: %d", |
| 11453 | qdf_status); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11454 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11455 | hdd_component_pdev_close(hdd_ctx->pdev); |
Rakshith Suresh Patkar | d9f4e61 | 2018-09-12 12:10:38 +0530 | [diff] [blame] | 11456 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11457 | hdd_component_psoc_close(hdd_ctx->psoc); |
| 11458 | dispatcher_pdev_close(hdd_ctx->pdev); |
| 11459 | ret = hdd_objmgr_release_and_destroy_pdev(hdd_ctx); |
| 11460 | if (ret) { |
| 11461 | hdd_err("Failed to destroy pdev; errno:%d", ret); |
| 11462 | QDF_ASSERT(0); |
| 11463 | } |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11464 | } |
| 11465 | |
| 11466 | /* |
| 11467 | * Reset total mac phy during module stop such that during |
| 11468 | * next module start same psoc is used to populate new service |
| 11469 | * ready data |
| 11470 | */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 11471 | tgt_hdl = wlan_psoc_get_tgt_if_handle(hdd_ctx->psoc); |
Arunk Khandavalli | a6305a3 | 2018-01-25 11:19:18 +0530 | [diff] [blame] | 11472 | if (tgt_hdl) |
| 11473 | target_psoc_set_total_mac_phy_cnt(tgt_hdl, 0); |
| 11474 | |
Liangwei Dong | 50a64a7 | 2018-01-11 01:17:00 -0500 | [diff] [blame] | 11475 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11476 | hif_ctx = cds_get_context(QDF_MODULE_ID_HIF); |
| 11477 | if (!hif_ctx) { |
| 11478 | hdd_err("Hif context is Null"); |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11479 | ret = -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11480 | } |
| 11481 | |
Arunk Khandavalli | 4b40433 | 2017-09-26 12:46:00 +0530 | [diff] [blame] | 11482 | if (hdd_ctx->target_hw_name) { |
| 11483 | qdf_mem_free(hdd_ctx->target_hw_name); |
| 11484 | hdd_ctx->target_hw_name = NULL; |
| 11485 | } |
| 11486 | |
Visweswara Tanuku | c949ad2 | 2019-03-20 13:00:30 +0530 | [diff] [blame] | 11487 | if (hdd_get_conparam() != QDF_GLOBAL_EPPING_MODE) { |
| 11488 | epping_disable(); |
| 11489 | epping_close(); |
| 11490 | } |
| 11491 | |
Sravan Kumar Kairam | 2729678 | 2017-04-21 22:04:18 +0530 | [diff] [blame] | 11492 | hdd_hif_close(hdd_ctx, hif_ctx); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11493 | |
| 11494 | ol_cds_free(); |
| 11495 | |
Dustin Brown | c2a156e | 2018-10-25 16:56:27 -0700 | [diff] [blame] | 11496 | if (IS_IDLE_STOP) { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11497 | ret = pld_power_off(qdf_ctx->dev); |
| 11498 | if (ret) |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11499 | hdd_err("Failed to power down device; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11500 | } |
Dustin Brown | 1e3ec6b | 2018-08-07 11:18:47 -0700 | [diff] [blame] | 11501 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11502 | /* Free the cache channels of the command SET_DISABLE_CHANNEL_LIST */ |
| 11503 | wlan_hdd_free_cache_channels(hdd_ctx); |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11504 | |
Jingxiang Ge | 3de0275 | 2019-01-29 15:47:03 +0800 | [diff] [blame] | 11505 | hdd_sap_destroy_ctx_all(hdd_ctx, is_recovery_stop); |
| 11506 | |
Dustin Brown | 29533f2 | 2018-07-24 13:11:56 -0700 | [diff] [blame] | 11507 | hdd_check_for_leaks(hdd_ctx, is_recovery_stop); |
Dustin Brown | 26b3d04 | 2017-12-21 11:13:27 -0800 | [diff] [blame] | 11508 | hdd_debug_domain_set(QDF_DEBUG_DOMAIN_INIT); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11509 | |
Arunk Khandavalli | 847969d | 2017-09-25 15:15:36 +0530 | [diff] [blame] | 11510 | /* Once the firmware sequence is completed reset this flag */ |
| 11511 | hdd_ctx->imps_enabled = false; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11512 | hdd_ctx->driver_status = DRIVER_MODULES_CLOSED; |
Dustin Brown | 550f6d2 | 2017-12-14 15:44:01 -0800 | [diff] [blame] | 11513 | hdd_info("Wlan transitioned (now CLOSED)"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11514 | |
Kai Liu | eabb1df | 2018-11-08 14:58:54 +0800 | [diff] [blame] | 11515 | pld_request_bus_bandwidth(hdd_ctx->parent_dev, PLD_BUS_WIDTH_NONE); |
| 11516 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11517 | done: |
Manjunathappa Prakash | 71c74a4 | 2017-10-19 23:28:43 -0700 | [diff] [blame] | 11518 | cds_set_module_stop_in_progress(false); |
Dustin Brown | 4bc0a62 | 2017-12-06 15:56:50 -0800 | [diff] [blame] | 11519 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 11520 | hdd_exit(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11521 | |
Arun Khandavalli | a172c3e | 2016-08-26 17:33:13 +0530 | [diff] [blame] | 11522 | return ret; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11523 | } |
| 11524 | |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11525 | #ifdef WLAN_FEATURE_MEMDUMP_ENABLE |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11526 | /** |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11527 | * hdd_state_info_dump() - prints state information of hdd layer |
| 11528 | * @buf: buffer pointer |
| 11529 | * @size: size of buffer to be filled |
| 11530 | * |
| 11531 | * This function is used to dump state information of hdd layer |
| 11532 | * |
| 11533 | * Return: None |
| 11534 | */ |
| 11535 | static void hdd_state_info_dump(char **buf_ptr, uint16_t *size) |
| 11536 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 11537 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 11538 | struct hdd_station_ctx *hdd_sta_ctx; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 11539 | struct hdd_adapter *adapter; |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11540 | uint16_t len = 0; |
| 11541 | char *buf = *buf_ptr; |
| 11542 | |
| 11543 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 11544 | if (!hdd_ctx) { |
| 11545 | hdd_err("Failed to get hdd context "); |
| 11546 | return; |
| 11547 | } |
| 11548 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 11549 | hdd_debug("size of buffer: %d", *size); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11550 | |
| 11551 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | 214671b | 2017-10-30 19:45:23 -0700 | [diff] [blame] | 11552 | "\n is_wiphy_suspended %d", hdd_ctx->is_wiphy_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11553 | len += scnprintf(buf + len, *size - len, |
Rajeev Kumar | eada0d0 | 2016-12-08 17:44:17 -0800 | [diff] [blame] | 11554 | "\n is_scheduler_suspended %d", |
| 11555 | hdd_ctx->is_scheduler_suspended); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11556 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 11557 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11558 | if (adapter->dev) |
| 11559 | len += scnprintf(buf + len, *size - len, |
| 11560 | "\n device name: %s", adapter->dev->name); |
wadesong | 42968e9 | 2017-06-08 14:11:21 +0800 | [diff] [blame] | 11561 | len += scnprintf(buf + len, *size - len, |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11562 | "\n device_mode: %d", adapter->device_mode); |
| 11563 | switch (adapter->device_mode) { |
| 11564 | case QDF_STA_MODE: |
| 11565 | case QDF_P2P_CLIENT_MODE: |
| 11566 | hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 11567 | len += scnprintf(buf + len, *size - len, |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 11568 | "\n conn_state: %d", |
| 11569 | hdd_sta_ctx->conn_info.conn_state); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11570 | break; |
| 11571 | |
| 11572 | default: |
| 11573 | break; |
| 11574 | } |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11575 | } |
| 11576 | |
| 11577 | *size -= len; |
| 11578 | *buf_ptr += len; |
| 11579 | } |
| 11580 | |
| 11581 | /** |
| 11582 | * hdd_register_debug_callback() - registration function for hdd layer |
| 11583 | * to print hdd state information |
| 11584 | * |
| 11585 | * Return: None |
| 11586 | */ |
| 11587 | static void hdd_register_debug_callback(void) |
| 11588 | { |
| 11589 | qdf_register_debug_callback(QDF_MODULE_ID_HDD, &hdd_state_info_dump); |
| 11590 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11591 | #else /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Wen Gong | aa6d55d | 2018-04-26 16:33:21 +0800 | [diff] [blame] | 11592 | static void hdd_register_debug_callback(void) |
| 11593 | { |
| 11594 | } |
Wen Gong | 3f00338 | 2018-05-14 14:26:37 +0800 | [diff] [blame] | 11595 | #endif /* WLAN_FEATURE_MEMDUMP_ENABLE */ |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 11596 | |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11597 | /* |
| 11598 | * wlan_init_bug_report_lock() - Initialize bug report lock |
| 11599 | * |
| 11600 | * This function is used to create bug report lock |
| 11601 | * |
| 11602 | * Return: None |
| 11603 | */ |
| 11604 | static void wlan_init_bug_report_lock(void) |
| 11605 | { |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 11606 | struct cds_context *p_cds_context; |
SaidiReddy Yenuga | 699d90e | 2017-04-14 16:09:24 +0530 | [diff] [blame] | 11607 | |
| 11608 | p_cds_context = cds_get_global_context(); |
| 11609 | if (!p_cds_context) { |
| 11610 | hdd_err("cds context is NULL"); |
| 11611 | return; |
| 11612 | } |
| 11613 | |
| 11614 | qdf_spinlock_create(&p_cds_context->bug_report_lock); |
| 11615 | } |
| 11616 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11617 | #ifdef CONFIG_DP_TRACE |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11618 | void hdd_dp_trace_init(struct hdd_config *config) |
| 11619 | { |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11620 | bool live_mode = DP_TRACE_CONFIG_DEFAULT_LIVE_MODE; |
| 11621 | uint8_t thresh = DP_TRACE_CONFIG_DEFAULT_THRESH; |
| 11622 | uint16_t thresh_time_limit = DP_TRACE_CONFIG_DEFAULT_THRESH_TIME_LIMIT; |
| 11623 | uint8_t verbosity = DP_TRACE_CONFIG_DEFAULT_VERBOSTY; |
| 11624 | uint8_t proto_bitmap = DP_TRACE_CONFIG_DEFAULT_BITMAP; |
| 11625 | uint8_t config_params[DP_TRACE_CONFIG_NUM_PARAMS]; |
| 11626 | uint8_t num_entries = 0; |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11627 | uint32_t bw_compute_interval; |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11628 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11629 | if (!config->enable_dp_trace) { |
| 11630 | hdd_err("dp trace is disabled from ini"); |
| 11631 | return; |
| 11632 | } |
| 11633 | |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11634 | hdd_string_to_u8_array(config->dp_trace_config, config_params, |
| 11635 | &num_entries, sizeof(config_params)); |
| 11636 | |
| 11637 | /* calculating, num bw timer intervals in a second (1000ms) */ |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11638 | bw_compute_interval = GET_BW_COMPUTE_INTV(config); |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11639 | if (bw_compute_interval <= 1000 && bw_compute_interval > 0) |
Lin Bai | aa7f8d7 | 2017-10-18 17:23:45 +0800 | [diff] [blame] | 11640 | thresh_time_limit = 1000 / bw_compute_interval; |
Jiachao Wu | 1b00ecb | 2017-07-05 19:13:41 +0800 | [diff] [blame] | 11641 | else if (bw_compute_interval > 1000) { |
| 11642 | hdd_err("busBandwidthComputeInterval > 1000, using 1000"); |
| 11643 | thresh_time_limit = 1; |
| 11644 | } else |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11645 | hdd_err("busBandwidthComputeInterval is 0, using defaults"); |
| 11646 | |
| 11647 | switch (num_entries) { |
| 11648 | case 4: |
| 11649 | proto_bitmap = config_params[3]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11650 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11651 | case 3: |
| 11652 | verbosity = config_params[2]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11653 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11654 | case 2: |
| 11655 | thresh = config_params[1]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11656 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11657 | case 1: |
| 11658 | live_mode = config_params[0]; |
Alok Kumar | b5a33a2 | 2018-05-07 18:09:14 +0530 | [diff] [blame] | 11659 | /* fall through */ |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11660 | default: |
Dustin Brown | a7bb6ae | 2018-08-16 16:51:50 -0700 | [diff] [blame] | 11661 | hdd_debug("live_mode %u thresh %u time_limit %u verbosity %u bitmap 0x%x", |
| 11662 | live_mode, thresh, thresh_time_limit, |
| 11663 | verbosity, proto_bitmap); |
Mohit Khanna | f8f9682 | 2017-05-17 17:11:59 -0700 | [diff] [blame] | 11664 | }; |
| 11665 | |
| 11666 | qdf_dp_trace_init(live_mode, thresh, thresh_time_limit, |
| 11667 | verbosity, proto_bitmap); |
| 11668 | |
| 11669 | } |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11670 | #endif |
| 11671 | |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11672 | #ifdef DISABLE_CHANNEL_LIST |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11673 | static QDF_STATUS wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11674 | { |
| 11675 | return qdf_mutex_create(&hdd_ctx->cache_channel_lock); |
| 11676 | } |
| 11677 | #else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11678 | static QDF_STATUS wlan_hdd_cache_chann_mutex_create(struct hdd_context *hdd_ctx) |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11679 | { |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11680 | return QDF_STATUS_SUCCESS; |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11681 | } |
| 11682 | #endif |
| 11683 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11684 | static QDF_STATUS hdd_open_adapter_no_trans(struct hdd_context *hdd_ctx, |
| 11685 | enum QDF_OPMODE op_mode, |
| 11686 | const char *iface_name, |
| 11687 | uint8_t *mac_addr_bytes) |
| 11688 | { |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11689 | struct osif_vdev_sync *vdev_sync; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11690 | struct hdd_adapter *adapter; |
| 11691 | QDF_STATUS status; |
| 11692 | int errno; |
| 11693 | |
| 11694 | QDF_BUG(rtnl_is_locked()); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11695 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11696 | errno = osif_vdev_sync_create(hdd_ctx->parent_dev, &vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11697 | if (errno) |
| 11698 | return qdf_status_from_os_return(errno); |
| 11699 | |
| 11700 | adapter = hdd_open_adapter(hdd_ctx, op_mode, iface_name, |
| 11701 | mac_addr_bytes, NET_NAME_UNKNOWN, true); |
| 11702 | if (!adapter) { |
| 11703 | status = QDF_STATUS_E_INVAL; |
| 11704 | goto destroy_sync; |
| 11705 | } |
| 11706 | |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11707 | osif_vdev_sync_register(adapter->dev, vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11708 | |
| 11709 | return QDF_STATUS_SUCCESS; |
| 11710 | |
| 11711 | destroy_sync: |
Dustin Brown | 2c5e048 | 2019-02-05 16:14:43 -0800 | [diff] [blame] | 11712 | osif_vdev_sync_destroy(vdev_sync); |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11713 | |
| 11714 | return status; |
| 11715 | } |
| 11716 | |
| 11717 | #ifdef WLAN_OPEN_P2P_INTERFACE |
| 11718 | /** |
| 11719 | * hdd_open_p2p_interface - Open P2P interface |
| 11720 | * @hdd_ctx: HDD context |
| 11721 | * |
| 11722 | * Return: QDF_STATUS |
| 11723 | */ |
| 11724 | static QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11725 | { |
| 11726 | QDF_STATUS status; |
| 11727 | bool p2p_dev_addr_admin; |
| 11728 | bool is_p2p_locally_administered = false; |
| 11729 | |
| 11730 | cfg_p2p_get_device_addr_admin(hdd_ctx->psoc, &p2p_dev_addr_admin); |
| 11731 | |
| 11732 | if (p2p_dev_addr_admin) { |
| 11733 | if (hdd_ctx->num_provisioned_addr && |
| 11734 | !(hdd_ctx->provisioned_mac_addr[0].bytes[0] & 0x02)) { |
| 11735 | hdd_ctx->p2p_device_address = |
| 11736 | hdd_ctx->provisioned_mac_addr[0]; |
| 11737 | |
| 11738 | /* |
| 11739 | * Generate the P2P Device Address. This consists of |
| 11740 | * the device's primary MAC address with the locally |
| 11741 | * administered bit set. |
| 11742 | */ |
| 11743 | |
| 11744 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11745 | is_p2p_locally_administered = true; |
| 11746 | } else if (!(hdd_ctx->derived_mac_addr[0].bytes[0] & 0x02)) { |
| 11747 | hdd_ctx->p2p_device_address = |
| 11748 | hdd_ctx->derived_mac_addr[0]; |
| 11749 | /* |
| 11750 | * Generate the P2P Device Address. This consists of |
| 11751 | * the device's primary MAC address with the locally |
| 11752 | * administered bit set. |
| 11753 | */ |
| 11754 | hdd_ctx->p2p_device_address.bytes[0] |= 0x02; |
| 11755 | is_p2p_locally_administered = true; |
| 11756 | } |
| 11757 | } |
| 11758 | if (!is_p2p_locally_administered) { |
| 11759 | uint8_t *p2p_dev_addr; |
| 11760 | |
| 11761 | p2p_dev_addr = wlan_hdd_get_intf_addr(hdd_ctx, |
| 11762 | QDF_P2P_DEVICE_MODE); |
| 11763 | if (!p2p_dev_addr) { |
| 11764 | hdd_err("Failed to get MAC address for new p2p device"); |
| 11765 | return QDF_STATUS_E_INVAL; |
| 11766 | } |
| 11767 | |
| 11768 | qdf_mem_copy(hdd_ctx->p2p_device_address.bytes, |
| 11769 | p2p_dev_addr, QDF_MAC_ADDR_SIZE); |
| 11770 | } |
| 11771 | |
| 11772 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_P2P_DEVICE_MODE, |
| 11773 | "p2p%d", |
| 11774 | hdd_ctx->p2p_device_address.bytes); |
| 11775 | if (QDF_IS_STATUS_ERROR(status)) { |
| 11776 | hdd_err("Failed to open p2p interface"); |
| 11777 | return QDF_STATUS_E_INVAL; |
| 11778 | } |
| 11779 | |
| 11780 | return QDF_STATUS_SUCCESS; |
| 11781 | } |
| 11782 | #else |
| 11783 | static inline QDF_STATUS hdd_open_p2p_interface(struct hdd_context *hdd_ctx) |
| 11784 | { |
| 11785 | return QDF_STATUS_SUCCESS; |
| 11786 | } |
| 11787 | #endif |
| 11788 | |
| 11789 | static QDF_STATUS hdd_open_ocb_interface(struct hdd_context *hdd_ctx) |
| 11790 | { |
| 11791 | QDF_STATUS status; |
| 11792 | uint8_t *mac_addr; |
| 11793 | |
| 11794 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_OCB_MODE); |
| 11795 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_OCB_MODE, |
| 11796 | "wlanocb%d", mac_addr); |
| 11797 | if (QDF_IS_STATUS_ERROR(status)) |
| 11798 | hdd_err("Failed to open 802.11p interface"); |
| 11799 | |
| 11800 | return status; |
| 11801 | } |
| 11802 | |
| 11803 | static QDF_STATUS hdd_open_concurrent_interface(struct hdd_context *hdd_ctx) |
| 11804 | { |
| 11805 | QDF_STATUS status; |
| 11806 | const char *iface_name; |
| 11807 | uint8_t *mac_addr; |
| 11808 | |
| 11809 | if (qdf_str_eq(hdd_ctx->config->enable_concurrent_sta, "")) |
| 11810 | return QDF_STATUS_SUCCESS; |
| 11811 | |
| 11812 | iface_name = hdd_ctx->config->enable_concurrent_sta; |
| 11813 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11814 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11815 | iface_name, mac_addr); |
| 11816 | if (QDF_IS_STATUS_ERROR(status)) |
| 11817 | hdd_err("Failed to open concurrent station interface"); |
| 11818 | |
| 11819 | return status; |
| 11820 | } |
| 11821 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11822 | static QDF_STATUS |
| 11823 | hdd_open_adapters_for_mission_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11824 | { |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11825 | enum dot11p_mode dot11p_mode; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11826 | QDF_STATUS status; |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11827 | uint8_t *mac_addr; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11828 | |
| 11829 | ucfg_mlme_get_dot11p_mode(hdd_ctx->psoc, &dot11p_mode); |
| 11830 | |
| 11831 | /* Create only 802.11p interface? */ |
| 11832 | if (dot11p_mode == CFG_11P_STANDALONE) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11833 | return hdd_open_ocb_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11834 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11835 | mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_STA_MODE); |
| 11836 | status = hdd_open_adapter_no_trans(hdd_ctx, QDF_STA_MODE, |
| 11837 | "wlan%d", mac_addr); |
| 11838 | if (QDF_IS_STATUS_ERROR(status)) |
| 11839 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11840 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11841 | /* opening concurrent STA is best effort, continue on error */ |
| 11842 | hdd_open_concurrent_interface(hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11843 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11844 | status = hdd_open_p2p_interface(hdd_ctx); |
| 11845 | if (status) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11846 | goto err_close_adapters; |
| 11847 | |
| 11848 | /* Open 802.11p Interface */ |
| 11849 | if (dot11p_mode == CFG_11P_CONCURRENT) { |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11850 | status = hdd_open_ocb_interface(hdd_ctx); |
| 11851 | if (QDF_IS_STATUS_ERROR(status)) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11852 | goto err_close_adapters; |
| 11853 | } |
| 11854 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11855 | return QDF_STATUS_SUCCESS; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11856 | |
| 11857 | err_close_adapters: |
| 11858 | hdd_close_all_adapters(hdd_ctx, true); |
| 11859 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11860 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11861 | } |
| 11862 | |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11863 | static QDF_STATUS hdd_open_adapters_for_ftm_mode(struct hdd_context *hdd_ctx) |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11864 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11865 | uint8_t *mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_FTM_MODE); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11866 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11867 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_FTM_MODE, |
| 11868 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11869 | } |
| 11870 | |
| 11871 | static QDF_STATUS |
| 11872 | hdd_open_adapters_for_monitor_mode(struct hdd_context *hdd_ctx) |
| 11873 | { |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11874 | uint8_t *mac_addr = wlan_hdd_get_intf_addr(hdd_ctx, QDF_MONITOR_MODE); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11875 | |
Dustin Brown | 693b535 | 2019-01-17 10:00:31 -0800 | [diff] [blame] | 11876 | return hdd_open_adapter_no_trans(hdd_ctx, QDF_MONITOR_MODE, |
| 11877 | "wlan%d", mac_addr); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11878 | } |
| 11879 | |
| 11880 | static QDF_STATUS hdd_open_adapters_for_epping_mode(struct hdd_context *hdd_ctx) |
| 11881 | { |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11882 | epping_enable_adapter(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11883 | return QDF_STATUS_SUCCESS; |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11884 | } |
| 11885 | |
| 11886 | typedef QDF_STATUS (*hdd_open_mode_handler)(struct hdd_context *hdd_ctx); |
| 11887 | |
| 11888 | static const hdd_open_mode_handler |
| 11889 | hdd_open_mode_handlers[QDF_GLOBAL_MAX_MODE] = { |
| 11890 | [QDF_GLOBAL_MISSION_MODE] = hdd_open_adapters_for_mission_mode, |
| 11891 | [QDF_GLOBAL_FTM_MODE] = hdd_open_adapters_for_ftm_mode, |
| 11892 | [QDF_GLOBAL_MONITOR_MODE] = hdd_open_adapters_for_monitor_mode, |
| 11893 | [QDF_GLOBAL_EPPING_MODE] = hdd_open_adapters_for_epping_mode, |
| 11894 | }; |
| 11895 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11896 | static QDF_STATUS hdd_open_adapters_for_mode(struct hdd_context *hdd_ctx, |
| 11897 | enum QDF_GLOBAL_MODE driver_mode) |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11898 | { |
| 11899 | QDF_STATUS status; |
| 11900 | |
| 11901 | if (driver_mode < 0 || |
| 11902 | driver_mode >= QDF_GLOBAL_MAX_MODE || |
| 11903 | !hdd_open_mode_handlers[driver_mode]) { |
| 11904 | hdd_err("Driver mode %d not supported", driver_mode); |
| 11905 | return -ENOTSUPP; |
| 11906 | } |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11907 | |
| 11908 | hdd_hold_rtnl_lock(); |
Dustin Brown | 61cc393 | 2018-10-18 16:12:13 -0700 | [diff] [blame] | 11909 | status = hdd_open_mode_handlers[driver_mode](hdd_ctx); |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11910 | hdd_release_rtnl_lock(); |
| 11911 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 11912 | return status; |
Dustin Brown | a2deeb7 | 2018-10-18 14:19:27 -0700 | [diff] [blame] | 11913 | } |
| 11914 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11915 | int hdd_wlan_startup(struct hdd_context *hdd_ctx) |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11916 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 11917 | QDF_STATUS status; |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11918 | int errno; |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 11919 | bool is_imps_enabled; |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11920 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 11921 | hdd_enter(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 11922 | |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 11923 | hdd_action_oui_config(hdd_ctx); |
| 11924 | |
Sravan Kumar Kairam | 6b727a4 | 2017-08-29 15:39:58 +0530 | [diff] [blame] | 11925 | qdf_nbuf_init_replenish_timer(); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11926 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11927 | status = wlan_hdd_cache_chann_mutex_create(hdd_ctx); |
| 11928 | if (QDF_IS_STATUS_ERROR(status)) |
| 11929 | return qdf_status_to_os_return(status); |
Ashish Kumar Dhanotiya | 3f78e68 | 2018-03-14 11:19:27 +0530 | [diff] [blame] | 11930 | |
Ajit Pal Singh | 2c7aecd | 2017-05-19 15:09:23 +0530 | [diff] [blame] | 11931 | #ifdef FEATURE_WLAN_CH_AVOID |
| 11932 | mutex_init(&hdd_ctx->avoid_freq_lock); |
| 11933 | #endif |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 11934 | |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 11935 | osif_request_manager_init(); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11936 | hdd_driver_memdump_init(); |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 11937 | hdd_bus_bandwidth_init(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 11938 | |
Arunk Khandavalli | 5ff037547 | 2019-01-11 17:26:47 +0530 | [diff] [blame] | 11939 | #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE |
| 11940 | status = qdf_mc_timer_init(&hdd_ctx->skip_acs_scan_timer, |
| 11941 | QDF_TIMER_TYPE_SW, |
| 11942 | hdd_skip_acs_scan_timer_handler, |
| 11943 | hdd_ctx); |
| 11944 | if (QDF_IS_STATUS_ERROR(status)) |
| 11945 | hdd_err("Failed to init ACS Skip timer"); |
| 11946 | qdf_spinlock_create(&hdd_ctx->acs_skip_lock); |
| 11947 | #endif |
| 11948 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11949 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 11950 | if (errno) { |
| 11951 | hdd_err("Failed to start modules; errno:%d", errno); |
| 11952 | goto memdump_deinit; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11953 | } |
| 11954 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 11955 | if (hdd_get_conparam() == QDF_GLOBAL_EPPING_MODE) |
| 11956 | return 0; |
| 11957 | |
Yingying Tang | 80e15f3 | 2016-09-27 18:23:01 +0800 | [diff] [blame] | 11958 | wlan_hdd_update_wiphy(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11959 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11960 | hdd_ctx->mac_handle = cds_get_context(QDF_MODULE_ID_SME); |
| 11961 | if (!hdd_ctx->mac_handle) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 11962 | hdd_err("Mac Handle is null"); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11963 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11964 | } |
| 11965 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11966 | errno = hdd_wiphy_init(hdd_ctx); |
| 11967 | if (errno) { |
| 11968 | hdd_err("Failed to initialize wiphy; errno:%d", errno); |
| 11969 | goto stop_modules; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11970 | } |
| 11971 | |
Nirav Shah | d21a2e3 | 2018-04-20 16:34:43 +0530 | [diff] [blame] | 11972 | hdd_dp_trace_init(hdd_ctx->config); |
Nirav Shah | cc1f1ae | 2016-04-26 11:41:29 +0530 | [diff] [blame] | 11973 | |
Ashish Kumar Dhanotiya | 7a11e27 | 2018-11-28 13:16:55 +0530 | [diff] [blame] | 11974 | errno = hdd_initialize_mac_address(hdd_ctx); |
| 11975 | if (errno) { |
| 11976 | hdd_err("MAC initializtion failed: %d", errno); |
| 11977 | goto unregister_wiphy; |
| 11978 | } |
Prashanth Bhatta | 75fa9a1 | 2016-01-11 18:30:08 -0800 | [diff] [blame] | 11979 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11980 | errno = register_netdevice_notifier(&hdd_netdev_notifier); |
| 11981 | if (errno) { |
| 11982 | hdd_err("register_netdevice_notifier failed; errno:%d", errno); |
| 11983 | goto unregister_wiphy; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 11984 | } |
Arun Khandavalli | 08479ba | 2017-08-07 19:56:23 +0530 | [diff] [blame] | 11985 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11986 | errno = register_reboot_notifier(&system_reboot_notifier); |
| 11987 | if (errno) { |
| 11988 | hdd_err("Failed to register reboot notifier; errno:%d", errno); |
| 11989 | goto unregister_netdev; |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 11990 | } |
| 11991 | |
Sandeep Puligilla | 3461878 | 2019-01-04 17:42:42 -0800 | [diff] [blame] | 11992 | wlan_hdd_update_11n_mode(hdd_ctx); |
Yingying Tang | 3ba3dbc | 2016-09-27 16:36:58 +0800 | [diff] [blame] | 11993 | |
Arunk Khandavalli | 40943af | 2017-05-15 19:25:34 +0530 | [diff] [blame] | 11994 | hdd_lpass_notify_wlan_version(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 11995 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 11996 | errno = hdd_register_notifiers(hdd_ctx); |
| 11997 | if (errno) |
| 11998 | goto unregister_reboot; |
Prashanth Bhatta | 9b03ab3 | 2016-04-28 12:35:13 -0700 | [diff] [blame] | 11999 | |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 12000 | status = wlansap_global_init(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12001 | if (QDF_IS_STATUS_ERROR(status)) |
| 12002 | goto unregister_notifiers; |
Paul Zhang | fb02f45 | 2017-12-22 11:58:43 +0800 | [diff] [blame] | 12003 | |
Pragaspathi Thilagaraj | 784c492 | 2018-12-02 22:47:29 +0530 | [diff] [blame] | 12004 | ucfg_mlme_is_imps_enabled(hdd_ctx->psoc, &is_imps_enabled); |
| 12005 | hdd_set_idle_ps_config(hdd_ctx, is_imps_enabled); |
Arun Kumar Khandavalli | deda5a8 | 2019-03-11 15:32:19 +0530 | [diff] [blame] | 12006 | hdd_debugfs_mws_coex_info_init(hdd_ctx); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12007 | |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12008 | hdd_exit(); |
| 12009 | |
| 12010 | return 0; |
| 12011 | |
| 12012 | unregister_notifiers: |
| 12013 | hdd_unregister_notifiers(hdd_ctx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12014 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12015 | unregister_reboot: |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 12016 | unregister_reboot_notifier(&system_reboot_notifier); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12017 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12018 | unregister_netdev: |
Poddar, Siddarth | aee8ff6 | 2017-10-04 12:53:22 +0530 | [diff] [blame] | 12019 | unregister_netdevice_notifier(&hdd_netdev_notifier); |
| 12020 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12021 | unregister_wiphy: |
Rachit Kankane | 3080733 | 2018-06-27 18:39:36 +0530 | [diff] [blame] | 12022 | qdf_dp_trace_deinit(); |
Prashanth Bhatta | c2a16f6 | 2015-12-03 15:06:15 -0800 | [diff] [blame] | 12023 | wiphy_unregister(hdd_ctx->wiphy); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12024 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12025 | stop_modules: |
Rajeev Kumar | 3fef4e8 | 2017-03-31 20:25:23 -0700 | [diff] [blame] | 12026 | hdd_wlan_stop_modules(hdd_ctx, false); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12027 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12028 | memdump_deinit: |
Dustin Brown | 86d196b | 2018-08-02 11:51:49 -0700 | [diff] [blame] | 12029 | hdd_bus_bandwidth_deinit(hdd_ctx); |
Dustin Brown | 021cecd | 2017-12-11 13:56:43 -0800 | [diff] [blame] | 12030 | hdd_driver_memdump_deinit(); |
Naveen Rawat | e02f8f5 | 2018-04-05 11:58:04 -0700 | [diff] [blame] | 12031 | osif_request_manager_deinit(); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12032 | qdf_nbuf_deinit_replenish_timer(); |
Ryan Hsu | cfef0ae | 2016-04-28 10:20:46 -0700 | [diff] [blame] | 12033 | |
Nachiket Kukade | 8003d25 | 2017-03-30 15:55:58 +0530 | [diff] [blame] | 12034 | if (cds_is_fw_down()) |
| 12035 | hdd_err("Not setting the complete event as fw is down"); |
| 12036 | else |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12037 | hdd_start_complete(errno); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12038 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12039 | hdd_exit(); |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12040 | |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 12041 | return errno; |
Dustin Brown | 92bd838 | 2018-10-31 15:49:46 -0700 | [diff] [blame] | 12042 | } |
| 12043 | |
| 12044 | QDF_STATUS hdd_psoc_create_vdevs(struct hdd_context *hdd_ctx) |
| 12045 | { |
| 12046 | enum QDF_GLOBAL_MODE driver_mode = hdd_get_conparam(); |
| 12047 | QDF_STATUS status; |
| 12048 | |
| 12049 | status = hdd_open_adapters_for_mode(hdd_ctx, driver_mode); |
| 12050 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12051 | hdd_err("Failed to create vdevs; status:%d", status); |
| 12052 | return status; |
| 12053 | } |
| 12054 | |
| 12055 | if (hdd_ctx->rps) |
| 12056 | hdd_set_rps_cpu_mask(hdd_ctx); |
| 12057 | |
| 12058 | if (driver_mode != QDF_GLOBAL_FTM_MODE) |
| 12059 | hdd_psoc_idle_timer_start(hdd_ctx); |
| 12060 | |
| 12061 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12062 | } |
| 12063 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12064 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12065 | * hdd_wlan_update_target_info() - update target type info |
| 12066 | * @hdd_ctx: HDD context |
| 12067 | * @context: hif context |
| 12068 | * |
| 12069 | * Update target info received from firmware in hdd context |
| 12070 | * Return:None |
| 12071 | */ |
| 12072 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12073 | 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] | 12074 | { |
| 12075 | struct hif_target_info *tgt_info = hif_get_target_info_handle(context); |
| 12076 | |
| 12077 | if (!tgt_info) { |
| 12078 | hdd_err("Target info is Null"); |
| 12079 | return; |
| 12080 | } |
| 12081 | |
| 12082 | hdd_ctx->target_type = tgt_info->target_type; |
| 12083 | } |
| 12084 | |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12085 | 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] | 12086 | { |
| 12087 | struct hdd_context *hdd_ctx = (struct hdd_context *)data; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12088 | int status; |
| 12089 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12090 | struct osif_request *request = NULL; |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12091 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12092 | hdd_enter(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12093 | |
| 12094 | if (!rsp) { |
| 12095 | hdd_err("data is null"); |
| 12096 | return; |
| 12097 | } |
| 12098 | |
| 12099 | status = wlan_hdd_validate_context(hdd_ctx); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12100 | if (status != 0) |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12101 | return; |
| 12102 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12103 | request = osif_request_get(context); |
Dundi Raviteja | 3bcf3a8 | 2018-05-22 13:24:18 +0530 | [diff] [blame] | 12104 | if (!request) { |
| 12105 | hdd_err("obselete request"); |
| 12106 | return; |
| 12107 | } |
| 12108 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12109 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, rsp->vdev_id); |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12110 | if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12111 | hdd_err("Invalid adapter or adapter has invalid magic"); |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12112 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12113 | return; |
| 12114 | } |
| 12115 | |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12116 | hdd_debug("rsp->arp_req_enqueue :%x", rsp->arp_req_enqueue); |
| 12117 | hdd_debug("rsp->arp_req_tx_success :%x", rsp->arp_req_tx_success); |
| 12118 | hdd_debug("rsp->arp_req_tx_failure :%x", rsp->arp_req_tx_failure); |
| 12119 | hdd_debug("rsp->arp_rsp_recvd :%x", rsp->arp_rsp_recvd); |
| 12120 | hdd_debug("rsp->out_of_order_arp_rsp_drop_cnt :%x", |
| 12121 | rsp->out_of_order_arp_rsp_drop_cnt); |
| 12122 | hdd_debug("rsp->dad_detected :%x", rsp->dad_detected); |
| 12123 | hdd_debug("rsp->connect_status :%x", rsp->connect_status); |
| 12124 | hdd_debug("rsp->ba_session_establishment_status :%x", |
| 12125 | rsp->ba_session_establishment_status); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12126 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12127 | 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] | 12128 | adapter->dad |= rsp->dad_detected; |
| 12129 | adapter->con_status = rsp->connect_status; |
| 12130 | |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12131 | /* Flag true indicates connectivity check stats present. */ |
| 12132 | if (rsp->connect_stats_present) { |
Alok Kumar | ce2c29a | 2018-10-12 15:44:02 +0530 | [diff] [blame] | 12133 | hdd_debug("rsp->tcp_ack_recvd :%x", rsp->tcp_ack_recvd); |
| 12134 | hdd_debug("rsp->icmpv4_rsp_recvd :%x", rsp->icmpv4_rsp_recvd); |
Poddar, Siddarth | 31797fa | 2018-01-22 17:24:15 +0530 | [diff] [blame] | 12135 | adapter->hdd_stats.hdd_tcp_stats.rx_fw_cnt = rsp->tcp_ack_recvd; |
| 12136 | adapter->hdd_stats.hdd_icmpv4_stats.rx_fw_cnt = |
| 12137 | rsp->icmpv4_rsp_recvd; |
| 12138 | } |
| 12139 | |
Jeff Johnson | f1a99ea | 2018-06-28 13:27:01 -0700 | [diff] [blame] | 12140 | osif_request_complete(request); |
| 12141 | osif_request_put(request); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12142 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12143 | hdd_exit(); |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12144 | } |
| 12145 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12146 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12147 | /** |
| 12148 | * hdd_md_host_evt_cb - Callback for Motion Detection Event |
| 12149 | * @ctx: HDD context |
| 12150 | * @event: motion detect event |
| 12151 | * |
| 12152 | * Callback for Motion Detection Event. Re-enables Motion |
| 12153 | * Detection again upon event |
| 12154 | * |
| 12155 | * Return: QDF_STATUS QDF_STATUS_SUCCESS on Success and |
| 12156 | * QDF_STATUS_E_FAILURE on failure |
| 12157 | */ |
| 12158 | QDF_STATUS hdd_md_host_evt_cb(void *ctx, struct sir_md_evt *event) |
| 12159 | { |
| 12160 | struct hdd_adapter *adapter = NULL; |
| 12161 | struct hdd_context *hdd_ctx; |
| 12162 | QDF_STATUS status; |
| 12163 | struct sme_motion_det_en motion_det; |
| 12164 | |
| 12165 | if (!ctx || !event) |
| 12166 | return QDF_STATUS_E_INVAL; |
| 12167 | |
| 12168 | hdd_ctx = (struct hdd_context *)ctx; |
| 12169 | status = wlan_hdd_validate_context(hdd_ctx); |
| 12170 | if (0 != status) |
| 12171 | return QDF_STATUS_E_INVAL; |
| 12172 | |
| 12173 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, event->vdev_id); |
| 12174 | if (!adapter || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) { |
| 12175 | hdd_err("Invalid adapter or adapter has invalid magic"); |
| 12176 | return QDF_STATUS_E_INVAL; |
| 12177 | } |
| 12178 | |
| 12179 | hdd_debug("Motion Detection CB vdev_id=%u, status=%u", |
| 12180 | event->vdev_id, event->status); |
| 12181 | |
| 12182 | if (adapter->motion_detection_mode) { |
| 12183 | motion_det.vdev_id = event->vdev_id; |
| 12184 | motion_det.enable = 1; |
| 12185 | hdd_debug("Motion Detect CB -> Enable Motion Detection again"); |
| 12186 | sme_motion_det_enable(hdd_ctx->mac_handle, &motion_det); |
| 12187 | } |
| 12188 | |
| 12189 | return QDF_STATUS_SUCCESS; |
| 12190 | } |
| 12191 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12192 | |
Anurag Chouhan | 3920c0f | 2017-09-11 17:10:56 +0530 | [diff] [blame] | 12193 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 12194 | * hdd_register_cb - Register HDD callbacks. |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12195 | * @hdd_ctx: HDD context |
| 12196 | * |
| 12197 | * Register the HDD callbacks to CDS/SME. |
| 12198 | * |
| 12199 | * Return: 0 for success or Error code for failure |
| 12200 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12201 | int hdd_register_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12202 | { |
| 12203 | QDF_STATUS status; |
| 12204 | int ret = 0; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12205 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12206 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12207 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12208 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12209 | hdd_err("in ftm mode, no need to register callbacks"); |
| 12210 | return ret; |
| 12211 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12212 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12213 | mac_handle = hdd_ctx->mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12214 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12215 | sme_register_oem_data_rsp_callback(mac_handle, |
| 12216 | hdd_send_oem_data_rsp_msg); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12217 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12218 | sme_register_mgmt_frame_ind_callback(mac_handle, |
Deepthi Gowri | d5a58fe | 2016-09-03 16:01:28 +0530 | [diff] [blame] | 12219 | hdd_indicate_mgmt_frame); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12220 | sme_set_tsfcb(mac_handle, hdd_get_tsf_cb, hdd_ctx); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12221 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12222 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12223 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12224 | sme_ext_scan_register_callback(mac_handle, |
| 12225 | wlan_hdd_cfg80211_extscan_callback); |
| 12226 | sme_stats_ext2_register_callback(mac_handle, |
lifeng | 6683166 | 2017-05-19 16:01:35 +0800 | [diff] [blame] | 12227 | wlan_hdd_cfg80211_stats_ext2_callback); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12228 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12229 | sme_set_rssi_threshold_breached_cb(mac_handle, |
| 12230 | hdd_rssi_threshold_breached); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12231 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12232 | sme_set_link_layer_stats_ind_cb(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12233 | wlan_hdd_cfg80211_link_layer_stats_callback); |
| 12234 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12235 | 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] | 12236 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12237 | sme_set_link_layer_ext_cb(mac_handle, |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12238 | wlan_hdd_cfg80211_link_layer_stats_ext_callback); |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 12239 | sme_update_hidden_ssid_status_cb(mac_handle, |
| 12240 | hdd_hidden_ssid_enable_roaming); |
Zhang Qian | ca38fb1 | 2016-12-23 11:10:48 +0800 | [diff] [blame] | 12241 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12242 | status = sme_set_lost_link_info_cb(mac_handle, |
Sreelakshmi Konamki | 58c7243 | 2016-11-09 17:06:44 +0530 | [diff] [blame] | 12243 | hdd_lost_link_info_cb); |
| 12244 | /* print error and not block the startup process */ |
| 12245 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12246 | hdd_err("set lost link info callback failed"); |
| 12247 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12248 | ret = hdd_register_data_stall_detect_cb(); |
| 12249 | if (ret) { |
| 12250 | hdd_err("Register data stall detect detect callback failed."); |
| 12251 | return ret; |
| 12252 | } |
| 12253 | |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12254 | wlan_hdd_dcc_register_for_dcc_stats_event(hdd_ctx); |
| 12255 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12256 | sme_register_set_connection_info_cb(mac_handle, |
| 12257 | hdd_set_connection_in_progress, |
| 12258 | hdd_is_connection_in_progress); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12259 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12260 | status = sme_congestion_register_callback(mac_handle, |
| 12261 | hdd_update_cca_info_cb); |
Padma, Santhosh Kumar | 16dacfb | 2017-03-21 19:05:40 +0530 | [diff] [blame] | 12262 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12263 | hdd_err("set congestion callback failed"); |
| 12264 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12265 | status = sme_set_bt_activity_info_cb(mac_handle, |
Vidyullatha Kanchanapally | be0ebb3 | 2017-03-23 14:36:21 +0530 | [diff] [blame] | 12266 | hdd_bt_activity_cb); |
| 12267 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12268 | hdd_err("set bt activity info callback failed"); |
| 12269 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12270 | status = sme_register_tx_queue_cb(mac_handle, |
Varun Reddy Yeturu | 076eaa8 | 2018-01-16 12:16:14 -0800 | [diff] [blame] | 12271 | hdd_tx_queue_cb); |
| 12272 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12273 | hdd_err("Register tx queue callback failed"); |
| 12274 | |
Visweswara Tanuku | 633976b | 2019-01-07 16:13:12 +0530 | [diff] [blame] | 12275 | #ifdef WLAN_FEATURE_MOTION_DETECTION |
| 12276 | sme_set_md_host_evt_cb(mac_handle, hdd_md_host_evt_cb, (void *)hdd_ctx); |
| 12277 | #endif /* WLAN_FEATURE_MOTION_DETECTION */ |
| 12278 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12279 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12280 | |
| 12281 | return ret; |
| 12282 | } |
| 12283 | |
| 12284 | /** |
| 12285 | * hdd_deregister_cb() - De-Register HDD callbacks. |
| 12286 | * @hdd_ctx: HDD context |
| 12287 | * |
| 12288 | * De-Register the HDD callbacks to CDS/SME. |
| 12289 | * |
| 12290 | * Return: void |
| 12291 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12292 | void hdd_deregister_cb(struct hdd_context *hdd_ctx) |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12293 | { |
| 12294 | QDF_STATUS status; |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12295 | int ret; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12296 | mac_handle_t mac_handle; |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12297 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12298 | hdd_enter(); |
Sourav Mohapatra | 674925f | 2018-04-16 11:16:58 +0530 | [diff] [blame] | 12299 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) { |
| 12300 | hdd_err("in ftm mode, no need to deregister callbacks"); |
| 12301 | return; |
| 12302 | } |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12303 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12304 | mac_handle = hdd_ctx->mac_handle; |
| 12305 | sme_deregister_tx_queue_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12306 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12307 | sme_reset_link_layer_stats_ind_cb(mac_handle); |
| 12308 | sme_reset_rssi_threshold_breached_cb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12309 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12310 | sme_stats_ext_register_callback(mac_handle, |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12311 | wlan_hdd_cfg80211_stats_ext_callback); |
| 12312 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12313 | status = sme_reset_tsfcb(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12314 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 12315 | hdd_err("Failed to de-register tsfcb the callback:%d", |
| 12316 | status); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12317 | |
Poddar, Siddarth | 3487278 | 2017-08-10 14:08:51 +0530 | [diff] [blame] | 12318 | ret = hdd_deregister_data_stall_detect_cb(); |
| 12319 | if (ret) |
| 12320 | hdd_err("Failed to de-register data stall detect event callback"); |
| 12321 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12322 | sme_deregister_oem_data_rsp_callback(mac_handle); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12323 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12324 | hdd_exit(); |
Arun Khandavalli | 4b55da7 | 2016-07-19 19:55:01 +0530 | [diff] [blame] | 12325 | } |
| 12326 | |
| 12327 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12328 | * hdd_softap_sta_deauth() - handle deauth req from HDD |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12329 | * @adapter: Pointer to the HDD adapter |
| 12330 | * @param: Params to the operation |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12331 | * |
| 12332 | * This to take counter measure to handle deauth req from HDD |
| 12333 | * |
| 12334 | * Return: None |
| 12335 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12336 | QDF_STATUS hdd_softap_sta_deauth(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12337 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12338 | { |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12339 | QDF_STATUS qdf_status = QDF_STATUS_E_FAULT; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12340 | |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12341 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12342 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12343 | /* Ignore request to deauth bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12344 | if (param->peerMacAddr.bytes[0] & 0x1) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12345 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12346 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12347 | qdf_status = |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12348 | wlansap_deauth_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12349 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12350 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12351 | hdd_exit(); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12352 | return qdf_status; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12353 | } |
| 12354 | |
| 12355 | /** |
| 12356 | * hdd_softap_sta_disassoc() - take counter measure to handle deauth req from HDD |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12357 | * @adapter: Pointer to the HDD |
| 12358 | * @param: pointer to station deletion parameters |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12359 | * |
| 12360 | * This to take counter measure to handle deauth req from HDD |
| 12361 | * |
| 12362 | * Return: None |
| 12363 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12364 | void hdd_softap_sta_disassoc(struct hdd_adapter *adapter, |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12365 | struct csr_del_sta_params *param) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12366 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12367 | hdd_enter(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12368 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12369 | /* Ignore request to disassoc bcmc station */ |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12370 | if (param->peerMacAddr.bytes[0] & 0x1) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12371 | return; |
| 12372 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12373 | wlansap_disassoc_sta(WLAN_HDD_GET_SAP_CTX_PTR(adapter), |
Jeff Johnson | 50e37e9 | 2019-03-08 11:32:25 -0800 | [diff] [blame] | 12374 | param); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12375 | } |
| 12376 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12377 | void wlan_hdd_disable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12378 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12379 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12380 | struct hdd_adapter *adapter = NULL; |
| 12381 | struct csr_roam_profile *roam_profile; |
| 12382 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12383 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12384 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12385 | hdd_debug("No active sta session"); |
| 12386 | return; |
| 12387 | } |
| 12388 | |
| 12389 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12390 | roam_profile = hdd_roam_profile(adapter); |
| 12391 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12392 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12393 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12394 | adapter->device_mode == QDF_STA_MODE && |
| 12395 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12396 | hdd_debug("%d Disable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12397 | sme_stop_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12398 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12399 | ecsr_driver_disabled); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12400 | } |
| 12401 | } |
| 12402 | } |
| 12403 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12404 | void wlan_hdd_enable_roaming(struct hdd_adapter *cur_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12405 | { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12406 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(cur_adapter); |
| 12407 | struct hdd_adapter *adapter = NULL; |
| 12408 | struct csr_roam_profile *roam_profile; |
| 12409 | struct hdd_station_ctx *sta_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12410 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12411 | if (!policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc)) { |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12412 | hdd_debug("No active sta session"); |
| 12413 | return; |
| 12414 | } |
| 12415 | |
| 12416 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12417 | roam_profile = hdd_roam_profile(adapter); |
| 12418 | sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 12419 | |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12420 | if (cur_adapter->vdev_id != adapter->vdev_id && |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12421 | adapter->device_mode == QDF_STA_MODE && |
| 12422 | hdd_conn_is_connected(sta_ctx)) { |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12423 | hdd_debug("%d Enable roaming", adapter->vdev_id); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12424 | sme_start_roaming(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12425 | adapter->vdev_id, |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 12426 | REASON_DRIVER_ENABLED); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12427 | } |
| 12428 | } |
| 12429 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12430 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12431 | /** |
| 12432 | * nl_srv_bcast_svc() - Wrapper function to send bcast msgs to SVC mcast group |
| 12433 | * @skb: sk buffer pointer |
| 12434 | * |
| 12435 | * Sends the bcast message to SVC multicast group with generic nl socket |
| 12436 | * if CNSS_GENL is enabled. Else, use the legacy netlink socket to send. |
| 12437 | * |
| 12438 | * Return: None |
| 12439 | */ |
| 12440 | static void nl_srv_bcast_svc(struct sk_buff *skb) |
| 12441 | { |
| 12442 | #ifdef CNSS_GENL |
| 12443 | nl_srv_bcast(skb, CLD80211_MCGRP_SVC_MSGS, WLAN_NL_MSG_SVC); |
| 12444 | #else |
| 12445 | nl_srv_bcast(skb); |
| 12446 | #endif |
| 12447 | } |
| 12448 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12449 | 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] | 12450 | { |
| 12451 | struct sk_buff *skb; |
| 12452 | struct nlmsghdr *nlh; |
| 12453 | tAniMsgHdr *ani_hdr; |
| 12454 | void *nl_data = NULL; |
| 12455 | int flags = GFP_KERNEL; |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12456 | struct radio_index_tlv *radio_info; |
| 12457 | int tlv_len; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12458 | |
| 12459 | if (in_interrupt() || irqs_disabled() || in_atomic()) |
| 12460 | flags = GFP_ATOMIC; |
| 12461 | |
| 12462 | skb = alloc_skb(NLMSG_SPACE(WLAN_NL_MAX_PAYLOAD), flags); |
| 12463 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12464 | if (!skb) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12465 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12466 | |
| 12467 | nlh = (struct nlmsghdr *)skb->data; |
| 12468 | nlh->nlmsg_pid = 0; /* from kernel */ |
| 12469 | nlh->nlmsg_flags = 0; |
| 12470 | nlh->nlmsg_seq = 0; |
| 12471 | nlh->nlmsg_type = WLAN_NL_MSG_SVC; |
| 12472 | |
| 12473 | ani_hdr = NLMSG_DATA(nlh); |
| 12474 | ani_hdr->type = type; |
| 12475 | |
| 12476 | switch (type) { |
| 12477 | case WLAN_SVC_FW_CRASHED_IND: |
Komal Seelam | 78ff65a | 2016-08-18 15:25:24 +0530 | [diff] [blame] | 12478 | case WLAN_SVC_FW_SHUTDOWN_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12479 | case WLAN_SVC_LTE_COEX_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12480 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND: |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12481 | case WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12482 | ani_hdr->length = 0; |
| 12483 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr))); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12484 | break; |
| 12485 | case WLAN_SVC_WLAN_STATUS_IND: |
| 12486 | case WLAN_SVC_WLAN_VERSION_IND: |
| 12487 | case WLAN_SVC_DFS_CAC_START_IND: |
| 12488 | case WLAN_SVC_DFS_CAC_END_IND: |
| 12489 | case WLAN_SVC_DFS_RADAR_DETECT_IND: |
| 12490 | case WLAN_SVC_DFS_ALL_CHANNEL_UNAVAIL_IND: |
| 12491 | case WLAN_SVC_WLAN_TP_IND: |
Mohit Khanna | e71e226 | 2015-11-10 09:37:24 -0800 | [diff] [blame] | 12492 | case WLAN_SVC_WLAN_TP_TX_IND: |
Nirav Shah | bd36b06 | 2016-07-18 11:12:59 +0530 | [diff] [blame] | 12493 | case WLAN_SVC_RPS_ENABLE_IND: |
Orhan K AKYILDIZ | e7445a2 | 2017-01-19 21:21:47 -0800 | [diff] [blame] | 12494 | case WLAN_SVC_CORE_MINFREQ: |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12495 | ani_hdr->length = len; |
| 12496 | nlh->nlmsg_len = NLMSG_LENGTH((sizeof(tAniMsgHdr) + len)); |
| 12497 | nl_data = (char *)ani_hdr + sizeof(tAniMsgHdr); |
| 12498 | memcpy(nl_data, data, len); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12499 | break; |
| 12500 | |
| 12501 | default: |
Jeff Johnson | 34c88b7 | 2016-08-15 14:27:11 -0700 | [diff] [blame] | 12502 | hdd_err("WLAN SVC: Attempt to send unknown nlink message %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12503 | type); |
| 12504 | kfree_skb(skb); |
| 12505 | return; |
| 12506 | } |
| 12507 | |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12508 | /* |
Jeff Johnson | 0d52c7a | 2017-01-12 08:46:55 -0800 | [diff] [blame] | 12509 | * Add radio index at the end of the svc event in TLV format |
| 12510 | * to maintain the backward compatibility with userspace |
| 12511 | * applications. |
| 12512 | */ |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12513 | |
| 12514 | tlv_len = 0; |
| 12515 | |
| 12516 | if ((sizeof(*ani_hdr) + len + sizeof(struct radio_index_tlv)) |
| 12517 | < WLAN_NL_MAX_PAYLOAD) { |
| 12518 | radio_info = (struct radio_index_tlv *)((char *) ani_hdr + |
| 12519 | sizeof(*ani_hdr) + len); |
| 12520 | radio_info->type = (unsigned short) WLAN_SVC_WLAN_RADIO_INDEX; |
| 12521 | radio_info->length = (unsigned short) sizeof(radio_info->radio); |
| 12522 | radio_info->radio = radio; |
| 12523 | tlv_len = sizeof(*radio_info); |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 12524 | hdd_debug("Added radio index tlv - radio index %d", |
| 12525 | radio_info->radio); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12526 | } |
| 12527 | |
| 12528 | nlh->nlmsg_len += tlv_len; |
| 12529 | skb_put(skb, NLMSG_SPACE(sizeof(tAniMsgHdr) + len + tlv_len)); |
| 12530 | |
Selvaraj, Sridhar | 046d77d | 2017-03-07 14:53:13 +0530 | [diff] [blame] | 12531 | nl_srv_bcast_svc(skb); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12532 | } |
| 12533 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12534 | #ifdef FEATURE_WLAN_AUTO_SHUTDOWN |
| 12535 | void wlan_hdd_auto_shutdown_cb(void) |
| 12536 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12537 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12538 | |
| 12539 | if (!hdd_ctx) |
| 12540 | return; |
| 12541 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12542 | hdd_debug("Wlan Idle. Sending Shutdown event.."); |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12543 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
| 12544 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12545 | } |
| 12546 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12547 | 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] | 12548 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12549 | struct hdd_adapter *adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12550 | bool ap_connected = false, sta_connected = false; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12551 | mac_handle_t mac_handle; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12552 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12553 | mac_handle = hdd_ctx->mac_handle; |
| 12554 | if (!mac_handle) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12555 | return; |
| 12556 | |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12557 | if (hdd_ctx->config->wlan_auto_shutdown == 0) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12558 | return; |
| 12559 | |
| 12560 | if (enable == false) { |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12561 | if (sme_set_auto_shutdown_timer(mac_handle, 0) != |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12562 | QDF_STATUS_SUCCESS) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12563 | hdd_err("Failed to stop wlan auto shutdown timer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12564 | } |
Kondabattini, Ganesh | 96ac37b | 2016-09-02 23:12:15 +0530 | [diff] [blame] | 12565 | wlan_hdd_send_svc_nlink_msg(hdd_ctx->radio_index, |
Manikandan Mohan | 5b1980a | 2016-05-06 12:41:18 -0700 | [diff] [blame] | 12566 | WLAN_SVC_WLAN_AUTO_SHUTDOWN_CANCEL_IND, NULL, 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12567 | return; |
| 12568 | } |
| 12569 | |
| 12570 | /* To enable shutdown timer check conncurrency */ |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12571 | if (policy_mgr_concurrent_open_sessions_running(hdd_ctx->psoc)) { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12572 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12573 | if (adapter->device_mode == QDF_STA_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12574 | if (WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12575 | conn_info.conn_state == |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12576 | eConnectionState_Associated) { |
| 12577 | sta_connected = true; |
| 12578 | break; |
| 12579 | } |
| 12580 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12581 | |
| 12582 | if (adapter->device_mode == QDF_SAP_MODE) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12583 | if (WLAN_HDD_GET_AP_CTX_PTR(adapter)-> |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12584 | ap_active == true) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12585 | ap_connected = true; |
| 12586 | break; |
| 12587 | } |
| 12588 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12589 | } |
| 12590 | } |
| 12591 | |
| 12592 | if (ap_connected == true || sta_connected == true) { |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12593 | hdd_debug("CC Session active. Shutdown timer not enabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12594 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12595 | } |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12596 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 12597 | if (sme_set_auto_shutdown_timer(mac_handle, |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12598 | hdd_ctx->config->wlan_auto_shutdown) |
Jeff Johnson | 6875531 | 2017-02-10 11:46:55 -0800 | [diff] [blame] | 12599 | != QDF_STATUS_SUCCESS) |
| 12600 | hdd_err("Failed to start wlan auto shutdown timer"); |
| 12601 | else |
Dustin Brown | 5e89ef8 | 2018-03-14 11:50:23 -0700 | [diff] [blame] | 12602 | hdd_info("Auto Shutdown timer for %d seconds enabled", |
Dundi Raviteja | 8e33828 | 2018-09-25 17:16:04 +0530 | [diff] [blame] | 12603 | hdd_ctx->config->wlan_auto_shutdown); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12604 | } |
| 12605 | #endif |
| 12606 | |
Jeff Johnson | 6dff3ee | 2017-10-06 14:58:57 -0700 | [diff] [blame] | 12607 | struct hdd_adapter * |
| 12608 | hdd_get_con_sap_adapter(struct hdd_adapter *this_sap_adapter, |
| 12609 | bool check_start_bss) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12610 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12611 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(this_sap_adapter); |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12612 | struct hdd_adapter *adapter, *con_sap_adapter; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12613 | |
| 12614 | con_sap_adapter = NULL; |
| 12615 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12616 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12617 | if (adapter && ((adapter->device_mode == QDF_SAP_MODE) || |
| 12618 | (adapter->device_mode == QDF_P2P_GO_MODE)) && |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12619 | adapter != this_sap_adapter) { |
| 12620 | if (check_start_bss) { |
| 12621 | if (test_bit(SOFTAP_BSS_STARTED, |
| 12622 | &adapter->event_flags)) { |
| 12623 | con_sap_adapter = adapter; |
| 12624 | break; |
| 12625 | } |
| 12626 | } else { |
| 12627 | con_sap_adapter = adapter; |
| 12628 | break; |
| 12629 | } |
| 12630 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12631 | } |
| 12632 | |
| 12633 | return con_sap_adapter; |
| 12634 | } |
| 12635 | |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 12636 | #ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12637 | static inline bool hdd_adapter_is_sta(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12638 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12639 | return adapter->device_mode == QDF_STA_MODE || |
| 12640 | adapter->device_mode == QDF_P2P_CLIENT_MODE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12641 | } |
| 12642 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12643 | static inline bool hdd_adapter_is_ap(struct hdd_adapter *adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12644 | { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12645 | return adapter->device_mode == QDF_SAP_MODE || |
| 12646 | adapter->device_mode == QDF_P2P_GO_MODE; |
| 12647 | } |
| 12648 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12649 | static bool hdd_any_adapter_is_assoc(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12650 | { |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12651 | struct hdd_adapter *adapter; |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12652 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12653 | hdd_for_each_adapter(hdd_ctx, adapter) { |
| 12654 | if (hdd_adapter_is_sta(adapter) && |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12655 | WLAN_HDD_GET_STATION_CTX_PTR(adapter)-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 12656 | conn_info.conn_state == eConnectionState_Associated) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12657 | return true; |
| 12658 | } |
| 12659 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 12660 | if (hdd_adapter_is_ap(adapter) && |
Jeff Johnson | 136c51b | 2017-10-27 20:02:41 -0700 | [diff] [blame] | 12661 | WLAN_HDD_GET_AP_CTX_PTR(adapter)->ap_active) { |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12662 | return true; |
| 12663 | } |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12664 | } |
| 12665 | |
| 12666 | return false; |
| 12667 | } |
| 12668 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12669 | 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] | 12670 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12671 | qdf_periodic_work_start(&hdd_ctx->bus_bw_work, |
| 12672 | hdd_ctx->config->bus_bw_compute_interval); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12673 | } |
| 12674 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12675 | void hdd_bus_bw_compute_timer_start(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12676 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12677 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12678 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12679 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12680 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12681 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12682 | } |
| 12683 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12684 | 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] | 12685 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12686 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12687 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12688 | if (hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12689 | __hdd_bus_bw_compute_timer_start(hdd_ctx); |
| 12690 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12691 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12692 | } |
| 12693 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12694 | 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] | 12695 | { |
Dustin Brown | a20bad5 | 2019-03-05 12:03:30 -0800 | [diff] [blame] | 12696 | if (!qdf_periodic_work_stop_sync(&hdd_ctx->bus_bw_work)) |
| 12697 | return; |
| 12698 | |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12699 | ucfg_ipa_set_perf_level(hdd_ctx->pdev, 0, 0); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12700 | hdd_reset_tcp_delack(hdd_ctx); |
| 12701 | } |
| 12702 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12703 | void hdd_bus_bw_compute_timer_stop(struct hdd_context *hdd_ctx) |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12704 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12705 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12706 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12707 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12708 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12709 | hdd_exit(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12710 | } |
| 12711 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12712 | 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] | 12713 | { |
Dustin Brown | 491d54b | 2018-03-14 12:39:11 -0700 | [diff] [blame] | 12714 | hdd_enter(); |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12715 | |
Dustin Brown | 5ec6b55 | 2017-03-31 12:11:40 -0700 | [diff] [blame] | 12716 | if (!hdd_any_adapter_is_assoc(hdd_ctx)) |
| 12717 | __hdd_bus_bw_compute_timer_stop(hdd_ctx); |
| 12718 | |
Dustin Brown | e74003f | 2018-03-14 12:51:58 -0700 | [diff] [blame] | 12719 | hdd_exit(); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12720 | } |
Tiger Yu | 8b119e9 | 2019-04-09 13:55:07 +0800 | [diff] [blame^] | 12721 | #endif /*WLAN_FEATURE_DP_BUS_BANDWIDTH*/ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12722 | |
| 12723 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12724 | * wlan_hdd_stop_sap() - This function stops bss of SAP. |
| 12725 | * @ap_adapter: SAP adapter |
| 12726 | * |
| 12727 | * This function will process the stopping of sap adapter. |
| 12728 | * |
| 12729 | * Return: None |
| 12730 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12731 | void wlan_hdd_stop_sap(struct hdd_adapter *ap_adapter) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12732 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12733 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12734 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12735 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12736 | struct hdd_context *hdd_ctx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12737 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12738 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12739 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12740 | return; |
| 12741 | } |
| 12742 | |
| 12743 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12744 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12745 | if (wlan_hdd_validate_context(hdd_ctx)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12746 | return; |
Abhishek Singh | 23edd1c | 2016-05-05 11:56:06 +0530 | [diff] [blame] | 12747 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12748 | mutex_lock(&hdd_ctx->sap_lock); |
| 12749 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
Ryan Hsu | 8ecb0fa | 2016-01-18 15:40:55 -0800 | [diff] [blame] | 12750 | wlan_hdd_del_station(ap_adapter); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12751 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12752 | hdd_debug("Now doing SAP STOPBSS"); |
Anurag Chouhan | f04e84f | 2016-03-03 10:12:12 +0530 | [diff] [blame] | 12753 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12754 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(hdd_ap_ctx-> |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12755 | sap_context)) { |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12756 | qdf_status = qdf_wait_for_event_completion(&hostapd_state-> |
Naveen Rawat | b56880c | 2016-12-13 17:56:03 -0800 | [diff] [blame] | 12757 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12758 | SME_CMD_STOP_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12759 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12760 | mutex_unlock(&hdd_ctx->sap_lock); |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12761 | hdd_err("SAP Stop Failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12762 | return; |
| 12763 | } |
| 12764 | } |
| 12765 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12766 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12767 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12768 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12769 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12770 | false); |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12771 | hdd_debug("SAP Stop Success"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12772 | } else { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12773 | hdd_err("Can't stop ap because its not started"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12774 | } |
| 12775 | mutex_unlock(&hdd_ctx->sap_lock); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12776 | } |
| 12777 | |
| 12778 | /** |
| 12779 | * wlan_hdd_start_sap() - this function starts bss of SAP. |
| 12780 | * @ap_adapter: SAP adapter |
| 12781 | * |
| 12782 | * This function will process the starting of sap adapter. |
| 12783 | * |
| 12784 | * Return: None |
| 12785 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 12786 | void wlan_hdd_start_sap(struct hdd_adapter *ap_adapter, bool reinit) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12787 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 12788 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 12789 | struct hdd_hostapd_state *hostapd_state; |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12790 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12791 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 12792 | struct sap_config *sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12793 | |
Jeff Johnson | d36fa33 | 2019-03-18 13:42:25 -0700 | [diff] [blame] | 12794 | if (!ap_adapter) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12795 | hdd_err("ap_adapter is NULL here"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12796 | return; |
| 12797 | } |
| 12798 | |
Krunal Soni | 9b04c9b | 2016-03-10 13:08:05 -0800 | [diff] [blame] | 12799 | if (QDF_SAP_MODE != ap_adapter->device_mode) { |
Peng Xu | f5d60c8 | 2015-10-02 17:17:03 -0700 | [diff] [blame] | 12800 | hdd_err("SoftAp role has not been enabled"); |
| 12801 | return; |
| 12802 | } |
| 12803 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12804 | hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
| 12805 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
| 12806 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
Jeff Johnson | b942486 | 2017-10-30 08:49:35 -0700 | [diff] [blame] | 12807 | sap_config = &ap_adapter->session.ap.sap_config; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12808 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12809 | mutex_lock(&hdd_ctx->sap_lock); |
| 12810 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) |
| 12811 | goto end; |
| 12812 | |
| 12813 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12814 | hdd_err("SAP Not able to set AP IEs"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12815 | goto end; |
| 12816 | } |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 12817 | wlan_reg_set_channel_params(hdd_ctx->pdev, |
Abhinav Kumar | 6f69448 | 2018-09-04 16:07:39 +0530 | [diff] [blame] | 12818 | hdd_ap_ctx->sap_config.channel, 0, |
| 12819 | &hdd_ap_ctx->sap_config.ch_params); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12820 | |
Wei Song | 2f76f64 | 2016-11-18 16:32:53 +0800 | [diff] [blame] | 12821 | qdf_event_reset(&hostapd_state->qdf_event); |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 12822 | 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] | 12823 | &hdd_ap_ctx->sap_config, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12824 | ap_adapter->dev) |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 12825 | != QDF_STATUS_SUCCESS) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12826 | goto end; |
| 12827 | |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 12828 | hdd_debug("Waiting for SAP to start"); |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 12829 | qdf_status = qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 12830 | SME_CMD_START_BSS_TIMEOUT); |
Anurag Chouhan | ce0dc99 | 2016-02-16 18:18:03 +0530 | [diff] [blame] | 12831 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12832 | hdd_err("SAP Start failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12833 | goto end; |
| 12834 | } |
Jeff Johnson | 28f8a77 | 2016-08-15 15:30:36 -0700 | [diff] [blame] | 12835 | hdd_info("SAP Start Success"); |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12836 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12837 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12838 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 12839 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 12840 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 12841 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 12842 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 12843 | true); |
| 12844 | } |
Sourav Mohapatra | 9bc6711 | 2017-11-08 09:36:11 +0530 | [diff] [blame] | 12845 | mutex_unlock(&hdd_ctx->sap_lock); |
| 12846 | |
| 12847 | return; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12848 | end: |
Vignesh Viswanathan | 85b455e | 2018-01-17 19:54:33 +0530 | [diff] [blame] | 12849 | wlansap_reset_sap_config_add_ie(sap_config, eUPDATE_IE_ALL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12850 | mutex_unlock(&hdd_ctx->sap_lock); |
Manikandan Mohan | 3dad1a4 | 2017-06-14 10:50:18 -0700 | [diff] [blame] | 12851 | /* SAP context and beacon cleanup will happen during driver unload |
| 12852 | * in hdd_stop_adapter |
| 12853 | */ |
| 12854 | hdd_err("SAP restart after SSR failed! Reload WLAN and try SAP again"); |
| 12855 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12856 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12857 | |
| 12858 | /** |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12859 | * hdd_get_fw_version() - Get FW version |
| 12860 | * @hdd_ctx: pointer to HDD context. |
| 12861 | * @major_spid: FW version - major spid. |
| 12862 | * @minor_spid: FW version - minor spid |
| 12863 | * @ssid: FW version - ssid |
| 12864 | * @crmid: FW version - crmid |
| 12865 | * |
| 12866 | * This function is called to get the firmware build version stored |
| 12867 | * as part of the HDD context |
| 12868 | * |
| 12869 | * Return: None |
| 12870 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 12871 | void hdd_get_fw_version(struct hdd_context *hdd_ctx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12872 | uint32_t *major_spid, uint32_t *minor_spid, |
| 12873 | uint32_t *siid, uint32_t *crmid) |
| 12874 | { |
| 12875 | *major_spid = (hdd_ctx->target_fw_version & 0xf0000000) >> 28; |
| 12876 | *minor_spid = (hdd_ctx->target_fw_version & 0xf000000) >> 24; |
| 12877 | *siid = (hdd_ctx->target_fw_version & 0xf00000) >> 20; |
| 12878 | *crmid = hdd_ctx->target_fw_version & 0x7fff; |
| 12879 | } |
| 12880 | |
| 12881 | #ifdef QCA_CONFIG_SMP |
| 12882 | /** |
| 12883 | * wlan_hdd_get_cpu() - get cpu_index |
| 12884 | * |
| 12885 | * Return: cpu_index |
| 12886 | */ |
| 12887 | int wlan_hdd_get_cpu(void) |
| 12888 | { |
| 12889 | int cpu_index = get_cpu(); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 12890 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 12891 | put_cpu(); |
| 12892 | return cpu_index; |
| 12893 | } |
| 12894 | #endif |
| 12895 | |
| 12896 | /** |
| 12897 | * hdd_get_fwpath() - get framework path |
| 12898 | * |
| 12899 | * This function is used to get the string written by |
| 12900 | * userspace to start the wlan driver |
| 12901 | * |
| 12902 | * Return: string |
| 12903 | */ |
| 12904 | const char *hdd_get_fwpath(void) |
| 12905 | { |
| 12906 | return fwpath.string; |
| 12907 | } |
| 12908 | |
Dustin Brown | 94ce20f | 2018-09-04 13:11:38 -0700 | [diff] [blame] | 12909 | static inline int hdd_state_query_cb(void) |
| 12910 | { |
| 12911 | return !!wlan_hdd_validate_context(cds_get_context(QDF_MODULE_ID_HDD)); |
| 12912 | } |
| 12913 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12914 | static int __hdd_op_protect_cb(void **out_sync, const char *func) |
| 12915 | { |
| 12916 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 12917 | |
| 12918 | if (!hdd_ctx) |
| 12919 | return -EAGAIN; |
| 12920 | |
| 12921 | return __osif_psoc_sync_op_start(hdd_ctx->parent_dev, |
| 12922 | (struct osif_psoc_sync **)out_sync, |
| 12923 | func); |
| 12924 | } |
| 12925 | |
| 12926 | static void __hdd_op_unprotect_cb(void *sync, const char *func) |
| 12927 | { |
| 12928 | __osif_psoc_sync_op_stop(sync, func); |
| 12929 | } |
| 12930 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12931 | /** |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12932 | * hdd_init() - Initialize Driver |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12933 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12934 | * This function initilizes CDS global context with the help of cds_init. This |
| 12935 | * has to be the first function called after probe to get a valid global |
| 12936 | * context. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12937 | * |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12938 | * Return: 0 for success, errno on failure |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12939 | */ |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12940 | int hdd_init(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12941 | { |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12942 | QDF_STATUS status; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12943 | |
Jeff Johnson | 7aaeeea | 2017-09-26 13:16:24 -0700 | [diff] [blame] | 12944 | status = cds_init(); |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12945 | if (QDF_IS_STATUS_ERROR(status)) { |
| 12946 | hdd_err("Failed to allocate CDS context"); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12947 | return -ENOMEM; |
wadesong | ae4ffd1 | 2017-10-24 16:45:54 +0800 | [diff] [blame] | 12948 | } |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 12949 | |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12950 | qdf_op_callbacks_register(__hdd_op_protect_cb, __hdd_op_unprotect_cb); |
Hanumanth Reddy Pothula | 788a37e | 2017-08-17 18:40:11 +0530 | [diff] [blame] | 12951 | |
| 12952 | wlan_init_bug_report_lock(); |
| 12953 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12954 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12955 | wlan_logging_sock_init_svc(); |
| 12956 | #endif |
| 12957 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12958 | hdd_trace_init(); |
Padma, Santhosh Kumar | 9aba02f | 2016-08-11 16:30:25 +0530 | [diff] [blame] | 12959 | hdd_register_debug_callback(); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12960 | wlan_roam_debug_init(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12961 | |
Dustin Brown | fe50cef | 2018-12-10 10:42:37 -0800 | [diff] [blame] | 12962 | return 0; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12963 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12964 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12965 | /** |
| 12966 | * hdd_deinit() - Deinitialize Driver |
| 12967 | * |
| 12968 | * This function frees CDS global context with the help of cds_deinit. This |
| 12969 | * has to be the last function call in remove callback to free the global |
| 12970 | * context. |
| 12971 | */ |
| 12972 | void hdd_deinit(void) |
| 12973 | { |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12974 | wlan_roam_debug_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12975 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12976 | #ifdef WLAN_LOGGING_SOCK_SVC_ENABLE |
| 12977 | wlan_logging_sock_deinit_svc(); |
| 12978 | #endif |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12979 | |
| 12980 | wlan_destroy_bug_report_lock(); |
Dustin Brown | 265e82b | 2019-03-18 11:07:32 -0700 | [diff] [blame] | 12981 | qdf_op_callbacks_register(NULL, NULL); |
Qiwei Cai | ad9b01c | 2018-07-09 17:21:31 +0800 | [diff] [blame] | 12982 | cds_deinit(); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 12983 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12984 | |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12985 | #ifdef QCA_WIFI_NAPIER_EMULATION |
| 12986 | #define HDD_WLAN_START_WAIT_TIME ((CDS_WMA_TIMEOUT + 5000) * 100) |
| 12987 | #else |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12988 | #define HDD_WLAN_START_WAIT_TIME (CDS_WMA_TIMEOUT + 5000) |
Yue Ma | 6e7b1a0 | 2017-04-03 14:17:46 -0700 | [diff] [blame] | 12989 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 12990 | |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 12991 | static int wlan_hdd_state_ctrl_param_open(struct inode *inode, |
| 12992 | struct file *file) |
| 12993 | { |
| 12994 | return 0; |
| 12995 | } |
| 12996 | |
| 12997 | static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp, |
| 12998 | const char __user *user_buf, |
| 12999 | size_t count, |
| 13000 | loff_t *f_pos) |
| 13001 | { |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13002 | char buf[3]; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13003 | static const char wlan_off_str[] = "OFF"; |
| 13004 | static const char wlan_on_str[] = "ON"; |
| 13005 | int ret; |
| 13006 | unsigned long rc; |
| 13007 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13008 | if (copy_from_user(buf, user_buf, 3)) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13009 | pr_err("Failed to read buffer\n"); |
| 13010 | return -EINVAL; |
| 13011 | } |
| 13012 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13013 | if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13014 | pr_debug("Wifi turning off from UI\n"); |
| 13015 | goto exit; |
| 13016 | } |
| 13017 | |
Srinivas Girigowda | d241288 | 2018-09-07 15:42:04 -0700 | [diff] [blame] | 13018 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13019 | pr_info("Wifi Turning On from UI\n"); |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13020 | |
SaidiReddy Yenuga | c356f15 | 2017-04-06 17:43:01 +0530 | [diff] [blame] | 13021 | if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) { |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13022 | pr_err("Invalid value received from framework"); |
| 13023 | goto exit; |
| 13024 | } |
| 13025 | |
| 13026 | if (!cds_is_driver_loaded()) { |
Sachin Ahuja | ee62b54 | 2017-04-21 14:14:16 +0530 | [diff] [blame] | 13027 | init_completion(&wlan_start_comp); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13028 | rc = wait_for_completion_timeout(&wlan_start_comp, |
| 13029 | msecs_to_jiffies(HDD_WLAN_START_WAIT_TIME)); |
| 13030 | if (!rc) { |
Srinivas Girigowda | 09625b0 | 2018-09-10 15:28:09 -0700 | [diff] [blame] | 13031 | hdd_alert("Timed-out!!"); |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13032 | ret = -EINVAL; |
Sachin Ahuja | dddd263 | 2017-03-07 19:07:24 +0530 | [diff] [blame] | 13033 | return ret; |
| 13034 | } |
| 13035 | |
| 13036 | hdd_start_complete(0); |
| 13037 | } |
| 13038 | |
| 13039 | exit: |
| 13040 | return count; |
| 13041 | } |
| 13042 | |
| 13043 | |
| 13044 | const struct file_operations wlan_hdd_state_fops = { |
| 13045 | .owner = THIS_MODULE, |
| 13046 | .open = wlan_hdd_state_ctrl_param_open, |
| 13047 | .write = wlan_hdd_state_ctrl_param_write, |
| 13048 | }; |
| 13049 | |
| 13050 | static int wlan_hdd_state_ctrl_param_create(void) |
| 13051 | { |
| 13052 | unsigned int wlan_hdd_state_major = 0; |
| 13053 | int ret; |
| 13054 | struct device *dev; |
| 13055 | |
| 13056 | device = MKDEV(wlan_hdd_state_major, 0); |
| 13057 | |
| 13058 | ret = alloc_chrdev_region(&device, 0, dev_num, "qcwlanstate"); |
| 13059 | if (ret) { |
| 13060 | pr_err("Failed to register qcwlanstate"); |
| 13061 | goto dev_alloc_err; |
| 13062 | } |
| 13063 | wlan_hdd_state_major = MAJOR(device); |
| 13064 | |
| 13065 | class = class_create(THIS_MODULE, WLAN_MODULE_NAME); |
| 13066 | if (IS_ERR(class)) { |
| 13067 | pr_err("wlan_hdd_state class_create error"); |
| 13068 | goto class_err; |
| 13069 | } |
| 13070 | |
| 13071 | dev = device_create(class, NULL, device, NULL, WLAN_MODULE_NAME); |
| 13072 | if (IS_ERR(dev)) { |
| 13073 | pr_err("wlan_hdd_statedevice_create error"); |
| 13074 | goto err_class_destroy; |
| 13075 | } |
| 13076 | |
| 13077 | cdev_init(&wlan_hdd_state_cdev, &wlan_hdd_state_fops); |
| 13078 | ret = cdev_add(&wlan_hdd_state_cdev, device, dev_num); |
| 13079 | if (ret) { |
| 13080 | pr_err("Failed to add cdev error"); |
| 13081 | goto cdev_add_err; |
| 13082 | } |
| 13083 | |
| 13084 | pr_info("wlan_hdd_state %s major(%d) initialized", |
| 13085 | WLAN_MODULE_NAME, wlan_hdd_state_major); |
| 13086 | |
| 13087 | return 0; |
| 13088 | |
| 13089 | cdev_add_err: |
| 13090 | device_destroy(class, device); |
| 13091 | err_class_destroy: |
| 13092 | class_destroy(class); |
| 13093 | class_err: |
| 13094 | unregister_chrdev_region(device, dev_num); |
| 13095 | dev_alloc_err: |
| 13096 | return -ENODEV; |
| 13097 | } |
| 13098 | |
| 13099 | static void wlan_hdd_state_ctrl_param_destroy(void) |
| 13100 | { |
| 13101 | cdev_del(&wlan_hdd_state_cdev); |
| 13102 | device_destroy(class, device); |
| 13103 | class_destroy(class); |
| 13104 | unregister_chrdev_region(device, dev_num); |
| 13105 | |
| 13106 | pr_info("Device node unregistered"); |
| 13107 | } |
| 13108 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13109 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13110 | * hdd_component_init() - Initialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13111 | * |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13112 | * Return: QDF_STATUS |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13113 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13114 | static QDF_STATUS hdd_component_init(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13115 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13116 | QDF_STATUS status; |
| 13117 | |
| 13118 | /* initialize converged components */ |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13119 | status = target_if_init(wma_get_psoc_from_scn_handle); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13120 | if (QDF_IS_STATUS_ERROR(status)) |
| 13121 | return status; |
| 13122 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13123 | status = ucfg_mlme_global_init(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13124 | if (QDF_IS_STATUS_ERROR(status)) |
| 13125 | goto target_if_deinit; |
| 13126 | |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13127 | status = dispatcher_init(); |
| 13128 | if (QDF_IS_STATUS_ERROR(status)) |
| 13129 | goto mlme_global_deinit; |
| 13130 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13131 | /* initialize non-converged components */ |
| 13132 | status = ucfg_mlme_init(); |
| 13133 | if (QDF_IS_STATUS_ERROR(status)) |
| 13134 | goto dispatcher_deinit; |
| 13135 | |
| 13136 | status = ucfg_fwol_init(); |
| 13137 | if (QDF_IS_STATUS_ERROR(status)) |
| 13138 | goto mlme_deinit; |
| 13139 | |
| 13140 | status = disa_init(); |
| 13141 | if (QDF_IS_STATUS_ERROR(status)) |
| 13142 | goto fwol_deinit; |
| 13143 | |
| 13144 | status = pmo_init(); |
| 13145 | if (QDF_IS_STATUS_ERROR(status)) |
| 13146 | goto disa_deinit; |
| 13147 | |
| 13148 | status = ucfg_ocb_init(); |
| 13149 | if (QDF_IS_STATUS_ERROR(status)) |
| 13150 | goto pmo_deinit; |
| 13151 | |
| 13152 | status = ipa_init(); |
| 13153 | if (QDF_IS_STATUS_ERROR(status)) |
| 13154 | goto ocb_deinit; |
| 13155 | |
| 13156 | status = ucfg_action_oui_init(); |
| 13157 | if (QDF_IS_STATUS_ERROR(status)) |
| 13158 | goto ipa_deinit; |
| 13159 | |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13160 | status = nan_init(); |
| 13161 | if (QDF_IS_STATUS_ERROR(status)) |
| 13162 | goto action_oui_deinit; |
| 13163 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13164 | status = ucfg_p2p_init(); |
| 13165 | if (QDF_IS_STATUS_ERROR(status)) |
| 13166 | goto nan_deinit; |
| 13167 | |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13168 | status = policy_mgr_init(); |
| 13169 | if (QDF_IS_STATUS_ERROR(status)) |
| 13170 | goto p2p_deinit; |
| 13171 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13172 | status = ucfg_tdls_init(); |
| 13173 | if (QDF_IS_STATUS_ERROR(status)) |
| 13174 | goto policy_deinit; |
| 13175 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13176 | return QDF_STATUS_SUCCESS; |
| 13177 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13178 | policy_deinit: |
| 13179 | policy_mgr_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13180 | p2p_deinit: |
| 13181 | ucfg_p2p_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13182 | nan_deinit: |
| 13183 | nan_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13184 | action_oui_deinit: |
| 13185 | ucfg_action_oui_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13186 | ipa_deinit: |
| 13187 | ipa_deinit(); |
| 13188 | ocb_deinit: |
| 13189 | ucfg_ocb_deinit(); |
| 13190 | pmo_deinit: |
| 13191 | pmo_deinit(); |
| 13192 | disa_deinit: |
| 13193 | disa_deinit(); |
| 13194 | fwol_deinit: |
| 13195 | ucfg_fwol_deinit(); |
| 13196 | mlme_deinit: |
| 13197 | ucfg_mlme_deinit(); |
| 13198 | dispatcher_deinit: |
| 13199 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13200 | mlme_global_deinit: |
| 13201 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13202 | target_if_deinit: |
| 13203 | target_if_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13204 | |
| 13205 | return status; |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13206 | } |
| 13207 | |
| 13208 | /** |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13209 | * hdd_component_deinit() - Deinitialize all components |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13210 | * |
| 13211 | * Return: None |
| 13212 | */ |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13213 | static void hdd_component_deinit(void) |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13214 | { |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13215 | /* deinitialize non-converged components */ |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13216 | ucfg_tdls_deinit(); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13217 | policy_mgr_deinit(); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13218 | ucfg_p2p_deinit(); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13219 | nan_deinit(); |
Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame] | 13220 | ucfg_action_oui_deinit(); |
Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame] | 13221 | ipa_deinit(); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13222 | ucfg_ocb_deinit(); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13223 | pmo_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13224 | disa_deinit(); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13225 | ucfg_fwol_deinit(); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13226 | ucfg_mlme_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13227 | |
| 13228 | /* deinitialize converged components */ |
| 13229 | dispatcher_deinit(); |
Abhishek Singh | d5cf22d | 2019-01-08 19:51:09 +0530 | [diff] [blame] | 13230 | ucfg_mlme_global_deinit(); |
Arif Hussain | 4969811 | 2018-07-31 00:32:50 -0700 | [diff] [blame] | 13231 | target_if_deinit(); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13232 | } |
| 13233 | |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13234 | QDF_STATUS hdd_component_psoc_open(struct wlan_objmgr_psoc *psoc) |
| 13235 | { |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13236 | QDF_STATUS status; |
| 13237 | |
| 13238 | status = ucfg_mlme_psoc_open(psoc); |
| 13239 | if (QDF_IS_STATUS_ERROR(status)) |
| 13240 | return status; |
| 13241 | |
| 13242 | status = ucfg_fwol_psoc_open(psoc); |
| 13243 | if (QDF_IS_STATUS_ERROR(status)) |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13244 | goto err_fwol; |
| 13245 | |
| 13246 | status = ucfg_pmo_psoc_open(psoc); |
| 13247 | if (QDF_IS_STATUS_ERROR(status)) |
| 13248 | goto err_pmo; |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13249 | |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13250 | status = ucfg_policy_mgr_psoc_open(psoc); |
| 13251 | if (QDF_IS_STATUS_ERROR(status)) |
| 13252 | goto err_plcy_mgr; |
| 13253 | |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13254 | status = ucfg_p2p_psoc_open(psoc); |
| 13255 | if (QDF_IS_STATUS_ERROR(status)) |
| 13256 | goto err_p2p; |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13257 | |
| 13258 | status = ucfg_tdls_psoc_open(psoc); |
| 13259 | if (QDF_IS_STATUS_ERROR(status)) |
| 13260 | goto err_tdls; |
| 13261 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13262 | return status; |
| 13263 | |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13264 | err_tdls: |
| 13265 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13266 | err_p2p: |
| 13267 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13268 | err_plcy_mgr: |
| 13269 | ucfg_pmo_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13270 | err_pmo: |
| 13271 | ucfg_fwol_psoc_close(psoc); |
| 13272 | err_fwol: |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13273 | ucfg_mlme_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13274 | |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13275 | return status; |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13276 | } |
| 13277 | |
| 13278 | void hdd_component_psoc_close(struct wlan_objmgr_psoc *psoc) |
| 13279 | { |
Wu Gao | 5f79340 | 2018-12-08 11:04:00 +0800 | [diff] [blame] | 13280 | ucfg_tdls_psoc_close(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13281 | ucfg_p2p_psoc_close(psoc); |
Krunal Soni | e9c12f5 | 2018-10-04 11:45:42 -0700 | [diff] [blame] | 13282 | ucfg_policy_mgr_psoc_close(psoc); |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 13283 | ucfg_pmo_psoc_close(psoc); |
Sourav Mohapatra | 113685f | 2018-08-29 14:21:55 +0530 | [diff] [blame] | 13284 | ucfg_fwol_psoc_close(psoc); |
Vignesh Viswanathan | a0921c4 | 2018-09-04 19:03:35 +0530 | [diff] [blame] | 13285 | ucfg_mlme_psoc_close(psoc); |
Vignesh Viswanathan | 21c58cb | 2018-05-24 15:53:58 +0530 | [diff] [blame] | 13286 | } |
| 13287 | |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13288 | void hdd_component_psoc_enable(struct wlan_objmgr_psoc *psoc) |
| 13289 | { |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13290 | ocb_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13291 | disa_psoc_enable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13292 | nan_psoc_enable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13293 | p2p_psoc_enable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13294 | policy_mgr_psoc_enable(psoc); |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13295 | ucfg_tdls_psoc_enable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13296 | } |
| 13297 | |
| 13298 | void hdd_component_psoc_disable(struct wlan_objmgr_psoc *psoc) |
| 13299 | { |
Wu Gao | a67c380 | 2018-12-27 12:07:52 +0800 | [diff] [blame] | 13300 | ucfg_tdls_psoc_disable(psoc); |
Wu Gao | d6b5e40 | 2018-12-03 22:09:24 +0800 | [diff] [blame] | 13301 | policy_mgr_psoc_disable(psoc); |
Wu Gao | 637d58a | 2018-12-08 10:37:34 +0800 | [diff] [blame] | 13302 | p2p_psoc_disable(psoc); |
Nachiket Kukade | 63bb63d | 2018-11-21 14:42:14 +0530 | [diff] [blame] | 13303 | nan_psoc_disable(psoc); |
Nachiket Kukade | 98f562a | 2017-12-15 12:18:07 +0530 | [diff] [blame] | 13304 | disa_psoc_disable(psoc); |
Zhang Qian | 47e22ce | 2018-01-04 15:38:38 +0800 | [diff] [blame] | 13305 | ocb_psoc_disable(psoc); |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13306 | } |
| 13307 | |
Sandeep Puligilla | b7beb47 | 2018-08-13 22:54:20 -0700 | [diff] [blame] | 13308 | QDF_STATUS hdd_component_pdev_open(struct wlan_objmgr_pdev *pdev) |
| 13309 | { |
| 13310 | return ucfg_mlme_pdev_open(pdev); |
| 13311 | } |
| 13312 | |
| 13313 | void hdd_component_pdev_close(struct wlan_objmgr_pdev *pdev) |
| 13314 | { |
| 13315 | ucfg_mlme_pdev_close(pdev); |
| 13316 | } |
| 13317 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13318 | static QDF_STATUS hdd_qdf_print_init(void) |
| 13319 | { |
| 13320 | QDF_STATUS status; |
| 13321 | int qdf_print_idx; |
| 13322 | |
| 13323 | status = qdf_print_setup(); |
| 13324 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13325 | pr_err("Failed qdf_print_setup; status:%u\n", status); |
| 13326 | return status; |
| 13327 | } |
| 13328 | |
| 13329 | qdf_print_idx = qdf_print_ctrl_register(cinfo, NULL, NULL, "MCL_WLAN"); |
| 13330 | if (qdf_print_idx < 0) { |
| 13331 | pr_err("Failed to register for qdf_print_ctrl\n"); |
| 13332 | return QDF_STATUS_E_FAILURE; |
| 13333 | } |
| 13334 | |
| 13335 | qdf_set_pidx(qdf_print_idx); |
| 13336 | |
| 13337 | return QDF_STATUS_SUCCESS; |
| 13338 | } |
| 13339 | |
| 13340 | static void hdd_qdf_print_deinit(void) |
| 13341 | { |
| 13342 | int qdf_pidx = qdf_get_pidx(); |
| 13343 | |
| 13344 | qdf_set_pidx(-1); |
| 13345 | qdf_print_ctrl_cleanup(qdf_pidx); |
| 13346 | |
| 13347 | /* currently, no qdf print 'un-setup'*/ |
| 13348 | } |
| 13349 | |
| 13350 | static QDF_STATUS hdd_qdf_init(void) |
| 13351 | { |
| 13352 | QDF_STATUS status; |
| 13353 | |
| 13354 | status = hdd_qdf_print_init(); |
| 13355 | if (QDF_IS_STATUS_ERROR(status)) |
| 13356 | goto exit; |
| 13357 | |
| 13358 | status = qdf_debugfs_init(); |
| 13359 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13360 | hdd_err("Failed to init debugfs; status:%u", status); |
| 13361 | goto print_deinit; |
| 13362 | } |
| 13363 | |
| 13364 | qdf_lock_stats_init(); |
| 13365 | qdf_mem_init(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13366 | qdf_delayed_work_feature_init(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13367 | qdf_periodic_work_feature_init(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13368 | qdf_mc_timer_manager_init(); |
| 13369 | qdf_event_list_init(); |
| 13370 | |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13371 | status = qdf_talloc_feature_init(); |
| 13372 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13373 | hdd_err("Failed to init talloc; status:%u", status); |
| 13374 | goto event_deinit; |
| 13375 | } |
| 13376 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13377 | status = qdf_cpuhp_init(); |
| 13378 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13379 | hdd_err("Failed to init cpuhp; status:%u", status); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13380 | goto talloc_deinit; |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13381 | } |
| 13382 | |
| 13383 | status = qdf_trace_spin_lock_init(); |
| 13384 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13385 | hdd_err("Failed to init spinlock; status:%u", status); |
| 13386 | goto cpuhp_deinit; |
| 13387 | } |
| 13388 | |
| 13389 | qdf_trace_init(); |
| 13390 | qdf_register_debugcb_init(); |
| 13391 | |
| 13392 | return QDF_STATUS_SUCCESS; |
| 13393 | |
| 13394 | cpuhp_deinit: |
| 13395 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13396 | talloc_deinit: |
| 13397 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13398 | event_deinit: |
| 13399 | qdf_event_list_destroy(); |
| 13400 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13401 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13402 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13403 | qdf_mem_exit(); |
| 13404 | qdf_lock_stats_deinit(); |
| 13405 | qdf_debugfs_exit(); |
| 13406 | print_deinit: |
| 13407 | hdd_qdf_print_deinit(); |
| 13408 | |
| 13409 | exit: |
| 13410 | return status; |
| 13411 | } |
| 13412 | |
| 13413 | static void hdd_qdf_deinit(void) |
| 13414 | { |
| 13415 | /* currently, no debugcb deinit */ |
| 13416 | |
| 13417 | qdf_trace_deinit(); |
| 13418 | |
| 13419 | /* currently, no trace spinlock deinit */ |
| 13420 | |
| 13421 | qdf_cpuhp_deinit(); |
Dustin Brown | d315c45 | 2018-11-27 11:28:48 -0800 | [diff] [blame] | 13422 | qdf_talloc_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13423 | qdf_event_list_destroy(); |
| 13424 | qdf_mc_timer_manager_exit(); |
Dustin Brown | 4a93bb5 | 2019-03-13 11:46:34 -0700 | [diff] [blame] | 13425 | qdf_periodic_work_feature_deinit(); |
Dustin Brown | c279631 | 2019-03-13 16:43:36 -0700 | [diff] [blame] | 13426 | qdf_delayed_work_feature_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13427 | qdf_mem_exit(); |
| 13428 | qdf_lock_stats_deinit(); |
| 13429 | qdf_debugfs_exit(); |
| 13430 | hdd_qdf_print_deinit(); |
| 13431 | } |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13432 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13433 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
| 13434 | static bool is_monitor_mode_supported(void) |
| 13435 | { |
| 13436 | return true; |
| 13437 | } |
| 13438 | #else |
| 13439 | static bool is_monitor_mode_supported(void) |
| 13440 | { |
| 13441 | pr_err("Monitor mode not supported!"); |
| 13442 | return false; |
| 13443 | } |
| 13444 | #endif |
| 13445 | |
| 13446 | #ifdef WLAN_FEATURE_EPPING |
| 13447 | static bool is_epping_mode_supported(void) |
| 13448 | { |
| 13449 | return true; |
| 13450 | } |
| 13451 | #else |
| 13452 | static bool is_epping_mode_supported(void) |
| 13453 | { |
| 13454 | pr_err("Epping mode not supported!"); |
| 13455 | return false; |
| 13456 | } |
| 13457 | #endif |
| 13458 | |
| 13459 | #ifdef QCA_WIFI_FTM |
| 13460 | static bool is_ftm_mode_supported(void) |
| 13461 | { |
| 13462 | return true; |
| 13463 | } |
| 13464 | #else |
| 13465 | static bool is_ftm_mode_supported(void) |
| 13466 | { |
| 13467 | pr_err("FTM mode not supported!"); |
| 13468 | return false; |
| 13469 | } |
| 13470 | #endif |
| 13471 | |
| 13472 | /** |
| 13473 | * is_con_mode_valid() check con mode is valid or not |
| 13474 | * @mode: global con mode |
| 13475 | * |
| 13476 | * Return: TRUE on success FALSE on failure |
| 13477 | */ |
| 13478 | static bool is_con_mode_valid(enum QDF_GLOBAL_MODE mode) |
| 13479 | { |
| 13480 | switch (mode) { |
| 13481 | case QDF_GLOBAL_MONITOR_MODE: |
| 13482 | return is_monitor_mode_supported(); |
| 13483 | case QDF_GLOBAL_EPPING_MODE: |
| 13484 | return is_epping_mode_supported(); |
| 13485 | case QDF_GLOBAL_FTM_MODE: |
| 13486 | return is_ftm_mode_supported(); |
| 13487 | case QDF_GLOBAL_MISSION_MODE: |
| 13488 | return true; |
| 13489 | default: |
| 13490 | return false; |
| 13491 | } |
| 13492 | } |
| 13493 | |
| 13494 | static void hdd_stop_present_mode(struct hdd_context *hdd_ctx, |
| 13495 | enum QDF_GLOBAL_MODE curr_mode) |
| 13496 | { |
| 13497 | if (hdd_ctx->driver_status == DRIVER_MODULES_CLOSED) |
| 13498 | return; |
| 13499 | |
| 13500 | switch (curr_mode) { |
| 13501 | case QDF_GLOBAL_MONITOR_MODE: |
| 13502 | hdd_info("Release wakelock for monitor mode!"); |
| 13503 | qdf_wake_lock_release(&hdd_ctx->monitor_mode_wakelock, |
| 13504 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13505 | /* fallthrough */ |
| 13506 | case QDF_GLOBAL_MISSION_MODE: |
| 13507 | case QDF_GLOBAL_FTM_MODE: |
| 13508 | hdd_abort_mac_scan_all_adapters(hdd_ctx); |
| 13509 | wlan_cfg80211_cleanup_scan_queue(hdd_ctx->pdev, NULL); |
| 13510 | hdd_stop_all_adapters(hdd_ctx); |
| 13511 | hdd_deinit_all_adapters(hdd_ctx, false); |
| 13512 | |
| 13513 | break; |
| 13514 | default: |
| 13515 | break; |
| 13516 | } |
| 13517 | } |
| 13518 | |
| 13519 | static void hdd_cleanup_present_mode(struct hdd_context *hdd_ctx, |
| 13520 | enum QDF_GLOBAL_MODE curr_mode) |
| 13521 | { |
| 13522 | int driver_status; |
| 13523 | |
| 13524 | driver_status = hdd_ctx->driver_status; |
| 13525 | |
| 13526 | switch (curr_mode) { |
| 13527 | case QDF_GLOBAL_MISSION_MODE: |
| 13528 | case QDF_GLOBAL_MONITOR_MODE: |
| 13529 | case QDF_GLOBAL_FTM_MODE: |
| 13530 | hdd_close_all_adapters(hdd_ctx, false); |
| 13531 | break; |
| 13532 | case QDF_GLOBAL_EPPING_MODE: |
| 13533 | epping_disable(); |
| 13534 | epping_close(); |
| 13535 | break; |
| 13536 | default: |
| 13537 | return; |
| 13538 | } |
| 13539 | } |
| 13540 | |
| 13541 | static int |
| 13542 | hdd_parse_driver_mode(const char *mode_str, enum QDF_GLOBAL_MODE *out_mode) |
| 13543 | { |
| 13544 | QDF_STATUS status; |
| 13545 | uint32_t mode; |
| 13546 | |
| 13547 | *out_mode = QDF_GLOBAL_MAX_MODE; |
| 13548 | |
| 13549 | status = qdf_uint32_parse(mode_str, &mode); |
| 13550 | if (QDF_IS_STATUS_ERROR(status)) |
| 13551 | return qdf_status_to_os_return(status); |
| 13552 | |
| 13553 | if (mode >= QDF_GLOBAL_MAX_MODE) |
| 13554 | return -ERANGE; |
| 13555 | |
| 13556 | *out_mode = (enum QDF_GLOBAL_MODE)mode; |
| 13557 | |
| 13558 | return 0; |
| 13559 | } |
| 13560 | |
| 13561 | /** |
| 13562 | * __hdd_driver_mode_change() - Handles a driver mode change |
| 13563 | * @hdd_ctx: Pointer to the global HDD context |
| 13564 | * @next_mode: the driver mode to transition to |
| 13565 | * |
| 13566 | * This function is invoked when user updates con_mode using sys entry, |
| 13567 | * to initialize and bring-up driver in that specific mode. |
| 13568 | * |
| 13569 | * Return: Errno |
| 13570 | */ |
| 13571 | static int __hdd_driver_mode_change(struct hdd_context *hdd_ctx, |
| 13572 | enum QDF_GLOBAL_MODE next_mode) |
| 13573 | { |
| 13574 | enum QDF_GLOBAL_MODE curr_mode; |
| 13575 | int errno; |
| 13576 | |
| 13577 | hdd_info("Driver mode changing to %d", next_mode); |
| 13578 | |
| 13579 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13580 | if (errno) |
| 13581 | return errno; |
| 13582 | |
| 13583 | if (!is_con_mode_valid(next_mode)) { |
| 13584 | hdd_err_rl("Requested driver mode is invalid"); |
| 13585 | return -EINVAL; |
| 13586 | } |
| 13587 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13588 | curr_mode = hdd_get_conparam(); |
| 13589 | if (curr_mode == next_mode) { |
| 13590 | hdd_err_rl("Driver is already in the requested mode"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13591 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13592 | } |
| 13593 | |
| 13594 | /* ensure adapters are stopped */ |
| 13595 | hdd_stop_present_mode(hdd_ctx, curr_mode); |
| 13596 | |
| 13597 | errno = hdd_wlan_stop_modules(hdd_ctx, true); |
| 13598 | if (errno) { |
| 13599 | hdd_err("Stop wlan modules failed"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13600 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13601 | } |
| 13602 | |
| 13603 | /* Cleanup present mode before switching to new mode */ |
| 13604 | hdd_cleanup_present_mode(hdd_ctx, curr_mode); |
| 13605 | |
| 13606 | hdd_set_conparam(next_mode); |
| 13607 | |
| 13608 | errno = hdd_wlan_start_modules(hdd_ctx, false); |
| 13609 | if (errno) { |
| 13610 | hdd_err("Start wlan modules failed: %d", errno); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13611 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13612 | } |
| 13613 | |
| 13614 | errno = hdd_open_adapters_for_mode(hdd_ctx, next_mode); |
| 13615 | if (errno) { |
| 13616 | hdd_err("Failed to open adapters"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13617 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13618 | } |
| 13619 | |
| 13620 | if (next_mode == QDF_GLOBAL_MONITOR_MODE) { |
| 13621 | struct hdd_adapter *adapter = |
| 13622 | hdd_get_adapter(hdd_ctx, QDF_MONITOR_MODE); |
| 13623 | |
| 13624 | QDF_BUG(adapter); |
| 13625 | if (!adapter) { |
| 13626 | hdd_err("Failed to get monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13627 | return -EINVAL; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13628 | } |
| 13629 | |
| 13630 | errno = hdd_start_adapter(adapter); |
| 13631 | if (errno) { |
| 13632 | hdd_err("Failed to start monitor adapter"); |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13633 | return errno; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13634 | } |
| 13635 | |
| 13636 | hdd_info("Acquire wakelock for monitor mode"); |
| 13637 | qdf_wake_lock_acquire(&hdd_ctx->monitor_mode_wakelock, |
| 13638 | WIFI_POWER_EVENT_WAKELOCK_MONITOR_MODE); |
| 13639 | } |
| 13640 | |
| 13641 | /* con_mode is a global module parameter */ |
| 13642 | con_mode = next_mode; |
| 13643 | hdd_info("Driver mode successfully changed to %d", next_mode); |
| 13644 | |
Dustin Brown | e0a7727 | 2019-03-19 16:28:06 -0700 | [diff] [blame] | 13645 | return 0; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13646 | } |
| 13647 | |
| 13648 | static int hdd_driver_mode_change(enum QDF_GLOBAL_MODE mode) |
| 13649 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13650 | struct osif_driver_sync *driver_sync; |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13651 | struct hdd_context *hdd_ctx; |
| 13652 | QDF_STATUS status; |
| 13653 | int errno; |
| 13654 | |
| 13655 | hdd_enter(); |
| 13656 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13657 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13658 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13659 | hdd_err("Failed to start 'mode change'; status:%u", status); |
| 13660 | errno = qdf_status_to_os_return(status); |
| 13661 | goto exit; |
| 13662 | } |
| 13663 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13664 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13665 | |
| 13666 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 13667 | errno = wlan_hdd_validate_context(hdd_ctx); |
| 13668 | if (errno) |
| 13669 | goto trans_stop; |
| 13670 | |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13671 | errno = __hdd_driver_mode_change(hdd_ctx, mode); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13672 | |
| 13673 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13674 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 26afe8f | 2019-03-01 12:37:24 -0800 | [diff] [blame] | 13675 | |
| 13676 | exit: |
| 13677 | hdd_exit(); |
| 13678 | |
| 13679 | return errno; |
| 13680 | } |
| 13681 | |
| 13682 | static int hdd_set_con_mode(enum QDF_GLOBAL_MODE mode) |
| 13683 | { |
| 13684 | con_mode = mode; |
| 13685 | |
| 13686 | return 0; |
| 13687 | } |
| 13688 | |
| 13689 | static int (*hdd_set_con_mode_cb)(enum QDF_GLOBAL_MODE mode) = hdd_set_con_mode; |
| 13690 | |
| 13691 | static void hdd_driver_mode_change_register(void) |
| 13692 | { |
| 13693 | hdd_set_con_mode_cb = hdd_driver_mode_change; |
| 13694 | } |
| 13695 | |
| 13696 | static void hdd_driver_mode_change_unregister(void) |
| 13697 | { |
| 13698 | hdd_set_con_mode_cb = hdd_set_con_mode; |
| 13699 | } |
| 13700 | |
| 13701 | static int con_mode_handler(const char *kmessage, const struct kernel_param *kp) |
| 13702 | { |
| 13703 | enum QDF_GLOBAL_MODE mode; |
| 13704 | int errno; |
| 13705 | |
| 13706 | errno = hdd_parse_driver_mode(kmessage, &mode); |
| 13707 | if (errno) { |
| 13708 | hdd_err_rl("Failed to parse driver mode '%s'", kmessage); |
| 13709 | return errno; |
| 13710 | } |
| 13711 | |
| 13712 | return hdd_set_con_mode_cb(mode); |
| 13713 | } |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13714 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13715 | /** |
| 13716 | * hdd_driver_load() - Perform the driver-level load operation |
| 13717 | * |
| 13718 | * Note: this is used in both static and DLKM driver builds |
| 13719 | * |
| 13720 | * Return: Errno |
| 13721 | */ |
| 13722 | static int hdd_driver_load(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13723 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13724 | struct osif_driver_sync *driver_sync; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13725 | QDF_STATUS status; |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13726 | int errno; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13727 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13728 | pr_err("%s: Loading driver v%s\n", WLAN_MODULE_NAME, |
Rajeev Kumar | e555e2d | 2018-09-17 11:52:37 -0700 | [diff] [blame] | 13729 | g_wlan_driver_version); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13730 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13731 | status = hdd_qdf_init(); |
| 13732 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13733 | errno = qdf_status_to_os_return(status); |
| 13734 | goto exit; |
| 13735 | } |
| 13736 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13737 | osif_sync_init(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13738 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13739 | status = osif_driver_sync_create_and_trans(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13740 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13741 | hdd_err("Failed to init driver sync; status:%u", status); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13742 | errno = qdf_status_to_os_return(status); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13743 | goto sync_deinit; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13744 | } |
| 13745 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13746 | errno = hdd_init(); |
| 13747 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13748 | hdd_err("Failed to init HDD; errno:%d", errno); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13749 | goto trans_stop; |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13750 | } |
| 13751 | |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13752 | status = hdd_component_init(); |
| 13753 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13754 | hdd_err("Failed to init components; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13755 | errno = qdf_status_to_os_return(status); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13756 | goto hdd_deinit; |
| 13757 | } |
Mukul Sharma | d75a667 | 2017-06-22 15:40:53 +0530 | [diff] [blame] | 13758 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13759 | status = qdf_wake_lock_create(&wlan_wake_lock, "wlan"); |
| 13760 | if (QDF_IS_STATUS_ERROR(status)) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13761 | hdd_err("Failed to create wake lock; status:%u", status); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13762 | errno = qdf_status_to_os_return(status); |
| 13763 | goto comp_deinit; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13764 | } |
| 13765 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13766 | hdd_set_conparam(con_mode); |
| 13767 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13768 | errno = wlan_hdd_state_ctrl_param_create(); |
| 13769 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13770 | hdd_err("Failed to create ctrl param; errno:%d", errno); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13771 | goto wakelock_destroy; |
| 13772 | } |
| 13773 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13774 | errno = pld_init(); |
| 13775 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13776 | hdd_err("Failed to init PLD; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13777 | goto param_destroy; |
| 13778 | } |
| 13779 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13780 | hdd_driver_mode_change_register(); |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13781 | |
| 13782 | osif_driver_sync_register(driver_sync); |
| 13783 | osif_driver_sync_trans_stop(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13784 | |
| 13785 | /* psoc probe can happen in registration; do after 'load' transition */ |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13786 | errno = wlan_hdd_register_driver(); |
| 13787 | if (errno) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13788 | hdd_err("Failed to register driver; errno:%d", errno); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13789 | goto pld_deinit; |
Sachin Ahuja | 16904db | 2017-12-13 19:56:57 +0530 | [diff] [blame] | 13790 | } |
| 13791 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13792 | hdd_debug("%s: driver loaded", WLAN_MODULE_NAME); |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13793 | |
| 13794 | return 0; |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13795 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13796 | pld_deinit: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13797 | status = osif_driver_sync_trans_start(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13798 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13799 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13800 | osif_driver_sync_unregister(); |
| 13801 | osif_driver_sync_wait_for_ops(driver_sync); |
| 13802 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13803 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13804 | pld_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13805 | |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13806 | param_destroy: |
| 13807 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13808 | wakelock_destroy: |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13809 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13810 | comp_deinit: |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13811 | hdd_component_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13812 | hdd_deinit: |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13813 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13814 | trans_stop: |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13815 | osif_driver_sync_trans_stop(driver_sync); |
| 13816 | osif_driver_sync_destroy(driver_sync); |
| 13817 | sync_deinit: |
| 13818 | osif_sync_deinit(); |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13819 | hdd_qdf_deinit(); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13820 | |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13821 | exit: |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13822 | return errno; |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13823 | } |
| 13824 | |
| 13825 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13826 | * hdd_driver_unload() - Performs the driver-level unload operation |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13827 | * |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13828 | * Note: this is used in both static and DLKM driver builds |
| 13829 | * |
| 13830 | * Return: None |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13831 | */ |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13832 | static void hdd_driver_unload(void) |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13833 | { |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13834 | struct osif_driver_sync *driver_sync; |
Will Huang | 3604972 | 2018-04-13 11:48:51 +0800 | [diff] [blame] | 13835 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13836 | QDF_STATUS status; |
Ashish Kumar Dhanotiya | 7a031ce | 2017-01-23 13:11:30 +0530 | [diff] [blame] | 13837 | |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 13838 | pr_info("%s: Unloading driver v%s\n", WLAN_MODULE_NAME, |
| 13839 | QWLAN_VERSIONSTR); |
| 13840 | |
Dustin Brown | 8c0b5e3 | 2019-01-18 13:56:02 -0800 | [diff] [blame] | 13841 | if (g_is_system_reboot_triggered) { |
| 13842 | hdd_info("System rebooting; Skipping unload"); |
| 13843 | return; |
| 13844 | } |
| 13845 | |
| 13846 | if (hdd_ctx) |
| 13847 | hdd_psoc_idle_timer_stop(hdd_ctx); |
| 13848 | |
| 13849 | /* trigger SoC remove */ |
| 13850 | wlan_hdd_unregister_driver(); |
| 13851 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13852 | status = osif_driver_sync_trans_start_wait(&driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13853 | QDF_BUG(QDF_IS_STATUS_SUCCESS(status)); |
| 13854 | if (QDF_IS_STATUS_ERROR(status)) { |
| 13855 | hdd_err("Unable to unload wlan; status:%u", status); |
Arunk Khandavalli | 830c969 | 2018-03-22 12:17:40 +0530 | [diff] [blame] | 13856 | return; |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13857 | } |
| 13858 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13859 | osif_driver_sync_unregister(); |
| 13860 | osif_driver_sync_wait_for_ops(driver_sync); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13861 | |
Will Huang | ba035ec | 2018-07-05 11:13:30 +0800 | [diff] [blame] | 13862 | cds_set_driver_loaded(false); |
| 13863 | cds_set_unload_in_progress(true); |
| 13864 | |
Dustin Brown | 95ff00b | 2019-02-28 13:41:13 -0800 | [diff] [blame] | 13865 | hdd_driver_mode_change_unregister(); |
Dustin Brown | 25843ad | 2018-09-17 14:54:33 -0700 | [diff] [blame] | 13866 | pld_deinit(); |
Dustin Brown | 4b9dbe6 | 2018-09-14 15:41:11 -0700 | [diff] [blame] | 13867 | wlan_hdd_state_ctrl_param_destroy(); |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13868 | hdd_set_conparam(0); |
Anurag Chouhan | a37b5b7 | 2016-02-21 14:53:42 +0530 | [diff] [blame] | 13869 | qdf_wake_lock_destroy(&wlan_wake_lock); |
Dustin Brown | d585cb3 | 2018-09-12 17:12:23 -0700 | [diff] [blame] | 13870 | hdd_component_deinit(); |
Arunk Khandavalli | 2dc0c96 | 2016-10-20 12:37:26 +0530 | [diff] [blame] | 13871 | hdd_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13872 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13873 | osif_driver_sync_trans_stop(driver_sync); |
| 13874 | osif_driver_sync_destroy(driver_sync); |
Dustin Brown | 623e7e3 | 2018-09-05 14:27:50 -0700 | [diff] [blame] | 13875 | |
Dustin Brown | c1d81af | 2019-03-01 13:43:43 -0800 | [diff] [blame] | 13876 | osif_sync_deinit(); |
Dustin Brown | 21a1d46 | 2018-07-31 15:13:06 -0700 | [diff] [blame] | 13877 | |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13878 | hdd_qdf_deinit(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13879 | } |
| 13880 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13881 | #ifndef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13882 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13883 | * wlan_boot_cb() - Wlan boot callback |
| 13884 | * @kobj: object whose directory we're creating the link in. |
| 13885 | * @attr: attribute the user is interacting with |
| 13886 | * @buff: the buffer containing the user data |
| 13887 | * @count: number of bytes in the buffer |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13888 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13889 | * This callback is invoked when the fs is ready to start the |
| 13890 | * wlan driver initialization. |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13891 | * |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13892 | * 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] | 13893 | */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13894 | static ssize_t wlan_boot_cb(struct kobject *kobj, |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13895 | struct kobj_attribute *attr, |
| 13896 | const char *buf, |
| 13897 | size_t count) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13898 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13899 | |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13900 | if (wlan_loader->loaded_state) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13901 | hdd_err("wlan driver already initialized"); |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13902 | return -EALREADY; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13903 | } |
| 13904 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 13905 | if (hdd_driver_load()) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13906 | return -EIO; |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13907 | |
| 13908 | wlan_loader->loaded_state = MODULE_INITIALIZED; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13909 | |
| 13910 | return count; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13911 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13912 | |
| 13913 | /** |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13914 | * hdd_sysfs_cleanup() - cleanup sysfs |
| 13915 | * |
| 13916 | * Return: None |
| 13917 | * |
| 13918 | */ |
| 13919 | static void hdd_sysfs_cleanup(void) |
| 13920 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13921 | /* remove from group */ |
| 13922 | if (wlan_loader->boot_wlan_obj && wlan_loader->attr_group) |
| 13923 | sysfs_remove_group(wlan_loader->boot_wlan_obj, |
| 13924 | wlan_loader->attr_group); |
| 13925 | |
| 13926 | /* unlink the object from parent */ |
| 13927 | kobject_del(wlan_loader->boot_wlan_obj); |
| 13928 | |
| 13929 | /* free the object */ |
| 13930 | kobject_put(wlan_loader->boot_wlan_obj); |
| 13931 | |
| 13932 | kfree(wlan_loader->attr_group); |
| 13933 | kfree(wlan_loader); |
| 13934 | |
| 13935 | wlan_loader = NULL; |
| 13936 | } |
| 13937 | |
| 13938 | /** |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13939 | * wlan_init_sysfs() - Creates the sysfs to be invoked when the fs is |
| 13940 | * ready |
| 13941 | * |
| 13942 | * This is creates the syfs entry boot_wlan. Which shall be invoked |
| 13943 | * when the filesystem is ready. |
| 13944 | * |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13945 | * QDF API cannot be used here since this function is called even before |
| 13946 | * initializing WLAN driver. |
| 13947 | * |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 13948 | * Return: 0 for success, errno on failure |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13949 | */ |
| 13950 | static int wlan_init_sysfs(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 13951 | { |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13952 | int ret = -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13953 | |
| 13954 | wlan_loader = kzalloc(sizeof(*wlan_loader), GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13955 | if (!wlan_loader) |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13956 | return -ENOMEM; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13957 | |
| 13958 | wlan_loader->boot_wlan_obj = NULL; |
| 13959 | wlan_loader->attr_group = kzalloc(sizeof(*(wlan_loader->attr_group)), |
| 13960 | GFP_KERNEL); |
Srinivas Girigowda | b841da7 | 2017-03-25 18:04:39 -0700 | [diff] [blame] | 13961 | if (!wlan_loader->attr_group) |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13962 | goto error_return; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13963 | |
| 13964 | wlan_loader->loaded_state = 0; |
| 13965 | wlan_loader->attr_group->attrs = attrs; |
| 13966 | |
Qun Zhang | 4a83a46 | 2018-09-11 16:28:51 +0800 | [diff] [blame] | 13967 | wlan_loader->boot_wlan_obj = kobject_create_and_add(WLAN_LOADER_NAME, |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13968 | kernel_kobj); |
| 13969 | if (!wlan_loader->boot_wlan_obj) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13970 | hdd_err("sysfs create and add failed"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13971 | goto error_return; |
| 13972 | } |
| 13973 | |
| 13974 | ret = sysfs_create_group(wlan_loader->boot_wlan_obj, |
| 13975 | wlan_loader->attr_group); |
| 13976 | if (ret) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13977 | hdd_err("sysfs create group failed; errno:%d", ret); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13978 | goto error_return; |
| 13979 | } |
| 13980 | |
| 13981 | return 0; |
| 13982 | |
| 13983 | error_return: |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 13984 | hdd_sysfs_cleanup(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13985 | |
| 13986 | return ret; |
| 13987 | } |
| 13988 | |
| 13989 | /** |
| 13990 | * wlan_deinit_sysfs() - Removes the sysfs created to initialize the wlan |
| 13991 | * |
| 13992 | * Return: 0 on success or errno on failure |
| 13993 | */ |
| 13994 | static int wlan_deinit_sysfs(void) |
| 13995 | { |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13996 | if (!wlan_loader) { |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 13997 | hdd_err("wlan_loader is null"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 13998 | return -EINVAL; |
| 13999 | } |
| 14000 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14001 | hdd_sysfs_cleanup(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14002 | return 0; |
| 14003 | } |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14004 | |
Mahesh Kumar Kalikot Veetil | 5a3dec6 | 2016-11-02 12:46:40 -0700 | [diff] [blame] | 14005 | #endif /* MODULE */ |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14006 | |
| 14007 | #ifdef MODULE |
| 14008 | /** |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14009 | * hdd_module_init() - Module init helper |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14010 | * |
| 14011 | * Module init helper function used by both module and static driver. |
| 14012 | * |
| 14013 | * Return: 0 for success, errno on failure |
| 14014 | */ |
| 14015 | static int hdd_module_init(void) |
| 14016 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14017 | if (hdd_driver_load()) |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 14018 | return -EINVAL; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14019 | |
Dustin Brown | ab482ac | 2017-06-09 17:00:44 -0700 | [diff] [blame] | 14020 | return 0; |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14021 | } |
| 14022 | #else |
| 14023 | static int __init hdd_module_init(void) |
| 14024 | { |
| 14025 | int ret = -EINVAL; |
| 14026 | |
| 14027 | ret = wlan_init_sysfs(); |
Srinivas Girigowda | 5e7dafe | 2016-11-02 14:09:13 -0700 | [diff] [blame] | 14028 | if (ret) |
Dustin Brown | a2a39dc | 2018-09-17 15:29:59 -0700 | [diff] [blame] | 14029 | hdd_err("Failed to create sysfs entry"); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14030 | |
| 14031 | return ret; |
| 14032 | } |
| 14033 | #endif |
| 14034 | |
| 14035 | |
| 14036 | #ifdef MODULE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14037 | /** |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14038 | * hdd_module_exit() - Exit function |
| 14039 | * |
| 14040 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14041 | * |
| 14042 | * Return: None |
| 14043 | */ |
| 14044 | static void __exit hdd_module_exit(void) |
| 14045 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14046 | hdd_driver_unload(); |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14047 | } |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14048 | #else |
| 14049 | static void __exit hdd_module_exit(void) |
| 14050 | { |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14051 | hdd_driver_unload(); |
Arun Khandavalli | fae9294 | 2016-08-01 13:31:08 +0530 | [diff] [blame] | 14052 | wlan_deinit_sysfs(); |
| 14053 | } |
| 14054 | #endif |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14055 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14056 | static int fwpath_changed_handler(const char *kmessage, |
| 14057 | const struct kernel_param *kp) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14058 | { |
| 14059 | return param_set_copystring(kmessage, kp); |
| 14060 | } |
Prashanth Bhatta | 5da711e | 2015-11-30 14:28:52 -0800 | [diff] [blame] | 14061 | |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14062 | static int con_mode_handler_ftm(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14063 | const struct kernel_param *kp) |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 14064 | { |
| 14065 | int ret; |
| 14066 | |
| 14067 | ret = param_set_int(kmessage, kp); |
| 14068 | |
| 14069 | if (con_mode_ftm != QDF_GLOBAL_FTM_MODE) { |
| 14070 | pr_err("Only FTM mode supported!"); |
| 14071 | return -ENOTSUPP; |
| 14072 | } |
| 14073 | |
| 14074 | hdd_set_conparam(con_mode_ftm); |
| 14075 | con_mode = con_mode_ftm; |
| 14076 | |
| 14077 | return ret; |
| 14078 | } |
| 14079 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 14080 | #ifdef WLAN_FEATURE_EPPING |
| 14081 | static int con_mode_handler_epping(const char *kmessage, |
| 14082 | const struct kernel_param *kp) |
| 14083 | { |
| 14084 | int ret; |
| 14085 | |
| 14086 | ret = param_set_int(kmessage, kp); |
| 14087 | |
| 14088 | if (con_mode_epping != QDF_GLOBAL_EPPING_MODE) { |
| 14089 | pr_err("Only EPPING mode supported!"); |
| 14090 | return -ENOTSUPP; |
| 14091 | } |
| 14092 | |
| 14093 | hdd_set_conparam(con_mode_epping); |
| 14094 | con_mode = con_mode_epping; |
| 14095 | |
| 14096 | return ret; |
| 14097 | } |
| 14098 | #endif |
| 14099 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14100 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14101 | static int con_mode_handler_monitor(const char *kmessage, |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 14102 | const struct kernel_param *kp) |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14103 | { |
| 14104 | int ret; |
| 14105 | |
| 14106 | ret = param_set_int(kmessage, kp); |
| 14107 | |
| 14108 | if (con_mode_monitor != QDF_GLOBAL_MONITOR_MODE) { |
| 14109 | pr_err("Only Monitor mode supported!"); |
| 14110 | return -ENOTSUPP; |
| 14111 | } |
| 14112 | |
| 14113 | hdd_set_conparam(con_mode_monitor); |
| 14114 | con_mode = con_mode_monitor; |
| 14115 | |
| 14116 | return ret; |
| 14117 | } |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 14118 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 14119 | |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14120 | /** |
| 14121 | * hdd_get_conparam() - driver exit point |
| 14122 | * |
| 14123 | * This is the driver exit point (invoked when module is unloaded using rmmod) |
| 14124 | * |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14125 | * Return: enum QDF_GLOBAL_MODE |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14126 | */ |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14127 | enum QDF_GLOBAL_MODE hdd_get_conparam(void) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14128 | { |
Jeff Johnson | 876c1a6 | 2017-12-12 10:43:07 -0800 | [diff] [blame] | 14129 | return (enum QDF_GLOBAL_MODE) curr_con_mode; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14130 | } |
| 14131 | |
Dustin Brown | f0f7056 | 2018-09-14 10:29:38 -0700 | [diff] [blame] | 14132 | void hdd_set_conparam(int32_t con_param) |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14133 | { |
Prashanth Bhatta | 05aaf01 | 2015-12-10 17:34:24 -0800 | [diff] [blame] | 14134 | curr_con_mode = con_param; |
Prashanth Bhatta | edd6ca2 | 2015-12-10 17:21:29 -0800 | [diff] [blame] | 14135 | } |
| 14136 | |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14137 | /** |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14138 | * hdd_clean_up_pre_cac_interface() - Clean up the pre cac interface |
| 14139 | * @hdd_ctx: HDD context |
| 14140 | * |
| 14141 | * Cleans up the pre cac interface, if it exists |
| 14142 | * |
| 14143 | * Return: None |
| 14144 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14145 | void hdd_clean_up_pre_cac_interface(struct hdd_context *hdd_ctx) |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14146 | { |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14147 | uint8_t vdev_id; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14148 | QDF_STATUS status; |
Jeff Johnson | 85b5c11 | 2017-08-11 15:15:23 -0700 | [diff] [blame] | 14149 | struct hdd_adapter *precac_adapter; |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14150 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14151 | status = wlan_sap_get_pre_cac_vdev_id(hdd_ctx->mac_handle, &vdev_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14152 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14153 | hdd_err("failed to get pre cac vdev id"); |
| 14154 | return; |
| 14155 | } |
| 14156 | |
Jeff Johnson | 55d2ab4 | 2019-03-06 11:43:49 -0800 | [diff] [blame] | 14157 | precac_adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14158 | if (!precac_adapter) { |
Jeff Johnson | dd2f1fc | 2018-05-06 11:22:52 -0700 | [diff] [blame] | 14159 | hdd_err("invalid pre cac adapter"); |
Manishekar Chandrasekaran | 9e8c7be | 2016-08-03 14:57:14 +0530 | [diff] [blame] | 14160 | return; |
| 14161 | } |
| 14162 | |
| 14163 | qdf_create_work(0, &hdd_ctx->sap_pre_cac_work, |
| 14164 | wlan_hdd_sap_pre_cac_failure, |
| 14165 | (void *)precac_adapter); |
| 14166 | qdf_sched_work(0, &hdd_ctx->sap_pre_cac_work); |
| 14167 | |
| 14168 | } |
| 14169 | |
| 14170 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14171 | * hdd_update_ol_config - API to update ol configuration parameters |
| 14172 | * @hdd_ctx: HDD context |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14173 | * |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14174 | * Return: void |
| 14175 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14176 | static void hdd_update_ol_config(struct hdd_context *hdd_ctx) |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14177 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14178 | struct ol_config_info cfg = {0}; |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14179 | struct ol_context *ol_ctx = cds_get_context(QDF_MODULE_ID_BMI); |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14180 | bool self_recovery = false; |
| 14181 | QDF_STATUS status; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14182 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14183 | if (!ol_ctx) |
| 14184 | return; |
| 14185 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14186 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14187 | if (QDF_IS_STATUS_ERROR(status)) |
| 14188 | hdd_err("Failed to get self recovery ini config"); |
| 14189 | |
| 14190 | cfg.enable_self_recovery = self_recovery; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14191 | cfg.enable_uart_print = hdd_ctx->config->enablefwprint; |
| 14192 | cfg.enable_fw_log = hdd_ctx->config->enable_fw_log; |
| 14193 | cfg.enable_ramdump_collection = hdd_ctx->config->is_ramdump_enabled; |
Jeff Johnson | b8bf907 | 2016-09-23 17:39:27 -0700 | [diff] [blame] | 14194 | cfg.enable_lpass_support = hdd_lpass_is_supported(hdd_ctx); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14195 | |
| 14196 | ol_init_ini_config(ol_ctx, &cfg); |
| 14197 | } |
| 14198 | |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14199 | #ifdef FEATURE_RUNTIME_PM |
| 14200 | /** |
| 14201 | * hdd_populate_runtime_cfg() - populate runtime configuration |
| 14202 | * @hdd_ctx: hdd context |
| 14203 | * @cfg: pointer to the configuration memory being populated |
| 14204 | * |
| 14205 | * Return: void |
| 14206 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14207 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14208 | struct hif_config_info *cfg) |
| 14209 | { |
| 14210 | cfg->enable_runtime_pm = hdd_ctx->config->runtime_pm; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14211 | cfg->runtime_pm_delay = |
| 14212 | ucfg_pmo_get_runtime_pm_delay(hdd_ctx->psoc); |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14213 | } |
| 14214 | #else |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14215 | static void hdd_populate_runtime_cfg(struct hdd_context *hdd_ctx, |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14216 | struct hif_config_info *cfg) |
| 14217 | { |
| 14218 | } |
| 14219 | #endif |
| 14220 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14221 | /** |
| 14222 | * hdd_update_hif_config - API to update HIF configuration parameters |
| 14223 | * @hdd_ctx: HDD Context |
| 14224 | * |
| 14225 | * Return: void |
| 14226 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14227 | static void hdd_update_hif_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14228 | { |
Anurag Chouhan | df2b268 | 2016-02-29 14:15:27 +0530 | [diff] [blame] | 14229 | struct hif_opaque_softc *scn = cds_get_context(QDF_MODULE_ID_HIF); |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14230 | struct hif_config_info cfg = {0}; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14231 | bool prevent_link_down = false; |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14232 | bool self_recovery = false; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14233 | QDF_STATUS status; |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14234 | |
| 14235 | if (!scn) |
| 14236 | return; |
| 14237 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14238 | status = ucfg_mlme_get_prevent_link_down(hdd_ctx->psoc, |
| 14239 | &prevent_link_down); |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14240 | if (QDF_IS_STATUS_ERROR(status)) |
| 14241 | hdd_err("Failed to get prevent_link_down config"); |
| 14242 | |
Vignesh Viswanathan | a1f3a1a | 2018-10-04 13:10:46 +0530 | [diff] [blame] | 14243 | status = ucfg_mlme_get_self_recovery(hdd_ctx->psoc, &self_recovery); |
| 14244 | if (QDF_IS_STATUS_ERROR(status)) |
| 14245 | hdd_err("Failed to get self recovery ini config"); |
| 14246 | |
| 14247 | cfg.enable_self_recovery = self_recovery; |
Houston Hoffman | c7c69f0 | 2016-03-24 22:45:52 -0700 | [diff] [blame] | 14248 | hdd_populate_runtime_cfg(hdd_ctx, &cfg); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14249 | hif_init_ini_config(scn, &cfg); |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14250 | |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14251 | if (prevent_link_down) |
Dustin Brown | ee3e059 | 2017-09-07 13:50:11 -0700 | [diff] [blame] | 14252 | hif_vote_link_up(scn); |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14253 | } |
| 14254 | |
| 14255 | /** |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14256 | * hdd_update_dp_config() - Propagate config parameters to Lithium |
| 14257 | * datapath |
| 14258 | * @hdd_ctx: HDD Context |
| 14259 | * |
| 14260 | * Return: 0 for success/errno for failure |
| 14261 | */ |
| 14262 | static int hdd_update_dp_config(struct hdd_context *hdd_ctx) |
| 14263 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14264 | struct cdp_config_params params = {0}; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14265 | QDF_STATUS status; |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14266 | void *soc; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14267 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14268 | soc = cds_get_context(QDF_MODULE_ID_SOC); |
| 14269 | params.tso_enable = cfg_get(hdd_ctx->psoc, CFG_DP_TSO); |
| 14270 | params.lro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_LRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14271 | #ifdef QCA_LL_TX_FLOW_CONTROL_V2 |
| 14272 | params.tx_flow_stop_queue_threshold = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14273 | cfg_get(hdd_ctx->psoc, CFG_DP_TX_FLOW_STOP_QUEUE_TH); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14274 | params.tx_flow_start_queue_offset = |
jitiphil | 47c3d9a | 2018-11-08 18:30:55 +0530 | [diff] [blame] | 14275 | cfg_get(hdd_ctx->psoc, |
| 14276 | CFG_DP_TX_FLOW_START_QUEUE_OFFSET); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14277 | #endif |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14278 | params.flow_steering_enable = |
| 14279 | cfg_get(hdd_ctx->psoc, CFG_DP_FLOW_STEERING_ENABLED); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14280 | params.napi_enable = hdd_ctx->napi_enable; |
| 14281 | params.tcp_udp_checksumoffload = |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14282 | cfg_get(hdd_ctx->psoc, |
| 14283 | CFG_DP_TCP_UDP_CKSUM_OFFLOAD); |
Sravan Kumar Kairam | 0af1ee5 | 2018-12-12 20:37:51 +0530 | [diff] [blame] | 14284 | params.ipa_enable = ucfg_ipa_is_enabled(); |
Mohit Khanna | 8141877 | 2018-10-30 14:14:46 -0700 | [diff] [blame] | 14285 | params.gro_enable = cfg_get(hdd_ctx->psoc, CFG_DP_GRO); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14286 | |
jitiphil | 377bcc1 | 2018-10-05 19:46:08 +0530 | [diff] [blame] | 14287 | status = cdp_update_config_parameters(soc, ¶ms); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14288 | if (status) { |
Dustin Brown | a286862 | 2018-03-20 11:38:14 -0700 | [diff] [blame] | 14289 | hdd_err("Failed to attach config parameters"); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14290 | return status; |
| 14291 | } |
| 14292 | |
| 14293 | return 0; |
| 14294 | } |
| 14295 | |
| 14296 | /** |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14297 | * hdd_update_config() - Initialize driver per module ini parameters |
| 14298 | * @hdd_ctx: HDD Context |
| 14299 | * |
| 14300 | * API is used to initialize all driver per module configuration parameters |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14301 | * Return: 0 for success, errno for failure |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14302 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14303 | int hdd_update_config(struct hdd_context *hdd_ctx) |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14304 | { |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14305 | int ret; |
| 14306 | |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14307 | if (ucfg_pmo_is_ns_offloaded(hdd_ctx->psoc)) |
| 14308 | hdd_ctx->ns_offload_enable = true; |
| 14309 | |
Komal Seelam | ec702b0 | 2016-02-24 18:42:16 +0530 | [diff] [blame] | 14310 | hdd_update_ol_config(hdd_ctx); |
| 14311 | hdd_update_hif_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14312 | if (QDF_GLOBAL_FTM_MODE == hdd_get_conparam()) |
| 14313 | ret = hdd_update_cds_config_ftm(hdd_ctx); |
| 14314 | else |
| 14315 | ret = hdd_update_cds_config(hdd_ctx); |
Tushnim Bhattacharyya | 329514d | 2017-02-07 09:14:25 -0800 | [diff] [blame] | 14316 | ret = hdd_update_user_config(hdd_ctx); |
Arun Khandavalli | c811dcc | 2016-06-26 07:37:21 +0530 | [diff] [blame] | 14317 | |
| 14318 | return ret; |
Komal Seelam | c11bb22 | 2016-01-27 18:57:10 +0530 | [diff] [blame] | 14319 | } |
| 14320 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14321 | /** |
| 14322 | * hdd_update_pmo_config - API to update pmo configuration parameters |
| 14323 | * @hdd_ctx: HDD context |
| 14324 | * |
| 14325 | * Return: void |
| 14326 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14327 | static int hdd_update_pmo_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14328 | { |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14329 | struct pmo_psoc_cfg psoc_cfg = {0}; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14330 | QDF_STATUS status; |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14331 | enum pmo_wow_enable_type wow_enable; |
| 14332 | |
| 14333 | ucfg_pmo_get_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14334 | |
| 14335 | /* |
| 14336 | * Value of hdd_ctx->wowEnable can be, |
| 14337 | * 0 - Disable both magic pattern match and pattern byte match. |
| 14338 | * 1 - Enable magic pattern match on all interfaces. |
| 14339 | * 2 - Enable pattern byte match on all interfaces. |
| 14340 | * 3 - Enable both magic patter and pattern byte match on |
| 14341 | * all interfaces. |
| 14342 | */ |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14343 | wow_enable = ucfg_pmo_get_wow_enable(hdd_ctx->psoc); |
| 14344 | psoc_cfg.magic_ptrn_enable = (wow_enable & 0x01) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14345 | psoc_cfg.ptrn_match_enable_all_vdev = |
Wu Gao | 66454f1 | 2018-09-26 19:55:41 +0800 | [diff] [blame] | 14346 | (wow_enable & 0x02) ? true : false; |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14347 | psoc_cfg.ap_arpns_support = hdd_ctx->ap_arpns_support; |
Will Huang | 3cd2b7c | 2017-11-17 13:16:56 +0800 | [diff] [blame] | 14348 | psoc_cfg.d0_wow_supported = wma_d0_wow_is_supported(); |
Bala Venkatesh | 46e2903 | 2018-11-14 18:24:55 +0530 | [diff] [blame] | 14349 | ucfg_mlme_get_sap_max_modulated_dtim(hdd_ctx->psoc, |
| 14350 | &psoc_cfg.sta_max_li_mod_dtim); |
| 14351 | |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14352 | |
Mukul Sharma | 9223f23 | 2017-03-08 18:42:27 +0530 | [diff] [blame] | 14353 | hdd_lpass_populate_pmo_config(&psoc_cfg, hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14354 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14355 | status = ucfg_pmo_update_psoc_config(hdd_ctx->psoc, &psoc_cfg); |
Dustin Brown | b9987af | 2018-03-01 17:15:11 -0800 | [diff] [blame] | 14356 | if (QDF_IS_STATUS_ERROR(status)) |
| 14357 | hdd_err("failed pmo psoc configuration; status:%d", status); |
| 14358 | |
| 14359 | return qdf_status_to_os_return(status); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14360 | } |
| 14361 | |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14362 | void hdd_update_ie_whitelist_attr(struct probe_req_whitelist_attr *ie_whitelist, |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14363 | struct hdd_context *hdd_ctx) |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14364 | { |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14365 | struct wlan_fwol_ie_whitelist whitelist = {0}; |
| 14366 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14367 | QDF_STATUS status; |
| 14368 | bool is_ie_whitelist_enable = false; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14369 | uint8_t i = 0; |
| 14370 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14371 | status = ucfg_fwol_get_ie_whitelist(psoc, &is_ie_whitelist_enable); |
| 14372 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14373 | hdd_err("Unable to get IE whitelist param"); |
| 14374 | return; |
| 14375 | } |
| 14376 | |
| 14377 | ie_whitelist->white_list = is_ie_whitelist_enable; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14378 | if (!ie_whitelist->white_list) |
| 14379 | return; |
| 14380 | |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14381 | status = ucfg_fwol_get_all_whitelist_params(psoc, &whitelist); |
| 14382 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14383 | hdd_err("Unable to get all whitelist params"); |
| 14384 | return; |
| 14385 | } |
| 14386 | |
| 14387 | ie_whitelist->ie_bitmap[0] = whitelist.ie_bitmap_0; |
| 14388 | ie_whitelist->ie_bitmap[1] = whitelist.ie_bitmap_1; |
| 14389 | ie_whitelist->ie_bitmap[2] = whitelist.ie_bitmap_2; |
| 14390 | ie_whitelist->ie_bitmap[3] = whitelist.ie_bitmap_3; |
| 14391 | ie_whitelist->ie_bitmap[4] = whitelist.ie_bitmap_4; |
| 14392 | ie_whitelist->ie_bitmap[5] = whitelist.ie_bitmap_5; |
| 14393 | ie_whitelist->ie_bitmap[6] = whitelist.ie_bitmap_6; |
| 14394 | ie_whitelist->ie_bitmap[7] = whitelist.ie_bitmap_7; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14395 | |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14396 | ie_whitelist->num_vendor_oui = whitelist.no_of_probe_req_ouis; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14397 | for (i = 0; i < ie_whitelist->num_vendor_oui; i++) |
Dundi Raviteja | 9ab4e7b | 2018-09-28 14:18:28 +0530 | [diff] [blame] | 14398 | ie_whitelist->voui[i] = whitelist.probe_req_voui[i]; |
Rajeev Kumar Sirasanagandla | aec0b08 | 2017-06-21 11:59:41 +0530 | [diff] [blame] | 14399 | } |
| 14400 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14401 | uint32_t hdd_limit_max_per_index_score(uint32_t per_index_score) |
| 14402 | { |
| 14403 | uint8_t i, score; |
| 14404 | |
| 14405 | for (i = 0; i < MAX_INDEX_PER_INI; i++) { |
| 14406 | score = WLAN_GET_SCORE_PERCENTAGE(per_index_score, i); |
| 14407 | if (score > MAX_INDEX_SCORE) |
| 14408 | WLAN_SET_SCORE_PERCENTAGE(per_index_score, |
| 14409 | MAX_INDEX_SCORE, i); |
| 14410 | } |
| 14411 | |
| 14412 | return per_index_score; |
| 14413 | } |
| 14414 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14415 | QDF_STATUS hdd_update_score_config( |
| 14416 | struct scoring_config *score_config, struct hdd_context *hdd_ctx) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14417 | { |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14418 | struct hdd_config *cfg = hdd_ctx->config; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14419 | QDF_STATUS status; |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14420 | struct wlan_mlme_nss_chains vdev_ini_cfg; |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14421 | bool bval = false; |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14422 | uint32_t channel_bonding_mode; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14423 | |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14424 | qdf_mem_zero(&vdev_ini_cfg, sizeof(struct wlan_mlme_nss_chains)); |
gaurank kathpalia | 651abcd | 2018-11-12 22:41:23 +0530 | [diff] [blame] | 14425 | /* Populate the nss chain params from ini for this vdev type */ |
| 14426 | sme_populate_nss_chain_params(hdd_ctx->mac_handle, &vdev_ini_cfg, |
| 14427 | QDF_STA_MODE, |
| 14428 | hdd_ctx->num_rf_chains); |
| 14429 | |
| 14430 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_2GHZ]; |
| 14431 | score_config->vdev_nss_24g = vdev_ini_cfg.rx_nss[NSS_CHAINS_BAND_5GHZ]; |
| 14432 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14433 | sme_update_score_config(hdd_ctx->mac_handle, score_config); |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14434 | |
Wu Gao | ed616a1 | 2019-01-16 15:19:21 +0800 | [diff] [blame] | 14435 | ucfg_mlme_get_channel_bonding_24ghz(hdd_ctx->psoc, |
| 14436 | &channel_bonding_mode); |
| 14437 | score_config->cb_mode_24G = channel_bonding_mode; |
| 14438 | ucfg_mlme_get_channel_bonding_5ghz(hdd_ctx->psoc, |
| 14439 | &channel_bonding_mode); |
| 14440 | score_config->cb_mode_5G = channel_bonding_mode; |
gaurank kathpalia | ae52c98 | 2018-10-04 01:35:18 +0530 | [diff] [blame] | 14441 | |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14442 | if (cfg->dot11Mode == eHDD_DOT11_MODE_AUTO || |
| 14443 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax || |
| 14444 | cfg->dot11Mode == eHDD_DOT11_MODE_11ax_ONLY) |
| 14445 | score_config->he_cap = 1; |
| 14446 | |
| 14447 | if (score_config->he_cap || |
| 14448 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac || |
| 14449 | cfg->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY) |
| 14450 | score_config->vht_cap = 1; |
| 14451 | |
| 14452 | if (score_config->vht_cap || cfg->dot11Mode == eHDD_DOT11_MODE_11n || |
| 14453 | cfg->dot11Mode == eHDD_DOT11_MODE_11n_ONLY) |
| 14454 | score_config->ht_cap = 1; |
| 14455 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14456 | status = ucfg_mlme_get_vht_for_24ghz(hdd_ctx->psoc, &bval); |
| 14457 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14458 | hdd_err("Failed to get vht_for_24ghz"); |
| 14459 | if (score_config->vht_cap && bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14460 | score_config->vht_24G_cap = 1; |
| 14461 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14462 | status = ucfg_mlme_get_vht_enable_tx_bf(hdd_ctx->psoc, |
| 14463 | &bval); |
| 14464 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 14465 | hdd_err("unable to get vht_enable_tx_bf"); |
| 14466 | |
| 14467 | if (bval) |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14468 | score_config->beamformee_cap = 1; |
| 14469 | |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14470 | return QDF_STATUS_SUCCESS; |
Abhishek Singh | b6cdaf1 | 2017-11-10 14:43:39 +0530 | [diff] [blame] | 14471 | } |
| 14472 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14473 | /** |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14474 | * hdd_update_dfs_config() - API to update dfs configuration parameters. |
| 14475 | * @hdd_ctx: HDD context |
| 14476 | * |
| 14477 | * Return: 0 if success else err |
| 14478 | */ |
| 14479 | static int hdd_update_dfs_config(struct hdd_context *hdd_ctx) |
| 14480 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14481 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Abhishek Singh | 98278ce | 2018-12-27 11:41:03 +0530 | [diff] [blame] | 14482 | struct dfs_user_config dfs_cfg = {0}; |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14483 | QDF_STATUS status; |
| 14484 | |
Arif Hussain | 224d381 | 2018-11-16 17:58:38 -0800 | [diff] [blame] | 14485 | ucfg_mlme_get_dfs_filter_offload(hdd_ctx->psoc, |
| 14486 | &dfs_cfg.dfs_is_phyerr_filter_offload); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14487 | status = ucfg_dfs_update_config(psoc, &dfs_cfg); |
| 14488 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14489 | hdd_err("failed dfs psoc configuration"); |
| 14490 | return -EINVAL; |
| 14491 | } |
| 14492 | |
| 14493 | return 0; |
| 14494 | } |
| 14495 | |
| 14496 | /** |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14497 | * hdd_update_scan_config - API to update scan configuration parameters |
| 14498 | * @hdd_ctx: HDD context |
| 14499 | * |
| 14500 | * Return: 0 if success else err |
| 14501 | */ |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14502 | static int hdd_update_scan_config(struct hdd_context *hdd_ctx) |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14503 | { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14504 | struct wlan_objmgr_psoc *psoc = hdd_ctx->psoc; |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14505 | struct scan_user_cfg scan_cfg; |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14506 | QDF_STATUS status; |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14507 | uint32_t mcast_mcc_rest_time = 0; |
Vignesh Viswanathan | a851d75 | 2018-10-03 19:44:38 +0530 | [diff] [blame] | 14508 | |
Sandeep Puligilla | d788702 | 2019-02-26 00:48:52 -0800 | [diff] [blame] | 14509 | qdf_mem_zero(&scan_cfg, sizeof(scan_cfg)); |
Krunal Soni | d2c33e1 | 2018-12-06 15:02:37 -0800 | [diff] [blame] | 14510 | status = ucfg_mlme_get_sta_miracast_mcc_rest_time(hdd_ctx->psoc, |
| 14511 | &mcast_mcc_rest_time); |
| 14512 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14513 | hdd_err("ucfg_mlme_get_sta_miracast_mcc_rest_time, use def"); |
| 14514 | return -EIO; |
| 14515 | } |
| 14516 | scan_cfg.sta_miracast_mcc_rest_time = mcast_mcc_rest_time; |
Dundi Raviteja | 85a240a | 2018-09-10 15:03:07 +0530 | [diff] [blame] | 14517 | hdd_update_ie_whitelist_attr(&scan_cfg.ie_whitelist, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14518 | |
Abhinav Kumar | b074f2f | 2018-09-15 15:32:11 +0530 | [diff] [blame] | 14519 | status = hdd_update_score_config(&scan_cfg.score_config, hdd_ctx); |
Vignesh Viswanathan | 987f0bb | 2018-09-17 17:00:29 +0530 | [diff] [blame] | 14520 | if (QDF_IS_STATUS_ERROR(status)) { |
| 14521 | hdd_err("Failed to update scoring config"); |
| 14522 | return -EINVAL; |
| 14523 | } |
Abhishek Singh | b20db96 | 2017-03-03 21:28:46 +0530 | [diff] [blame] | 14524 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14525 | status = ucfg_scan_update_user_config(psoc, &scan_cfg); |
| 14526 | if (status != QDF_STATUS_SUCCESS) { |
| 14527 | hdd_err("failed pmo psoc configuration"); |
| 14528 | return -EINVAL; |
| 14529 | } |
| 14530 | |
| 14531 | return 0; |
| 14532 | } |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14533 | |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14534 | int hdd_update_components_config(struct hdd_context *hdd_ctx) |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14535 | { |
| 14536 | int ret; |
| 14537 | |
| 14538 | ret = hdd_update_pmo_config(hdd_ctx); |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14539 | if (ret) |
| 14540 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14541 | |
Abhishek Singh | 257a948 | 2017-03-06 16:52:39 +0530 | [diff] [blame] | 14542 | ret = hdd_update_scan_config(hdd_ctx); |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14543 | if (ret) |
| 14544 | return ret; |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14545 | |
Frank Liu | d4b2fa0 | 2017-03-29 11:46:48 +0800 | [diff] [blame] | 14546 | ret = hdd_update_tdls_config(hdd_ctx); |
Venkata Sharath Chandra Manchala | 4aaae0f | 2017-07-10 11:59:19 -0700 | [diff] [blame] | 14547 | if (ret) |
| 14548 | return ret; |
| 14549 | |
| 14550 | ret = hdd_update_dp_config(hdd_ctx); |
bings | 81fe50a | 2017-11-27 14:33:26 +0800 | [diff] [blame] | 14551 | if (ret) |
| 14552 | return ret; |
| 14553 | |
| 14554 | ret = hdd_update_dfs_config(hdd_ctx); |
Mukul Sharma | 9d797a0 | 2017-01-05 20:26:03 +0530 | [diff] [blame] | 14555 | |
| 14556 | return ret; |
| 14557 | } |
| 14558 | |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14559 | /** |
| 14560 | * wlan_hdd_get_dfs_mode() - get ACS DFS mode |
| 14561 | * @mode : cfg80211 DFS mode |
| 14562 | * |
| 14563 | * Return: return SAP ACS DFS mode else return ACS_DFS_MODE_NONE |
| 14564 | */ |
| 14565 | enum sap_acs_dfs_mode wlan_hdd_get_dfs_mode(enum dfs_mode mode) |
| 14566 | { |
| 14567 | switch (mode) { |
| 14568 | case DFS_MODE_ENABLE: |
| 14569 | return ACS_DFS_MODE_ENABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14570 | case DFS_MODE_DISABLE: |
| 14571 | return ACS_DFS_MODE_DISABLE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14572 | case DFS_MODE_DEPRIORITIZE: |
| 14573 | return ACS_DFS_MODE_DEPRIORITIZE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14574 | default: |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14575 | hdd_debug("ACS dfs mode is NONE"); |
| 14576 | return ACS_DFS_MODE_NONE; |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14577 | } |
| 14578 | } |
| 14579 | |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14580 | /** |
| 14581 | * hdd_enable_disable_ca_event() - enable/disable channel avoidance event |
| 14582 | * @hddctx: pointer to hdd context |
| 14583 | * @set_value: enable/disable |
| 14584 | * |
| 14585 | * When Host sends vendor command enable, FW will send *ONE* CA ind to |
| 14586 | * Host(even though it is duplicate). When Host send vendor command |
| 14587 | * disable,FW doesn't perform any action. Whenever any change in |
| 14588 | * CA *and* WLAN is in SAP/P2P-GO mode, FW sends CA ind to host. |
| 14589 | * |
| 14590 | * return - 0 on success, appropriate error values on failure. |
| 14591 | */ |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14592 | 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] | 14593 | { |
| 14594 | QDF_STATUS status; |
| 14595 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14596 | if (0 != wlan_hdd_validate_context(hdd_ctx)) |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14597 | return -EAGAIN; |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14598 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14599 | status = sme_enable_disable_chanavoidind_event(hdd_ctx->mac_handle, |
| 14600 | set_value); |
Selvaraj, Sridhar | ebda0f2 | 2016-08-29 16:05:23 +0530 | [diff] [blame] | 14601 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 14602 | hdd_err("Failed to send chan avoid command to SME"); |
| 14603 | return -EINVAL; |
| 14604 | } |
| 14605 | return 0; |
| 14606 | } |
Agrawal Ashish | 6563461 | 2016-08-18 13:24:32 +0530 | [diff] [blame] | 14607 | |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14608 | /** |
| 14609 | * hdd_set_roaming_in_progress() - to set the roaming in progress flag |
| 14610 | * @value: value to set |
| 14611 | * |
| 14612 | * This function will set the passed value to roaming in progress flag. |
| 14613 | * |
| 14614 | * Return: None |
| 14615 | */ |
| 14616 | void hdd_set_roaming_in_progress(bool value) |
| 14617 | { |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14618 | struct hdd_context *hdd_ctx; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14619 | |
| 14620 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14621 | if (!hdd_ctx) { |
| 14622 | hdd_err("HDD context is NULL"); |
| 14623 | return; |
| 14624 | } |
| 14625 | |
| 14626 | hdd_ctx->roaming_in_progress = value; |
Srinivas Girigowda | 3d5250d | 2017-03-06 17:32:16 -0800 | [diff] [blame] | 14627 | hdd_debug("Roaming in Progress set to %d", value); |
Abhinav Kumar | 2b431b6 | 2019-03-18 20:23:58 +0530 | [diff] [blame] | 14628 | if (!hdd_ctx->roaming_in_progress) { |
| 14629 | /* Reset scan reject params on successful roam complete */ |
| 14630 | hdd_debug("Reset scan reject params"); |
| 14631 | hdd_init_scan_reject_params(hdd_ctx); |
| 14632 | } |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14633 | } |
| 14634 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14635 | bool hdd_is_roaming_in_progress(struct hdd_context *hdd_ctx) |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14636 | { |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14637 | if (!hdd_ctx) { |
| 14638 | hdd_err("HDD context is NULL"); |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14639 | return false; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14640 | } |
Varun Reddy Yeturu | a578414 | 2017-03-10 12:11:44 -0800 | [diff] [blame] | 14641 | |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14642 | hdd_debug("roaming_in_progress = %d", hdd_ctx->roaming_in_progress); |
| 14643 | |
| 14644 | return hdd_ctx->roaming_in_progress; |
Varun Reddy Yeturu | dce1c56 | 2016-11-18 10:00:45 -0800 | [diff] [blame] | 14645 | } |
| 14646 | |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14647 | bool hdd_is_connection_in_progress(uint8_t *out_vdev_id, |
| 14648 | enum scan_reject_states *out_reason) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14649 | { |
Jeff Johnson | 40dae4e | 2017-08-29 14:00:25 -0700 | [diff] [blame] | 14650 | struct hdd_station_ctx *hdd_sta_ctx = NULL; |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14651 | struct hdd_adapter *adapter = NULL; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14652 | uint8_t sta_id = 0; |
| 14653 | uint8_t *sta_mac = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14654 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14655 | mac_handle_t mac_handle; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14656 | |
| 14657 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14658 | if (!hdd_ctx) { |
| 14659 | hdd_err("HDD context is NULL"); |
| 14660 | return false; |
| 14661 | } |
| 14662 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14663 | mac_handle = hdd_ctx->mac_handle; |
| 14664 | |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14665 | hdd_for_each_adapter(hdd_ctx, adapter) { |
Tushnim Bhattacharyya | 929afa4 | 2018-06-01 15:04:44 -0700 | [diff] [blame] | 14666 | hdd_debug("Adapter with device mode %s(%d) exists", |
Dustin Brown | 458027c | 2018-10-19 12:26:27 -0700 | [diff] [blame] | 14667 | qdf_opmode_str(adapter->device_mode), |
| 14668 | adapter->device_mode); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14669 | if (((QDF_STA_MODE == adapter->device_mode) |
| 14670 | || (QDF_P2P_CLIENT_MODE == adapter->device_mode) |
| 14671 | || (QDF_P2P_DEVICE_MODE == adapter->device_mode)) |
| 14672 | && (eConnectionState_Connecting == |
| 14673 | (WLAN_HDD_GET_STATION_CTX_PTR(adapter))-> |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14674 | conn_info.conn_state)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14675 | hdd_debug("%pK(%d) Connection is in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14676 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14677 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14678 | if (out_vdev_id && out_reason) { |
| 14679 | *out_vdev_id = adapter->vdev_id; |
| 14680 | *out_reason = CONNECTION_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14681 | } |
| 14682 | return true; |
| 14683 | } |
Archana Ramachandran | 62886ce | 2017-03-24 14:46:32 -0700 | [diff] [blame] | 14684 | /* |
| 14685 | * sme_neighbor_middle_of_roaming is for LFR2 |
| 14686 | * hdd_is_roaming_in_progress is for LFR3 |
| 14687 | */ |
| 14688 | if (((QDF_STA_MODE == adapter->device_mode) && |
| 14689 | sme_neighbor_middle_of_roaming( |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14690 | mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14691 | adapter->vdev_id)) || |
Padma, Santhosh Kumar | 86747ec | 2018-05-29 18:28:29 +0530 | [diff] [blame] | 14692 | hdd_is_roaming_in_progress(hdd_ctx)) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14693 | hdd_debug("%pK(%d) Reassociation in progress", |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14694 | WLAN_HDD_GET_STATION_CTX_PTR(adapter), |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14695 | adapter->vdev_id); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14696 | if (out_vdev_id && out_reason) { |
| 14697 | *out_vdev_id = adapter->vdev_id; |
| 14698 | *out_reason = REASSOC_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14699 | } |
| 14700 | return true; |
| 14701 | } |
| 14702 | if ((QDF_STA_MODE == adapter->device_mode) || |
| 14703 | (QDF_P2P_CLIENT_MODE == adapter->device_mode) || |
| 14704 | (QDF_P2P_DEVICE_MODE == adapter->device_mode)) { |
| 14705 | hdd_sta_ctx = |
| 14706 | WLAN_HDD_GET_STATION_CTX_PTR(adapter); |
| 14707 | if ((eConnectionState_Associated == |
Jeff Johnson | e795151 | 2019-02-27 10:02:51 -0800 | [diff] [blame] | 14708 | hdd_sta_ctx->conn_info.conn_state) |
Vignesh Viswanathan | 0a56929 | 2018-02-14 15:34:47 +0530 | [diff] [blame] | 14709 | && sme_is_sta_key_exchange_in_progress( |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14710 | mac_handle, adapter->vdev_id)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14711 | sta_mac = (uint8_t *) |
Jeff Johnson | 1e851a1 | 2017-10-28 14:36:12 -0700 | [diff] [blame] | 14712 | &(adapter->mac_addr.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14713 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14714 | " is in middle of WPS/EAPOL exchange.", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14715 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14716 | if (out_vdev_id && out_reason) { |
| 14717 | *out_vdev_id = adapter->vdev_id; |
| 14718 | *out_reason = EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14719 | } |
| 14720 | return true; |
| 14721 | } |
| 14722 | } else if ((QDF_SAP_MODE == adapter->device_mode) || |
| 14723 | (QDF_P2P_GO_MODE == adapter->device_mode)) { |
| 14724 | for (sta_id = 0; sta_id < WLAN_MAX_STA_COUNT; |
| 14725 | sta_id++) { |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14726 | if (!((adapter->sta_info[sta_id].in_use) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14727 | && (OL_TXRX_PEER_STATE_CONN == |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14728 | adapter->sta_info[sta_id].peer_state))) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14729 | continue; |
| 14730 | |
| 14731 | sta_mac = (uint8_t *) |
Jeff Johnson | bb8b56a | 2017-10-23 07:02:36 -0700 | [diff] [blame] | 14732 | &(adapter->sta_info[sta_id]. |
Jeff Johnson | f235651 | 2017-10-21 16:04:12 -0700 | [diff] [blame] | 14733 | sta_mac.bytes[0]); |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14734 | hdd_debug("client " MAC_ADDRESS_STR |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14735 | " of SAP/GO is in middle of WPS/EAPOL exchange", |
Srinivas Girigowda | 34fbba0 | 2019-04-08 12:07:44 -0700 | [diff] [blame] | 14736 | QDF_MAC_ADDR_ARRAY(sta_mac)); |
Jeff Johnson | a2ac4e7 | 2019-03-06 08:35:29 -0800 | [diff] [blame] | 14737 | if (out_vdev_id && out_reason) { |
| 14738 | *out_vdev_id = adapter->vdev_id; |
| 14739 | *out_reason = SAP_EAPOL_IN_PROGRESS; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14740 | } |
| 14741 | return true; |
| 14742 | } |
| 14743 | if (hdd_ctx->connection_in_progress) { |
Vignesh Viswanathan | 82bd253 | 2017-09-20 11:17:12 +0530 | [diff] [blame] | 14744 | hdd_debug("AP/GO: connection is in progress"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14745 | return true; |
| 14746 | } |
| 14747 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14748 | } |
Dustin Brown | 920397d | 2017-12-13 16:27:50 -0800 | [diff] [blame] | 14749 | |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14750 | return false; |
| 14751 | } |
| 14752 | |
| 14753 | /** |
| 14754 | * hdd_restart_sap() - to restart SAP in driver internally |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14755 | * @ap_adapter: Pointer to SAP struct hdd_adapter structure |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14756 | * |
| 14757 | * Return: None |
| 14758 | */ |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14759 | void hdd_restart_sap(struct hdd_adapter *ap_adapter) |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14760 | { |
Jeff Johnson | 8725103 | 2017-08-29 13:31:11 -0700 | [diff] [blame] | 14761 | struct hdd_ap_ctx *hdd_ap_ctx; |
Jeff Johnson | ca2530c | 2017-09-30 18:25:40 -0700 | [diff] [blame] | 14762 | struct hdd_hostapd_state *hostapd_state; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14763 | QDF_STATUS qdf_status; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14764 | struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(ap_adapter); |
Jeff Johnson | 8f8ceb9 | 2019-03-24 08:16:55 -0700 | [diff] [blame] | 14765 | struct sap_config *sap_config; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14766 | void *sap_ctx; |
| 14767 | |
| 14768 | hdd_ap_ctx = WLAN_HDD_GET_AP_CTX_PTR(ap_adapter); |
Jeff Johnson | 91df29d | 2017-10-27 19:29:50 -0700 | [diff] [blame] | 14769 | sap_config = &hdd_ap_ctx->sap_config; |
Jeff Johnson | 0bbe66f | 2017-10-27 19:23:49 -0700 | [diff] [blame] | 14770 | sap_ctx = hdd_ap_ctx->sap_context; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14771 | |
| 14772 | mutex_lock(&hdd_ctx->sap_lock); |
| 14773 | if (test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags)) { |
| 14774 | wlan_hdd_del_station(ap_adapter); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14775 | hostapd_state = WLAN_HDD_GET_HOSTAP_STATE_PTR(ap_adapter); |
| 14776 | qdf_event_reset(&hostapd_state->qdf_stop_bss_event); |
| 14777 | if (QDF_STATUS_SUCCESS == wlansap_stop_bss(sap_ctx)) { |
| 14778 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14779 | qdf_wait_for_event_completion(&hostapd_state-> |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14780 | qdf_stop_bss_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14781 | SME_CMD_STOP_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14782 | |
| 14783 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14784 | hdd_err("SAP Stop Failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14785 | goto end; |
| 14786 | } |
| 14787 | } |
| 14788 | clear_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14789 | policy_mgr_decr_session_set_pcl(hdd_ctx->psoc, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14790 | ap_adapter->device_mode, ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14791 | hdd_green_ap_start_state_mc(hdd_ctx, ap_adapter->device_mode, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14792 | false); |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14793 | hdd_err("SAP Stop Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14794 | |
| 14795 | if (0 != wlan_hdd_cfg80211_update_apies(ap_adapter)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14796 | hdd_err("SAP Not able to set AP IEs"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14797 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14798 | eUPDATE_IE_ALL); |
| 14799 | goto end; |
| 14800 | } |
| 14801 | |
| 14802 | qdf_event_reset(&hostapd_state->qdf_event); |
| 14803 | if (wlansap_start_bss(sap_ctx, hdd_hostapd_sap_event_cb, |
| 14804 | sap_config, |
| 14805 | ap_adapter->dev) != QDF_STATUS_SUCCESS) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14806 | hdd_err("SAP Start Bss fail"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14807 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14808 | eUPDATE_IE_ALL); |
| 14809 | goto end; |
| 14810 | } |
| 14811 | |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14812 | hdd_info("Waiting for SAP to start"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14813 | qdf_status = |
Nachiket Kukade | 0396b73 | 2017-11-14 16:35:16 +0530 | [diff] [blame] | 14814 | qdf_wait_for_event_completion(&hostapd_state->qdf_event, |
Abhishek Singh | d1f21c7 | 2019-01-21 15:16:34 +0530 | [diff] [blame] | 14815 | SME_CMD_START_BSS_TIMEOUT); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14816 | wlansap_reset_sap_config_add_ie(sap_config, |
| 14817 | eUPDATE_IE_ALL); |
| 14818 | if (!QDF_IS_STATUS_SUCCESS(qdf_status)) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14819 | hdd_err("SAP Start failed"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14820 | goto end; |
| 14821 | } |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14822 | hdd_err("SAP Start Success"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14823 | set_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags); |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14824 | if (hostapd_state->bss_state == BSS_START) { |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14825 | policy_mgr_incr_active_session(hdd_ctx->psoc, |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14826 | ap_adapter->device_mode, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14827 | ap_adapter->vdev_id); |
Jeff Johnson | e8846ab | 2018-03-31 11:54:45 -0700 | [diff] [blame] | 14828 | hdd_green_ap_start_state_mc(hdd_ctx, |
Himanshu Agarwal | 813b2bf | 2018-01-22 16:32:15 +0530 | [diff] [blame] | 14829 | ap_adapter->device_mode, |
| 14830 | true); |
| 14831 | } |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14832 | } |
| 14833 | end: |
| 14834 | mutex_unlock(&hdd_ctx->sap_lock); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14835 | } |
| 14836 | |
| 14837 | /** |
| 14838 | * hdd_check_and_restart_sap_with_non_dfs_acs() - Restart SAP |
| 14839 | * with non dfs acs |
| 14840 | * |
| 14841 | * Restarts SAP in non-DFS ACS mode when STA-AP mode DFS is not supported |
| 14842 | * |
| 14843 | * Return: None |
| 14844 | */ |
| 14845 | void hdd_check_and_restart_sap_with_non_dfs_acs(void) |
| 14846 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14847 | struct hdd_adapter *ap_adapter; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14848 | struct hdd_context *hdd_ctx; |
Jeff Johnson | 2b6982c | 2018-05-29 14:56:11 -0700 | [diff] [blame] | 14849 | struct cds_context *cds_ctx; |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14850 | uint8_t restart_chan; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14851 | |
| 14852 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14853 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14854 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14855 | return; |
| 14856 | } |
| 14857 | |
| 14858 | cds_ctx = cds_get_context(QDF_MODULE_ID_QDF); |
| 14859 | if (!cds_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14860 | hdd_err("Invalid CDS Context"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14861 | return; |
| 14862 | } |
| 14863 | |
Dustin Brown | 1dbefe6 | 2018-09-11 16:32:03 -0700 | [diff] [blame] | 14864 | if (policy_mgr_get_concurrency_mode(hdd_ctx->psoc) |
Tushnim Bhattacharyya | de1070d | 2017-03-09 13:23:55 -0800 | [diff] [blame] | 14865 | != (QDF_STA_MASK | QDF_SAP_MASK)) { |
Dustin Brown | 7e761c7 | 2018-07-31 13:50:17 -0700 | [diff] [blame] | 14866 | hdd_debug("Concurrency mode is not SAP"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14867 | return; |
| 14868 | } |
| 14869 | |
| 14870 | ap_adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14871 | if (ap_adapter && |
| 14872 | test_bit(SOFTAP_BSS_STARTED, &ap_adapter->event_flags) && |
| 14873 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, |
| 14874 | ap_adapter->session.ap.operating_channel)) { |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14875 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14876 | hdd_warn("STA-AP Mode DFS not supported, Switch SAP channel to Non DFS"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14877 | |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14878 | restart_chan = |
| 14879 | hdd_get_safe_channel_from_pcl_and_acs_range(ap_adapter); |
| 14880 | if (!restart_chan || |
Dustin Brown | 07901ec | 2018-09-07 11:02:41 -0700 | [diff] [blame] | 14881 | wlan_reg_is_dfs_ch(hdd_ctx->pdev, restart_chan)) |
Rajeev Kumar Sirasanagandla | 4133d86 | 2018-08-23 12:21:36 +0530 | [diff] [blame] | 14882 | restart_chan = SAP_DEFAULT_5GHZ_CHANNEL; |
| 14883 | |
| 14884 | hdd_switch_sap_channel(ap_adapter, restart_chan, true); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14885 | } |
| 14886 | } |
| 14887 | |
| 14888 | /** |
| 14889 | * hdd_set_connection_in_progress() - to set the connection in |
| 14890 | * progress flag |
| 14891 | * @value: value to set |
| 14892 | * |
| 14893 | * This function will set the passed value to connection in progress flag. |
| 14894 | * If value is previously being set to true then no need to set it again. |
| 14895 | * |
| 14896 | * Return: true if value is being set correctly and false otherwise. |
| 14897 | */ |
| 14898 | bool hdd_set_connection_in_progress(bool value) |
| 14899 | { |
| 14900 | bool status = true; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14901 | struct hdd_context *hdd_ctx; |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14902 | |
| 14903 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 14904 | if (!hdd_ctx) { |
Jeff Johnson | 6867ec3 | 2017-09-29 20:30:20 -0700 | [diff] [blame] | 14905 | hdd_err("HDD context is NULL"); |
Tushnim Bhattacharyya | 9e81b4c | 2017-02-15 17:11:14 -0800 | [diff] [blame] | 14906 | return false; |
| 14907 | } |
| 14908 | |
| 14909 | qdf_spin_lock(&hdd_ctx->connection_status_lock); |
| 14910 | /* |
| 14911 | * if the value is set to true previously and if someone is |
| 14912 | * trying to make it true again then it could be some race |
| 14913 | * condition being triggered. Avoid this situation by returning |
| 14914 | * false |
| 14915 | */ |
| 14916 | if (hdd_ctx->connection_in_progress && value) |
| 14917 | status = false; |
| 14918 | else |
| 14919 | hdd_ctx->connection_in_progress = value; |
| 14920 | qdf_spin_unlock(&hdd_ctx->connection_status_lock); |
| 14921 | return status; |
| 14922 | } |
| 14923 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14924 | 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] | 14925 | { |
| 14926 | if (!adapter) { |
| 14927 | hdd_err("Invalid adapter"); |
| 14928 | return -EINVAL; |
| 14929 | } |
| 14930 | hdd_info("Send MCC P2P QUOTA to WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14931 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14932 | WMA_VDEV_MCC_SET_TIME_QUOTA, |
| 14933 | set_value, VDEV_CMD); |
| 14934 | return 0; |
| 14935 | |
| 14936 | } |
| 14937 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14938 | 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] | 14939 | { |
| 14940 | if (!adapter) { |
| 14941 | hdd_err("Invalid adapter"); |
| 14942 | return -EINVAL; |
| 14943 | } |
| 14944 | |
| 14945 | hdd_info("Send MCC latency WMA: %d", set_value); |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 14946 | sme_cli_set_command(adapter->vdev_id, |
Archana Ramachandran | b8c04f9 | 2017-03-17 20:05:47 -0700 | [diff] [blame] | 14947 | WMA_VDEV_MCC_SET_TIME_LATENCY, |
| 14948 | set_value, VDEV_CMD); |
| 14949 | return 0; |
| 14950 | } |
| 14951 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14952 | 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] | 14953 | *psoc, uint8_t vdev_id) |
| 14954 | { |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14955 | struct hdd_adapter *adapter = NULL; |
Jeff Johnson | d49c4a1 | 2017-08-28 12:08:05 -0700 | [diff] [blame] | 14956 | struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
Archana Ramachandran | ea34c4f | 2017-03-19 18:56:18 -0700 | [diff] [blame] | 14957 | |
| 14958 | /* |
| 14959 | * Currently PSOC is not being used. But this logic will |
| 14960 | * change once we have the converged implementation of |
| 14961 | * HDD context per PSOC in place. This would break if |
| 14962 | * multiple vdev objects reuse the vdev id. |
| 14963 | */ |
| 14964 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 14965 | if (!adapter) |
| 14966 | hdd_err("Get adapter by vdev id failed"); |
| 14967 | |
| 14968 | return adapter; |
| 14969 | } |
| 14970 | |
Jeff Johnson | 9d29524 | 2017-08-29 14:39:48 -0700 | [diff] [blame] | 14971 | 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] | 14972 | int8_t *rssi, int8_t *snr) |
| 14973 | { |
| 14974 | QDF_STATUS status; |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14975 | mac_handle_t mac_handle; |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14976 | struct csr_roam_profile *roam_profile; |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14977 | |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14978 | roam_profile = hdd_roam_profile(adapter); |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 14979 | mac_handle = hdd_adapter_get_mac_handle(adapter); |
| 14980 | status = sme_get_rssi_snr_by_bssid(mac_handle, |
Jeff Johnson | 025618c | 2018-03-18 14:41:00 -0700 | [diff] [blame] | 14981 | roam_profile, bssid, rssi, snr); |
Hanumanth Reddy Pothula | 9005178 | 2017-05-04 22:14:43 +0530 | [diff] [blame] | 14982 | if (QDF_STATUS_SUCCESS != status) { |
| 14983 | hdd_warn("sme_get_rssi_snr_by_bssid failed"); |
| 14984 | return -EINVAL; |
| 14985 | } |
| 14986 | |
| 14987 | return 0; |
| 14988 | } |
| 14989 | |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 14990 | /** |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 14991 | * hdd_reset_limit_off_chan() - reset limit off-channel command parameters |
| 14992 | * @adapter - HDD adapter |
| 14993 | * |
| 14994 | * Return: 0 on success and non zero value on failure |
| 14995 | */ |
| 14996 | int hdd_reset_limit_off_chan(struct hdd_adapter *adapter) |
| 14997 | { |
| 14998 | struct hdd_context *hdd_ctx; |
| 14999 | int ret; |
| 15000 | QDF_STATUS status; |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15001 | uint8_t sys_pref = 0; |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15002 | |
| 15003 | hdd_ctx = WLAN_HDD_GET_CTX(adapter); |
| 15004 | ret = wlan_hdd_validate_context(hdd_ctx); |
| 15005 | if (ret < 0) |
| 15006 | return ret; |
| 15007 | |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15008 | ucfg_policy_mgr_get_sys_pref(hdd_ctx->psoc, |
| 15009 | &sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15010 | /* set the system preferece to default */ |
Krunal Soni | e71838d | 2018-09-27 10:45:05 -0700 | [diff] [blame] | 15011 | policy_mgr_set_cur_conc_system_pref(hdd_ctx->psoc, sys_pref); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15012 | |
| 15013 | /* clear the bitmap */ |
| 15014 | adapter->active_ac = 0; |
| 15015 | |
| 15016 | hdd_debug("reset ac_bitmap for session %hu active_ac %0x", |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15017 | adapter->vdev_id, adapter->active_ac); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15018 | |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15019 | status = sme_send_limit_off_channel_params(hdd_ctx->mac_handle, |
Jeff Johnson | 5a6fc96 | 2019-02-04 14:20:25 -0800 | [diff] [blame] | 15020 | adapter->vdev_id, |
Jeff Johnson | 1652836 | 2018-06-14 12:34:16 -0700 | [diff] [blame] | 15021 | false, 0, 0, false); |
Ganesh Kondabattini | 479a8ae | 2017-10-03 16:49:24 +0530 | [diff] [blame] | 15022 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 15023 | hdd_err("failed to reset limit off chan params"); |
| 15024 | ret = -EINVAL; |
| 15025 | } |
Ganesh Kondabattini | 3573957 | 2017-06-21 16:26:39 +0530 | [diff] [blame] | 15026 | |
| 15027 | return ret; |
| 15028 | } |
| 15029 | |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15030 | void hdd_set_rx_mode_rps(bool enable) |
| 15031 | { |
| 15032 | struct cds_config_info *cds_cfg = cds_get_ini_config(); |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15033 | struct hdd_context *hdd_ctx; |
| 15034 | struct hdd_adapter *adapter; |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15035 | |
Ryan Hsu | 0e878fa | 2018-05-04 15:22:09 -0700 | [diff] [blame] | 15036 | if (!cds_cfg) |
| 15037 | return; |
| 15038 | |
| 15039 | hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD); |
| 15040 | if (!hdd_ctx) |
| 15041 | return; |
| 15042 | |
| 15043 | adapter = hdd_get_adapter(hdd_ctx, QDF_SAP_MODE); |
| 15044 | if (!adapter) |
| 15045 | return; |
| 15046 | |
| 15047 | if (!hdd_ctx->rps && cds_cfg->uc_offload_enabled) { |
Yun Park | ff6a16a | 2017-09-26 16:38:18 -0700 | [diff] [blame] | 15048 | if (enable && !cds_cfg->rps_enabled) |
| 15049 | hdd_send_rps_ind(adapter); |
| 15050 | else if (!enable && cds_cfg->rps_enabled) |
| 15051 | hdd_send_rps_disable_ind(adapter); |
| 15052 | } |
| 15053 | } |
| 15054 | |
Abhinav Kumar | 338e57d | 2019-02-04 17:30:10 +0530 | [diff] [blame] | 15055 | void hdd_hidden_ssid_enable_roaming(hdd_handle_t hdd_handle, uint8_t vdev_id) |
| 15056 | { |
| 15057 | struct hdd_context *hdd_ctx = hdd_handle_to_context(hdd_handle); |
| 15058 | struct hdd_adapter *adapter; |
| 15059 | |
| 15060 | adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id); |
| 15061 | |
| 15062 | if (!adapter) { |
| 15063 | hdd_err("Adapter is null"); |
| 15064 | return; |
| 15065 | } |
| 15066 | /* enable roaming on all adapters once hdd get hidden ssid rsp */ |
| 15067 | wlan_hdd_enable_roaming(adapter); |
| 15068 | } |
| 15069 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15070 | /* Register the module init/exit functions */ |
| 15071 | module_init(hdd_module_init); |
| 15072 | module_exit(hdd_module_exit); |
| 15073 | |
| 15074 | MODULE_LICENSE("Dual BSD/GPL"); |
| 15075 | MODULE_AUTHOR("Qualcomm Atheros, Inc."); |
| 15076 | MODULE_DESCRIPTION("WLAN HOST DEVICE DRIVER"); |
| 15077 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15078 | static const struct kernel_param_ops con_mode_ops = { |
| 15079 | .set = con_mode_handler, |
| 15080 | .get = param_get_int, |
| 15081 | }; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15082 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15083 | static const struct kernel_param_ops con_mode_ftm_ops = { |
| 15084 | .set = con_mode_handler_ftm, |
| 15085 | .get = param_get_int, |
| 15086 | }; |
Arunk Khandavalli | ba3d558 | 2017-07-11 19:48:32 +0530 | [diff] [blame] | 15087 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15088 | #ifdef WLAN_FEATURE_EPPING |
| 15089 | static const struct kernel_param_ops con_mode_epping_ops = { |
| 15090 | .set = con_mode_handler_epping, |
| 15091 | .get = param_get_int, |
| 15092 | }; |
| 15093 | #endif |
| 15094 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15095 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15096 | static const struct kernel_param_ops con_mode_monitor_ops = { |
| 15097 | .set = con_mode_handler_monitor, |
| 15098 | .get = param_get_int, |
| 15099 | }; |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15100 | #endif |
Ravi Joshi | a307f63 | 2017-07-17 23:41:41 -0700 | [diff] [blame] | 15101 | |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15102 | static const struct kernel_param_ops fwpath_ops = { |
| 15103 | .set = fwpath_changed_handler, |
| 15104 | .get = param_get_string, |
| 15105 | }; |
| 15106 | |
| 15107 | module_param_cb(con_mode, &con_mode_ops, &con_mode, |
| 15108 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15109 | |
| 15110 | module_param_cb(con_mode_ftm, &con_mode_ftm_ops, &con_mode_ftm, |
| 15111 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 15112 | |
Nirav Shah | 6aeecf9 | 2019-02-13 14:05:03 +0530 | [diff] [blame] | 15113 | #ifdef WLAN_FEATURE_EPPING |
| 15114 | module_param_cb(con_mode_epping, &con_mode_epping_ops, |
| 15115 | &con_mode_epping, 0644); |
| 15116 | #endif |
| 15117 | |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15118 | #ifdef FEATURE_MONITOR_MODE_SUPPORT |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15119 | module_param_cb(con_mode_monitor, &con_mode_monitor_ops, &con_mode_monitor, |
| 15120 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Nirav Shah | 73713f7 | 2018-05-17 14:50:41 +0530 | [diff] [blame] | 15121 | #endif |
Srinivas Girigowda | 841da29 | 2018-02-21 16:33:00 -0800 | [diff] [blame] | 15122 | |
| 15123 | module_param_cb(fwpath, &fwpath_ops, &fwpath, |
| 15124 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 15125 | |
| 15126 | module_param(enable_dfs_chan_scan, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15127 | |
| 15128 | module_param(enable_11d, int, S_IRUSR | S_IRGRP | S_IROTH); |
| 15129 | |
| 15130 | module_param(country_code, charp, S_IRUSR | S_IRGRP | S_IROTH); |
Dustin Brown | 4bbd546 | 2019-03-22 11:18:13 -0700 | [diff] [blame] | 15131 | |
| 15132 | static int timer_multiplier_get_handler(char *buffer, |
| 15133 | const struct kernel_param *kp) |
| 15134 | { |
| 15135 | return scnprintf(buffer, PAGE_SIZE, "%u", qdf_timer_get_multiplier()); |
| 15136 | } |
| 15137 | |
| 15138 | static int timer_multiplier_set_handler(const char *kmessage, |
| 15139 | const struct kernel_param *kp) |
| 15140 | { |
| 15141 | QDF_STATUS status; |
| 15142 | uint32_t scalar; |
| 15143 | |
| 15144 | status = qdf_uint32_parse(kmessage, &scalar); |
| 15145 | if (QDF_IS_STATUS_ERROR(status)) |
| 15146 | return qdf_status_to_os_return(status); |
| 15147 | |
| 15148 | if (!cfg_in_range(CFG_TIMER_MULTIPLIER, scalar)) |
| 15149 | return -ERANGE; |
| 15150 | |
| 15151 | qdf_timer_set_multiplier(scalar); |
| 15152 | |
| 15153 | return 0; |
| 15154 | } |
| 15155 | |
| 15156 | static const struct kernel_param_ops timer_multiplier_ops = { |
| 15157 | .get = timer_multiplier_get_handler, |
| 15158 | .set = timer_multiplier_set_handler, |
| 15159 | }; |
| 15160 | |
| 15161 | module_param_cb(timer_multiplier, &timer_multiplier_ops, NULL, 0644); |
| 15162 | |